Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.minecraft.server;
- import java.util.Random;
- public class BlockLongGrass extends BlockPlant implements IBlockFragilePlantElement {
- public static final BlockStateEnum<EnumTallGrassType> TYPE = BlockStateEnum.of("type", EnumTallGrassType.class);
- protected BlockLongGrass() {
- super(Material.REPLACEABLE_PLANT);
- j(this.blockStateList.getBlockData().set(TYPE, EnumTallGrassType.DEAD_BUSH));
- float f = 0.4F;
- a(0.5F - f, 0.0F, 0.5f - f, 0.5F + f, 0.8F, 0.5F + f);
- }
- public boolean f(World world, BlockPosition position, IBlockData data) {
- return c(world.getType(position.down()).getBlock());
- }
- public boolean a(World world, BlockPosition position) {
- return true;
- }
- public Item getDropType(IBlockData data, Random random, int i) {
- if (random.nextInt(8) == 0) return Items.WHEAT_SEEDS;
- return null;
- }
- public int getDropCount(int i, Random random) {
- return 1 + random.nextInt(i * 2 + 1);
- }
- public void a(World world, EntityHuman human, BlockPosition position, IBlockData data, TileEntity entity) {
- if (!world.isClientSide && human.bZ() != null && human.bZ().getItem() == Items.SHEARS) {
- human.b(StatisticList.MINE_BLOCK_COUNT[Block.getId(this)]);
- a(world, position, new ItemStack(Blocks.TALLGRASS, 1, data.get(TYPE).a()));
- } else {
- super.a(world, human, position, data, entity);
- }
- }
- public int getDropData(World world, BlockPosition position) {
- IBlockData data = world.getType(position);
- return data.getBlock().toLegacyData(data);
- }
- public boolean a(World world, BlockPosition position, IBlockData data, boolean b) {
- return (data.get(TYPE) != EnumTallGrassType.DEAD_BUSH);
- }
- public boolean a(World world, Random random, BlockPosition position, IBlockData data) {
- return true;
- }
- public void b(World world, Random random, BlockPosition position, IBlockData data) {
- BlockTallPlant.EnumTallFlowerVariants grass = BlockTallPlant.EnumTallFlowerVariants.GRASS;
- if (data.get(TYPE) == EnumTallGrassType.FERN) {
- grass = BlockTallPlant.EnumTallFlowerVariants.FERN;
- }
- if (Blocks.DOUBLE_PLANT.canPlace(world, position)) {
- Blocks.DOUBLE_PLANT.a(world, position, grass, 2);
- }
- }
- public IBlockData fromLegacyData(int i) {
- return getBlockData().set(TYPE, EnumTallGrassType.a(i));
- }
- public int toLegacyData(IBlockData data) {
- return data.get(TYPE).a();
- }
- protected BlockStateList getStateList() {
- return new BlockStateList(this, TYPE);
- }
- public enum EnumTallGrassType implements INamable {
- DEAD_BUSH(0, "dead_bush"),
- GRASS(1, "tall_grass"),
- FERN(2, "fern");
- private static final BlockLongGrass.EnumTallGrassType[] d = new BlockLongGrass.EnumTallGrassType[values().length];
- private final int e;
- private final String name;
- EnumTallGrassType(int i, String name) {
- this.e = i;
- this.name = name;
- }
- public int a() {
- return e;
- }
- public String toString() {
- return name;
- }
- public static BlockLongGrass.EnumTallGrassType a(int i) {
- if (i < 0 || i >= d.length) {
- i = 0;
- }
- return d[i];
- }
- public String getName() {
- return this.name;
- }
- static {
- for (EnumTallGrassType var3 : values()) {
- d[var3.a()] = var3;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement