mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-28 07:56:44 +01:00
Fix tree fertilizer spreading podzol. Backport a440ab6
This commit is contained in:
parent
65d21c374b
commit
ba63cc3e7f
1 changed files with 15 additions and 13 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue