From 02e8524b4a297a8c16dabdbece9ccba4a8a52659 Mon Sep 17 00:00:00 2001 From: ACGaming <4818419+ACGaming@users.noreply.github.com> Date: Mon, 3 Jun 2024 13:59:52 +0200 Subject: [PATCH] Clean up leaves code --- .../block/leaves/BlockNetherLeaves.java | 12 ++++------ .../block/leaves/BlockNetherLeaves2.java | 13 +++++----- .../block/leaves/BlockOverworldLeaves.java | 14 +++-------- .../block/leaves/BlockOverworldLeaves2.java | 14 +++-------- .../block/leaves/BlockRedwoodLeaves.java | 24 ++++++------------- 5 files changed, 24 insertions(+), 53 deletions(-) diff --git a/src/main/java/com/progwml6/natura/nether/block/leaves/BlockNetherLeaves.java b/src/main/java/com/progwml6/natura/nether/block/leaves/BlockNetherLeaves.java index ac3dfa39..c8effeb6 100644 --- a/src/main/java/com/progwml6/natura/nether/block/leaves/BlockNetherLeaves.java +++ b/src/main/java/com/progwml6/natura/nether/block/leaves/BlockNetherLeaves.java @@ -30,7 +30,7 @@ public class BlockNetherLeaves extends BlockLeavesBase { - public static PropertyEnum TYPE = PropertyEnum.create("type", BlockNetherLeaves.LeavesType.class); + public static final PropertyEnum TYPE = PropertyEnum.create("type", BlockNetherLeaves.LeavesType.class); public BlockNetherLeaves() { @@ -63,6 +63,7 @@ protected int getSaplingDropChance(IBlockState state) } // sapling item + @Nonnull @Override public Item getItemDropped(IBlockState state, Random rand, int fortune) { @@ -92,6 +93,7 @@ public ItemStack getPickBlock(@Nonnull IBlockState state, RayTraceResult target, } // item dropped on silktouching + @Nonnull @Override protected ItemStack getSilkTouchDrop(@Nonnull IBlockState state) { @@ -139,6 +141,7 @@ public int getMetaFromState(IBlockState state) return meta; } + @Nonnull @Override public List onSheared(ItemStack item, IBlockAccess world, BlockPos pos, int fortune) { @@ -147,12 +150,6 @@ public List onSheared(ItemStack item, IBlockAccess world, BlockPos po return Lists.newArrayList(this.getSilkTouchDrop(state)); } - @Override - public boolean isLeaves(IBlockState state, IBlockAccess world, BlockPos pos) - { - return true; - } - @Override public void getDrops(NonNullList drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { @@ -187,6 +184,7 @@ public enum LeavesType implements IStringSerializable, EnumBlock.IEnumMeta this.wailaLeavesMeta = wailaLeavesMeta; } + @Nonnull @Override public String getName() { diff --git a/src/main/java/com/progwml6/natura/nether/block/leaves/BlockNetherLeaves2.java b/src/main/java/com/progwml6/natura/nether/block/leaves/BlockNetherLeaves2.java index a50465ef..661aeeb5 100644 --- a/src/main/java/com/progwml6/natura/nether/block/leaves/BlockNetherLeaves2.java +++ b/src/main/java/com/progwml6/natura/nether/block/leaves/BlockNetherLeaves2.java @@ -30,7 +30,7 @@ public class BlockNetherLeaves2 extends BlockLeavesBase { - public static PropertyEnum TYPE = PropertyEnum.create("type", BlockNetherLeaves2.LeavesType.class); + public static final PropertyEnum TYPE = PropertyEnum.create("type", BlockNetherLeaves2.LeavesType.class); public BlockNetherLeaves2() { @@ -57,6 +57,7 @@ public void getSubBlocks(CreativeTabs tab, NonNullList list) } // sapling item + @Nonnull @Override public Item getItemDropped(IBlockState state, Random rand, int fortune) { @@ -84,6 +85,7 @@ public int damageDropped(IBlockState state) } } + @Nonnull @Override public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) { @@ -91,6 +93,7 @@ public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World wo } // item dropped on silktouching + @Nonnull @Override protected ItemStack getSilkTouchDrop(@Nonnull IBlockState state) { @@ -138,6 +141,7 @@ public int getMetaFromState(IBlockState state) return meta; } + @Nonnull @Override public List onSheared(ItemStack item, IBlockAccess world, BlockPos pos, int fortune) { @@ -146,12 +150,6 @@ public List onSheared(ItemStack item, IBlockAccess world, BlockPos po return Lists.newArrayList(this.getSilkTouchDrop(state)); } - @Override - public boolean isLeaves(IBlockState state, IBlockAccess world, BlockPos pos) - { - return true; - } - /** * Returns the quantity of items to drop on block destruction. */ @@ -177,6 +175,7 @@ public enum LeavesType implements IStringSerializable, EnumBlock.IEnumMeta this.meta = this.ordinal(); } + @Nonnull @Override public String getName() { diff --git a/src/main/java/com/progwml6/natura/overworld/block/leaves/BlockOverworldLeaves.java b/src/main/java/com/progwml6/natura/overworld/block/leaves/BlockOverworldLeaves.java index 6fdd8f8c..3f84aa38 100644 --- a/src/main/java/com/progwml6/natura/overworld/block/leaves/BlockOverworldLeaves.java +++ b/src/main/java/com/progwml6/natura/overworld/block/leaves/BlockOverworldLeaves.java @@ -56,17 +56,13 @@ protected int getSaplingDropChance(IBlockState state) } // sapling item + @Nonnull @Override public Item getItemDropped(IBlockState state, Random rand, int fortune) { return Item.getItemFromBlock(NaturaOverworld.overworldSapling); } - @Override - protected void dropApple(World worldIn, BlockPos pos, IBlockState state, int chance) - { - } - // sapling meta @Override public int damageDropped(IBlockState state) @@ -75,6 +71,7 @@ public int damageDropped(IBlockState state) } // item dropped on silktouching + @Nonnull @Override protected ItemStack getSilkTouchDrop(@Nonnull IBlockState state) { @@ -122,16 +119,11 @@ public int getMetaFromState(IBlockState state) return meta; } + @Nonnull @Override public List onSheared(ItemStack item, IBlockAccess world, BlockPos pos, int fortune) { IBlockState state = world.getBlockState(pos); return Lists.newArrayList(this.getSilkTouchDrop(state)); } - - @Override - public boolean isLeaves(IBlockState state, IBlockAccess world, BlockPos pos) - { - return true; - } } diff --git a/src/main/java/com/progwml6/natura/overworld/block/leaves/BlockOverworldLeaves2.java b/src/main/java/com/progwml6/natura/overworld/block/leaves/BlockOverworldLeaves2.java index f0ed6c67..019fffb6 100644 --- a/src/main/java/com/progwml6/natura/overworld/block/leaves/BlockOverworldLeaves2.java +++ b/src/main/java/com/progwml6/natura/overworld/block/leaves/BlockOverworldLeaves2.java @@ -56,17 +56,13 @@ protected int getSaplingDropChance(IBlockState state) } // sapling item + @Nonnull @Override public Item getItemDropped(IBlockState state, Random rand, int fortune) { return Item.getItemFromBlock(NaturaOverworld.overworldSapling2); } - @Override - protected void dropApple(World worldIn, BlockPos pos, IBlockState state, int chance) - { - } - // sapling meta @Override public int damageDropped(IBlockState state) @@ -75,6 +71,7 @@ public int damageDropped(IBlockState state) } // item dropped on silktouching + @Nonnull @Override protected ItemStack getSilkTouchDrop(@Nonnull IBlockState state) { @@ -122,16 +119,11 @@ public int getMetaFromState(IBlockState state) return meta; } + @Nonnull @Override public List onSheared(ItemStack item, IBlockAccess world, BlockPos pos, int fortune) { IBlockState state = world.getBlockState(pos); return Lists.newArrayList(this.getSilkTouchDrop(state)); } - - @Override - public boolean isLeaves(IBlockState state, IBlockAccess world, BlockPos pos) - { - return true; - } } diff --git a/src/main/java/com/progwml6/natura/overworld/block/leaves/BlockRedwoodLeaves.java b/src/main/java/com/progwml6/natura/overworld/block/leaves/BlockRedwoodLeaves.java index f9cb6ca6..18607947 100644 --- a/src/main/java/com/progwml6/natura/overworld/block/leaves/BlockRedwoodLeaves.java +++ b/src/main/java/com/progwml6/natura/overworld/block/leaves/BlockRedwoodLeaves.java @@ -29,7 +29,7 @@ public class BlockRedwoodLeaves extends BlockLeavesBase { - public final static PropertyEnum TYPE = PropertyEnum.create("type", RedwoodType.class); + public static final PropertyEnum TYPE = PropertyEnum.create("type", RedwoodType.class); public BlockRedwoodLeaves() { @@ -43,9 +43,7 @@ public BlockRedwoodLeaves() @Override public void updateTick(World worldIn, @Nonnull BlockPos pos, @Nonnull IBlockState state, Random rand) { - if (!worldIn.isRemote) - { - if (state.getValue(CHECK_DECAY).booleanValue() && state.getValue(DECAYABLE).booleanValue()) + if (!worldIn.isRemote && state.getValue(CHECK_DECAY) && state.getValue(DECAYABLE)) { boolean nearbyTree = false; byte range = 4; @@ -61,7 +59,7 @@ public void updateTick(World worldIn, @Nonnull BlockPos pos, @Nonnull IBlockStat IBlockState iblockstate = worldIn.getBlockState(mutableblockpos.setPos(posX, posY, posZ)); Block block = iblockstate.getBlock(); - if (block != null && block.canSustainLeaves(iblockstate, worldIn, pos.add(posX, posY, posZ))) + if (block.canSustainLeaves(iblockstate, worldIn, pos.add(posX, posY, posZ))) { nearbyTree = true; } @@ -74,7 +72,6 @@ public void updateTick(World worldIn, @Nonnull BlockPos pos, @Nonnull IBlockStat this.destroy(worldIn, pos); } } - } } private void destroy(World worldIn, BlockPos pos) @@ -99,17 +96,13 @@ protected int getSaplingDropChance(IBlockState state) } // sapling item + @Nonnull @Override public Item getItemDropped(IBlockState state, Random rand, int fortune) { return Item.getItemFromBlock(NaturaOverworld.redwoodSapling); } - @Override - protected void dropApple(World worldIn, BlockPos pos, IBlockState state, int chance) - { - } - // sapling meta @Override public int damageDropped(IBlockState state) @@ -118,6 +111,7 @@ public int damageDropped(IBlockState state) } // item dropped on silktouching + @Nonnull @Override protected ItemStack getSilkTouchDrop(@Nonnull IBlockState state) { @@ -165,6 +159,7 @@ public int getMetaFromState(IBlockState state) return meta; } + @Nonnull @Override public List onSheared(ItemStack item, IBlockAccess world, BlockPos pos, int fortune) { @@ -172,12 +167,6 @@ public List onSheared(ItemStack item, IBlockAccess world, BlockPos po return Lists.newArrayList(this.getSilkTouchDrop(state)); } - @Override - public boolean isLeaves(IBlockState state, IBlockAccess world, BlockPos pos) - { - return true; - } - public enum RedwoodType implements IStringSerializable, EnumBlock.IEnumMeta { NORMAL; @@ -189,6 +178,7 @@ public enum RedwoodType implements IStringSerializable, EnumBlock.IEnumMeta this.meta = this.ordinal(); } + @Nonnull @Override public String getName() {