diff --git a/CHANGELOG.md b/CHANGELOG.md index ea3b28b6d..385008e5e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ - Refactor Platform FarmLandBlock to have Platform Name - Move Config Classes to Config Package - Correct BWG Pitcher Plant Item Models +- Slight Change to FruitBlockProcessor#finalizeProcessing to be more Efficient # 2.2.5 - Make Pale Pumpkin Set Compostable diff --git a/Common/src/main/java/net/potionstudios/biomeswevegone/world/level/levelgen/structure/processor/processors/FruitBlockProcessor.java b/Common/src/main/java/net/potionstudios/biomeswevegone/world/level/levelgen/structure/processor/processors/FruitBlockProcessor.java index f087e090f..84927d907 100644 --- a/Common/src/main/java/net/potionstudios/biomeswevegone/world/level/levelgen/structure/processor/processors/FruitBlockProcessor.java +++ b/Common/src/main/java/net/potionstudios/biomeswevegone/world/level/levelgen/structure/processor/processors/FruitBlockProcessor.java @@ -16,6 +16,11 @@ import java.util.List; +/** + * Places Fruit Blocks Below Supported Leaves Blocks, if the block below is air. + * @see StructureProcessor + * @author Joseph T. McQuigg + */ public class FruitBlockProcessor extends StructureProcessor { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> @@ -37,13 +42,10 @@ private FruitBlockProcessor(Block fruitBlock) { List newInfo = new java.util.ArrayList<>(List.copyOf(processedBlockInfos)); processedBlockInfos.stream().filter(blockInfo -> blockInfo.state().is(this.fruitBlock.getLeaves())).forEach(leavesBlockInfo -> { - BlockPos leavesPos = leavesBlockInfo.pos(); - if (serverLevel.getBlockState(leavesPos.below()).isAir() && serverLevel.getRandom().nextBoolean()) { - newInfo.stream().filter(blockInfo -> blockInfo.pos().equals(leavesPos.below())).findFirst().ifPresent(fruitSpot -> { - newInfo.remove(fruitSpot); - newInfo.add(new StructureTemplate.StructureBlockInfo(fruitSpot.pos(), this.fruitBlock.defaultBlockState().setValue(BWGFruitBlock.AGE, serverLevel.getRandom().nextInt(BWGFruitBlock.MAX_AGE)), fruitSpot.nbt())); - }); - } + BlockPos fruitPos = leavesBlockInfo.pos().below(); + if (serverLevel.getBlockState(fruitPos).isAir() && serverLevel.getRandom().nextBoolean()) + newInfo.stream().filter(blockInfo -> blockInfo.pos().equals(fruitPos)).findFirst().ifPresent(fruitSpot -> + newInfo.set(newInfo.indexOf(fruitSpot), new StructureTemplate.StructureBlockInfo(fruitSpot.pos(), this.fruitBlock.defaultBlockState().setValue(BWGFruitBlock.AGE, serverLevel.getRandom().nextInt(BWGFruitBlock.MAX_AGE)), fruitSpot.nbt()))); }); return newInfo; }