Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.59 KB | None | 0 0
  1. package net.minecraft.server;
  2.  
  3. import java.util.Random;
  4.  
  5. public class BlockLongGrass extends BlockPlant implements IBlockFragilePlantElement {
  6.  
  7. public static final BlockStateEnum<EnumTallGrassType> TYPE = BlockStateEnum.of("type", EnumTallGrassType.class);
  8.  
  9. protected BlockLongGrass() {
  10. super(Material.REPLACEABLE_PLANT);
  11.  
  12. j(this.blockStateList.getBlockData().set(TYPE, EnumTallGrassType.DEAD_BUSH));
  13. float f = 0.4F;
  14. a(0.5F - f, 0.0F, 0.5f - f, 0.5F + f, 0.8F, 0.5F + f);
  15. }
  16.  
  17. public boolean f(World world, BlockPosition position, IBlockData data) {
  18. return c(world.getType(position.down()).getBlock());
  19. }
  20.  
  21. public boolean a(World world, BlockPosition position) {
  22. return true;
  23. }
  24.  
  25. public Item getDropType(IBlockData data, Random random, int i) {
  26. if (random.nextInt(8) == 0) return Items.WHEAT_SEEDS;
  27.  
  28. return null;
  29. }
  30.  
  31. public int getDropCount(int i, Random random) {
  32. return 1 + random.nextInt(i * 2 + 1);
  33. }
  34.  
  35. public void a(World world, EntityHuman human, BlockPosition position, IBlockData data, TileEntity entity) {
  36. if (!world.isClientSide && human.bZ() != null && human.bZ().getItem() == Items.SHEARS) {
  37. human.b(StatisticList.MINE_BLOCK_COUNT[Block.getId(this)]);
  38. a(world, position, new ItemStack(Blocks.TALLGRASS, 1, data.get(TYPE).a()));
  39. } else {
  40. super.a(world, human, position, data, entity);
  41. }
  42. }
  43.  
  44. public int getDropData(World world, BlockPosition position) {
  45. IBlockData data = world.getType(position);
  46. return data.getBlock().toLegacyData(data);
  47. }
  48.  
  49. public boolean a(World world, BlockPosition position, IBlockData data, boolean b) {
  50. return (data.get(TYPE) != EnumTallGrassType.DEAD_BUSH);
  51. }
  52.  
  53. public boolean a(World world, Random random, BlockPosition position, IBlockData data) {
  54. return true;
  55. }
  56.  
  57. public void b(World world, Random random, BlockPosition position, IBlockData data) {
  58. BlockTallPlant.EnumTallFlowerVariants grass = BlockTallPlant.EnumTallFlowerVariants.GRASS;
  59. if (data.get(TYPE) == EnumTallGrassType.FERN) {
  60. grass = BlockTallPlant.EnumTallFlowerVariants.FERN;
  61. }
  62.  
  63. if (Blocks.DOUBLE_PLANT.canPlace(world, position)) {
  64. Blocks.DOUBLE_PLANT.a(world, position, grass, 2);
  65. }
  66. }
  67.  
  68. public IBlockData fromLegacyData(int i) {
  69. return getBlockData().set(TYPE, EnumTallGrassType.a(i));
  70. }
  71.  
  72. public int toLegacyData(IBlockData data) {
  73. return data.get(TYPE).a();
  74. }
  75.  
  76. protected BlockStateList getStateList() {
  77. return new BlockStateList(this, TYPE);
  78. }
  79.  
  80. public enum EnumTallGrassType implements INamable {
  81. DEAD_BUSH(0, "dead_bush"),
  82. GRASS(1, "tall_grass"),
  83. FERN(2, "fern");
  84.  
  85. private static final BlockLongGrass.EnumTallGrassType[] d = new BlockLongGrass.EnumTallGrassType[values().length];
  86.  
  87. private final int e;
  88. private final String name;
  89.  
  90. EnumTallGrassType(int i, String name) {
  91. this.e = i;
  92. this.name = name;
  93. }
  94.  
  95. public int a() {
  96. return e;
  97. }
  98.  
  99. public String toString() {
  100. return name;
  101. }
  102.  
  103. public static BlockLongGrass.EnumTallGrassType a(int i) {
  104. if (i < 0 || i >= d.length) {
  105. i = 0;
  106. }
  107.  
  108. return d[i];
  109. }
  110.  
  111. public String getName() {
  112. return this.name;
  113. }
  114.  
  115. static {
  116. for (EnumTallGrassType var3 : values()) {
  117. d[var3.a()] = var3;
  118. }
  119.  
  120. }
  121. }
  122. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement