Make tree fertilizer work on slime saplings

This commit is contained in:
grimmauld 2020-10-16 12:18:14 +02:00
parent 893294b9e4
commit a440ab6772

View file

@ -31,7 +31,7 @@ public class TreeFertilizerItem extends Item {
return ActionResultType.SUCCESS; return ActionResultType.SUCCESS;
} }
TreesDreamWorld world = new TreesDreamWorld((ServerWorld) context.getWorld()); TreesDreamWorld world = new TreesDreamWorld((ServerWorld) context.getWorld(), context.getPos());
BlockPos saplingPos = context.getPos(); BlockPos saplingPos = context.getPos();
for (BlockPos pos : BlockPos.getAllInBoxMutable(-1, 0, -1, 1, 0, 1)) { for (BlockPos pos : BlockPos.getAllInBoxMutable(-1, 0, -1, 1, 0, 1)) {
@ -83,15 +83,17 @@ public class TreeFertilizerItem extends Item {
} }
private class TreesDreamWorld extends PlacementSimulationServerWorld { private class TreesDreamWorld extends PlacementSimulationServerWorld {
private final BlockPos saplingPos;
protected TreesDreamWorld(ServerWorld wrapped) { protected TreesDreamWorld(ServerWorld wrapped, BlockPos saplingPos) {
super(wrapped); super(wrapped);
this.saplingPos = saplingPos;
} }
@Override @Override
public BlockState getBlockState(BlockPos pos) { public BlockState getBlockState(BlockPos pos) {
if (pos.getY() <= 9) if (pos.getY() <= 9)
return Blocks.GRASS_BLOCK.getDefaultState(); return world.getBlockState(saplingPos.down());
return super.getBlockState(pos); return super.getBlockState(pos);
} }