From 9b94eecae3b7895c2dd351385a4da793fbfb6aa5 Mon Sep 17 00:00:00 2001 From: piexel Date: Sat, 24 Oct 2026 04:19:40 +0200 Subject: [PATCH] Move the built-in modules to the batch 4 API - BlocksModule writes through PlacementAccess.set(x, y, z, state) when a block has no block entity; WrittenBlocks keeps positions and states. - Hunk getters renamed to width(), height(), depth(). --- .../iris/builtin/blocks/WrittenBlocks.java | 35 ++++++++++++++----- .../iris/engine/actuator/DecorantModule.java | 8 ++--- .../iris/engine/actuator/TerrainShaper.java | 10 +++--- .../engine/decorator/DecorationScene.java | 2 +- .../iris/engine/decorator/DecoratorCore.java | 20 +++++------ .../decorator/IrisSeaSurfaceDecorator.java | 2 +- .../decorator/IrisShoreLineDecorator.java | 6 ++-- .../iris/engine/modifier/CaveApplying.java | 4 +-- .../iris/engine/modifier/DepositPlacer.java | 8 ++--- .../iris/engine/modifier/FloatingIslands.java | 2 +- .../iris/engine/modifier/MatterModule.java | 2 +- .../engine/modifier/PerfectionModule.java | 12 +++---- .../engine/modifier/SurfaceSmoothing.java | 14 ++++---- .../engine/object/placement/BlocksModule.java | 16 ++++----- .../object/placement/PlacementWorld.java | 15 ++++---- .../engine/object/placement/SnowModule.java | 4 +-- .../engine/object/placement/VacuumModule.java | 5 +-- 17 files changed, 93 insertions(+), 72 deletions(-) diff --git a/src/main/java/art/arcane/iris/builtin/blocks/WrittenBlocks.java b/src/main/java/art/arcane/iris/builtin/blocks/WrittenBlocks.java index df0c6d515..b7b9bec87 100644 --- a/src/main/java/art/arcane/iris/builtin/blocks/WrittenBlocks.java +++ b/src/main/java/art/arcane/iris/builtin/blocks/WrittenBlocks.java @@ -18,25 +18,44 @@ package art.arcane.iris.builtin.blocks; -import com.volmit.placement.PlacedBlock; +import com.volmit.block.BlockState; +import com.volmit.world.BlockPosition; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.function.BiConsumer; -/** The object's own blocks a placement wrote, in world positions, in the order they were written. */ +/** + * The object's own blocks a placement wrote, in world positions, in the order they were written. Positions and states + * are kept side by side, so recording a block allocates nothing beyond the position the placement already has. + */ public final class WrittenBlocks { - private final List blocks = new ArrayList<>(); + private final List positions = new ArrayList<>(); + private final List states = new ArrayList<>(); - public void add(PlacedBlock block) { - blocks.add(block); + public void add(BlockPosition position, BlockState state) { + positions.add(position); + states.add(state); } - public List blocks() { - return Collections.unmodifiableList(blocks); + public List positions() { + return Collections.unmodifiableList(positions); + } + + /** The written states, each at the index of its position in {@link #positions()}. */ + public List states() { + return Collections.unmodifiableList(states); + } + + /** Each written block's position and state, in the order they were written. */ + public void forEach(BiConsumer action) { + for (int index = 0; index < positions.size(); index++) { + action.accept(positions.get(index), states.get(index)); + } } public boolean isEmpty() { - return blocks.isEmpty(); + return positions.isEmpty(); } } diff --git a/src/main/java/art/arcane/iris/engine/actuator/DecorantModule.java b/src/main/java/art/arcane/iris/engine/actuator/DecorantModule.java index 6848c4fa6..2837c98ca 100644 --- a/src/main/java/art/arcane/iris/engine/actuator/DecorantModule.java +++ b/src/main/java/art/arcane/iris/engine/actuator/DecorantModule.java @@ -92,9 +92,9 @@ public final class DecorantModule implements IrisModule, ModuleLifecycle { int fluidHeight = scene.fluidHeight(); int worldHeight = scene.worldHeight(); - for (int i = 0; i < output.getWidth(); i++) { + for (int i = 0; i < output.width(); i++) { int realX = Math.round(x + i); - for (int j = 0; j < output.getDepth(); j++) { + for (int j = 0; j < output.depth(); j++) { int realZ = Math.round(z + j); DecoratedBiome biome = BiomeDecorators.biomeOf(settings, realX, realZ, terrain.surfaceKind(realX, realZ)); if (!decorators.hasDecorators(biome)) { @@ -103,7 +103,7 @@ public final class DecorantModule implements IrisModule, ModuleLifecycle { int height = terrain.surfaceHeight(realX, realZ); if (height >= 0 && height < fluidHeight && scene.isSolid(output.get(i, height, j)) - && height + 1 < output.getHeight() && scene.isWater(output.get(i, height + 1, j))) { + && height + 1 < output.height() && scene.isWater(output.get(i, height + 1, j))) { seaSurfaceDecorator.decorate(i, j, realX, Math.round(i + 1), Math.round(x + i - 1), realZ, Math.round(z + j + 1), Math.round(z + j - 1), @@ -120,7 +120,7 @@ public final class DecorantModule implements IrisModule, ModuleLifecycle { biome, height, worldHeight); } - if (height >= 0 && height < output.getHeight()) { + if (height >= 0 && height < output.height()) { surfaceDecorator.decorate(i, j, realX, realZ, biome, height, worldHeight - height); } } diff --git a/src/main/java/art/arcane/iris/engine/actuator/TerrainShaper.java b/src/main/java/art/arcane/iris/engine/actuator/TerrainShaper.java index 03071bb1b..22dc64da6 100644 --- a/src/main/java/art/arcane/iris/engine/actuator/TerrainShaper.java +++ b/src/main/java/art/arcane/iris/engine/actuator/TerrainShaper.java @@ -75,7 +75,7 @@ final class TerrainShaper { /** Fills the 16 x 16 columns of the chunk, one slice along x at a time. */ void shape(ChunkStageContext context) { Chunk chunk = new Chunk(context); - for (int sliceX = 0; sliceX < chunk.blocks.getWidth(); sliceX++) { + for (int sliceX = 0; sliceX < chunk.blocks.width(); sliceX++) { shapeSliver(chunk, sliceX); } } @@ -83,8 +83,8 @@ final class TerrainShaper { /** One plane from the sky to bedrock, one block thick along x. */ private void shapeSliver(Chunk chunk, int xf) { Hunk h = chunk.blocks; - int chunkHeight = h.getHeight(); - int chunkDepth = h.getDepth(); + int chunkHeight = h.height(); + int chunkDepth = h.depth(); int realX = xf + chunk.originX; for (int zf = 0; zf < chunkDepth; zf++) { @@ -192,7 +192,7 @@ final class TerrainShaper { /** The upper dimension's ground, filled in from the top of the column down to where it ends. */ private void fillUpperDimension(Chunk chunk, UpperDimension upper, int xf, int zf, int realX, int realZ) { Hunk h = chunk.blocks; - int chunkHeight = h.getHeight(); + int chunkHeight = h.height(); OptionalInt upperY = chunk.terrain.upperDimensionY(realX, realZ); if (upperY.isEmpty()) { return; @@ -273,7 +273,7 @@ final class TerrainShaper { this.settings = context.settings(); this.originX = context.originX(); this.originZ = context.originZ(); - this.clampedFluidHeight = Math.min(blocks.getHeight(), terrain.fluidHeight()); + this.clampedFluidHeight = Math.min(blocks.height(), terrain.fluidHeight()); int centreX = context.centreX(); int centreZ = context.centreZ(); this.bedrockEnabled = settings.at(BedrockSettings.class, centreX, centreZ).dimension().map(BedrockSettings::bedrock).orElse(true); diff --git a/src/main/java/art/arcane/iris/engine/decorator/DecorationScene.java b/src/main/java/art/arcane/iris/engine/decorator/DecorationScene.java index 4f5682981..a62a71add 100644 --- a/src/main/java/art/arcane/iris/engine/decorator/DecorationScene.java +++ b/src/main/java/art/arcane/iris/engine/decorator/DecorationScene.java @@ -95,7 +95,7 @@ public final class DecorationScene { /** The height of the chunk's volume. */ public int worldHeight() { - return blocks.getHeight(); + return blocks.height(); } public int fluidHeight() { diff --git a/src/main/java/art/arcane/iris/engine/decorator/DecoratorCore.java b/src/main/java/art/arcane/iris/engine/decorator/DecoratorCore.java index 0dee08c3f..bdd365d71 100644 --- a/src/main/java/art/arcane/iris/engine/decorator/DecoratorCore.java +++ b/src/main/java/art/arcane/iris/engine/decorator/DecoratorCore.java @@ -109,7 +109,7 @@ final class DecoratorCore { int x, int z, int realX, int height, int realZ, boolean underwater, boolean caveSkipFluid) { Hunk data = scene.blocks(); - if (height < 0 || height >= data.getHeight()) { + if (height < 0 || height >= data.height()) { return; } @@ -154,7 +154,7 @@ final class DecoratorCore { } int targetY = height + 1; - if (bd != null && targetY < data.getHeight() && scene.isAir(data.get(x, targetY, z))) { + if (bd != null && targetY < data.height() && scene.isAir(data.get(x, targetY, z))) { data.set(x, targetY, z, fixFacesForHunk(scene, bd, x, z, realX, targetY, realZ)); } } @@ -174,7 +174,7 @@ final class DecoratorCore { static void placeStackUp(ResolvedDecorator decorator, DecorationScene scene, int x, int z, int realX, int realZ, int height, int max, PlaceOpts opts) { Hunk data = scene.blocks(); - if (height < 0 || height >= data.getHeight()) { + if (height < 0 || height >= data.height()) { return; } @@ -187,7 +187,7 @@ final class DecoratorCore { if (stack == 1) { int targetY = height + 1; - if (targetY >= data.getHeight()) { + if (targetY >= data.height()) { return; } @@ -227,7 +227,7 @@ final class DecoratorCore { break; } - if (height + 1 + i >= data.getHeight()) { + if (height + 1 + i >= data.height()) { break; } @@ -249,7 +249,7 @@ final class DecoratorCore { static void placeStackDown(ResolvedDecorator decorator, DecorationScene scene, int x, int z, int realX, int realZ, int height, int minHeight, int max, PlaceOpts opts) { Hunk data = scene.blocks(); - if (height < 0 || height >= data.getHeight()) { + if (height < 0 || height >= data.height()) { return; } @@ -323,7 +323,7 @@ final class DecoratorCore { return; } - if (max > 1 && height + 1 < data.getHeight()) { + if (max > 1 && height + 1 < data.height()) { data.set(xf, height + 1, zf, bd); } } @@ -342,7 +342,7 @@ final class DecoratorCore { int placed = 0; for (int i = 0; i < stack; i++) { int h = height + 1 + i; - if (h >= height + max || h >= data.getHeight()) { + if (h >= height + max || h >= data.height()) { break; } double threshold = stack == 1 ? 0.0 : ((double) i) / (stack - 1); @@ -393,7 +393,7 @@ final class DecoratorCore { int xx = rX + face.dx(); int zz = rZ + face.dz(); - if (xx < 0 || xx > CHUNK_LAST || zz < 0 || zz > CHUNK_LAST || yy < 0 || yy >= hunk.getHeight()) { + if (xx < 0 || xx > CHUNK_LAST || zz < 0 || zz > CHUNK_LAST || yy < 0 || yy >= hunk.height()) { continue; } @@ -430,7 +430,7 @@ final class DecoratorCore { private static boolean canPlaceTwoBlockPlant(DecorationScene scene, int x, int z, int lowerY, int upperY, boolean caveSkipFluid) { Hunk data = scene.blocks(); - if (lowerY < 0 || upperY >= data.getHeight()) { + if (lowerY < 0 || upperY >= data.height()) { return false; } diff --git a/src/main/java/art/arcane/iris/engine/decorator/IrisSeaSurfaceDecorator.java b/src/main/java/art/arcane/iris/engine/decorator/IrisSeaSurfaceDecorator.java index 42f7574a2..e5b1fd4e6 100644 --- a/src/main/java/art/arcane/iris/engine/decorator/IrisSeaSurfaceDecorator.java +++ b/src/main/java/art/arcane/iris/engine/decorator/IrisSeaSurfaceDecorator.java @@ -56,7 +56,7 @@ public class IrisSeaSurfaceDecorator extends IrisEngineDecorator { if (stack == 1) { int targetY = height + 1; - if (targetY >= data.getHeight() || !DecoratorCore.canReplaceStackTarget(scene, data.get(x, targetY, z), false)) { + if (targetY >= data.height() || !DecoratorCore.canReplaceStackTarget(scene, data.get(x, targetY, z), false)) { return; } diff --git a/src/main/java/art/arcane/iris/engine/decorator/IrisShoreLineDecorator.java b/src/main/java/art/arcane/iris/engine/decorator/IrisShoreLineDecorator.java index 667807d2e..36218b994 100644 --- a/src/main/java/art/arcane/iris/engine/decorator/IrisShoreLineDecorator.java +++ b/src/main/java/art/arcane/iris/engine/decorator/IrisShoreLineDecorator.java @@ -60,7 +60,7 @@ public class IrisShoreLineDecorator extends IrisEngineDecorator { if (!decorator.isStacking()) { int targetY = height + 1; - if (targetY >= data.getHeight() + if (targetY >= data.height() || !DecoratorCore.canReplaceStackTarget(scene, data.get(x, targetY, z), false)) { return; } @@ -80,7 +80,7 @@ public class IrisShoreLineDecorator extends IrisEngineDecorator { if (stack == 1) { int targetY = height + 1; - if (targetY >= data.getHeight() || !DecoratorCore.canReplaceStackTarget(scene, data.get(x, targetY, z), false)) { + if (targetY >= data.height() || !DecoratorCore.canReplaceStackTarget(scene, data.get(x, targetY, z), false)) { return; } @@ -94,7 +94,7 @@ public class IrisShoreLineDecorator extends IrisEngineDecorator { for (int i = 0; i < stack; i++) { int h = height + i; int targetY = h + 1; - if (targetY >= data.getHeight() + if (targetY >= data.height() || !DecoratorCore.canReplaceStackTarget(scene, data.get(x, targetY, z), false)) { break; } diff --git a/src/main/java/art/arcane/iris/engine/modifier/CaveApplying.java b/src/main/java/art/arcane/iris/engine/modifier/CaveApplying.java index 1230bf1f6..5d0f54a6f 100644 --- a/src/main/java/art/arcane/iris/engine/modifier/CaveApplying.java +++ b/src/main/java/art/arcane/iris/engine/modifier/CaveApplying.java @@ -273,7 +273,7 @@ public class CaveApplying { // Surface-break carving must not leave an ore cap suspended across the opening. for (int columnIndex = 0; columnIndex < surfaceHeights.length; columnIndex++) { int surfaceY = surfaceHeights[columnIndex]; - if (surfaceY <= 0 || surfaceY >= output.getHeight()) { + if (surfaceY <= 0 || surfaceY >= output.height()) { continue; } @@ -540,7 +540,7 @@ public class CaveApplying { } private void processZone(CaveZone zone, int rx, int rz, int xx, int zz, Map customBiomeCache) { - int maxY = output.getHeight(); + int maxY = output.height(); if (zone.ceiling + 1 < maxY && classes.isDecorant(output.get(rx, zone.ceiling + 1, rz))) { output.set(rx, zone.ceiling + 1, rz, caveAir); diff --git a/src/main/java/art/arcane/iris/engine/modifier/DepositPlacer.java b/src/main/java/art/arcane/iris/engine/modifier/DepositPlacer.java index 646bcfd65..e1d5cf66e 100644 --- a/src/main/java/art/arcane/iris/engine/modifier/DepositPlacer.java +++ b/src/main/java/art/arcane/iris/engine/modifier/DepositPlacer.java @@ -138,7 +138,7 @@ final class DepositPlacer { this.mantle = context.mantle(); this.originX = context.originX(); this.originZ = context.originZ(); - this.worldHeight = blocks.getHeight(); + this.worldHeight = blocks.height(); this.minWorldY = terrain.minWorldY(); } @@ -413,9 +413,9 @@ final class DepositPlacer { } private static boolean isAirAt(Hunk data, int x, int y, int z, Predicate isAir) { - if (x < 0 || x >= data.getWidth() - || y < 0 || y >= data.getHeight() - || z < 0 || z >= data.getDepth()) { + if (x < 0 || x >= data.width() + || y < 0 || y >= data.height() + || z < 0 || z >= data.depth()) { return false; } return isAir.test(data.get(x, y, z)); diff --git a/src/main/java/art/arcane/iris/engine/modifier/FloatingIslands.java b/src/main/java/art/arcane/iris/engine/modifier/FloatingIslands.java index ab2469ccb..5d67f800a 100644 --- a/src/main/java/art/arcane/iris/engine/modifier/FloatingIslands.java +++ b/src/main/java/art/arcane/iris/engine/modifier/FloatingIslands.java @@ -448,7 +448,7 @@ final class FloatingIslands { this.originX = context.originX(); this.originZ = context.originZ(); this.output = context.hunk(BlockState.class); - this.height = output.getHeight(); + this.height = output.height(); this.blocks = context.world().resources().blocks(); this.settings = context.settings(); this.explosion = PaletteExplosion.of(settings, context.centreX(), context.centreZ()); diff --git a/src/main/java/art/arcane/iris/engine/modifier/MatterModule.java b/src/main/java/art/arcane/iris/engine/modifier/MatterModule.java index d8f8af0ad..467fc1e61 100644 --- a/src/main/java/art/arcane/iris/engine/modifier/MatterModule.java +++ b/src/main/java/art/arcane/iris/engine/modifier/MatterModule.java @@ -57,7 +57,7 @@ public final class MatterModule implements IrisModule { int originZ = context.originZ(); Hunk blocks = context.hunk(BlockState.class); int[] limits = upperLimits(context.terrain(), originX, originZ); - BlockBox chunk = new BlockBox(originX, 0, originZ, originX + CHUNK_WIDTH, blocks.getHeight(), originZ + CHUNK_WIDTH); + BlockBox chunk = new BlockBox(originX, 0, originZ, originX + CHUNK_WIDTH, blocks.height(), originZ + CHUNK_WIDTH); context.mantle().blocks().visit(chunk, (x, y, z, block) -> { int localX = x - originX; int localZ = z - originZ; diff --git a/src/main/java/art/arcane/iris/engine/modifier/PerfectionModule.java b/src/main/java/art/arcane/iris/engine/modifier/PerfectionModule.java index dae38916a..cfe52366b 100644 --- a/src/main/java/art/arcane/iris/engine/modifier/PerfectionModule.java +++ b/src/main/java/art/arcane/iris/engine/modifier/PerfectionModule.java @@ -77,9 +77,9 @@ public final class PerfectionModule implements IrisModule { /** {@code hidden} remembers per state instance what it is hidden as, itself for a block that is no ore. */ private static void hideOres(Hunk blocks, Map hidden) { - for (int x = 0; x < blocks.getWidth(); x++) { - for (int z = 0; z < blocks.getDepth(); z++) { - for (int y = blocks.getHeight() - 1; y >= 0; y--) { + for (int x = 0; x < blocks.width(); x++) { + for (int z = 0; z < blocks.depth(); z++) { + for (int y = blocks.height() - 1; y >= 0; y--) { BlockState block = blocks.get(x, y, z); BlockState shown = hidden.computeIfAbsent(block, state -> ORE_BASES.getOrDefault(state.material(), state)); if (shown != block) { @@ -98,8 +98,8 @@ public final class PerfectionModule implements IrisModule { /** One pass over every column; whether it removed anything. */ boolean removeUnsupportedDecorants() { boolean removed = false; - for (int x = 0; x < blocks.getWidth(); x++) { - for (int z = 0; z < blocks.getDepth(); z++) { + for (int x = 0; x < blocks.width(); x++) { + for (int z = 0; z < blocks.depth(); z++) { for (int surface : surfaces(x, z)) { removed |= removeIfUnsupported(x, surface, z); } @@ -149,7 +149,7 @@ public final class PerfectionModule implements IrisModule { } private int topSolid(int x, int z) { - for (int y = blocks.getHeight() - 1; y >= 0; y--) { + for (int y = blocks.height() - 1; y >= 0; y--) { if (isSolid(blocks.get(x, y, z))) { return y; } diff --git a/src/main/java/art/arcane/iris/engine/modifier/SurfaceSmoothing.java b/src/main/java/art/arcane/iris/engine/modifier/SurfaceSmoothing.java index 40842aebe..f098cabdd 100644 --- a/src/main/java/art/arcane/iris/engine/modifier/SurfaceSmoothing.java +++ b/src/main/java/art/arcane/iris/engine/modifier/SurfaceSmoothing.java @@ -85,7 +85,7 @@ final class SurfaceSmoothing { this.postRandom = new RNG(context.world().extension(IrisSeeds.class).orElseThrow().seed(IrisSeed.POST)); this.originX = context.originX(); this.originZ = context.originZ(); - this.planeWidth = blocks.getWidth() + 2; + this.planeWidth = blocks.width() + 2; this.heights = heightPlane(); this.walls = enabled(context, PostProcessingWallsSettings.class, PostProcessingWallsSettings::enabled, PostProcessingWallsSettings.DEFAULT_ENABLED); this.slabs = enabled(context, PostProcessingSlabsSettings.class, PostProcessingSlabsSettings::enabled, PostProcessingSlabsSettings.DEFAULT_ENABLED); @@ -98,8 +98,8 @@ final class SurfaceSmoothing { } private void smoothColumns() { - for (int i = 0; i < blocks.getWidth(); i++) { - for (int j = 0; j < blocks.getDepth(); j++) { + for (int i = 0; i < blocks.width(); i++) { + for (int j = 0; j < blocks.depth(); j++) { post(i, j); } } @@ -127,8 +127,8 @@ final class SurfaceSmoothing { } private int[] heightPlane() { - int width = blocks.getWidth(); - int depth = blocks.getDepth(); + int width = blocks.width(); + int depth = blocks.depth(); int[] plane = new int[planeWidth * (depth + 2)]; for (int j = -1; j <= depth; j++) { boolean edge = j == -1 || j == depth; @@ -346,7 +346,7 @@ final class SurfaceSmoothing { private void set(int x, int y, int z, BlockState block) { int localX = x - originX; int localZ = z - originZ; - if (localX < 0 || localZ < 0 || localX >= blocks.getWidth() || localZ >= blocks.getDepth() || y < 0 || y >= blocks.getHeight()) { + if (localX < 0 || localZ < 0 || localX >= blocks.width() || localZ >= blocks.depth() || y < 0 || y >= blocks.height()) { return; } blocks.set(localX, y, localZ, block); @@ -358,7 +358,7 @@ final class SurfaceSmoothing { * opposite edge. */ private BlockState get(int x, int y, int z) { - return blocks.get(clamp(x - originX, blocks.getWidth()), clamp(y, blocks.getHeight()), clamp(z - originZ, blocks.getDepth())); + return blocks.get(clamp(x - originX, blocks.width()), clamp(y, blocks.height()), clamp(z - originZ, blocks.depth())); } private static int clamp(int value, int size) { diff --git a/src/main/java/art/arcane/iris/engine/object/placement/BlocksModule.java b/src/main/java/art/arcane/iris/engine/object/placement/BlocksModule.java index b49124a67..5dde7efcd 100644 --- a/src/main/java/art/arcane/iris/engine/object/placement/BlocksModule.java +++ b/src/main/java/art/arcane/iris/engine/object/placement/BlocksModule.java @@ -40,7 +40,6 @@ import com.volmit.block.BlockState; import com.volmit.block.BlockTrait; import com.volmit.object.BlockEntityData; import com.volmit.object.ObjectBlock; -import com.volmit.placement.PlacedBlock; import com.volmit.stage.BlockStageContext; import com.volmit.stage.PlacementStageContext; import com.volmit.world.BlockPosition; @@ -133,9 +132,10 @@ public final class BlocksModule implements IrisModule { if (!shouldWrite(world, data, x, y, z, structurePiece)) { return; } - PlacedBlock placed = world.set(x, y, z, data, blockEntity); - placement.objectBlockWritten(placed.position()); - written.add(placed); + world.set(x, y, z, data, blockEntity); + BlockPosition position = new BlockPosition(x, y, z); + placement.objectBlockWritten(position); + written.add(position, data); } /** The object block as Iris places it: debug air shows where smart boring bored, and leaves never decay where the placer prevents it. */ @@ -230,11 +230,11 @@ public final class BlocksModule implements IrisModule { private static KList candidates(WrittenBlocks written, MarkerRule rule, ObjectPlacement placement) { KList candidates = new KList<>(); - for (PlacedBlock block : written.blocks()) { - if (rule.targets().stream().anyMatch(target -> marks(placement, rule, target, block.state()))) { - candidates.add(block.position()); + written.forEach((position, state) -> { + if (rule.targets().stream().anyMatch(target -> marks(placement, rule, target, state))) { + candidates.add(position); } - } + }); return candidates; } diff --git a/src/main/java/art/arcane/iris/engine/object/placement/PlacementWorld.java b/src/main/java/art/arcane/iris/engine/object/placement/PlacementWorld.java index 3e06a34f5..bcb736486 100644 --- a/src/main/java/art/arcane/iris/engine/object/placement/PlacementWorld.java +++ b/src/main/java/art/arcane/iris/engine/object/placement/PlacementWorld.java @@ -50,13 +50,16 @@ final class PlacementWorld { return has(get(x, y, z), BlockTrait.SOLID); } - PlacedBlock set(int x, int y, int z, BlockState state) { - return set(x, y, z, state, Optional.empty()); + void set(int x, int y, int z, BlockState state) { + access.set(x, y, z, state); } - PlacedBlock set(int x, int y, int z, BlockState state, Optional blockEntity) { - PlacedBlock block = new PlacedBlock(new BlockPosition(x, y, z), state, blockEntity); - access.set(block); - return block; + /** A block entity needs the record; a plain block takes the write that allocates nothing. */ + void set(int x, int y, int z, BlockState state, Optional blockEntity) { + if (blockEntity.isEmpty()) { + access.set(x, y, z, state); + return; + } + access.set(new PlacedBlock(new BlockPosition(x, y, z), state, blockEntity)); } } diff --git a/src/main/java/art/arcane/iris/engine/object/placement/SnowModule.java b/src/main/java/art/arcane/iris/engine/object/placement/SnowModule.java index 4bba49b6f..29dd41c01 100644 --- a/src/main/java/art/arcane/iris/engine/object/placement/SnowModule.java +++ b/src/main/java/art/arcane/iris/engine/object/placement/SnowModule.java @@ -26,7 +26,6 @@ import com.volmit.IrisModule; import com.volmit.ModuleInfo; import com.volmit.ModuleSetup; import com.volmit.block.BlockState; -import com.volmit.placement.PlacedBlock; import com.volmit.stage.PlacementStageContext; import com.volmit.world.BlockPosition; @@ -76,8 +75,7 @@ public final class SnowModule implements IrisModule { /** The highest written block of each column, columns in the order they were first written. */ private static Map columnTops(WrittenBlocks written) { Map tops = new LinkedHashMap<>(); - for (PlacedBlock block : written.blocks()) { - BlockPosition position = block.position(); + for (BlockPosition position : written.positions()) { tops.merge(columnKey(position), position, (current, next) -> next.y() > current.y() ? next : current); } return tops; diff --git a/src/main/java/art/arcane/iris/engine/object/placement/VacuumModule.java b/src/main/java/art/arcane/iris/engine/object/placement/VacuumModule.java index 1b9723e71..0e450ea51 100644 --- a/src/main/java/art/arcane/iris/engine/object/placement/VacuumModule.java +++ b/src/main/java/art/arcane/iris/engine/object/placement/VacuumModule.java @@ -33,6 +33,7 @@ import com.volmit.ModuleSetup; import com.volmit.block.BlockState; import com.volmit.block.BlockTrait; import com.volmit.stage.PlacementStageContext; +import com.volmit.world.BlockPosition; /** * Module {@code iris:vacuum}: bends the terrain around an object of a vacuum mode so it meets the object's @@ -68,8 +69,8 @@ public final class VacuumModule implements IrisModule { if (!prepared.mode().bendsTerrain() || written.isEmpty() || !prepared.terrain().hasWorld()) { return; } - int baseY = written.blocks().stream().mapToInt(block -> block.position().y()).min().orElseThrow(); - int topY = written.blocks().stream().mapToInt(block -> block.position().y()).max().orElseThrow(); + int baseY = written.positions().stream().mapToInt(BlockPosition::y).min().orElseThrow(); + int topY = written.positions().stream().mapToInt(BlockPosition::y).max().orElseThrow(); new Bend(context, prepared).apply(baseY, topY); }