diff --git a/src/main/java/com/progwml6/natura/nether/block/bush/BlockNetherBerryBush.java b/src/main/java/com/progwml6/natura/nether/block/bush/BlockNetherBerryBush.java index c2060526..d2740cd0 100644 --- a/src/main/java/com/progwml6/natura/nether/block/bush/BlockNetherBerryBush.java +++ b/src/main/java/com/progwml6/natura/nether/block/bush/BlockNetherBerryBush.java @@ -1,8 +1,7 @@ package com.progwml6.natura.nether.block.bush; import java.util.Random; - -import com.progwml6.natura.common.block.BlockEnumBerryBush; +import javax.annotation.Nonnull; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; @@ -12,6 +11,8 @@ import net.minecraftforge.common.EnumPlantType; import net.minecraftforge.common.ForgeHooks; +import com.progwml6.natura.common.block.BlockEnumBerryBush; + public class BlockNetherBerryBush extends BlockEnumBerryBush { public BlockNetherBerryBush() @@ -30,33 +31,25 @@ public EnumPlantType getPlantType(IBlockAccess world, BlockPos pos) @Override public void grow(World worldIn, Random rand, BlockPos pos, IBlockState state) { - int age = state.getValue(AGE).intValue(); + int age = state.getValue(AGE); if (age < 2) { int setMeta = rand.nextInt(2) + 1 + age; - worldIn.setBlockState(pos, this.getDefaultState().withProperty(AGE, Integer.valueOf(setMeta)), 4); + worldIn.setBlockState(pos, this.getDefaultState().withProperty(AGE, setMeta), 4); return; } - IBlockState upBlock = worldIn.getBlockState(pos.up()); - - if (upBlock == null || worldIn.isAirBlock(pos.up())) + if (worldIn.isAirBlock(pos.up()) && rand.nextInt(3) == 0) { - if (rand.nextInt(3) == 0) - { - worldIn.setBlockState(pos.up(), this.getDefaultState().withProperty(AGE, Integer.valueOf(0)), 2); - } - return; + worldIn.setBlockState(pos.up(), this.getDefaultState().withProperty(AGE, 0), 2); } - - return; } @Override - public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) + public void updateTick(@Nonnull World worldIn, @Nonnull BlockPos pos, @Nonnull IBlockState state, @Nonnull Random rand) { super.updateTick(worldIn, pos, state, rand); @@ -64,23 +57,22 @@ public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random ra for (height = 1; worldIn.getBlockState(pos.down(height)).getBlock() == this; ++height) { - ; } boolean canGrow = (rand.nextInt(75) == 0); if (ForgeHooks.onCropsGrowPre(worldIn, pos, state, canGrow)) { - int age = state.getValue(AGE).intValue(); + int age = state.getValue(AGE); if (age < 3) { - worldIn.setBlockState(pos, this.getDefaultState().withProperty(AGE, Integer.valueOf(age + 1)), 2); + worldIn.setBlockState(pos, this.getDefaultState().withProperty(AGE, age + 1), 2); } if (rand.nextInt(3) == 0 && height < 3 && worldIn.getBlockState(pos.up()).getBlock() == Blocks.AIR && age >= 2) { - worldIn.setBlockState(pos.up(), this.getDefaultState().withProperty(AGE, Integer.valueOf(0)), 2); + worldIn.setBlockState(pos.up(), this.getDefaultState().withProperty(AGE, 0), 2); } ForgeHooks.onCropsGrowPost(worldIn, pos, state, worldIn.getBlockState(pos)); diff --git a/src/main/java/com/progwml6/natura/overworld/block/bush/BlockOverworldBerryBush.java b/src/main/java/com/progwml6/natura/overworld/block/bush/BlockOverworldBerryBush.java index 817b87e9..0ad4ff54 100644 --- a/src/main/java/com/progwml6/natura/overworld/block/bush/BlockOverworldBerryBush.java +++ b/src/main/java/com/progwml6/natura/overworld/block/bush/BlockOverworldBerryBush.java @@ -1,8 +1,7 @@ package com.progwml6.natura.overworld.block.bush; import java.util.Random; - -import com.progwml6.natura.common.block.BlockEnumBerryBush; +import javax.annotation.Nonnull; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; @@ -12,6 +11,8 @@ import net.minecraft.world.World; import net.minecraftforge.common.ForgeHooks; +import com.progwml6.natura.common.block.BlockEnumBerryBush; + public class BlockOverworldBerryBush extends BlockEnumBerryBush { public BlockOverworldBerryBush() @@ -24,33 +25,25 @@ public BlockOverworldBerryBush() @Override public void grow(World worldIn, Random rand, BlockPos pos, IBlockState state) { - int age = state.getValue(AGE).intValue(); + int age = state.getValue(AGE); if (age < 2) { int setMeta = rand.nextInt(2) + 1 + age; - worldIn.setBlockState(pos, this.getDefaultState().withProperty(AGE, Integer.valueOf(setMeta)), 4); + worldIn.setBlockState(pos, this.getDefaultState().withProperty(AGE, setMeta), 4); return; } - IBlockState upBlock = worldIn.getBlockState(pos.up()); - - if (upBlock == null || worldIn.isAirBlock(pos.up())) + if (worldIn.isAirBlock(pos.up()) && rand.nextInt(3) == 0) { - if (rand.nextInt(3) == 0) - { - worldIn.setBlockState(pos.up(), this.getDefaultState().withProperty(AGE, Integer.valueOf(0)), 2); - } - return; + worldIn.setBlockState(pos.up(), this.getDefaultState().withProperty(AGE, 0), 2); } - - return; } @Override - public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) + public void updateTick(@Nonnull World worldIn, @Nonnull BlockPos pos, @Nonnull IBlockState state, @Nonnull Random rand) { super.updateTick(worldIn, pos, state, rand); @@ -58,34 +51,30 @@ public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random ra for (height = 1; worldIn.getBlockState(pos.down(height)).getBlock() == this; ++height) { - ; } boolean canGrow = (rand.nextInt(20) == 0); - if (worldIn.getLightFromNeighbors(pos) >= 8) + if (worldIn.getLightFromNeighbors(pos) >= 8 && ForgeHooks.onCropsGrowPre(worldIn, pos, state, canGrow)) { - if (ForgeHooks.onCropsGrowPre(worldIn, pos, state, canGrow)) - { - int age = state.getValue(AGE).intValue(); + int age = state.getValue(AGE); - if (age < 3) - { - worldIn.setBlockState(pos, this.getDefaultState().withProperty(AGE, Integer.valueOf(age + 1)), 2); - } - - if (rand.nextInt(3) == 0 && height < 3 && worldIn.getBlockState(pos.up()).getBlock() == Blocks.AIR && age >= 2) - { - worldIn.setBlockState(pos.up(), this.getDefaultState().withProperty(AGE, Integer.valueOf(0)), 2); - } + if (age < 3) + { + worldIn.setBlockState(pos, this.getDefaultState().withProperty(AGE, age + 1), 2); + } - ForgeHooks.onCropsGrowPost(worldIn, pos, state, worldIn.getBlockState(pos)); + if (rand.nextInt(3) == 0 && height < 3 && worldIn.getBlockState(pos.up()).getBlock() == Blocks.AIR && age >= 2) + { + worldIn.setBlockState(pos.up(), this.getDefaultState().withProperty(AGE, 0), 2); } + + ForgeHooks.onCropsGrowPost(worldIn, pos, state, worldIn.getBlockState(pos)); } } @Override - public boolean canSustainPlant(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing direction, net.minecraftforge.common.IPlantable plantable) + public boolean canSustainPlant(@Nonnull IBlockState state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, @Nonnull EnumFacing direction, @Nonnull net.minecraftforge.common.IPlantable plantable) { if (plantable instanceof BlockOverworldBerryBush && state.getPropertyKeys().contains(AGE)) {