Skip to content

Commit

Permalink
Fix slime tree feature not growing in worlds taller than 256
Browse files Browse the repository at this point in the history
Also cleans up some unneeded instanceof checks
  • Loading branch information
KnightMiner committed May 6, 2022
1 parent 6348004 commit 3b01d1d
Showing 1 changed file with 7 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,7 @@ public boolean place(FeaturePlaceContext<SlimeTreeConfig> context) {
return false;
}

private boolean place(LevelSimulatedRW generationReader, Random rand, BlockPos positionIn, Set<BlockPos> trunkBlockPosSet, Set<BlockPos> foliagePositions, BoundingBox boundingBoxIn, SlimeTreeConfig configIn) {
if (!(generationReader instanceof LevelAccessor)) {
return false;
}
private boolean place(WorldGenLevel level, Random rand, BlockPos positionIn, Set<BlockPos> trunkBlockPosSet, Set<BlockPos> foliagePositions, BoundingBox boundingBoxIn, SlimeTreeConfig configIn) {
// determine tree height
int height = rand.nextInt(configIn.randomHeight) + configIn.baseHeight;
if (configIn.canDoubleHeight && rand.nextInt(10) == 0) {
Expand All @@ -74,20 +71,17 @@ private boolean place(LevelSimulatedRW generationReader, Random rand, BlockPos p
// blockpos = positionIn;
// }

if (positionIn.getY() >= 1 && positionIn.getY() + height + 1 <= 256 && isSlimySoilAt(generationReader, positionIn.below())) {
this.setDirtAt(generationReader, positionIn.below(), positionIn);
this.placeTrunk(generationReader, rand, height, positionIn, trunkBlockPosSet, boundingBoxIn, configIn);
this.placeCanopy(generationReader, rand, height, positionIn, trunkBlockPosSet, boundingBoxIn, configIn);
if (positionIn.getY() >= 1 && positionIn.getY() + height + 1 <= level.getMaxBuildHeight() && isSlimySoilAt(level, positionIn.below())) {
this.setDirtAt(level, positionIn.below(), positionIn);
this.placeTrunk(level, rand, height, positionIn, trunkBlockPosSet, boundingBoxIn, configIn);
this.placeCanopy(level, rand, height, positionIn, trunkBlockPosSet, boundingBoxIn, configIn);
return true;
}
return false;
}

protected void setDirtAt(LevelSimulatedRW reader, BlockPos pos, BlockPos origin) {
if (!(reader instanceof LevelAccessor)) {
return;
}
BlockState state = ((LevelAccessor)reader).getBlockState(pos);
protected void setDirtAt(WorldGenLevel reader, BlockPos pos, BlockPos origin) {
BlockState state = reader.getBlockState(pos);
if (state.is(BlockTags.DIRT)) {
reader.setBlock(pos, Blocks.DIRT.defaultBlockState(), 2);
}
Expand Down

0 comments on commit 3b01d1d

Please sign in to comment.