diff --git a/src/main/java/com/simibubi/create/content/curiosities/TreeFertilizerItem.java b/src/main/java/com/simibubi/create/content/curiosities/TreeFertilizerItem.java index 104095a74..c47b26f17 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/TreeFertilizerItem.java +++ b/src/main/java/com/simibubi/create/content/curiosities/TreeFertilizerItem.java @@ -31,8 +31,8 @@ public class TreeFertilizerItem extends Item { return ActionResultType.SUCCESS; } - TreesDreamWorld world = new TreesDreamWorld((ServerWorld) context.getWorld()); BlockPos saplingPos = context.getPos(); + TreesDreamWorld world = new TreesDreamWorld((ServerWorld) context.getWorld(), saplingPos); for (BlockPos pos : BlockPos.getAllInBoxMutable(-1, 0, -1, 1, 0, 1)) { if (context.getWorld() @@ -45,8 +45,8 @@ public class TreeFertilizerItem extends Item { state.with(SaplingBlock.STAGE, 1)); for (BlockPos pos : world.blocksAdded.keySet()) { - BlockPos actualPos = pos.add(saplingPos) - .down(10); + BlockPos actualPos = pos.add(saplingPos).down(10); + BlockState newState = world.blocksAdded.get(pos); // Don't replace Bedrock if (context.getWorld() @@ -54,21 +54,15 @@ public class TreeFertilizerItem extends Item { .getBlockHardness(context.getWorld(), actualPos) == -1) continue; // Don't replace solid blocks with leaves - if (!world.getBlockState(pos) - .isNormalCube(world, pos) + if (!newState.isNormalCube(world, pos) && !context.getWorld() .getBlockState(actualPos) .getCollisionShape(context.getWorld(), actualPos) .isEmpty()) continue; - if (world.getBlockState(pos) - .getBlock() == Blocks.GRASS_BLOCK - || world.getBlockState(pos) - .getBlock() == Blocks.PODZOL) - continue; context.getWorld() - .setBlockState(actualPos, world.getBlockState(pos)); + .setBlockState(actualPos, newState); } if (context.getPlayer() != null && !context.getPlayer() @@ -83,18 +77,26 @@ public class TreeFertilizerItem extends Item { } private class TreesDreamWorld extends PlacementSimulationServerWorld { + private final BlockState soil; - protected TreesDreamWorld(ServerWorld wrapped) { + protected TreesDreamWorld(ServerWorld wrapped, BlockPos saplingPos) { super(wrapped); + soil = wrapped.getBlockState(saplingPos.down()); } @Override public BlockState getBlockState(BlockPos pos) { if (pos.getY() <= 9) - return Blocks.GRASS_BLOCK.getDefaultState(); + return soil; return super.getBlockState(pos); } + @Override + public boolean setBlockState(BlockPos pos, BlockState newState, int flags) { + if (newState.getBlock() == Blocks.PODZOL) + return true; + return super.setBlockState(pos, newState, flags); + } } }