diff --git a/src/main/java/techreborn/blocks/BlockRubberLog.java b/src/main/java/techreborn/blocks/BlockRubberLog.java index 05d479370..22ec73273 100644 --- a/src/main/java/techreborn/blocks/BlockRubberLog.java +++ b/src/main/java/techreborn/blocks/BlockRubberLog.java @@ -130,8 +130,8 @@ public class BlockRubberLog extends Block implements ITexturedBlock { super.updateTick(worldIn, pos, state, rand); if(!state.getValue(HAS_SAP)){ if(rand.nextInt(50) == 0){ - EnumFacing facing = EnumFacing.getHorizontal(rand.nextInt(3)); - if(worldIn.getBlockState(pos.down()).getBlock() == this && worldIn.getBlockState(pos.up()).getBlock() == this && worldIn.isAirBlock(pos.offset(facing))){ + EnumFacing facing = EnumFacing.getHorizontal(rand.nextInt(4)); + if(worldIn.getBlockState(pos.down()).getBlock() == this && worldIn.getBlockState(pos.up()).getBlock() == this){ worldIn.setBlockState(pos, state.withProperty(HAS_SAP, true).withProperty(SAP_SIDE, facing)); } } diff --git a/src/main/java/techreborn/blocks/BlockRubberSapling.java b/src/main/java/techreborn/blocks/BlockRubberSapling.java index 090840a7c..10d52d604 100644 --- a/src/main/java/techreborn/blocks/BlockRubberSapling.java +++ b/src/main/java/techreborn/blocks/BlockRubberSapling.java @@ -32,7 +32,9 @@ public class BlockRubberSapling extends BlockSapling { return; } worldIn.setBlockToAir(pos); - new RubberTreeGenerator(false).generate(worldIn, rand, pos); + if(!new RubberTreeGenerator(false).generate(worldIn, rand, pos)){ + worldIn.setBlockState(pos, state); //Re-add the sapling if the tree failed to grow + } } @Override diff --git a/src/main/java/techreborn/world/RubberTreeGenerator.java b/src/main/java/techreborn/world/RubberTreeGenerator.java index 5427d21a8..ec0f151e9 100644 --- a/src/main/java/techreborn/world/RubberTreeGenerator.java +++ b/src/main/java/techreborn/world/RubberTreeGenerator.java @@ -22,7 +22,7 @@ public class RubberTreeGenerator extends WorldGenerator { } public RubberTreeGenerator(boolean isWorldGen) { - super(); + super(!isWorldGen); this.isWorldGen = isWorldGen; } @@ -62,6 +62,7 @@ public class RubberTreeGenerator extends WorldGenerator { int yOffset; int zOffset; Block baseBlock = world.getBlockState(new BlockPos(x, y - 1, z)).getBlock(); + boolean hasPlacedBlock = false; if (baseBlock != null && baseBlock.canSustainPlant(world, new BlockPos(x, y - 1, z), EnumFacing.UP, (IPlantable) ModBlocks.rubberSapling) && y < worldHeight - treeHeight - 1) { for (yOffset = y; yOffset <= y + 1 + treeHeight; ++yOffset) { byte radius = 1; @@ -103,6 +104,7 @@ public class RubberTreeGenerator extends WorldGenerator { Block block = world.getBlockState(new BlockPos(xOffset, yOffset, zOffset)).getBlock(); if (((xPos != center | zPos != center) || rand.nextInt(2) != 0 && var12 != 0) && (block == null || block.isLeaves(world, new BlockPos(xOffset, yOffset, zOffset)) || block.isAir(world, new BlockPos(xOffset, yOffset, zOffset)) || block.canBeReplacedByLeaves(world, new BlockPos(xOffset, yOffset, zOffset)))) { this.setBlockAndNotifyAdequately(world, new BlockPos(xOffset, yOffset, zOffset), ModBlocks.rubberLeaves.getDefaultState()); + hasPlacedBlock = true; } } } @@ -116,7 +118,7 @@ public class RubberTreeGenerator extends WorldGenerator { IBlockState newState = ModBlocks.rubberLog.getDefaultState(); boolean isAddingSap = false; if(rand.nextInt(10) == 0){ - newState = newState.withProperty(BlockRubberLog.HAS_SAP, true).withProperty(BlockRubberLog.SAP_SIDE, EnumFacing.getHorizontal(rand.nextInt(3))); + newState = newState.withProperty(BlockRubberLog.HAS_SAP, true).withProperty(BlockRubberLog.SAP_SIDE, EnumFacing.getHorizontal(rand.nextInt(4))); isAddingSap = true; } if(isAddingSap){ @@ -124,6 +126,7 @@ public class RubberTreeGenerator extends WorldGenerator { } else { this.setBlockAndNotifyAdequately(world, blockpos, newState); } + hasPlacedBlock = true; topLogPos = blockpos; } } @@ -134,7 +137,7 @@ public class RubberTreeGenerator extends WorldGenerator { } } } - return true; + return hasPlacedBlock; } return false; }