diff --git a/core/src/main/java/art/arcane/iris/generation/decoration/tree/TreeBlockCanvas.java b/core/src/main/java/art/arcane/iris/generation/decoration/tree/TreeBlockCanvas.java deleted file mode 100644 index f4f85f48e..000000000 --- a/core/src/main/java/art/arcane/iris/generation/decoration/tree/TreeBlockCanvas.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Iris is a World Generator for Minecraft Bukkit Servers - * Copyright (c) 2022 Arcane Arts (Volmit Software) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package art.arcane.iris.generation.decoration.tree; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -public class TreeBlockCanvas { - public record Vec(int x, int y, int z) implements Comparable { - @Override - public int compareTo(Vec other) { - int comparison = Integer.compare(x, other.x); - if (comparison == 0) { - comparison = Integer.compare(y, other.y); - } - return comparison == 0 ? Integer.compare(z, other.z) : comparison; - } - } - - public enum Role { - TRUNK, SECONDARY_TRUNK, LEAF, SECONDARY_LEAF, DECORATOR - } - - public enum Axis { - NONE, X, Y, Z - } - - public record Cell(Role role, Axis axis, boolean exposed, int decoratorIndex, String facing) { - } - - private final Map cells = new HashMap<>(); - private final Set trunk = new HashSet<>(); - private final Set leaf = new HashSet<>(); - - public boolean has(int x, int y, int z) { - return cells.containsKey(new Vec(x, y, z)); - } - - public Cell get(int x, int y, int z) { - return cells.get(new Vec(x, y, z)); - } - - public void setTrunk(int x, int y, int z, Role role, Axis axis) { - Vec v = new Vec(x, y, z); - cells.put(v, new Cell(role, axis, false, -1, null)); - trunk.add(v); - leaf.remove(v); - } - - public boolean setLeaf(int x, int y, int z, Role role) { - Vec v = new Vec(x, y, z); - if (cells.containsKey(v)) { - return false; - } - cells.put(v, new Cell(role, Axis.NONE, false, -1, null)); - leaf.add(v); - return true; - } - - public boolean setDecor(int x, int y, int z, int decoratorIndex, String facing) { - Vec v = new Vec(x, y, z); - if (cells.containsKey(v)) { - return false; - } - cells.put(v, new Cell(Role.DECORATOR, Axis.NONE, false, decoratorIndex, facing)); - return true; - } - - public void markExposed(int x, int y, int z) { - Vec v = new Vec(x, y, z); - Cell c = cells.get(v); - if (c != null && !c.exposed()) { - cells.put(v, new Cell(c.role(), c.axis(), true, c.decoratorIndex(), c.facing())); - } - } - - public Map getCells() { - return cells; - } - - public Set getTrunk() { - return trunk; - } - - public Set getLeaf() { - return leaf; - } - - public boolean isEmpty() { - return cells.isEmpty(); - } -} diff --git a/core/src/main/java/art/arcane/iris/generation/decoration/tree/TreeGrounding.java b/core/src/main/java/art/arcane/iris/generation/decoration/tree/TreeGrounding.java deleted file mode 100644 index 68df796d6..000000000 --- a/core/src/main/java/art/arcane/iris/generation/decoration/tree/TreeGrounding.java +++ /dev/null @@ -1,122 +0,0 @@ -package art.arcane.iris.generation.decoration.tree; - -import art.arcane.iris.generation.geometry.IrisBlockVector; -import art.arcane.iris.generation.runtime.Engine; -import art.arcane.iris.pack.loading.IrisData; -import art.arcane.iris.structure.object.IObjectPlacer; -import art.arcane.iris.structure.object.IrisObjectPlacement; -import art.arcane.volmlib.nativelib.terrain.NativeBlockState; -import art.arcane.volmlib.nativelib.terrain.structure.NativeStructureVolume; -import art.arcane.volmlib.util.collection.KList; -import art.arcane.volmlib.util.math.BlockPosition; - -import java.util.ArrayList; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -public record TreeGrounding(List roots, int maxExtension, Set canopy) { - public TreeGrounding { - roots = List.copyOf(roots); - maxExtension = Math.max(0, Math.min(16, maxExtension)); - canopy = Set.copyOf(canopy); - } - - public static TreeGrounding create(List roots, int maxExtension, Set canopy) { - Map columns = new HashMap<>(); - for (Root root : roots) { - long key = ((long) root.x() << 32) | (root.z() & 0xffffffffL); - Root previous = columns.get(key); - if (previous == null || root.y() < previous.y()) { - columns.put(key, root); - } - } - List lowest = new ArrayList<>(columns.values()); - lowest.sort(Comparator.comparingInt(Root::x).thenComparingInt(Root::z)); - return new TreeGrounding(lowest, maxExtension, canopy); - } - - public boolean isCanopy(int x, int y, int z) { - return canopy.contains(new TreeBlockCanvas.Vec(x, y, z)); - } - - public KList supportOffsets() { - KList offsets = new KList<>(); - for (Root root : roots) { - offsets.add(new IrisBlockVector(root.x(), root.y(), root.z())); - } - return offsets; - } - - public Plan plan(IObjectPlacer placer, Placement placement) { - List extensions = new ArrayList<>(); - IrisObjectPlacement config = placement.config(); - BlockPosition origin = placement.origin(); - BlockPosition spin = placement.spin(); - int solidDepth = Math.max(1, config.getSurfaceSupportDepth()); - for (Root root : roots) { - IrisBlockVector offset = config.getRotation().rotate( - new IrisBlockVector(root.x(), root.y(), root.z()), spin.getX(), spin.getY(), spin.getZ()); - offset = config.getTranslate().translate(offset, config.getRotation(), spin.getX(), spin.getY(), spin.getZ()); - int x = origin.getX() + (int) Math.round(offset.getX()); - int y = origin.getY() + (int) Math.round(offset.getY()); - int z = origin.getZ() + (int) Math.round(offset.getZ()); - int surface = placer.getHighest(x, z, placement.data(), true); - int contact = Math.min(surface, y - 1); - if (y - contact - 1 > maxExtension) { - return Plan.UNSUPPORTED; - } - for (int below = 0; below < solidDepth; below++) { - if (placer.isCarved(x, contact - below, z) || !placer.isSurfaceSolid(x, contact - below, z)) { - return Plan.UNSUPPORTED; - } - } - if (contact < y - 1) { - NativeBlockState state = config.getRotation().rotate(root.state(), spin.getX(), spin.getY(), spin.getZ()); - if (state == null) { - return Plan.UNSUPPORTED; - } - Extension extension = new Extension(x, y - 1, contact, z, state); - if (intersectsStructure(placer, extension)) { - return Plan.UNSUPPORTED; - } - extensions.add(extension); - } - } - return new Plan(!roots.isEmpty(), List.copyOf(extensions)); - } - - private static boolean intersectsStructure(IObjectPlacer placer, Extension extension) { - Engine engine = placer.getEngine(); - if (engine == null) { - return false; - } - KList volumes = engine.getNativeStructureVolumes( - extension.x(), extension.z(), extension.x(), extension.z()); - if (volumes == null) { - return false; - } - for (NativeStructureVolume volume : volumes) { - if (volume.intersects(extension.x(), extension.bottomY() + engine.getMinHeight(), extension.z(), - extension.x(), extension.topY() + engine.getMinHeight(), extension.z())) { - return true; - } - } - return false; - } - - public record Root(int x, int y, int z, NativeBlockState state) { - } - - public record Placement(IrisData data, IrisObjectPlacement config, BlockPosition origin, BlockPosition spin) { - } - - public record Extension(int x, int topY, int bottomY, int z, NativeBlockState state) { - } - - public record Plan(boolean supported, List extensions) { - private static final Plan UNSUPPORTED = new Plan(false, List.of()); - } -} diff --git a/core/src/main/java/art/arcane/iris/generation/mantle/CaveObjectPlacementTransaction.java b/core/src/main/java/art/arcane/iris/generation/mantle/CaveObjectPlacementTransaction.java index 686ac03bf..1f3dd3da9 100644 --- a/core/src/main/java/art/arcane/iris/generation/mantle/CaveObjectPlacementTransaction.java +++ b/core/src/main/java/art/arcane/iris/generation/mantle/CaveObjectPlacementTransaction.java @@ -28,7 +28,6 @@ import art.arcane.iris.structure.object.IObjectPlacer; import art.arcane.iris.generation.block.TileData; import art.arcane.iris.generation.hydrology.cave.HydrologyCaveCell; import art.arcane.volmlib.nativelib.terrain.NativeBlockState; -import art.arcane.volmlib.util.math.BlockPosition; import art.arcane.volmlib.util.matter.MatterCavern; import art.arcane.iris.generation.block.B; import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap; @@ -56,13 +55,11 @@ final class CaveObjectPlacementTransaction implements IObjectPlacer { private int[] mutationZ = new int[64]; private Object[] mutationValues = new Object[64]; private byte[] mutationKinds = new byte[64]; - private boolean[] mutationCanopies = new boolean[64]; private int mutationCount; private final Long2ObjectOpenHashMap bufferedBlocks; private final Long2IntOpenHashMap surfaceHeights; private final Long2IntOpenHashMap caveCeilings; private int blockWrites; - private BlockPosition canopyPosition; private boolean originKnown; private int originX; private int originZ; @@ -129,34 +126,15 @@ final class CaveObjectPlacementTransaction implements IObjectPlacer { } private void applyMutations() { - boolean canopyOpen = false; - boolean skipCanopy = false; - try { - for (int index = 0; index < mutationCount; index++) { - int x = mutationX[index]; - int y = mutationY[index]; - int z = mutationZ[index]; - Object value = mutationValues[index]; - boolean canopy = mutationCanopies[index]; - if (value instanceof NativeBlockState) { - if (canopyOpen) { - delegate.endTreeCanopy(); - canopyOpen = false; - } - skipCanopy = canopy && !delegate.beginTreeCanopy(new BlockPosition(x, y, z)); - canopyOpen = canopy && !skipCanopy; - } - if (!canopy || !skipCanopy) { - switch (mutationKinds[index]) { - case BLOCK -> delegate.set(x, y, z, (NativeBlockState) value); - case TILE -> delegate.setTile(x, y, z, (TileData) value); - default -> delegate.setData(x, y, z, value); - } - } - } - } finally { - if (canopyOpen) { - delegate.endTreeCanopy(); + for (int index = 0; index < mutationCount; index++) { + int x = mutationX[index]; + int y = mutationY[index]; + int z = mutationZ[index]; + Object value = mutationValues[index]; + switch (mutationKinds[index]) { + case BLOCK -> delegate.set(x, y, z, (NativeBlockState) value); + case TILE -> delegate.setTile(x, y, z, (TileData) value); + default -> delegate.setData(x, y, z, value); } } } @@ -176,14 +154,12 @@ final class CaveObjectPlacementTransaction implements IObjectPlacer { mutationZ = Arrays.copyOf(mutationZ, capacity); mutationValues = Arrays.copyOf(mutationValues, capacity); mutationKinds = Arrays.copyOf(mutationKinds, capacity); - mutationCanopies = Arrays.copyOf(mutationCanopies, capacity); } mutationX[mutationCount] = x; mutationY[mutationCount] = y; mutationZ[mutationCount] = z; mutationValues[mutationCount] = value; mutationKinds[mutationCount] = kind; - mutationCanopies[mutationCount] = isCanopy(x, y, z); mutationCount++; } @@ -223,25 +199,6 @@ final class CaveObjectPlacementTransaction implements IObjectPlacer { blockWrites++; } - @Override - public boolean beginTreeCanopy(BlockPosition position) { - if (!IObjectPlacer.super.beginTreeCanopy(position)) { - return false; - } - canopyPosition = position; - return true; - } - - @Override - public void endTreeCanopy() { - canopyPosition = null; - } - - private boolean isCanopy(int x, int y, int z) { - return canopyPosition != null && canopyPosition.getX() == x - && canopyPosition.getY() == y && canopyPosition.getZ() == z; - } - @Override public NativeBlockState get(int x, int y, int z) { NativeBlockState buffered = bufferedBlocks.isEmpty() ? null : bufferedBlocks.get(bufferKey(x, y, z)); diff --git a/core/src/main/java/art/arcane/iris/generation/mantle/FloatingObjectPlacementTransaction.java b/core/src/main/java/art/arcane/iris/generation/mantle/FloatingObjectPlacementTransaction.java index df5bbf36a..b2817c2ac 100644 --- a/core/src/main/java/art/arcane/iris/generation/mantle/FloatingObjectPlacementTransaction.java +++ b/core/src/main/java/art/arcane/iris/generation/mantle/FloatingObjectPlacementTransaction.java @@ -25,7 +25,6 @@ import art.arcane.iris.structure.object.IObjectPlacer; import art.arcane.iris.generation.block.TileData; import art.arcane.iris.structure.object.ObjectWaterRule; import art.arcane.volmlib.nativelib.terrain.NativeBlockState; -import art.arcane.volmlib.util.math.BlockPosition; import art.arcane.iris.generation.block.B; import art.arcane.volmlib.util.collection.KList; import org.jetbrains.annotations.Nullable; @@ -48,7 +47,6 @@ final class FloatingObjectPlacementTransaction implements IObjectPlacer { private final ObjectWaterRule waterRule; private ObjectHydrologyVeto waterVeto; private int blockWrites; - private BlockPosition canopyPosition; FloatingObjectPlacementTransaction(IObjectPlacer delegate, ObjectContinuationBundle.PlacementKey placementKey, ObjectWaterRule waterRule) { @@ -100,17 +98,9 @@ final class FloatingObjectPlacementTransaction implements IObjectPlacer { } IrisMatterSupport.ensureRegistered(); LinkedHashMap payloads = new LinkedHashMap<>(); - boolean skipCanopy = false; for (BufferedMutation mutation : mutations) { ObjectContinuationBundle.ChunkPosition chunk = new ObjectContinuationBundle.ChunkPosition(mutation.x() >> 4, mutation.z() >> 4); Matter payload = payloads.computeIfAbsent(chunk, ignored -> new IrisMatter(16, engine.getHeight(), 16)); - if (mutation.value() instanceof NativeBlockState) { - skipCanopy = !ObjectContinuationPersistence.beginBlock(payload, mutation.x() & 15, - mutation.y(), mutation.z() & 15, mutation.canopy()); - } - if (mutation.canopy() && skipCanopy) { - continue; - } ObjectContinuationPersistence.put(payload, mutation.x() & 15, mutation.y(), mutation.z() & 15, mutation.value()); } LinkedHashMap> destinations = new LinkedHashMap<>(); @@ -120,27 +110,8 @@ final class FloatingObjectPlacementTransaction implements IObjectPlacer { } private void applyMutations() { - boolean canopyOpen = false; - boolean skipCanopy = false; - try { - for (BufferedMutation mutation : mutations) { - if (mutation.value() instanceof NativeBlockState) { - if (canopyOpen) { - delegate.endTreeCanopy(); - canopyOpen = false; - } - skipCanopy = mutation.canopy() - && !delegate.beginTreeCanopy(new BlockPosition(mutation.x(), mutation.y(), mutation.z())); - canopyOpen = mutation.canopy() && !skipCanopy; - } - if (!mutation.canopy() || !skipCanopy) { - mutation.apply(delegate); - } - } - } finally { - if (canopyOpen) { - delegate.endTreeCanopy(); - } + for (BufferedMutation mutation : mutations) { + mutation.apply(delegate); } } @@ -165,30 +136,11 @@ final class FloatingObjectPlacementTransaction implements IObjectPlacer { if (state == null || waterVeto().keepsBlock(x, y, z, state, waterRule)) { return; } - mutations.add(new BlockMutation(x, y, z, state, isCanopy(x, y, z))); + mutations.add(new BlockMutation(x, y, z, state)); bufferedBlocks.put(new PositionKey(x, y, z), state); blockWrites++; } - @Override - public boolean beginTreeCanopy(BlockPosition position) { - if (!IObjectPlacer.super.beginTreeCanopy(position)) { - return false; - } - canopyPosition = position; - return true; - } - - @Override - public void endTreeCanopy() { - canopyPosition = null; - } - - private boolean isCanopy(int x, int y, int z) { - return canopyPosition != null && canopyPosition.getX() == x - && canopyPosition.getY() == y && canopyPosition.getZ() == z; - } - @Override public NativeBlockState get(int x, int y, int z) { NativeBlockState state = bufferedBlocks.get(new PositionKey(x, y, z)); @@ -234,7 +186,7 @@ final class FloatingObjectPlacementTransaction implements IObjectPlacer { @Override public void setTile(int x, int y, int z, TileData tile) { if (tile != null) { - mutations.add(new TileMutation(x, y, z, tile, isCanopy(x, y, z))); + mutations.add(new TileMutation(x, y, z, tile)); } } @@ -243,7 +195,7 @@ final class FloatingObjectPlacementTransaction implements IObjectPlacer { if (data == null || keepsWater(x, y, z, data)) { return; } - mutations.add(new DataMutation(x, y, z, data, isCanopy(x, y, z))); + mutations.add(new DataMutation(x, y, z, data)); if (data instanceof NativeBlockState state) { bufferedBlocks.put(new PositionKey(x, y, z), state); blockWrites++; @@ -300,26 +252,24 @@ final class FloatingObjectPlacementTransaction implements IObjectPlacer { Object value(); - boolean canopy(); - void apply(IObjectPlacer placer); } - private record BlockMutation(int x, int y, int z, NativeBlockState value, boolean canopy) implements BufferedMutation { + private record BlockMutation(int x, int y, int z, NativeBlockState value) implements BufferedMutation { @Override public void apply(IObjectPlacer placer) { placer.set(x, y, z, value); } } - private record TileMutation(int x, int y, int z, TileData value, boolean canopy) implements BufferedMutation { + private record TileMutation(int x, int y, int z, TileData value) implements BufferedMutation { @Override public void apply(IObjectPlacer placer) { placer.setTile(x, y, z, value); } } - private record DataMutation(int x, int y, int z, Object value, boolean canopy) implements BufferedMutation { + private record DataMutation(int x, int y, int z, Object value) implements BufferedMutation { @Override public void apply(IObjectPlacer placer) { placer.setData(x, y, z, value); diff --git a/core/src/main/java/art/arcane/iris/generation/mantle/GoldenDebugObjectPlacer.java b/core/src/main/java/art/arcane/iris/generation/mantle/GoldenDebugObjectPlacer.java index 4ac2ef8bf..f7987cf74 100644 --- a/core/src/main/java/art/arcane/iris/generation/mantle/GoldenDebugObjectPlacer.java +++ b/core/src/main/java/art/arcane/iris/generation/mantle/GoldenDebugObjectPlacer.java @@ -24,7 +24,6 @@ import art.arcane.iris.structure.object.IObjectPlacer; import art.arcane.iris.generation.block.TileData; import art.arcane.iris.spi.IrisLogging; import art.arcane.volmlib.nativelib.terrain.NativeBlockState; -import art.arcane.volmlib.util.math.BlockPosition; final class GoldenDebugObjectPlacer implements IObjectPlacer { private static final int[] GOLDEN_DEBUG_TARGET = parseGoldenDebugTarget(resolveGoldenDebugSpec()); @@ -94,16 +93,6 @@ final class GoldenDebugObjectPlacer implements IObjectPlacer { delegate.set(x, y, z, d); } - @Override - public boolean beginTreeCanopy(BlockPosition position) { - return delegate.beginTreeCanopy(position); - } - - @Override - public void endTreeCanopy() { - delegate.endTreeCanopy(); - } - @Override public NativeBlockState get(int x, int y, int z) { return delegate.get(x, y, z); diff --git a/core/src/main/java/art/arcane/iris/generation/mantle/MutationLog.java b/core/src/main/java/art/arcane/iris/generation/mantle/MutationLog.java index 0386bc194..8ead45580 100644 --- a/core/src/main/java/art/arcane/iris/generation/mantle/MutationLog.java +++ b/core/src/main/java/art/arcane/iris/generation/mantle/MutationLog.java @@ -9,7 +9,6 @@ import java.util.Objects; final class MutationLog { private static final byte CUSTOM = 1; - private static final byte CANOPY = 2; private static final byte ENTERS_WATER = 4; private static final byte FORCED = 8; @@ -32,16 +31,16 @@ final class MutationLog { throw new IllegalArgumentException("Object mutation type " + key.type().getName() + " does not match its value " + value.getClass().getName()); } - log.add(key.x(), key.y(), key.z(), value, false, set.canopy(), ObjectWaterRule.KEEP_OUT); + log.add(key.x(), key.y(), key.z(), value, false, ObjectWaterRule.KEEP_OUT); } case ObjectDestinationTransaction.CustomBlockMutation block -> log.add(key.x(), key.y(), key.z(), - Objects.requireNonNull(block.state(), "custom block state"), true, block.canopy(), ObjectWaterRule.KEEP_OUT); + Objects.requireNonNull(block.state(), "custom block state"), true, ObjectWaterRule.KEEP_OUT); } } return log; } - void add(int blockX, int blockY, int blockZ, Object value, boolean custom, boolean canopy, ObjectWaterRule rule) { + void add(int blockX, int blockY, int blockZ, Object value, boolean custom, ObjectWaterRule rule) { if (size == values.length) { int capacity = size * 2; x = Arrays.copyOf(x, capacity); @@ -54,7 +53,7 @@ final class MutationLog { y[size] = blockY; z[size] = blockZ; values[size] = value; - flags[size] = (byte) ((custom ? CUSTOM : 0) | (canopy ? CANOPY : 0) | (rule == ObjectWaterRule.ENTERS_WATER ? ENTERS_WATER : 0) | (rule == ObjectWaterRule.FORCED ? FORCED : 0)); + flags[size] = (byte) ((custom ? CUSTOM : 0) | (rule == ObjectWaterRule.ENTERS_WATER ? ENTERS_WATER : 0) | (rule == ObjectWaterRule.FORCED ? FORCED : 0)); size++; } @@ -82,10 +81,6 @@ final class MutationLog { return (flags[index] & CUSTOM) != 0; } - boolean canopy(int index) { - return (flags[index] & CANOPY) != 0; - } - ObjectWaterRule waterRule(int index) { if ((flags[index] & FORCED) != 0) { return ObjectWaterRule.FORCED; diff --git a/core/src/main/java/art/arcane/iris/generation/mantle/ObjectContinuationPersistence.java b/core/src/main/java/art/arcane/iris/generation/mantle/ObjectContinuationPersistence.java index 2a588f411..9e8213302 100644 --- a/core/src/main/java/art/arcane/iris/generation/mantle/ObjectContinuationPersistence.java +++ b/core/src/main/java/art/arcane/iris/generation/mantle/ObjectContinuationPersistence.java @@ -14,7 +14,6 @@ import art.arcane.volmlib.util.matter.MatterSlice; import java.util.List; import java.util.Map; -import java.util.BitSet; import java.util.function.Supplier; public final class ObjectContinuationPersistence { @@ -71,35 +70,14 @@ public final class ObjectContinuationPersistence { } } - public static boolean beginBlock(Matter payload, int x, int y, int z, boolean canopy) { - if (canopy) { - MatterSlice blocks = payload.getSlice(NativeBlockState.class); - NativeBlockState existing = blocks == null ? null : blocks.get(x, y, z); - if (existing != null && existing.isSolid()) { - return false; - } - payload.slice(TreeCanopy.class).set(x, y, z, TreeCanopy.INSTANCE); - } else { - MatterSlice conditions = payload.getSlice(TreeCanopy.class); - if (conditions != null) { - conditions.set(x, y, z, null); - } - } - return true; - } - public static void restore(Mantle mantle, int chunkX, int chunkZ, Matter continuation, Hunk blocks, boolean applyBlocks) { - BitSet blocked = blockedCanopy(continuation, blocks, applyBlocks); MatterSlice states = continuation.getSlice(NativeBlockState.class); MantleChunk chunk = mantle.useChunk(chunkX, chunkZ); try { synchronized (chunk) { if (states != null) { states.iterateSync((x, y, z, state) -> { - if (blocked.get(cellIndex(x, y, z))) { - return; - } Matter section = chunk.get(y >> 4); if (section != null) { clearMetadata(section, x, y & 15, z); @@ -107,46 +85,18 @@ public final class ObjectContinuationPersistence { }); } for (Map.Entry, MatterSlice> entry : continuation.getSliceMap().entrySet()) { - if (entry.getKey() == TreeCanopy.class) { - continue; - } - entry.getValue().iterateSync((x, y, z, value) -> { - if (!blocked.get(cellIndex(x, y, z))) { - chunk.getOrCreate(y >> 4).slice(entry.getKey()).set(x, y & 15, z, value); - } - }); + entry.getValue().iterateSync((x, y, z, value) -> + chunk.getOrCreate(y >> 4).slice(entry.getKey()).set(x, y & 15, z, value)); } } } finally { chunk.release(); } if (applyBlocks && states != null) { - states.iterateSync((x, y, z, state) -> { - if (!blocked.get(cellIndex(x, y, z))) { - blocks.set(x, y, z, state); - } - }); + states.iterateSync((x, y, z, state) -> blocks.set(x, y, z, state)); } } - private static BitSet blockedCanopy(Matter continuation, Hunk blocks, boolean applyBlocks) { - BitSet blocked = new BitSet(); - MatterSlice conditions = continuation.getSlice(TreeCanopy.class); - if (conditions != null) { - conditions.iterateSync((x, y, z, condition) -> { - NativeBlockState existing = blocks.get(x, y, z); - if (!applyBlocks || existing != null && existing.isSolid()) { - blocked.set(cellIndex(x, y, z)); - } - }); - } - return blocked; - } - - private static int cellIndex(int x, int y, int z) { - return (y << 8) | (z << 4) | x; - } - private static void clearMetadata(Matter section, int x, int y, int z) { clearMetadata(section.getSlice(Identifier.class), x, y, z); clearMetadata(section.getSlice(String.class), x, y, z); diff --git a/core/src/main/java/art/arcane/iris/generation/mantle/ObjectDestinationTransaction.java b/core/src/main/java/art/arcane/iris/generation/mantle/ObjectDestinationTransaction.java index 1e8b36c8f..696cc77bd 100644 --- a/core/src/main/java/art/arcane/iris/generation/mantle/ObjectDestinationTransaction.java +++ b/core/src/main/java/art/arcane/iris/generation/mantle/ObjectDestinationTransaction.java @@ -9,7 +9,6 @@ import art.arcane.iris.generation.subterrain.SubterrainRasterizer; import art.arcane.iris.generation.block.TileData; import art.arcane.iris.structure.object.ObjectWaterRule; import art.arcane.volmlib.nativelib.terrain.NativeBlockState; -import art.arcane.volmlib.util.math.BlockPosition; import art.arcane.iris.generation.block.B; import art.arcane.iris.world.storage.matter.TileWrapper; import art.arcane.volmlib.util.matter.MatterCavern; @@ -35,7 +34,6 @@ final class ObjectDestinationTransaction implements ObjectPassPlacer { private final MutationLog log = new MutationLog(); private final List placements = new ArrayList<>(); private final Long2ObjectOpenHashMap> overlay; - private BlockPosition canopyPosition; private boolean subterrainKnown; private int subterrainX; private int subterrainY; @@ -98,7 +96,6 @@ final class ObjectDestinationTransaction implements ObjectPassPlacer { } int baseX = destinationChunkX << 4; int baseZ = destinationChunkZ << 4; - boolean skipCanopy = false; int end = plan.slotEnd(slot); for (int index = plan.slotStart(slot); index < end; index++) { int cell = plan.cellAt(index); @@ -106,20 +103,11 @@ final class ObjectDestinationTransaction implements ObjectPassPlacer { int y = ObjectSourcePlan.cellY(cell); int z = baseZ | ObjectSourcePlan.cellZ(cell); Object value = plan.valueAt(index); - boolean custom = ObjectSourcePlan.isCustom(cell); - boolean canopy = ObjectSourcePlan.isCanopy(cell); ObjectWaterRule rule = ObjectSourcePlan.waterRule(cell); - if (custom || value instanceof NativeBlockState) { - NativeBlockState existing = canopy ? get(x, y, z) : null; - skipCanopy = existing != null && existing.isSolid(); - } - if (canopy && skipCanopy) { - continue; - } - if (custom) { - set(x, y, z, (NativeBlockState) value, canopy, rule); + if (ObjectSourcePlan.isCustom(cell)) { + set(x, y, z, (NativeBlockState) value, rule); } else { - setData(x, y, z, value, canopy, rule); + setData(x, y, z, value, rule); } } } @@ -184,10 +172,10 @@ final class ObjectDestinationTransaction implements ObjectPassPlacer { @Override public void set(int x, int y, int z, NativeBlockState state) { - set(x, y, z, state, isCanopy(x, y, z), waterRule); + set(x, y, z, state, waterRule); } - private void set(int x, int y, int z, NativeBlockState state, boolean canopy, ObjectWaterRule rule) { + private void set(int x, int y, int z, NativeBlockState state, ObjectWaterRule rule) { if (state == null) { return; } @@ -202,29 +190,10 @@ final class ObjectDestinationTransaction implements ObjectPassPlacer { cell.block = baseState; cell.tile = CLEARED; cell.identifier = identifier; - log.add(x, y, z, state, true, canopy, rule); + log.add(x, y, z, state, true, rule); return; } - setData(x, y, z, state, canopy, rule); - } - - @Override - public boolean beginTreeCanopy(BlockPosition position) { - if (!ObjectPassPlacer.super.beginTreeCanopy(position)) { - return false; - } - canopyPosition = position; - return true; - } - - @Override - public void endTreeCanopy() { - canopyPosition = null; - } - - private boolean isCanopy(int x, int y, int z) { - return canopyPosition != null && canopyPosition.getX() == x - && canopyPosition.getY() == y && canopyPosition.getZ() == z; + setData(x, y, z, state, rule); } @Override @@ -296,10 +265,10 @@ final class ObjectDestinationTransaction implements ObjectPassPlacer { @Override public void setData(int x, int y, int z, T data) { - setData(x, y, z, data, isCanopy(x, y, z), waterRule); + setData(x, y, z, data, waterRule); } - private void setData(int x, int y, int z, Object data, boolean canopy, ObjectWaterRule rule) { + private void setData(int x, int y, int z, Object data, ObjectWaterRule rule) { if (data == null || y < 0 || y >= worldHeight || protectsSubterrain(x, y, z)) { return; @@ -319,7 +288,7 @@ final class ObjectDestinationTransaction implements ObjectPassPlacer { } else { cell.put(type, data); } - log.add(x, y, z, data, false, canopy, rule); + log.add(x, y, z, data, false, rule); } @Override @@ -548,11 +517,9 @@ final class ObjectDestinationTransaction implements ObjectPassPlacer { int z(); DataKey key(); - - boolean canopy(); } - record SetMutation(DataKey key, Object value, boolean canopy) implements Mutation { + record SetMutation(DataKey key, Object value) implements Mutation { @Override public int x() { return key.x(); @@ -564,7 +531,7 @@ final class ObjectDestinationTransaction implements ObjectPassPlacer { } } - record CustomBlockMutation(DataKey key, NativeBlockState state, boolean canopy) implements Mutation { + record CustomBlockMutation(DataKey key, NativeBlockState state) implements Mutation { @Override public int x() { return key.x(); diff --git a/core/src/main/java/art/arcane/iris/generation/mantle/ObjectSourcePlan.java b/core/src/main/java/art/arcane/iris/generation/mantle/ObjectSourcePlan.java index f1afbeb33..11f13ea95 100644 --- a/core/src/main/java/art/arcane/iris/generation/mantle/ObjectSourcePlan.java +++ b/core/src/main/java/art/arcane/iris/generation/mantle/ObjectSourcePlan.java @@ -32,7 +32,6 @@ final class ObjectSourcePlan { private static final int PLACEMENT_DESTINATION_BYTES = 40; private static final int UNKNOWN_PAYLOAD_BYTES = 256; private static final int CUSTOM_BIT = 1 << 8; - private static final int CANOPY_BIT = 1 << 9; private static final int ENTERS_WATER_BIT = 1 << 10; private static final int FORCED_BIT = 1 << 11; private static final int Y_SHIFT = 12; @@ -92,7 +91,7 @@ final class ObjectSourcePlan { if (y < 0 || y > MAXIMUM_Y) { throw new IllegalArgumentException("Object mutation height is outside the plan range: " + y); } - cells[position] = (y << Y_SHIFT) | (log.custom(logged) ? CUSTOM_BIT : 0) | (log.canopy(logged) ? CANOPY_BIT : 0) + cells[position] = (y << Y_SHIFT) | (log.custom(logged) ? CUSTOM_BIT : 0) | waterBits(log.waterRule(logged)) | ((log.z(logged) & 15) << 4) | (log.x(logged) & 15); valueIndexes[position] = table.indexOf(log.value(logged)); } @@ -240,10 +239,6 @@ final class ObjectSourcePlan { return (cell & CUSTOM_BIT) != 0; } - static boolean isCanopy(int cell) { - return (cell & CANOPY_BIT) != 0; - } - static ObjectWaterRule waterRule(int cell) { if ((cell & FORCED_BIT) != 0) { return ObjectWaterRule.FORCED; @@ -267,9 +262,9 @@ final class ObjectSourcePlan { Object value = valueAt(index); return isCustom(cell) ? new ObjectDestinationTransaction.CustomBlockMutation( - new ObjectDestinationTransaction.DataKey(x, y, z, NativeBlockState.class), (NativeBlockState) value, isCanopy(cell)) + new ObjectDestinationTransaction.DataKey(x, y, z, NativeBlockState.class), (NativeBlockState) value) : new ObjectDestinationTransaction.SetMutation( - new ObjectDestinationTransaction.DataKey(x, y, z, typeOf(value)), value, isCanopy(cell)); + new ObjectDestinationTransaction.DataKey(x, y, z, typeOf(value)), value); } List mutationsFor(int chunkX, int chunkZ) { @@ -331,17 +326,10 @@ final class ObjectSourcePlan { static byte[] encode(List mutations, int height) { IrisMatterSupport.ensureRegistered(); Matter payload = new IrisMatter(16, height, 16); - boolean skipCanopy = false; for (ObjectDestinationTransaction.Mutation mutation : mutations) { ObjectDestinationTransaction.DataKey key = mutation.key(); int x = key.x() & 15; int z = key.z() & 15; - if (key.type() == NativeBlockState.class) { - skipCanopy = !ObjectContinuationPersistence.beginBlock(payload, x, key.y(), z, mutation.canopy()); - } - if (mutation.canopy() && skipCanopy) { - continue; - } if (mutation instanceof ObjectDestinationTransaction.CustomBlockMutation custom) { payload.slice(NativeBlockState.class).set(x, key.y(), z, custom.state().placementBaseState()); payload.slice(Identifier.class).set(x, key.y(), z, Identifier.fromString(custom.state().deferredPlacementKey())); diff --git a/core/src/main/java/art/arcane/iris/generation/mantle/TreeCanopy.java b/core/src/main/java/art/arcane/iris/generation/mantle/TreeCanopy.java deleted file mode 100644 index e3270c6f8..000000000 --- a/core/src/main/java/art/arcane/iris/generation/mantle/TreeCanopy.java +++ /dev/null @@ -1,5 +0,0 @@ -package art.arcane.iris.generation.mantle; - -public enum TreeCanopy { - INSTANCE -} diff --git a/core/src/main/java/art/arcane/iris/pack/datapack/export/compile/object/BakedVariant.java b/core/src/main/java/art/arcane/iris/pack/datapack/export/compile/object/BakedVariant.java index 45b34b58a..2bd2c8775 100644 --- a/core/src/main/java/art/arcane/iris/pack/datapack/export/compile/object/BakedVariant.java +++ b/core/src/main/java/art/arcane/iris/pack/datapack/export/compile/object/BakedVariant.java @@ -5,11 +5,10 @@ import art.arcane.iris.pack.datapack.export.VanillaResourceIdentifier; import java.util.Objects; -public record BakedVariant(String id, TemplateVolume volume, int baseY, TreeRoots roots) { +public record BakedVariant(String id, TemplateVolume volume, int baseY) { public BakedVariant { VanillaResourceIdentifier.requireIdentifier(id, "template id"); Objects.requireNonNull(volume, "Template volume"); - Objects.requireNonNull(roots, "Template roots"); if (baseY > 0) { throw new IllegalArgumentException("Template base offset must not be positive, got " + baseY); } diff --git a/core/src/main/java/art/arcane/iris/pack/datapack/export/compile/object/ObjectSource.java b/core/src/main/java/art/arcane/iris/pack/datapack/export/compile/object/ObjectSource.java index 3aa6c01af..d5e2fa08e 100644 --- a/core/src/main/java/art/arcane/iris/pack/datapack/export/compile/object/ObjectSource.java +++ b/core/src/main/java/art/arcane/iris/pack/datapack/export/compile/object/ObjectSource.java @@ -1,6 +1,5 @@ package art.arcane.iris.pack.datapack.export.compile.object; -import art.arcane.iris.generation.decoration.tree.TreeGrounding; import art.arcane.iris.pack.datapack.export.StructureTemplateEncoder; import art.arcane.iris.pack.datapack.export.TemplateBlock; import art.arcane.iris.pack.datapack.export.TemplateVolume; @@ -9,16 +8,13 @@ import art.arcane.iris.structure.object.IrisObject; import art.arcane.volmlib.util.math.Vector3i; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; import java.util.Objects; import java.util.function.ToIntFunction; -public record ObjectSource(TemplateVolume volume, int baseY, TreeRoots roots) { +public record ObjectSource(TemplateVolume volume, int baseY) { public ObjectSource { Objects.requireNonNull(volume, "Object volume"); - Objects.requireNonNull(roots, "Object roots"); if (baseY > 0) { throw new IllegalArgumentException("Object base offset must not be positive, got " + baseY); } @@ -36,34 +32,11 @@ public record ObjectSource(TemplateVolume volume, int baseY, TreeRoots roots) { highestY = Math.max(highestY, block.y()); } List placed = new ArrayList<>(blocks.size()); - Map byPosition = new HashMap<>(blocks.size() * 2); for (TemplateBlock block : blocks) { - TemplateBlock shifted = new TemplateBlock(x.shift(block.x()), block.y() - lowestY, z.shift(block.z()), - block.state().waterlogged(false), block.nbt()); - placed.add(shifted); - byPosition.put(position(shifted.x(), shifted.y(), shifted.z()), shifted); + placed.add(new TemplateBlock(x.shift(block.x()), block.y() - lowestY, z.shift(block.z()), + block.state().waterlogged(false), block.nbt())); } - TreeRoots roots = roots(object.getTreeGrounding(), center, x, z, lowestY, byPosition); - return new ObjectSource(new TemplateVolume(x.size(), highestY - lowestY + 1, z.size(), placed), lowestY, roots); - } - - private static TreeRoots roots(TreeGrounding grounding, Vector3i center, Axis x, Axis z, int lowestY, Map blocks) { - if (grounding == null) { - return TreeRoots.NONE; - } - List cells = new ArrayList<>(grounding.roots().size()); - for (TreeGrounding.Root root : grounding.roots()) { - TemplateBlock block = blocks.get(position(x.shift(root.x() + center.getX()), root.y() + center.getY() - lowestY, - z.shift(root.z() + center.getZ()))); - if (block != null) { - cells.add(block); - } - } - return new TreeRoots(cells, grounding.maxExtension()); - } - - private static long position(int x, int y, int z) { - return ((long) (x & 0x1FFFFF) << 42) | ((long) (y & 0x1FFFFF) << 21) | (z & 0x1FFFFF); + return new ObjectSource(new TemplateVolume(x.size(), highestY - lowestY + 1, z.size(), placed), lowestY); } private record Axis(int size, int center, int nominalCenter) { diff --git a/core/src/main/java/art/arcane/iris/pack/datapack/export/compile/object/ObjectVariantBaker.java b/core/src/main/java/art/arcane/iris/pack/datapack/export/compile/object/ObjectVariantBaker.java index a87e48b20..ef876f403 100644 --- a/core/src/main/java/art/arcane/iris/pack/datapack/export/compile/object/ObjectVariantBaker.java +++ b/core/src/main/java/art/arcane/iris/pack/datapack/export/compile/object/ObjectVariantBaker.java @@ -11,7 +11,6 @@ import art.arcane.volmlib.util.nbt.tag.CompoundTag; import java.util.ArrayList; import java.util.Comparator; -import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -50,11 +49,10 @@ public final class ObjectVariantBaker { public BakedVariant bake(String templateId, ObjectSource source, VariantSpec spec) { long seed = ContentIds.seed(spec.descriptor()); TemplateVolume template = source.volume(); - List voxels = prepare(template, spec, seed, rootCells(source.roots())); + List voxels = prepare(template, spec, seed); if (!spec.reshapes()) { List kept = supported(voxels); - return new BakedVariant(templateId, volume(template.sizeX(), template.sizeY(), template.sizeZ(), kept), source.baseY(), - roots(kept, source.roots().reach())); + return new BakedVariant(templateId, volume(template.sizeX(), template.sizeY(), template.sizeZ(), kept), source.baseY()); } int sizeX = template.sizeX(); int sizeY = template.sizeY(); @@ -72,7 +70,7 @@ public final class ObjectVariantBaker { if (spec.snow() > 0) { voxels = snow(voxels, spec.snow(), seed); } - return reshaped(templateId, supported(voxels), source.baseY(), (int) Math.ceil(source.roots().reach() * spec.scale())); + return reshaped(templateId, supported(voxels), source.baseY()); } public static List alignBases(List variants) { @@ -93,12 +91,12 @@ public final class ObjectVariantBaker { blocks.add(new TemplateBlock(block.x(), block.y() + lift, block.z(), block.state(), block.nbt())); } aligned.add(new BakedVariant(variant.id() + "_lift" + lift, - new TemplateVolume(volume.sizeX(), volume.sizeY() + lift, volume.sizeZ(), blocks), lowest, variant.roots().lift(lift))); + new TemplateVolume(volume.sizeX(), volume.sizeY() + lift, volume.sizeZ(), blocks), lowest)); } return aligned; } - private List prepare(TemplateVolume source, VariantSpec spec, long seed, Set roots) { + private List prepare(TemplateVolume source, VariantSpec spec, long seed) { List voxels = new ArrayList<>(source.blocks().size()); for (TemplateBlock block : source.blocks()) { if (AIR.contains(block.state().name())) { @@ -128,29 +126,11 @@ public final class ObjectVariantBaker { if (spec.preventLeafDecay()) { state = persistentLeaves(state); } - voxels.add(new Voxel(block.x(), block.y(), block.z(), state, nbt, roots.contains(key(block.x(), block.y(), block.z())))); + voxels.add(new Voxel(block.x(), block.y(), block.z(), state, nbt)); } return voxels; } - private static Set rootCells(TreeRoots roots) { - Set cells = new HashSet<>(roots.cells().size() * 2); - for (TemplateBlock cell : roots.cells()) { - cells.add(key(cell.x(), cell.y(), cell.z())); - } - return cells; - } - - private static TreeRoots roots(List voxels, int reach) { - List cells = new ArrayList<>(); - for (Voxel voxel : voxels) { - if (voxel.root()) { - cells.add(new TemplateBlock(voxel.x(), voxel.y(), voxel.z(), voxel.state(), null)); - } - } - return cells.isEmpty() ? TreeRoots.NONE : new TreeRoots(cells, reach); - } - private static VanillaBlockState pick(ObjectEdit edit, double roll) { double cursor = roll * edit.totalWeight(); for (WeightedState state : edit.replace()) { @@ -241,7 +221,7 @@ public final class ObjectVariantBaker { for (int y = minY; y <= maxY; y++) { for (int x = minX; x <= maxX; x++) { for (int z = minZ; z <= maxZ; z++) { - scaled.put(key(x, y, z), new Voxel(x, y, z, voxel.state(), voxel.nbt(), voxel.root())); + scaled.put(key(x, y, z), new Voxel(x, y, z, voxel.state(), voxel.nbt())); } } } @@ -269,7 +249,7 @@ public final class ObjectVariantBaker { int x = (int) Math.floor(rotated[0]); int y = (int) Math.floor(rotated[1]) + rotatedCenterY; int z = (int) Math.floor(rotated[2]); - anchored.put(key(x, y, z), new Voxel(x, y, z, states.apply(voxel.state()), voxel.nbt(), voxel.root())); + anchored.put(key(x, y, z), new Voxel(x, y, z, states.apply(voxel.state()), voxel.nbt())); } return new ArrayList<>(anchored.values()); } @@ -298,7 +278,7 @@ public final class ObjectVariantBaker { state = states.apply(source.state()); turned[origin] = state; } - anchored.add(new Voxel(x[index], y[index] + liftY, z[index], state, source.nbt(), source.root())); + anchored.add(new Voxel(x[index], y[index] + liftY, z[index], state, source.nbt())); } return anchored; } @@ -355,7 +335,7 @@ public final class ObjectVariantBaker { double worldZ = voxel.z() + originZ; int x = (int) (voxel.x() + warp.field().offset(worldX, voxel.y(), worldZ)); int z = (int) (voxel.z() + warp.field().offset(worldZ, voxel.y(), worldX)); - warped.put(key(x, voxel.y(), z), new Voxel(x, voxel.y(), z, voxel.state(), voxel.nbt(), voxel.root())); + warped.put(key(x, voxel.y(), z), new Voxel(x, voxel.y(), z, voxel.state(), voxel.nbt())); } return new ArrayList<>(warped.values()); } @@ -380,14 +360,14 @@ public final class ObjectVariantBaker { int index = steps <= 0 ? 0 : (int) Math.floor(unit(seed, top.x(), top.y(), top.z(), 0, SNOW_SALT) * steps); int layers = Math.max(0, Math.min(index, SNOW_LAYER_STEPS)) + 1; covered.add(new Voxel(top.x(), top.y() + 1, top.z(), - new VanillaBlockState(SNOW, Map.of("layers", Integer.toString(layers))), null, false)); + new VanillaBlockState(SNOW, Map.of("layers", Integer.toString(layers))), null)); } return covered; } - private BakedVariant reshaped(String templateId, List voxels, int baseY, int reach) { + private BakedVariant reshaped(String templateId, List voxels, int baseY) { if (voxels.isEmpty()) { - return new BakedVariant(templateId, new TemplateVolume(1, 1, 1, List.of()), 0, TreeRoots.NONE); + return new BakedVariant(templateId, new TemplateVolume(1, 1, 1, List.of()), 0); } int extentX = 0; int extentZ = 0; @@ -401,10 +381,10 @@ public final class ObjectVariantBaker { } List local = new ArrayList<>(voxels.size()); for (Voxel voxel : voxels) { - local.add(new Voxel(voxel.x() + extentX, voxel.y() - minY, voxel.z() + extentZ, voxel.state(), voxel.nbt(), voxel.root())); + local.add(new Voxel(voxel.x() + extentX, voxel.y() - minY, voxel.z() + extentZ, voxel.state(), voxel.nbt())); } TemplateVolume volume = volume(extentX * 2 + 1, maxY - minY + 1, extentZ * 2 + 1, local); - return new BakedVariant(templateId, volume, minY + baseY, roots(local, reach)); + return new BakedVariant(templateId, volume, minY + baseY); } private static TemplateVolume volume(int sizeX, int sizeY, int sizeZ, List voxels) { @@ -437,6 +417,6 @@ public final class ObjectVariantBaker { return mixed ^ (mixed >>> 31); } - private record Voxel(int x, int y, int z, VanillaBlockState state, CompoundTag nbt, boolean root) { + private record Voxel(int x, int y, int z, VanillaBlockState state, CompoundTag nbt) { } } diff --git a/core/src/main/java/art/arcane/iris/pack/datapack/export/compile/object/PlacementCompiler.java b/core/src/main/java/art/arcane/iris/pack/datapack/export/compile/object/PlacementCompiler.java index 6bd41245e..c51223804 100644 --- a/core/src/main/java/art/arcane/iris/pack/datapack/export/compile/object/PlacementCompiler.java +++ b/core/src/main/java/art/arcane/iris/pack/datapack/export/compile/object/PlacementCompiler.java @@ -37,7 +37,6 @@ public final class PlacementCompiler { private static final int MAX_ANCHOR = 2031; private static final int DEFAULT_FLUID_HEIGHT = 63; private static final long WEIGHT_CEILING = 1_000_000L; - private static final long ROTATION_SHARES = 12L; private static final List QUARTER_NAMES = List.of("none", "counterclockwise_90", "180", "clockwise_90"); static final List FLUIDS = List.of("minecraft:water", "minecraft:flowing_water", "minecraft:lava", "minecraft:flowing_lava"); private static final Set STILT_MODES = Set.of(ObjectPlaceMode.STILT, ObjectPlaceMode.FAST_STILT, @@ -50,14 +49,12 @@ public final class PlacementCompiler { private final FeatureJson json; private final DimensionDef dimension; private final WideObjectStructures wide; - private final RootExtension roots; public PlacementCompiler(String namespace, ExportCapabilities capabilities, DimensionDef dimension) { this.namespace = VanillaResourceIdentifier.requireNamespace(namespace, "placement namespace"); json = new FeatureJson(capabilities); this.dimension = dimension; wide = new WideObjectStructures(namespace); - roots = new RootExtension(this.namespace, json); } public static boolean stilted(ObjectPlaceMode mode) { @@ -124,11 +121,10 @@ public final class PlacementCompiler { } HeightAnchor.Sampling sampling = input.anchor() == PlacementInput.Anchor.SURFACE && !paint && placement.getMode() != ObjectPlaceMode.FLOATING ? HeightAnchor.sampling(placement.getMode()) : HeightAnchor.Sampling.CENTER; - boolean grounded = grounds(input) && rooted(templates); - boolean branched = grounded || sampling != HeightAnchor.Sampling.CENTER; + boolean branched = sampling != HeightAnchor.Sampling.CENTER; JsonObject feature; if (branched) { - feature = branches(input, templates, processors, sampling, grounded, resources); + feature = branches(input, templates, processors, sampling); } else { feature = template(templates, processors); if (stilted(placement.getMode())) { @@ -212,29 +208,16 @@ public final class PlacementCompiler { } private JsonObject branches(PlacementInput input, List templates, List processors, - HeightAnchor.Sampling sampling, boolean grounded, List resources) { + HeightAnchor.Sampling sampling) { IrisObjectPlacement placement = input.placement(); - Map shared = new TreeMap<>(); - Branching branching = new Branching(input, processors, sampling, grounded, surfaceOffset(placement, lowestBase(templates)), - clamp(placement.getClamp()), shared); + Branching branching = new Branching(input, processors, sampling, surfaceOffset(placement, lowestBase(templates)), + clamp(placement.getClamp())); List branches = new ArrayList<>(); List weights = new ArrayList<>(); for (TemplateChoice choice : templates) { - long weight = grounded ? choice.weight() * (ROTATION_SHARES / choice.quarters().size()) : choice.weight(); - List> groups = new ArrayList<>(choice.quarters().size()); - if (grounded) { - for (int quarter : choice.quarters()) { - groups.add(List.of(quarter)); - } - } else { - groups.add(choice.quarters()); - } - for (List quarters : groups) { - branches.add(branch(branching, choice.variant(), quarters)); - weights.add(weight); - } + branches.add(branch(branching, choice.variant(), choice.quarters())); + weights.add(choice.weight()); } - resources.addAll(shared.values()); long divisor = 0; for (long weight : weights) { divisor = BigInteger.valueOf(divisor).gcd(BigInteger.valueOf(weight)).longValue(); @@ -261,14 +244,7 @@ public final class PlacementCompiler { variant.volume(), quarters, new TemplateColumn(placement.getTranslate().getX(), placement.getTranslate().getZ()))); } modifiers.addAll(branching.offset()); - if (branching.grounded() && variant.roots().present()) { - int quarter = quarters.getFirst(); - feature = overlay(feature, roots.pillars(variant.roots(), variant.volume(), quarter, branching.shared())); - JsonObject gap = RootExtension.gap(variant.roots(), variant.volume(), quarter); - if (gap != null) { - modifiers.add(Placements.filter(gap)); - } - } else if (stilted(placement.getMode())) { + if (stilted(placement.getMode())) { feature = stilts(feature, List.of(single), branching.input().stiltBases()); } if (branching.clamp() != null) { @@ -280,37 +256,6 @@ public final class PlacementCompiler { return branch; } - private JsonObject overlay(JsonObject template, List parts) { - JsonArray features = new JsonArray(parts.size() + 1); - JsonObject anchored = new JsonObject(); - anchored.add("feature", template); - anchored.add("placement", new JsonArray()); - features.add(anchored); - for (JsonObject part : parts) { - features.add(part); - } - JsonObject fields = new JsonObject(); - fields.add("features", features); - return json.syntax().feature("minecraft:overlay", fields); - } - - private static boolean grounds(PlacementInput input) { - IrisObjectPlacement placement = input.placement(); - ObjectPlaceMode mode = placement.getMode(); - return input.anchor() == PlacementInput.Anchor.SURFACE && !placement.isForcePlace() && !placement.isFromBottom() - && mode != ObjectPlaceMode.PAINT && mode != ObjectPlaceMode.FLOATING && mode != ObjectPlaceMode.CEILING_HANG - && mode != ObjectPlaceMode.STRUCTURE_PIECE; - } - - private static boolean rooted(List templates) { - for (TemplateChoice template : templates) { - if (template.variant().roots().present()) { - return true; - } - } - return false; - } - private static JsonArray array(List values) { JsonArray array = new JsonArray(values.size()); for (JsonObject value : values) { @@ -671,7 +616,7 @@ public final class PlacementCompiler { return tallest; } - private record Branching(PlacementInput input, List processors, HeightAnchor.Sampling sampling, boolean grounded, - List offset, JsonObject clamp, Map shared) { + private record Branching(PlacementInput input, List processors, HeightAnchor.Sampling sampling, + List offset, JsonObject clamp) { } } diff --git a/core/src/main/java/art/arcane/iris/pack/datapack/export/compile/object/RootExtension.java b/core/src/main/java/art/arcane/iris/pack/datapack/export/compile/object/RootExtension.java deleted file mode 100644 index 9f6af038f..000000000 --- a/core/src/main/java/art/arcane/iris/pack/datapack/export/compile/object/RootExtension.java +++ /dev/null @@ -1,92 +0,0 @@ -package art.arcane.iris.pack.datapack.export.compile.object; - -import art.arcane.iris.pack.datapack.export.TemplateBlock; -import art.arcane.iris.pack.datapack.export.TemplateVolume; -import art.arcane.iris.pack.datapack.export.VanillaBlockState; -import art.arcane.iris.pack.datapack.export.compile.WeightedState; -import art.arcane.iris.pack.datapack.export.compile.decoration.Placements; -import art.arcane.iris.pack.datapack.export.ir.JsonResource; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -final class RootExtension { - private static final int PROBE_LIMIT = 16; - private static final int QUARTER_DEGREES = 90; - - private final String namespace; - private final FeatureJson json; - - RootExtension(String namespace, FeatureJson json) { - this.namespace = namespace; - this.json = json; - } - - static JsonObject gap(TreeRoots roots, TemplateVolume volume, int quarter) { - List columns = new ArrayList<>(roots.cells().size()); - for (TemplateBlock cell : roots.cells()) { - TemplateColumn column = TemplateColumn.of(volume, cell.x(), cell.z(), quarter); - int top = Math.min(PROBE_LIMIT, cell.y() - 1); - int bottom = Math.max(-PROBE_LIMIT, cell.y() - 1 - roots.reach()); - if (bottom > top || Math.abs(column.x()) > PROBE_LIMIT || Math.abs(column.z()) > PROBE_LIMIT) { - continue; - } - JsonObject open = Placements.typed("minecraft:volume_match"); - open.add("min", FeatureJson.vector(column.x(), bottom, column.z())); - open.add("max", FeatureJson.vector(column.x(), top, column.z())); - open.add("match", Placements.not(Placements.solid(0, 0, 0))); - columns.add(Placements.not(open)); - } - return columns.isEmpty() ? null : Placements.allOf(columns); - } - - List pillars(TreeRoots roots, TemplateVolume volume, int quarter, Map shared) { - BlockStateRotation rotation = BlockStateRotation.of(0, quarter * QUARTER_DEGREES, 0); - List pillars = new ArrayList<>(roots.cells().size()); - for (TemplateBlock cell : roots.cells()) { - TemplateColumn column = TemplateColumn.of(volume, cell.x(), cell.z(), quarter); - JsonObject entry = new JsonObject(); - entry.addProperty("feature", pillar(rotation.apply(cell.state()), shared)); - JsonArray placement = new JsonArray(); - for (JsonObject offset : json.offset(column.x(), cell.y() - 1, cell.y() - 1, column.z())) { - placement.add(offset); - } - entry.add("placement", placement); - pillars.add(entry); - } - return pillars; - } - - private String pillar(VanillaBlockState state, Map shared) { - JsonObject block = json.syntax().provider(List.of(new WeightedState(state, 1))); - JsonObject cap = new JsonObject(); - JsonObject capFields = new JsonObject(); - capFields.add("to_place", block); - cap.add("feature", json.syntax().feature("minecraft:simple_block", capFields)); - JsonArray capPlacement = new JsonArray(1); - capPlacement.add(Placements.verticalOffset(-1)); - cap.add("placement", capPlacement); - JsonObject canReplace = PlacementCompiler.canReplace(); - JsonObject columnFields = new JsonObject(); - columnFields.add("block", block); - columnFields.add("can_replace", canReplace); - columnFields.addProperty("direction", "down"); - columnFields.add("cap_feature", cap); - JsonObject gated = new JsonObject(); - gated.add("feature", json.syntax().feature("minecraft:single_block_pillar", columnFields)); - JsonArray gate = new JsonArray(1); - gate.add(Placements.filter(canReplace)); - gated.add("placement", gate); - JsonArray features = new JsonArray(1); - features.add(gated); - JsonObject overlayFields = new JsonObject(); - overlayFields.add("features", features); - JsonObject feature = json.syntax().feature("minecraft:overlay", overlayFields); - String path = "object/root/" + ContentIds.hash(feature); - shared.putIfAbsent(path, new JsonResource("data/" + namespace + "/" + json.syntax().featureFolder() + "/" + path + ".json", feature)); - return namespace + ":" + path; - } -} diff --git a/core/src/main/java/art/arcane/iris/pack/datapack/export/compile/object/TreeRoots.java b/core/src/main/java/art/arcane/iris/pack/datapack/export/compile/object/TreeRoots.java deleted file mode 100644 index cfd4c7122..000000000 --- a/core/src/main/java/art/arcane/iris/pack/datapack/export/compile/object/TreeRoots.java +++ /dev/null @@ -1,51 +0,0 @@ -package art.arcane.iris.pack.datapack.export.compile.object; - -import art.arcane.iris.pack.datapack.export.TemplateBlock; - -import java.util.ArrayList; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public record TreeRoots(List cells, int reach) { - private static final int MAX_REACH = 16; - private static final Comparator COLUMN_ORDER = Comparator - .comparingInt(TemplateBlock::x) - .thenComparingInt(TemplateBlock::z); - public static final TreeRoots NONE = new TreeRoots(List.of(), 0); - - public TreeRoots { - cells = lowestPerColumn(cells); - reach = Math.max(0, Math.min(MAX_REACH, reach)); - } - - public boolean present() { - return !cells.isEmpty(); - } - - public TreeRoots lift(int dy) { - if (dy == 0 || cells.isEmpty()) { - return this; - } - List lifted = new ArrayList<>(cells.size()); - for (TemplateBlock cell : cells) { - lifted.add(new TemplateBlock(cell.x(), cell.y() + dy, cell.z(), cell.state(), null)); - } - return new TreeRoots(lifted, reach); - } - - private static List lowestPerColumn(List cells) { - Map columns = new HashMap<>(); - for (TemplateBlock cell : cells) { - long key = ((long) cell.x() << 32) | (cell.z() & 0xFFFFFFFFL); - TemplateBlock previous = columns.get(key); - if (previous == null || cell.y() < previous.y()) { - columns.put(key, new TemplateBlock(cell.x(), cell.y(), cell.z(), cell.state(), null)); - } - } - List lowest = new ArrayList<>(columns.values()); - lowest.sort(COLUMN_ORDER); - return List.copyOf(lowest); - } -} diff --git a/core/src/main/java/art/arcane/iris/structure/object/HeightmapObjectPlacer.java b/core/src/main/java/art/arcane/iris/structure/object/HeightmapObjectPlacer.java index e463d4b92..e4ad06f65 100644 --- a/core/src/main/java/art/arcane/iris/structure/object/HeightmapObjectPlacer.java +++ b/core/src/main/java/art/arcane/iris/structure/object/HeightmapObjectPlacer.java @@ -22,7 +22,6 @@ import art.arcane.iris.pack.loading.IrisData; import art.arcane.iris.generation.runtime.Engine; import art.arcane.iris.generation.block.TileData; import art.arcane.volmlib.nativelib.terrain.NativeBlockState; -import art.arcane.volmlib.util.math.BlockPosition; import art.arcane.volmlib.util.math.RNG; public class HeightmapObjectPlacer implements IObjectPlacer { @@ -48,16 +47,6 @@ public class HeightmapObjectPlacer implements IObjectPlacer { oplacer.set(param1Int1, param1Int2, param1Int3, param1BlockData); } - @Override - public boolean beginTreeCanopy(BlockPosition position) { - return oplacer.beginTreeCanopy(position); - } - - @Override - public void endTreeCanopy() { - oplacer.endTreeCanopy(); - } - public NativeBlockState get(int param1Int1, int param1Int2, int param1Int3) { return oplacer.get(param1Int1, param1Int2, param1Int3); } diff --git a/core/src/main/java/art/arcane/iris/structure/object/IObjectPlacer.java b/core/src/main/java/art/arcane/iris/structure/object/IObjectPlacer.java index d32eabc95..1e9e93e08 100644 --- a/core/src/main/java/art/arcane/iris/structure/object/IObjectPlacer.java +++ b/core/src/main/java/art/arcane/iris/structure/object/IObjectPlacer.java @@ -24,7 +24,6 @@ import art.arcane.iris.pack.loading.IrisData; import art.arcane.iris.generation.runtime.Engine; import art.arcane.volmlib.nativelib.terrain.NativeBlockState; -import art.arcane.volmlib.util.math.BlockPosition; import org.jetbrains.annotations.Nullable; public interface IObjectPlacer { @@ -36,14 +35,6 @@ public interface IObjectPlacer { NativeBlockState get(int x, int y, int z); - default boolean beginTreeCanopy(BlockPosition position) { - NativeBlockState existing = get(position.getX(), position.getY(), position.getZ()); - return existing == null || !existing.isSolid(); - } - - default void endTreeCanopy() { - } - boolean isPreventingDecay(); boolean isCarved(int x, int y, int z); diff --git a/core/src/main/java/art/arcane/iris/structure/object/IrisObject.java b/core/src/main/java/art/arcane/iris/structure/object/IrisObject.java index e84640924..738d5836a 100644 --- a/core/src/main/java/art/arcane/iris/structure/object/IrisObject.java +++ b/core/src/main/java/art/arcane/iris/structure/object/IrisObject.java @@ -20,7 +20,6 @@ package art.arcane.iris.structure.object; import art.arcane.iris.structure.object.FloatingObjectFootprint; import art.arcane.iris.generation.block.TileData; -import art.arcane.iris.generation.decoration.tree.TreeGrounding; import art.arcane.iris.generation.cave.CarveResult; import art.arcane.iris.pack.value.IrisPosition; @@ -148,9 +147,6 @@ public class IrisObject extends IrisRegistrant { transient final ConcurrentHashMap placementBakes = new ConcurrentHashMap<>(); transient volatile ObjectPlacementBake.Layout placementLayout; @Getter - @Setter - private transient TreeGrounding treeGrounding; - @Getter VectorMap blocks; @Getter VectorMap states; @@ -210,7 +206,6 @@ public class IrisObject extends IrisRegistrant { copy.setLoader(getLoader()); copy.setLoadFile(getLoadFile()); copy.setCenter(getCenter().clone()); - copy.setTreeGrounding(treeGrounding); blocks.forEach(copy.blocks::put); states.forEach((position, tile) -> copy.states.put(position, tile.clone())); @@ -362,9 +357,6 @@ public class IrisObject extends IrisRegistrant { KList getSurfaceSupportOffsets() { return surfaceSupportOffsets.aquire(() -> { - if (treeGrounding != null) { - return treeGrounding.supportOffsets(); - } readLock.lock(); try { int lowestY = Integer.MAX_VALUE; diff --git a/core/src/main/java/art/arcane/iris/structure/object/IrisObjectShaping.java b/core/src/main/java/art/arcane/iris/structure/object/IrisObjectShaping.java index de2db28a0..1c5440e9b 100644 --- a/core/src/main/java/art/arcane/iris/structure/object/IrisObjectShaping.java +++ b/core/src/main/java/art/arcane/iris/structure/object/IrisObjectShaping.java @@ -20,8 +20,6 @@ package art.arcane.iris.structure.object; import art.arcane.iris.generation.block.TileData; import art.arcane.iris.generation.decoration.IrisProceduralBlocks; -import art.arcane.iris.generation.decoration.tree.TreeBlockCanvas; -import art.arcane.iris.generation.decoration.tree.TreeGrounding; import art.arcane.iris.spi.IrisLogging; import art.arcane.volmlib.nativelib.terrain.NativeBlockState; @@ -31,9 +29,6 @@ import art.arcane.volmlib.util.math.Vector3i; import art.arcane.volmlib.util.format.Form; import art.arcane.volmlib.util.scheduling.PrecisionStopwatch; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; import java.util.Set; /** @@ -269,19 +264,6 @@ final class IrisObjectShaping { self.shrinkOffset = offset; self.blocks = b; self.states = s; - if (self.getTreeGrounding() != null) { - List roots = new ArrayList<>(); - for (TreeGrounding.Root root : self.getTreeGrounding().roots()) { - roots.add(new TreeGrounding.Root(root.x() + offset.getX(), root.y() + offset.getY(), - root.z() + offset.getZ(), root.state())); - } - Set canopy = new HashSet<>(); - for (TreeBlockCanvas.Vec leaf : self.getTreeGrounding().canopy()) { - canopy.add(new TreeBlockCanvas.Vec(leaf.x() + offset.getX(), leaf.y() + offset.getY(), - leaf.z() + offset.getZ())); - } - self.setTreeGrounding(TreeGrounding.create(roots, self.getTreeGrounding().maxExtension(), canopy)); - } self.surfaceSupportOffsets.reset(); self.floatingFootprint.reset(); } diff --git a/core/src/main/java/art/arcane/iris/structure/object/IrisObjectTransforms.java b/core/src/main/java/art/arcane/iris/structure/object/IrisObjectTransforms.java index 3c28e7a9e..eb1d59141 100644 --- a/core/src/main/java/art/arcane/iris/structure/object/IrisObjectTransforms.java +++ b/core/src/main/java/art/arcane/iris/structure/object/IrisObjectTransforms.java @@ -23,8 +23,6 @@ import art.arcane.iris.pack.value.IrisPosition; import art.arcane.volmlib.nativelib.terrain.NativeBlockState; import art.arcane.iris.generation.block.B; -import art.arcane.iris.generation.decoration.tree.TreeBlockCanvas; -import art.arcane.iris.generation.decoration.tree.TreeGrounding; import art.arcane.iris.generation.block.VectorMap; import art.arcane.iris.generation.geometry.AxisAlignedBB; import art.arcane.iris.generation.geometry.IrisBlockVector; @@ -35,12 +33,10 @@ import art.arcane.volmlib.util.interpolation.Interpolation3D; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; -import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.Map; -import java.util.Set; /** * Geometric transforms for {@link IrisObject}: scaling and the interpolated upscalers. @@ -67,7 +63,6 @@ final class IrisObjectTransforms { boolean fractional = scale != Math.rint(scale); List voxels; IrisObject output; - TreeGrounding grounding; Vector3i sourceCenter; self.readLock.lock(); try { @@ -78,7 +73,6 @@ final class IrisObjectTransforms { output.setLoadFile(self.getLoadFile()); voxels = new ArrayList<>(self.blocks.size()); sourceCenter = self.getCenter().clone(); - grounding = self.getTreeGrounding(); IrisBlockVector targetCenter = new IrisBlockVector(output.getCenter().getX(), output.getCenter().getY(), output.getCenter().getZ()); for (Map.Entry entry : self.blocks) { @@ -100,21 +94,19 @@ final class IrisObjectTransforms { } TileData tile = self.states.get(sourcePosition); voxels.add(new ScaledVoxel(sourcePosition.clone(), minimum, maximum, corner, entry.getValue(), - tile == null ? null : tile.clone(), grounding != null && grounding.isCanopy( - sourcePosition.getBlockX(), sourcePosition.getBlockY(), sourcePosition.getBlockZ()))); + tile == null ? null : tile.clone())); } } finally { self.readLock.unlock(); } - Set canopy = grounding == null ? null : new HashSet<>(); if (fractional) { voxels.sort(Comparator.comparingInt((ScaledVoxel voxel) -> voxel.source().getBlockX()) .thenComparingInt(voxel -> voxel.source().getBlockY()) .thenComparingInt(voxel -> voxel.source().getBlockZ())); - writeResampledVoxels(output, voxels, scale, canopy); + writeResampledVoxels(output, voxels, scale); } else { for (ScaledVoxel voxel : voxels) { - writeScaledVoxel(output, voxel, canopy); + writeScaledVoxel(output, voxel); } } @@ -127,43 +119,10 @@ final class IrisObjectTransforms { } } removeInapplicableTiles(output, scaledBlocks); - if (grounding != null) { - canopy.removeIf(cell -> !output.blocks.containsKey(new IrisBlockVector(cell.x(), cell.y(), cell.z()))); - scaleRoots(grounding, sourceCenter, output, scale, savedOrigin, canopy); - } return output; } - private static void scaleRoots(TreeGrounding grounding, Vector3i sourceCenter, IrisObject output, - double scale, boolean savedOrigin, Set canopy) { - List roots = new ArrayList<>(); - Vector3i targetCenter = output.getCenter(); - for (TreeGrounding.Root root : grounding.roots()) { - IrisBlockVector position = new IrisBlockVector(root.x(), root.y(), root.z()); - if (!savedOrigin) { - position.add(new IrisBlockVector(sourceCenter.getX(), sourceCenter.getY(), sourceCenter.getZ())); - } - IrisBlockVector minimum = scaledMinimum(position, scale); - IrisBlockVector maximum = scaledMaximum(position, scale); - if (!savedOrigin) { - IrisBlockVector offset = new IrisBlockVector(targetCenter.getX(), targetCenter.getY(), targetCenter.getZ()); - minimum.subtract(offset); - maximum.subtract(offset); - } - int y = minimum.getBlockY(); - for (int x = minimum.getBlockX(); x <= maximum.getBlockX(); x++) { - for (int z = minimum.getBlockZ(); z <= maximum.getBlockZ(); z++) { - NativeBlockState state = output.blocks.get(new IrisBlockVector(x, y, z)); - if (state != null && !canopy.contains(new TreeBlockCanvas.Vec(x, y, z))) { - roots.add(new TreeGrounding.Root(x, y, z, state)); - } - } - } - } - output.setTreeGrounding(TreeGrounding.create(roots, (int) Math.ceil(grounding.maxExtension() * scale), canopy)); - } - - private static void writeScaledVoxel(IrisObject output, ScaledVoxel voxel, Set canopy) { + private static void writeScaledVoxel(IrisObject output, ScaledVoxel voxel) { IrisBlockVector minimum = voxel.minimum(); IrisBlockVector maximum = voxel.maximum(); IrisBlockVector position = minimum.clone(); @@ -173,14 +132,13 @@ final class IrisObjectTransforms { position.setZ(z); for (int y = minimum.getBlockY(); y <= maximum.getBlockY(); y++) { position.setY(y); - writeScaledBlock(output, position, voxel, canopy); + writeScaledBlock(output, position, voxel); } } } } - private static void writeResampledVoxels(IrisObject output, List voxels, double scale, - Set canopy) { + private static void writeResampledVoxels(IrisObject output, List voxels, double scale) { VectorMap samples = new VectorMap<>(); IrisBlockVector position = new IrisBlockVector(); for (ScaledVoxel voxel : voxels) { @@ -199,22 +157,12 @@ final class IrisObjectTransforms { } } for (Map.Entry entry : samples) { - writeScaledBlock(output, entry.getKey(), entry.getValue(), canopy); + writeScaledBlock(output, entry.getKey(), entry.getValue()); } } - private static void writeScaledBlock(IrisObject output, IrisBlockVector position, ScaledVoxel voxel, - Set canopy) { + private static void writeScaledBlock(IrisObject output, IrisBlockVector position, ScaledVoxel voxel) { output.blocks.put(position, voxel.block()); - if (canopy != null) { - TreeBlockCanvas.Vec cell = new TreeBlockCanvas.Vec(position.getBlockX(), - position.getBlockY(), position.getBlockZ()); - if (voxel.canopy()) { - canopy.add(cell); - } else { - canopy.remove(cell); - } - } if (voxel.tile() == null) { output.states.remove(position); } else { @@ -519,7 +467,7 @@ final class IrisObjectTransforms { } private record ScaledVoxel(IrisBlockVector source, IrisBlockVector minimum, IrisBlockVector maximum, - IrisVector corner, NativeBlockState block, TileData tile, boolean canopy) { + IrisVector corner, NativeBlockState block, TileData tile) { private double overlap(IrisBlockVector position, double scale) { return overlap(corner.getX(), position.getX(), scale) * overlap(corner.getY(), position.getY(), scale) diff --git a/core/src/main/java/art/arcane/iris/structure/object/ObjectBlockPass.java b/core/src/main/java/art/arcane/iris/structure/object/ObjectBlockPass.java index e864c0ca8..a7cd38a27 100644 --- a/core/src/main/java/art/arcane/iris/structure/object/ObjectBlockPass.java +++ b/core/src/main/java/art/arcane/iris/structure/object/ObjectBlockPass.java @@ -99,33 +99,22 @@ final class ObjectBlockPass { continue; } - boolean canopy = bake.canopy(index); - if (canopy && !state.placer.beginTreeCanopy(new BlockPosition(xx, yy, zz))) { - continue; + data = rotated; + if (facts.waterloggable()) { + data = waterlogCandidate || facts.authoredWaterlogged() + ? IrisProceduralBlocks.normalizeWaterlogging(data, state.placer.get(xx, yy, zz), waterlogCandidate) + : facts.dry(); } - try { - data = rotated; - if (facts.waterloggable()) { - data = waterlogCandidate || facts.authoredWaterlogged() - ? IrisProceduralBlocks.normalizeWaterlogging(data, state.placer.get(xx, yy, zz), waterlogCandidate) - : facts.dry(); - } + if (!is(ObjectPlaceMode.STRUCTURE_PIECE) && B.isVineBlock(data)) { + data = attachVineFaces(state.placer, data, xx, yy, zz); + } - if (!is(ObjectPlaceMode.STRUCTURE_PIECE) && B.isVineBlock(data)) { - data = attachVineFaces(state.placer, data, xx, yy, zz); - } - - String marker = markers == null ? null : markers[index]; - if (handleCustomData(data, facts.air(), tile, marker, xx, yy, zz)) { - lifecycle.run(PlacementStage.BLOCK_WRITTEN, context, state, new PlacementBlockWrite(xx, yy, zz, data)); - if (state.isRejected()) { - return; - } - } - } finally { - if (canopy) { - state.placer.endTreeCanopy(); + String marker = markers == null ? null : markers[index]; + if (handleCustomData(data, facts.air(), tile, marker, xx, yy, zz)) { + lifecycle.run(PlacementStage.BLOCK_WRITTEN, context, state, new PlacementBlockWrite(xx, yy, zz, data)); + if (state.isRejected()) { + return; } } } diff --git a/core/src/main/java/art/arcane/iris/structure/object/ObjectPlaceMode.java b/core/src/main/java/art/arcane/iris/structure/object/ObjectPlaceMode.java index dcd916dae..680094919 100644 --- a/core/src/main/java/art/arcane/iris/structure/object/ObjectPlaceMode.java +++ b/core/src/main/java/art/arcane/iris/structure/object/ObjectPlaceMode.java @@ -133,7 +133,6 @@ public enum ObjectPlaceMode { new PlacementModuleNativeStructureProtection().install(lifecycle); new PlacementModuleBounds().install(lifecycle); new PlacementModuleCollision().install(lifecycle); - new PlacementModuleTreeGrounding().install(lifecycle); new PlacementModuleBore().install(lifecycle); new PlacementModuleBlocks().install(lifecycle); PlacementLifecycleDependency finish = switch (this) { diff --git a/core/src/main/java/art/arcane/iris/structure/object/ObjectPlacementBake.java b/core/src/main/java/art/arcane/iris/structure/object/ObjectPlacementBake.java index 395bce1aa..6a82ec7b8 100644 --- a/core/src/main/java/art/arcane/iris/structure/object/ObjectPlacementBake.java +++ b/core/src/main/java/art/arcane/iris/structure/object/ObjectPlacementBake.java @@ -2,7 +2,6 @@ package art.arcane.iris.structure.object; import art.arcane.iris.generation.block.TileData; import art.arcane.iris.generation.block.VectorMap; -import art.arcane.iris.generation.decoration.tree.TreeGrounding; import art.arcane.iris.generation.geometry.IrisBlockVector; import art.arcane.volmlib.nativelib.terrain.NativeBlockState; import it.unimi.dsi.fastutil.ints.IntArrayList; @@ -23,7 +22,6 @@ final class ObjectPlacementBake { private final int[] offsetZ; private final int[] layerY; private final short[] paletteIndexes; - private final long[] canopy; private final int[] tileBlocks; private final TileData[] tileValues; private final int[] sources; @@ -37,7 +35,6 @@ final class ObjectPlacementBake { this.offsetZ = cells.offsetZ(); this.layerY = cells.layerY(); this.paletteIndexes = cells.paletteIndexes(); - this.canopy = cells.canopy(); this.tileBlocks = cells.tileBlocks(); this.tileValues = cells.tileValues(); this.sources = cells.sources(); @@ -93,7 +90,7 @@ final class ObjectPlacementBake { if (index != count) { throw new IllegalStateException("Object " + object.getLoadKey() + " changed while its placement bake was built"); } - return new Cells(x, y, z, layerDiffers ? layer : null, layout.paletteIndexes, layout.canopy, layout.tileBlocks, + return new Cells(x, y, z, layerDiffers ? layer : null, layout.paletteIndexes, layout.tileBlocks, layout.tileValues, null); } @@ -106,15 +103,11 @@ final class ObjectPlacementBake { private static Cells gather(Layout layout, int[] x, int[] y, int[] z, int[] sources) { int count = sources.length; short[] paletteIndexes = new short[count]; - long[] canopy = layout.canopy == null ? null : new long[(count + 63) >>> 6]; IntArrayList tileBlocks = layout.tileBlocks == null ? null : new IntArrayList(); List tileValues = layout.tileBlocks == null ? null : new ArrayList<>(); for (int index = 0; index < count; index++) { int source = sources[index]; paletteIndexes[index] = layout.paletteIndexes[source]; - if (canopy != null && (layout.canopy[source >>> 6] & (1L << (source & 63))) != 0L) { - canopy[index >>> 6] |= 1L << (index & 63); - } if (tileBlocks != null) { int slot = Arrays.binarySearch(layout.tileBlocks, source); if (slot >= 0) { @@ -124,7 +117,7 @@ final class ObjectPlacementBake { } } boolean tiled = tileBlocks != null && !tileBlocks.isEmpty(); - return new Cells(x, y, z, null, paletteIndexes, canopy, tiled ? tileBlocks.toIntArray() : null, + return new Cells(x, y, z, null, paletteIndexes, tiled ? tileBlocks.toIntArray() : null, tiled ? tileValues.toArray(new TileData[0]) : null, sources); } @@ -168,10 +161,6 @@ final class ObjectPlacementBake { return tileValues; } - boolean canopy(int index) { - return canopy != null && (canopy[index >>> 6] & (1L << (index & 63))) != 0L; - } - String[] markers(String[] sourceMarkers) { if (sources == null) { return sourceMarkers; @@ -233,26 +222,22 @@ final class ObjectPlacementBake { static final class Layout { private final long blocksRevision; private final long statesRevision; - private final TreeGrounding grounding; private final int count; private final short[] paletteIndexes; private final NativeBlockState[] palette; private final int[] tileBlocks; private final TileData[] tileValues; - private final long[] canopy; private volatile RotationResampler resampler; - private Layout(long blocksRevision, long statesRevision, TreeGrounding grounding, int count, short[] paletteIndexes, - NativeBlockState[] palette, int[] tileBlocks, TileData[] tileValues, long[] canopy) { + private Layout(long blocksRevision, long statesRevision, int count, short[] paletteIndexes, + NativeBlockState[] palette, int[] tileBlocks, TileData[] tileValues) { this.blocksRevision = blocksRevision; this.statesRevision = statesRevision; - this.grounding = grounding; this.count = count; this.paletteIndexes = paletteIndexes; this.palette = palette; this.tileBlocks = tileBlocks; this.tileValues = tileValues; - this.canopy = canopy; } private static Layout of(IrisObject object) { @@ -276,7 +261,6 @@ final class ObjectPlacementBake { VectorMap states = object.states; long blocksRevision = blocks.modificationRevision(); long statesRevision = states.modificationRevision(); - TreeGrounding grounding = object.getTreeGrounding(); boolean hasStates = !states.isEmpty(); int size = blocks.size(); short[] paletteIndexes = new short[size]; @@ -284,7 +268,6 @@ final class ObjectPlacementBake { List tileValues = new ArrayList<>(); List palette = new ArrayList<>(); IdentityHashMap paletteSlots = new IdentityHashMap<>(); - long[] canopy = null; VectorMap.Cursor cursor = blocks.cursor(); int index = 0; while (cursor.next()) { @@ -314,26 +297,19 @@ final class ObjectPlacementBake { tileValues.add(tile); } } - if (grounding != null && grounding.isCanopy(source.getBlockX(), source.getBlockY(), source.getBlockZ())) { - if (canopy == null) { - canopy = new long[(size + 63) >>> 6]; - } - canopy[index >>> 6] |= 1L << (index & 63); - } index++; } if (index != size) { throw new IllegalStateException("Object " + object.getLoadKey() + " changed while its placement layout was built"); } - return new Layout(blocksRevision, statesRevision, grounding, index, paletteIndexes, + return new Layout(blocksRevision, statesRevision, index, paletteIndexes, palette.toArray(new NativeBlockState[0]), tileBlocks.isEmpty() ? null : tileBlocks.toIntArray(), - tileValues.isEmpty() ? null : tileValues.toArray(new TileData[0]), canopy); + tileValues.isEmpty() ? null : tileValues.toArray(new TileData[0])); } private boolean matches(IrisObject object) { return object.blocks.modificationRevision() == blocksRevision - && object.states.modificationRevision() == statesRevision - && object.getTreeGrounding() == grounding; + && object.states.modificationRevision() == statesRevision; } private RotationResampler resampler(IrisObject object) { @@ -366,7 +342,7 @@ final class ObjectPlacementBake { } } - private record Cells(int[] offsetX, int[] offsetY, int[] offsetZ, int[] layerY, short[] paletteIndexes, long[] canopy, + private record Cells(int[] offsetX, int[] offsetY, int[] offsetZ, int[] layerY, short[] paletteIndexes, int[] tileBlocks, TileData[] tileValues, int[] sources) { } } diff --git a/core/src/main/java/art/arcane/iris/structure/object/PlacementModuleStilt.java b/core/src/main/java/art/arcane/iris/structure/object/PlacementModuleStilt.java index 27bfd6a4f..45ef482a9 100644 --- a/core/src/main/java/art/arcane/iris/structure/object/PlacementModuleStilt.java +++ b/core/src/main/java/art/arcane/iris/structure/object/PlacementModuleStilt.java @@ -55,7 +55,7 @@ public final class PlacementModuleStilt implements PlacementModule { lifecycle.add(SEAT, PlacementStage.BEFORE_BLOCKS, this::seat, PlacementModuleAnchor.FINAL_HEIGHT); } lifecycle.add(FILL, PlacementStage.AFTER_BLOCKS, this::fill, PlacementModuleAnchor.HEIGHT, - PlacementModuleBlocks.COMPLETE, PlacementModuleTreeGrounding.ROOTS); + PlacementModuleBlocks.COMPLETE); } private static StiltLayers stiltLayers(ObjectPlacementBake bake, PlacementPalette palette) { @@ -72,7 +72,7 @@ public final class PlacementModuleStilt implements PlacementModule { } private void seat(PlacementContext context, PlacementState state, Void ignored) { - if (state.grounding != null || state.placer.caveCell(context.x, state.y, context.z) == null) { + if (state.placer.caveCell(context.x, state.y, context.z) == null) { return; } PlacementModuleBlocks.bake(context, state); @@ -223,9 +223,6 @@ public final class PlacementModuleStilt implements PlacementModule { state.reject("cave-no-ground"); return; } - if (state.grounding != null) { - return; - } ObjectPlacementBake bake = state.bake; PlacementPalette palette = state.palette; StiltLayers layers = stiltLayers(bake, palette); diff --git a/core/src/main/java/art/arcane/iris/structure/object/PlacementModuleTreeGrounding.java b/core/src/main/java/art/arcane/iris/structure/object/PlacementModuleTreeGrounding.java deleted file mode 100644 index ab20de0ee..000000000 --- a/core/src/main/java/art/arcane/iris/structure/object/PlacementModuleTreeGrounding.java +++ /dev/null @@ -1,57 +0,0 @@ -package art.arcane.iris.structure.object; - -import art.arcane.iris.generation.decoration.tree.TreeGrounding; -import art.arcane.volmlib.nativelib.terrain.NativeBlockState; -import art.arcane.volmlib.util.math.BlockPosition; - -/** Procedural trees extend their roots into supporting terrain instead of stilting or floating. */ -final class PlacementModuleTreeGrounding implements PlacementModule { - static final PlacementLifecycleDependency PLAN = new PlacementLifecycleDependency("grounding.plan"); - static final PlacementLifecycleDependency ROOTS = new PlacementLifecycleDependency("grounding.roots"); - - @Override - public void install(PlacementLifecycleBuilder lifecycle) { - lifecycle.add(PLAN, PlacementStage.VALIDATE, PlacementModuleTreeGrounding::plan, PlacementModuleAnchor.POSITIONED); - lifecycle.add(ROOTS, PlacementStage.AFTER_BLOCKS, PlacementModuleTreeGrounding::extendRoots, - PLAN, PlacementModuleBlocks.COMPLETE); - } - - private static void plan(PlacementContext context, PlacementState state, Void ignored) { - TreeGrounding grounding = context.self.getTreeGrounding(); - if (grounding == null || !isSurfaceTreePlacement(context, state)) { - return; - } - state.grounding = grounding.plan(state.placer, new TreeGrounding.Placement(context.rdata, state.config, - new BlockPosition(context.x, state.y + state.yrand, context.z), - new BlockPosition(state.spinX, state.spinY, state.spinZ))); - if (!state.grounding.supported()) { - state.reject("tree-grounding"); - } - } - - private static boolean isSurfaceTreePlacement(PlacementContext context, PlacementState state) { - IrisObjectPlacement config = state.config; - ObjectPlaceMode mode = config.getMode(); - return context.automatic && config.getCarvingSupport().supportsSurface() - && !config.isForcePlace() && !config.isFromBottom() && !state.ceilingHang - && mode != ObjectPlaceMode.PAINT && mode != ObjectPlaceMode.FLOATING - && mode != ObjectPlaceMode.STRUCTURE_PIECE; - } - - private static void extendRoots(PlacementContext context, PlacementState state, Void ignored) { - if (state.grounding == null) { - return; - } - boolean waterlogCandidate = state.config.isWaterloggable() || state.config.isUnderwater(); - for (TreeGrounding.Extension extension : state.grounding.extensions()) { - for (int rootY = extension.topY(); rootY >= extension.bottomY(); rootY--) { - NativeBlockState root = ObjectBlockPass.normalizePlacedWaterlogging(extension.state(), state.placer, - extension.x(), rootY, extension.z(), waterlogCandidate); - state.placer.set(extension.x(), rootY, extension.z(), root); - if (context.listener != null) { - context.listener.accept(new BlockPosition(extension.x(), rootY, extension.z()), root); - } - } - } - } -} diff --git a/core/src/main/java/art/arcane/iris/structure/object/PlacementModuleVacuum.java b/core/src/main/java/art/arcane/iris/structure/object/PlacementModuleVacuum.java index 0172e7755..a6ab417f8 100644 --- a/core/src/main/java/art/arcane/iris/structure/object/PlacementModuleVacuum.java +++ b/core/src/main/java/art/arcane/iris/structure/object/PlacementModuleVacuum.java @@ -26,7 +26,7 @@ final class PlacementModuleVacuum implements PlacementModule { vacuumTerrain(context.self, state.placer, state.config, context.x, context.z, state.bounds.minX(), state.bounds.maxX(), state.bounds.minZ(), state.bounds.maxZ(), state.vacuumLowest, state.vacuumHighest); - }, COLLECT, PlacementModuleBlocks.COMPLETE, PlacementModuleTreeGrounding.ROOTS); + }, COLLECT, PlacementModuleBlocks.COMPLETE); } private static void vacuumTerrain(IrisObject self, IObjectPlacer placer, IrisObjectPlacement config, int centerX, int centerZ, int lowX, int highX, int lowZ, int highZ, int baseY, int topY) { diff --git a/core/src/main/java/art/arcane/iris/structure/object/PlacementState.java b/core/src/main/java/art/arcane/iris/structure/object/PlacementState.java index dff353e6b..2b6d1eeb4 100644 --- a/core/src/main/java/art/arcane/iris/structure/object/PlacementState.java +++ b/core/src/main/java/art/arcane/iris/structure/object/PlacementState.java @@ -1,6 +1,5 @@ package art.arcane.iris.structure.object; -import art.arcane.iris.generation.decoration.tree.TreeGrounding; import art.arcane.iris.structure.object.PlacementContext.TransformedBounds; import art.arcane.iris.structure.object.PlacementContext.WorldBounds; import art.arcane.iris.generation.geometry.IrisBlockVector; @@ -34,7 +33,6 @@ public final class PlacementState { WorldBounds worldBounds; IrisPaintSurfaceProjection paintProjection; art.arcane.volmlib.util.collection.KList paintSupport; - TreeGrounding.Plan grounding; ObjectPlacementBake bake; PlacementPalette palette; int vacuumLowest = Integer.MAX_VALUE; diff --git a/core/src/main/java/art/arcane/iris/world/storage/matter/IrisMatterSupport.java b/core/src/main/java/art/arcane/iris/world/storage/matter/IrisMatterSupport.java index d3683f8ae..a67a35db7 100644 --- a/core/src/main/java/art/arcane/iris/world/storage/matter/IrisMatterSupport.java +++ b/core/src/main/java/art/arcane/iris/world/storage/matter/IrisMatterSupport.java @@ -42,7 +42,6 @@ public final class IrisMatterSupport { IrisMatter.registerSliceType(new EntityMatter()); IrisMatter.registerSliceType(new CustomBlockOwnershipMatter()); IrisMatter.registerSliceType(new ObjectContinuationMatter()); - IrisMatter.registerSliceType(new TreeCanopyMatter()); IrisMatter.registerSliceType("art.arcane.iris.core.link.Identifier", new IdentifierMatter()); IrisMatter.registerSliceType("art.arcane.iris.engine.framework.NativeStructureOwnershipBundle", new NativeStructureOwnershipMatter()); IrisMatter.registerSliceType(new PlatformBlockMatter()); diff --git a/core/src/main/java/art/arcane/iris/world/storage/matter/TreeCanopyMatter.java b/core/src/main/java/art/arcane/iris/world/storage/matter/TreeCanopyMatter.java deleted file mode 100644 index 1abf79d15..000000000 --- a/core/src/main/java/art/arcane/iris/world/storage/matter/TreeCanopyMatter.java +++ /dev/null @@ -1,39 +0,0 @@ -package art.arcane.iris.world.storage.matter; - -import art.arcane.iris.generation.mantle.TreeCanopy; -import art.arcane.volmlib.util.data.palette.Palette; -import art.arcane.volmlib.util.matter.Sliced; -import art.arcane.volmlib.util.matter.slices.RawMatter; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; - -@Sliced -public final class TreeCanopyMatter extends RawMatter { - public TreeCanopyMatter() { - this(1, 1, 1); - } - - public TreeCanopyMatter(int width, int height, int depth) { - super(width, height, depth, TreeCanopy.class); - } - - @Override - public Palette getGlobalPalette() { - return null; - } - - @Override - public void writeNode(TreeCanopy canopy, DataOutputStream output) throws IOException { - output.writeByte(1); - } - - @Override - public TreeCanopy readNode(DataInputStream input) throws IOException { - if (input.readUnsignedByte() != 1) { - throw new IOException("Invalid tree canopy placement condition"); - } - return TreeCanopy.INSTANCE; - } -} diff --git a/core/src/test/java/art/arcane/iris/generation/mantle/CaveObjectPlacementTransactionTest.java b/core/src/test/java/art/arcane/iris/generation/mantle/CaveObjectPlacementTransactionTest.java index 15036a4ba..0add6e52a 100644 --- a/core/src/test/java/art/arcane/iris/generation/mantle/CaveObjectPlacementTransactionTest.java +++ b/core/src/test/java/art/arcane/iris/generation/mantle/CaveObjectPlacementTransactionTest.java @@ -29,11 +29,9 @@ import art.arcane.iris.generation.block.TileData; import art.arcane.iris.generation.hydrology.cave.HydrologyCaveAction; import art.arcane.iris.generation.hydrology.cave.HydrologyCaveCell; import art.arcane.volmlib.nativelib.terrain.NativeBlockState; -import art.arcane.volmlib.util.math.BlockPosition; import org.junit.Test; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertSame; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; @@ -45,26 +43,6 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; public class CaveObjectPlacementTransactionTest { - @Test - public void canopyCommitRechecksSolidsAndSkipsAssociatedMetadata() { - IObjectPlacer delegate = createPlacer(128, 80, 20, 60); - CaveObjectPlacementTransaction transaction = new CaveObjectPlacementTransaction(delegate, 20, 10); - NativeBlockState canopy = mock(NativeBlockState.class); - NativeBlockState trunk = mock(NativeBlockState.class); - when(trunk.isSolid()).thenReturn(true); - when(delegate.beginTreeCanopy(any())).thenCallRealMethod(); - assertTrue(transaction.beginTreeCanopy(new BlockPosition(4, 30, 7))); - transaction.set(4, 30, 7, canopy); - transaction.setData(4, 30, 7, "canopy"); - transaction.endTreeCanopy(); - when(delegate.get(4, 30, 7)).thenReturn(trunk); - - assertEquals(CaveObjectPlacementTransaction.CommitResult.COMMITTED, transaction.commit()); - - verify(delegate, never()).set(4, 30, 7, canopy); - verify(delegate, never()).setData(4, 30, 7, "canopy"); - } - @Test public void validPlacementCommitsBlocksTilesAndMetadataTogether() { IObjectPlacer delegate = createPlacer(128, 80, 20, 60); diff --git a/core/src/test/java/art/arcane/iris/generation/mantle/FloatingObjectPlacementTransactionTest.java b/core/src/test/java/art/arcane/iris/generation/mantle/FloatingObjectPlacementTransactionTest.java index a63811bdb..c47e3f938 100644 --- a/core/src/test/java/art/arcane/iris/generation/mantle/FloatingObjectPlacementTransactionTest.java +++ b/core/src/test/java/art/arcane/iris/generation/mantle/FloatingObjectPlacementTransactionTest.java @@ -27,7 +27,6 @@ import art.arcane.iris.generation.block.TileData; import art.arcane.iris.structure.object.ObjectWaterRule; import art.arcane.volmlib.util.stream.ProceduralStream; import art.arcane.volmlib.nativelib.terrain.NativeBlockState; -import art.arcane.volmlib.util.math.BlockPosition; import org.junit.Test; import art.arcane.volmlib.util.mantle.runtime.Mantle; import art.arcane.volmlib.util.mantle.runtime.MantleChunk; @@ -38,7 +37,6 @@ import art.arcane.iris.structure.object.IObjectPlacer; import art.arcane.iris.world.storage.matter.IrisMatterSupport; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertNotNull; import static org.mockito.ArgumentMatchers.any; @@ -51,28 +49,6 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; public class FloatingObjectPlacementTransactionTest { - @Test - public void canopyCommitRechecksSolidsAndSkipsAssociatedMetadata() { - IslandObjectPlacer delegate = createPlacer(true); - FloatingObjectPlacementTransaction transaction = new FloatingObjectPlacementTransaction(delegate, - new ObjectContinuationBundle.PlacementKey(ObjectContinuationBundle.Kind.FLOATING, 0, 0, 0), ObjectWaterRule.KEEP_OUT); - NativeBlockState canopy = mock(NativeBlockState.class); - NativeBlockState trunk = mock(NativeBlockState.class); - when(trunk.isSolid()).thenReturn(true); - when(delegate.beginTreeCanopy(any())).thenCallRealMethod(); - when(delegate.canWriteObjectBlock(4, 101, 7)).thenReturn(true); - assertTrue(transaction.beginTreeCanopy(new BlockPosition(4, 101, 7))); - transaction.set(4, 101, 7, canopy); - transaction.setData(4, 101, 7, "canopy"); - transaction.endTreeCanopy(); - when(delegate.get(4, 101, 7)).thenReturn(trunk); - - assertEquals(FloatingObjectPlacementTransaction.CommitResult.COMMITTED, transaction.commit()); - - verify(delegate, never()).set(4, 101, 7, canopy); - verify(delegate, never()).setData(4, 101, 7, "canopy"); - } - @Test public void unsupportedFinalTerrainRejectsBlocksTilesAndMarkersTogether() { IslandObjectPlacer delegate = createPlacer(false); diff --git a/core/src/test/java/art/arcane/iris/generation/mantle/MutationLogTest.java b/core/src/test/java/art/arcane/iris/generation/mantle/MutationLogTest.java index 3f10b5136..4825d2d0b 100644 --- a/core/src/test/java/art/arcane/iris/generation/mantle/MutationLogTest.java +++ b/core/src/test/java/art/arcane/iris/generation/mantle/MutationLogTest.java @@ -19,10 +19,10 @@ public class MutationLogTest { public void logKeepsPositionsValuesAndFlagsInOrder() { NativeBlockState state = new KeyedBlockState("minecraft:stone"); MutationLog log = MutationLog.of(List.of( - new ObjectDestinationTransaction.SetMutation(new ObjectDestinationTransaction.DataKey(3, 70, -2, String.class), "marker", true), - new ObjectDestinationTransaction.CustomBlockMutation(new ObjectDestinationTransaction.DataKey(-17, 4, 40, NativeBlockState.class), state, false))); + new ObjectDestinationTransaction.SetMutation(new ObjectDestinationTransaction.DataKey(3, 70, -2, String.class), "marker"), + new ObjectDestinationTransaction.CustomBlockMutation(new ObjectDestinationTransaction.DataKey(-17, 4, 40, NativeBlockState.class), state))); for (int index = 0; index < 100; index++) { - log.add(index, index + 1, -index, "grow" + index, (index & 1) == 0, (index & 2) == 0, + log.add(index, index + 1, -index, "grow" + index, (index & 1) == 0, (index & 4) == 0 ? ObjectWaterRule.ENTERS_WATER : (index & 8) == 0 ? ObjectWaterRule.FORCED : ObjectWaterRule.KEEP_OUT); } @@ -32,17 +32,13 @@ public class MutationLogTest { assertEquals(-2, log.z(0)); assertEquals("marker", log.value(0)); assertFalse(log.custom(0)); - assertTrue(log.canopy(0)); assertSame(String.class, log.type(0)); assertSame(state, log.value(1)); assertTrue(log.custom(1)); - assertFalse(log.canopy(1)); assertSame(NativeBlockState.class, log.type(1)); assertEquals(99, log.x(101)); assertEquals("grow99", log.value(101)); assertFalse(log.custom(101)); - assertTrue(log.canopy(98)); - assertFalse(log.canopy(100)); assertEquals(ObjectWaterRule.KEEP_OUT, log.waterRule(0)); assertEquals(ObjectWaterRule.ENTERS_WATER, log.waterRule(98)); assertEquals(ObjectWaterRule.FORCED, log.waterRule(6)); @@ -52,7 +48,7 @@ public class MutationLogTest { @Test public void mismatchedMutationTypesAreRejected() { assertThrows(IllegalArgumentException.class, () -> MutationLog.of(List.of( - new ObjectDestinationTransaction.SetMutation(new ObjectDestinationTransaction.DataKey(0, 4, 0, Integer.class), "text", false)))); + new ObjectDestinationTransaction.SetMutation(new ObjectDestinationTransaction.DataKey(0, 4, 0, Integer.class), "text")))); } @Test @@ -64,10 +60,9 @@ public class MutationLogTest { int y = 4 + index; int z = (index * 5) - 20; String value = "value" + (index % 9); - boolean canopy = index % 4 == 0; - log.add(x, y, z, value, false, canopy, ObjectWaterRule.KEEP_OUT); + log.add(x, y, z, value, false, ObjectWaterRule.KEEP_OUT); if (index >= 10) { - tail.add(new ObjectDestinationTransaction.SetMutation(new ObjectDestinationTransaction.DataKey(x, y, z, String.class), value, canopy)); + tail.add(new ObjectDestinationTransaction.SetMutation(new ObjectDestinationTransaction.DataKey(x, y, z, String.class), value)); } } ObjectSourcePlan sliced = new ObjectSourcePlan(log, 10, List.of()); diff --git a/core/src/test/java/art/arcane/iris/generation/mantle/ObjectContinuationCanopyTest.java b/core/src/test/java/art/arcane/iris/generation/mantle/ObjectContinuationCanopyTest.java deleted file mode 100644 index 07643aeb9..000000000 --- a/core/src/test/java/art/arcane/iris/generation/mantle/ObjectContinuationCanopyTest.java +++ /dev/null @@ -1,222 +0,0 @@ -package art.arcane.iris.generation.mantle; - -import art.arcane.iris.generation.block.TileData; -import art.arcane.iris.generation.decoration.tree.TreeBlockMaterial; -import art.arcane.iris.generation.runtime.Engine; -import art.arcane.iris.integration.Identifier; -import art.arcane.iris.spi.IrisPlatform; -import art.arcane.iris.spi.IrisPlatforms; -import art.arcane.iris.spi.PlatformRegistries; -import art.arcane.iris.structure.object.IObjectPlacer; -import art.arcane.iris.structure.object.ObjectWaterRule; -import art.arcane.iris.testsupport.PlatformLeakGuard; -import art.arcane.iris.world.storage.matter.IrisMatterSupport; -import art.arcane.iris.world.storage.matter.TileWrapper; -import art.arcane.volmlib.nativelib.terrain.NativeBlockState; -import art.arcane.volmlib.util.hunk.Hunk; -import art.arcane.volmlib.util.mantle.runtime.Mantle; -import art.arcane.volmlib.util.mantle.runtime.MantleChunk; -import art.arcane.volmlib.util.math.BlockPosition; -import art.arcane.volmlib.util.matter.IrisMatter; -import art.arcane.volmlib.util.matter.Matter; -import art.arcane.volmlib.util.matter.MatterSlice; -import org.junit.After; -import org.junit.Before; -import org.junit.ClassRule; -import org.junit.Test; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.util.List; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public class ObjectContinuationCanopyTest { - @ClassRule - public static final PlatformLeakGuard PLATFORM_GUARD = PlatformLeakGuard.clean(); - - private IrisPlatform previous; - private NativeBlockState trunk; - private NativeBlockState canopy; - private NativeBlockState custom; - - @Before - public void bindPalette() { - IrisMatterSupport.ensureRegistered(); - previous = IrisPlatforms.isBound() ? IrisPlatforms.get() : null; - IrisPlatform platform = mock(IrisPlatform.class); - PlatformRegistries registries = mock(PlatformRegistries.class); - trunk = mock(NativeBlockState.class); - canopy = mock(NativeBlockState.class); - custom = mock(NativeBlockState.class); - when(trunk.key()).thenReturn("minecraft:oak_log"); - when(trunk.isSolid()).thenReturn(true); - when(canopy.key()).thenReturn("minecraft:red_stained_glass"); - when(canopy.isSolid()).thenReturn(true); - when(custom.isCustom()).thenReturn(true); - when(custom.placementBaseState()).thenReturn(canopy); - when(custom.deferredPlacementKey()).thenReturn("test:custom_canopy"); - when(platform.registries()).thenReturn(registries); - when(registries.decodeBlockState(trunk.key())).thenReturn(trunk); - when(registries.decodeBlockState(canopy.key())).thenReturn(canopy); - IrisPlatforms.unbind(); - IrisPlatforms.bind(platform); - } - - @After - public void restorePalette() { - IrisPlatforms.unbind(); - if (previous != null) { - IrisPlatforms.bind(previous); - } - } - - @Test - public void encodingKeepsTrunkProvenanceWhenLaterCustomCanopyOverlaps() throws Exception { - Matter payload = decode(List.of( - new ObjectDestinationTransaction.SetMutation(key(16, NativeBlockState.class), trunk, false), - new ObjectDestinationTransaction.SetMutation(key(16, String.class), "original-trunk", false), - new ObjectDestinationTransaction.CustomBlockMutation(key(16, NativeBlockState.class), custom, true), - new ObjectDestinationTransaction.SetMutation(key(16, String.class), "rejected-canopy", true), - new ObjectDestinationTransaction.CustomBlockMutation(key(17, NativeBlockState.class), custom, true))); - - assertSame(trunk, payload.getSlice(NativeBlockState.class).get(0, 5, 1)); - assertEquals("original-trunk", payload.getSlice(String.class).get(0, 5, 1)); - assertNull(payload.getSlice(Identifier.class).get(0, 5, 1)); - assertNull(payload.getSlice(TreeCanopy.class).get(0, 5, 1)); - assertSame(canopy, payload.getSlice(NativeBlockState.class).get(1, 5, 1)); - assertEquals(Identifier.fromString("test:custom_canopy"), payload.getSlice(Identifier.class).get(1, 5, 1)); - assertSame(TreeCanopy.INSTANCE, payload.getSlice(TreeCanopy.class).get(1, 5, 1)); - } - - @Test - public void unconditionalBlockClearsPreviousCanopyCondition() throws Exception { - Matter payload = decode(List.of( - new ObjectDestinationTransaction.CustomBlockMutation(key(16, NativeBlockState.class), custom, true), - new ObjectDestinationTransaction.SetMutation(key(16, NativeBlockState.class), trunk, false))); - - assertSame(trunk, payload.getSlice(NativeBlockState.class).get(0, 5, 1)); - MatterSlice conditions = payload.getSlice(TreeCanopy.class); - assertTrue(conditions == null || conditions.get(0, 5, 1) == null); - MatterSlice identifiers = payload.getSlice(Identifier.class); - assertTrue(identifiers == null || identifiers.get(0, 5, 1) == null); - } - - @Test - public void replayDefersCanopyAndPreservesLaterStructureMetadata() throws Exception { - ReplayFixture fixture = new ReplayFixture(); - Matter payload = customPayload(); - ObjectContinuationPersistence.restore(fixture.mantle, 1, 0, payload, fixture.blocks, false); - assertFalse(fixture.section.hasSlice(Identifier.class)); - assertNull(fixture.blocks.get(0, 5, 1)); - fixture.blocks.set(0, 5, 1, trunk); - Identifier existingId = Identifier.fromString("test:existing_structure"); - TreeBlockMaterial provenance = TreeBlockMaterial.of("minecraft:oak_log"); - TileWrapper tile = new TileWrapper(mock(TileData.class)); - fixture.section.slice(NativeBlockState.class).set(0, 5, 1, trunk); - fixture.section.slice(Identifier.class).set(0, 5, 1, existingId); - fixture.section.slice(String.class).set(0, 5, 1, "original-trunk"); - fixture.section.slice(TreeBlockMaterial.class).set(0, 5, 1, provenance); - fixture.section.slice(TileWrapper.class).set(0, 5, 1, tile); - - ObjectContinuationPersistence.restore(fixture.mantle, 1, 0, payload, fixture.blocks, true); - - assertSame(trunk, fixture.blocks.get(0, 5, 1)); - assertSame(trunk, fixture.section.getSlice(NativeBlockState.class).get(0, 5, 1)); - assertEquals(existingId, fixture.section.getSlice(Identifier.class).get(0, 5, 1)); - assertEquals("original-trunk", fixture.section.getSlice(String.class).get(0, 5, 1)); - assertEquals(provenance, fixture.section.getSlice(TreeBlockMaterial.class).get(0, 5, 1)); - assertSame(tile, fixture.section.getSlice(TileWrapper.class).get(0, 5, 1)); - assertFalse(fixture.section.hasSlice(TreeCanopy.class)); - } - - @Test - public void replayPlacesCustomCanopyIntoAirAndClearsOldTileMetadata() throws Exception { - ReplayFixture fixture = new ReplayFixture(); - fixture.section.slice(TileWrapper.class).set(0, 5, 1, new TileWrapper(mock(TileData.class))); - fixture.section.slice(TreeBlockMaterial.class).set(0, 5, 1, TreeBlockMaterial.of("minecraft:oak_log")); - - ObjectContinuationPersistence.restore(fixture.mantle, 1, 0, customPayload(), fixture.blocks, true); - - assertSame(canopy, fixture.blocks.get(0, 5, 1)); - assertEquals(Identifier.fromString("test:custom_canopy"), fixture.section.getSlice(Identifier.class).get(0, 5, 1)); - assertEquals("incoming-canopy", fixture.section.getSlice(String.class).get(0, 5, 1)); - assertNull(fixture.section.getSlice(TileWrapper.class).get(0, 5, 1)); - assertNull(fixture.section.getSlice(TreeBlockMaterial.class).get(0, 5, 1)); - assertFalse(fixture.section.hasSlice(TreeCanopy.class)); - } - - @Test - @SuppressWarnings("unchecked") - public void floatingContinuationRetainsCustomCanopyCondition() throws Exception { - IObjectPlacer delegate = mock(IObjectPlacer.class); - Engine engine = mock(Engine.class); - EngineMantle engineMantle = mock(EngineMantle.class); - Mantle mantle = mock(Mantle.class); - MantleChunk firstChunk = mock(MantleChunk.class); - MantleChunk secondChunk = mock(MantleChunk.class); - Matter first = new IrisMatter(16, 16, 16); - Matter second = new IrisMatter(16, 16, 16); - when(delegate.getEngine()).thenReturn(engine); - when(delegate.beginTreeCanopy(any())).thenCallRealMethod(); - when(engine.getHeight()).thenReturn(64); - when(engine.getMantle()).thenReturn(engineMantle); - when(engineMantle.getMantle()).thenReturn(mantle); - when(mantle.useChunk(0, 0)).thenReturn(firstChunk); - when(mantle.useChunk(1, 0)).thenReturn(secondChunk); - when(firstChunk.getOrCreate(0)).thenReturn(first); - when(secondChunk.getOrCreate(0)).thenReturn(second); - FloatingObjectPlacementTransaction transaction = new FloatingObjectPlacementTransaction(delegate, - new ObjectContinuationBundle.PlacementKey(ObjectContinuationBundle.Kind.FLOATING, 0, 0, 0), ObjectWaterRule.KEEP_OUT); - transaction.set(15, 5, 1, trunk); - assertTrue(transaction.beginTreeCanopy(new BlockPosition(16, 5, 1))); - transaction.set(16, 5, 1, custom); - transaction.setData(16, 5, 1, "floating-canopy"); - transaction.endTreeCanopy(); - - assertEquals(FloatingObjectPlacementTransaction.CommitResult.COMMITTED, transaction.commit()); - - Matter payload = second.getSlice(ObjectContinuationBundle.class) - .get(0, 0, 0).fragments().getFirst().decode(); - assertSame(TreeCanopy.INSTANCE, payload.getSlice(TreeCanopy.class).get(0, 5, 1)); - assertSame(canopy, payload.getSlice(NativeBlockState.class).get(0, 5, 1)); - assertEquals(Identifier.fromString("test:custom_canopy"), payload.getSlice(Identifier.class).get(0, 5, 1)); - assertEquals("floating-canopy", payload.getSlice(String.class).get(0, 5, 1)); - } - - private Matter customPayload() throws IOException { - return decode(List.of( - new ObjectDestinationTransaction.CustomBlockMutation(key(16, NativeBlockState.class), custom, true), - new ObjectDestinationTransaction.SetMutation(key(16, String.class), "incoming-canopy", true))); - } - - private static Matter decode(List mutations) throws IOException { - return Matter.read(new ByteArrayInputStream(ObjectSourcePlan.encode(mutations, 64))); - } - - private static ObjectDestinationTransaction.DataKey key(int x, Class type) { - return new ObjectDestinationTransaction.DataKey(x, 5, 1, type); - } - - private static final class ReplayFixture { - private final Mantle mantle; - private final Matter section = new IrisMatter(16, 16, 16); - private final Hunk blocks = Hunk.newArrayHunk(16, 64, 16); - - @SuppressWarnings("unchecked") - private ReplayFixture() { - mantle = mock(Mantle.class); - MantleChunk chunk = mock(MantleChunk.class); - when(mantle.useChunk(1, 0)).thenReturn(chunk); - when(chunk.get(0)).thenReturn(section); - when(chunk.getOrCreate(0)).thenReturn(section); - } - } -} diff --git a/core/src/test/java/art/arcane/iris/generation/mantle/ObjectContinuationTest.java b/core/src/test/java/art/arcane/iris/generation/mantle/ObjectContinuationTest.java index 12d1bfb05..c261e127f 100644 --- a/core/src/test/java/art/arcane/iris/generation/mantle/ObjectContinuationTest.java +++ b/core/src/test/java/art/arcane/iris/generation/mantle/ObjectContinuationTest.java @@ -170,11 +170,11 @@ public class ObjectContinuationTest { properties.put("CustomName", "continued chest"); TileWrapper tile = new TileWrapper(new TileData("minecraft:chest", properties)); List mutations = List.of( - new ObjectDestinationTransaction.CustomBlockMutation(key(NativeBlockState.class), custom, false), - new ObjectDestinationTransaction.SetMutation(key(String.class), "tree@42", false), - new ObjectDestinationTransaction.SetMutation(key(TreeBlockMaterial.class), TreeBlockMaterial.of("minecraft:oak_log"), false), - new ObjectDestinationTransaction.SetMutation(key(TileWrapper.class), tile, false), - new ObjectDestinationTransaction.SetMutation(new ObjectDestinationTransaction.DataKey(17, 5, 1, NativeBlockState.class), air, false)); + new ObjectDestinationTransaction.CustomBlockMutation(key(NativeBlockState.class), custom), + new ObjectDestinationTransaction.SetMutation(key(String.class), "tree@42"), + new ObjectDestinationTransaction.SetMutation(key(TreeBlockMaterial.class), TreeBlockMaterial.of("minecraft:oak_log")), + new ObjectDestinationTransaction.SetMutation(key(TileWrapper.class), tile), + new ObjectDestinationTransaction.SetMutation(new ObjectDestinationTransaction.DataKey(17, 5, 1, NativeBlockState.class), air)); ObjectContinuationBundle.Fragment fragment = new ObjectContinuationBundle.Fragment( new ObjectContinuationBundle.PlacementKey(ObjectContinuationBundle.Kind.BIOME, 0, 0, 2), new ObjectContinuationBundle.Bounds(15, 1, 17, 1), List.of(new ObjectContinuationBundle.ChunkPosition(0, 0), new ObjectContinuationBundle.ChunkPosition(1, 0)), @@ -219,7 +219,7 @@ public class ObjectContinuationTest { ObjectContinuationBundle.Fragment fragment = new ObjectContinuationBundle.Fragment( new ObjectContinuationBundle.PlacementKey(ObjectContinuationBundle.Kind.BIOME, 0, 0, 0), new ObjectContinuationBundle.Bounds(15, 1, 16, 1), List.of(new ObjectContinuationBundle.ChunkPosition(0, 0), new ObjectContinuationBundle.ChunkPosition(1, 0)), - ObjectSourcePlan.encode(List.of(new ObjectDestinationTransaction.SetMutation(key(IrisSpawner.class), spawner, false)), 64)); + ObjectSourcePlan.encode(List.of(new ObjectDestinationTransaction.SetMutation(key(IrisSpawner.class), spawner)), 64)); try (IrisMatterContext.Scope outer = IrisMatterContext.open(current)) { assertThrows(IOException.class, fragment::decode); @@ -282,7 +282,7 @@ public class ObjectContinuationTest { } private static ObjectDestinationTransaction.Mutation marker(int x, String marker) { - return new ObjectDestinationTransaction.SetMutation(new ObjectDestinationTransaction.DataKey(x, 5, 1, String.class), marker, false); + return new ObjectDestinationTransaction.SetMutation(new ObjectDestinationTransaction.DataKey(x, 5, 1, String.class), marker); } private static final class Fixture { diff --git a/core/src/test/java/art/arcane/iris/generation/mantle/ObjectDestinationTransactionTest.java b/core/src/test/java/art/arcane/iris/generation/mantle/ObjectDestinationTransactionTest.java index 6ba98b9b3..068ba6db5 100644 --- a/core/src/test/java/art/arcane/iris/generation/mantle/ObjectDestinationTransactionTest.java +++ b/core/src/test/java/art/arcane/iris/generation/mantle/ObjectDestinationTransactionTest.java @@ -18,7 +18,6 @@ import art.arcane.iris.spi.IrisPlatform; import art.arcane.iris.spi.IrisPlatforms; import art.arcane.iris.structure.object.ObjectWaterRule; import art.arcane.volmlib.nativelib.terrain.NativeBlockState; -import art.arcane.volmlib.util.math.BlockPosition; import art.arcane.iris.structure.object.IrisObject; import art.arcane.iris.structure.object.IrisObjectPlacement; import art.arcane.iris.structure.object.IrisObjectRotation; @@ -63,88 +62,6 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; public class ObjectDestinationTransactionTest { - @Test - public void separateSourceCanopiesPreservePriorSolidsAndTheirMetadata() { - for (boolean custom : new boolean[]{false, true}) { - MantleWriter writer = writer(); - NativeBlockState trunk = mock(NativeBlockState.class); - NativeBlockState canopy = mock(NativeBlockState.class); - NativeBlockState base = mock(NativeBlockState.class); - when(trunk.isSolid()).thenReturn(true); - if (custom) { - when(canopy.isCustom()).thenReturn(true); - when(canopy.deferredPlacementKey()).thenReturn("test:canopy"); - when(canopy.placementBaseState()).thenReturn(base); - } - TreeBlockMaterial trunkMaterial = new TreeBlockMaterial("test:trunk"); - TreeBlockMaterial canopyMaterial = new TreeBlockMaterial("test:canopy"); - ObjectDestinationTransaction source = new ObjectDestinationTransaction(writer, 0, 0); - for (int x : new int[]{17, 18}) { - assertTrue(source.beginTreeCanopy(new BlockPosition(x, 7, 1))); - source.set(x, 7, 1, canopy); - source.setData(x, 7, 1, "canopy"); - source.setData(x, 7, 1, canopyMaterial); - source.endTreeCanopy(); - } - ObjectSourcePlan plan = source.sourcePlanSince(0); - for (ObjectDestinationTransaction.Mutation mutation : plan.mutationsFor(1, 0)) { - assertTrue(mutation.canopy()); - } - ObjectDestinationTransaction destination = new ObjectDestinationTransaction(writer, 1, 0); - destination.set(17, 7, 1, trunk); - destination.setData(17, 7, 1, "trunk"); - destination.setData(17, 7, 1, trunkMaterial); - destination.apply(plan); - assertSame(trunk, destination.get(17, 7, 1)); - assertEquals("trunk", destination.getDataIfPresent(17, 7, 1, String.class)); - assertEquals(trunkMaterial, destination.getDataIfPresent(17, 7, 1, TreeBlockMaterial.class)); - assertNull(destination.getDataIfPresent(17, 7, 1, Identifier.class)); - assertSame(custom ? base : canopy, destination.get(18, 7, 1)); - assertEquals("canopy", destination.getDataIfPresent(18, 7, 1, String.class)); - destination.commit(); - verify(writer, never()).set(17, 7, 1, canopy); - verify(writer, never()).setData(17, 7, 1, canopy); - verify(writer, never()).setData(17, 7, 1, "canopy"); - verify(writer, never()).setData(17, 7, 1, canopyMaterial); - } - } - - @Test - public void skippedCanopyDoesNotSuppressLaterWoodAtTheSameCell() { - MantleWriter writer = writer(); - NativeBlockState existing = mock(NativeBlockState.class); - NativeBlockState canopy = mock(NativeBlockState.class); - NativeBlockState replacement = mock(NativeBlockState.class); - when(existing.isSolid()).thenReturn(true); - ObjectDestinationTransaction source = new ObjectDestinationTransaction(writer, 0, 0); - assertTrue(source.beginTreeCanopy(new BlockPosition(17, 7, 1))); - source.set(17, 7, 1, canopy); - source.setData(17, 7, 1, "canopy"); - source.endTreeCanopy(); - source.set(17, 7, 1, replacement); - source.setData(17, 7, 1, "replacement"); - ObjectDestinationTransaction destination = new ObjectDestinationTransaction(writer, 1, 0); - destination.set(17, 7, 1, existing); - destination.apply(source.sourcePlanSince(0)); - assertSame(replacement, destination.get(17, 7, 1)); - assertEquals("replacement", destination.getDataIfPresent(17, 7, 1, String.class)); - destination.commit(); - verify(writer, never()).setData(17, 7, 1, canopy); - verify(writer, never()).setData(17, 7, 1, "canopy"); - verify(writer).setData(17, 7, 1, replacement); - } - - @Test - public void canopyCaptureRejectsExistingSolidsWithoutMutations() { - MantleWriter writer = writer(); - NativeBlockState solid = mock(NativeBlockState.class); - when(solid.isSolid()).thenReturn(true); - when(writer.getPrerequisiteBlock(4, 7, 1)).thenReturn(solid); - ObjectDestinationTransaction source = new ObjectDestinationTransaction(writer, 0, 0); - assertFalse(source.beginTreeCanopy(new BlockPosition(4, 7, 1))); - assertEquals(0, source.mutationCheckpoint()); - } - @Test public void onlyUnderwaterObjectsDisplaceWaterAndNothingOpenOrCarvedBreaksContainment() { MantleWriter writer = writer(); @@ -251,7 +168,7 @@ public class ObjectDestinationTransactionTest { } @Test - public void canopiesDoNotFillChannels() { + public void solidBlocksDoNotFillChannels() { MantleWriter writer = writer(); IrisComplex complex = mock(IrisComplex.class); HydrologyRuntime runtime = mock(HydrologyRuntime.class); @@ -275,17 +192,17 @@ public class ObjectDestinationTransactionTest { ObjectDestinationTransaction transaction = new ObjectDestinationTransaction(writer, 0, 0); int start = transaction.mutationCheckpoint(); for (int y = 11; y <= 14; y++) { - setCanopy(transaction, 3, y, 3, leaves); + transaction.set(3, y, 3, leaves); } for (int y = 9; y <= 14; y++) { - setCanopy(transaction, 4, y, 3, leaves); + transaction.set(4, y, 3, leaves); } assertEquals("canopy leaves never fill a channel or pond between its bed and its surface", start, transaction.mutationCheckpoint()); - setCanopy(transaction, 3, 10, 3, leaves); - setCanopy(transaction, 3, 15, 3, leaves); - setCanopy(transaction, 4, 8, 3, leaves); - setCanopy(transaction, 5, 14, 3, leaves); + transaction.set(3, 10, 3, leaves); + transaction.set(3, 15, 3, leaves); + transaction.set(4, 8, 3, leaves); + transaction.set(5, 14, 3, leaves); assertEquals("the bed, the air above the surface and dry land keep their leaves", start + 4, transaction.mutationCheckpoint()); int underwater = transaction.beginObjectPlacement(ObjectWaterRule.ENTERS_WATER); @@ -958,12 +875,6 @@ public class ObjectDestinationTransactionTest { verify(writer).restoreData(0, 4, 0, Identifier.class, originalIdentifier); } - private static void setCanopy(ObjectDestinationTransaction transaction, int x, int y, int z, NativeBlockState state) { - assertTrue(transaction.beginTreeCanopy(new BlockPosition(x, y, z))); - transaction.set(x, y, z, state); - transaction.endTreeCanopy(); - } - @SuppressWarnings("unchecked") private static void followRasterStreams(IrisComplex complex, ChunkWaterRaster raster) { ProceduralStream roles = mock(ProceduralStream.class); diff --git a/core/src/test/java/art/arcane/iris/generation/mantle/ObjectSourcePlanCacheTest.java b/core/src/test/java/art/arcane/iris/generation/mantle/ObjectSourcePlanCacheTest.java index 9c88b387e..d50fa4e8e 100644 --- a/core/src/test/java/art/arcane/iris/generation/mantle/ObjectSourcePlanCacheTest.java +++ b/core/src/test/java/art/arcane/iris/generation/mantle/ObjectSourcePlanCacheTest.java @@ -364,7 +364,7 @@ public class ObjectSourcePlanCacheTest { List mutations = new ArrayList<>(); for (int[] chunk : chunks) { mutations.add(new ObjectDestinationTransaction.SetMutation( - new ObjectDestinationTransaction.DataKey(chunk[0] << 4, 4, chunk[1] << 4, String.class), "marker", false)); + new ObjectDestinationTransaction.DataKey(chunk[0] << 4, 4, chunk[1] << 4, String.class), "marker")); } return new ObjectSourcePlan(mutations); } diff --git a/core/src/test/java/art/arcane/iris/generation/mantle/ObjectSourcePlanTest.java b/core/src/test/java/art/arcane/iris/generation/mantle/ObjectSourcePlanTest.java index 029dc7e33..c748ef7df 100644 --- a/core/src/test/java/art/arcane/iris/generation/mantle/ObjectSourcePlanTest.java +++ b/core/src/test/java/art/arcane/iris/generation/mantle/ObjectSourcePlanTest.java @@ -74,14 +74,14 @@ public class ObjectSourcePlanTest { int z = centerZ + random.nextInt(2 * reach + 1) - reach; int y = random.nextInt(768); mutations.add(switch (random.nextInt(6)) { - case 0 -> new ObjectDestinationTransaction.CustomBlockMutation(key(x, y, z, NativeBlockState.class), custom, random.nextBoolean()); - case 1 -> new ObjectDestinationTransaction.SetMutation(key(x, y, z, String.class), placementMarker, random.nextBoolean()); + case 0 -> new ObjectDestinationTransaction.CustomBlockMutation(key(x, y, z, NativeBlockState.class), custom); + case 1 -> new ObjectDestinationTransaction.SetMutation(key(x, y, z, String.class), placementMarker); case 2 -> new ObjectDestinationTransaction.SetMutation(key(x, y, z, TreeBlockMaterial.class), - new TreeBlockMaterial("minecraft:oak_log"), random.nextBoolean()); - case 3 -> new ObjectDestinationTransaction.SetMutation(key(x, y, z, MatterMarker.class), marker, random.nextBoolean()); + new TreeBlockMaterial("minecraft:oak_log")); + case 3 -> new ObjectDestinationTransaction.SetMutation(key(x, y, z, MatterMarker.class), marker); default -> { NativeBlockState state = states[random.nextInt(states.length)]; - yield new ObjectDestinationTransaction.SetMutation(key(x, y, z, NativeBlockState.class), state, random.nextBoolean()); + yield new ObjectDestinationTransaction.SetMutation(key(x, y, z, NativeBlockState.class), state); } }); } @@ -109,11 +109,11 @@ public class ObjectSourcePlanTest { @Test public void heightsOutsideThePackedRangeAreRejected() { assertThrows(IllegalArgumentException.class, () -> new ObjectSourcePlan(List.of( - new ObjectDestinationTransaction.SetMutation(key(0, -1, 0, String.class), "marker", false)))); + new ObjectDestinationTransaction.SetMutation(key(0, -1, 0, String.class), "marker")))); assertThrows(IllegalArgumentException.class, () -> new ObjectSourcePlan(List.of( - new ObjectDestinationTransaction.SetMutation(key(0, 1 << 22, 0, String.class), "marker", false)))); + new ObjectDestinationTransaction.SetMutation(key(0, 1 << 22, 0, String.class), "marker")))); assertThrows(IllegalArgumentException.class, () -> new ObjectSourcePlan(List.of( - new ObjectDestinationTransaction.SetMutation(key(0, 4, 0, Object.class), "marker", false)))); + new ObjectDestinationTransaction.SetMutation(key(0, 4, 0, Object.class), "marker")))); } @Test @@ -139,7 +139,7 @@ public class ObjectSourcePlanTest { List trees = new ArrayList<>(); for (int index = 0; index < 100; index++) { trees.add(new ObjectDestinationTransaction.SetMutation(key(index & 15, 4, 0, TreeBlockMaterial.class), - new TreeBlockMaterial("minecraft:oak_log"), false)); + new TreeBlockMaterial("minecraft:oak_log"))); } int single = new ObjectSourcePlan(one).estimatedRetainedBytes(); @@ -150,15 +150,15 @@ public class ObjectSourcePlanTest { @Test public void retainedBytesIncludeVariableLengthMarkers() { ObjectDestinationTransaction.DataKey key = new ObjectDestinationTransaction.DataKey(0, 4, 0, String.class); - ObjectSourcePlan shortMarker = new ObjectSourcePlan(List.of(new ObjectDestinationTransaction.SetMutation(key, "a", false))); - ObjectSourcePlan longMarker = new ObjectSourcePlan(List.of(new ObjectDestinationTransaction.SetMutation(key, "a".repeat(4096), false))); + ObjectSourcePlan shortMarker = new ObjectSourcePlan(List.of(new ObjectDestinationTransaction.SetMutation(key, "a"))); + ObjectSourcePlan longMarker = new ObjectSourcePlan(List.of(new ObjectDestinationTransaction.SetMutation(key, "a".repeat(4096)))); assertTrue(longMarker.estimatedRetainedBytes() - shortMarker.estimatedRetainedBytes() >= 8190); } @Test public void unknownPayloadsAreWeighedInsteadOfDisablingRetention() { ObjectSourcePlan unknown = new ObjectSourcePlan(List.of(new ObjectDestinationTransaction.SetMutation( - key(0, 4, 0, Object.class), new Object(), false))); + key(0, 4, 0, Object.class), new Object()))); assertTrue(unknown.estimatedRetainedBytes() > new ObjectSourcePlan(List.of(mutationAt(0, 0))).estimatedRetainedBytes()); assertTrue(unknown.estimatedRetainedBytes() < 4096); @@ -169,9 +169,9 @@ public class ObjectSourcePlanTest { List shortMarkers = List.of(mutationAt(0, 0), mutationAt(16, 0)); List longMarkers = List.of( new ObjectDestinationTransaction.SetMutation( - new ObjectDestinationTransaction.DataKey(0, 4, 0, String.class), "a".repeat(4096), false), + new ObjectDestinationTransaction.DataKey(0, 4, 0, String.class), "a".repeat(4096)), new ObjectDestinationTransaction.SetMutation( - new ObjectDestinationTransaction.DataKey(16, 4, 0, String.class), "b".repeat(4096), false)); + new ObjectDestinationTransaction.DataKey(16, 4, 0, String.class), "b".repeat(4096))); ObjectDestinationTransaction.PlacementRange whole = new ObjectDestinationTransaction.PlacementRange(0, 2); ObjectSourcePlan shortPlain = new ObjectSourcePlan(shortMarkers); ObjectSourcePlan shortCrossing = new ObjectSourcePlan(shortMarkers, List.of(whole)); @@ -224,6 +224,6 @@ public class ObjectSourcePlanTest { private static ObjectDestinationTransaction.Mutation mutationAt(int x, int z) { return new ObjectDestinationTransaction.SetMutation( - new ObjectDestinationTransaction.DataKey(x, 4, z, String.class), "marker", false); + new ObjectDestinationTransaction.DataKey(x, 4, z, String.class), "marker"); } } diff --git a/core/src/test/java/art/arcane/iris/pack/datapack/export/compile/object/ObjectSourceTest.java b/core/src/test/java/art/arcane/iris/pack/datapack/export/compile/object/ObjectSourceTest.java index 8f64b3615..4c0b07a46 100644 --- a/core/src/test/java/art/arcane/iris/pack/datapack/export/compile/object/ObjectSourceTest.java +++ b/core/src/test/java/art/arcane/iris/pack/datapack/export/compile/object/ObjectSourceTest.java @@ -1,6 +1,5 @@ package art.arcane.iris.pack.datapack.export.compile.object; -import art.arcane.iris.generation.decoration.tree.TreeGrounding; import art.arcane.iris.pack.datapack.export.TemplateBlock; import art.arcane.iris.pack.datapack.export.ir.ExportDiagnostic; import art.arcane.iris.spi.IrisPlatform; @@ -16,10 +15,8 @@ import org.junit.Test; import java.util.ArrayList; import java.util.List; -import java.util.Set; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; @@ -102,43 +99,6 @@ public class ObjectSourceTest { assertEquals(3, variant.volume().blocks().size()); } - @Test - public void treeRootsFollowTheTemplateShift() { - IrisObject object = new IrisObject(3, 3, 3); - NativeBlockState root = blockState("minecraft:oak_wood[axis=y]"); - object.setUnsigned(1, -1, 1, root); - object.setUnsigned(0, -2, 1, root); - object.setUnsigned(0, -1, 1, root); - object.setUnsigned(1, 0, 1, blockState("minecraft:oak_log[axis=y]")); - object.setTreeGrounding(TreeGrounding.create(List.of( - new TreeGrounding.Root(0, -2, 0, root), - new TreeGrounding.Root(-1, -3, 0, root), - new TreeGrounding.Root(-1, -2, 0, root)), 3, Set.of())); - - ObjectSource source = ObjectSource.of(object, "procedural/tree", new ArrayList<>()); - - assertEquals(-2, source.baseY()); - assertEquals(3, source.roots().reach()); - assertEquals(List.of("0,0,1", "1,1,1"), cells(source.roots())); - assertEquals("minecraft:oak_wood", source.roots().cells().getFirst().state().name()); - } - - @Test - public void objectsWithoutGroundingHaveNoRoots() { - IrisObject object = new IrisObject(1, 1, 1); - object.setUnsigned(0, 0, 0, blockState("minecraft:stone")); - - assertFalse(ObjectSource.of(object, "objects/rock", new ArrayList<>()).roots().present()); - } - - private static List cells(TreeRoots roots) { - List cells = new ArrayList<>(); - for (TemplateBlock cell : roots.cells()) { - cells.add(cell.x() + "," + cell.y() + "," + cell.z()); - } - return cells; - } - private static TemplateBlock blockAt(ObjectSource source, int x, int y, int z) { for (TemplateBlock block : source.volume().blocks()) { if (block.x() == x && block.y() == y && block.z() == z) { diff --git a/core/src/test/java/art/arcane/iris/pack/datapack/export/compile/object/ObjectStageTest.java b/core/src/test/java/art/arcane/iris/pack/datapack/export/compile/object/ObjectStageTest.java index cab898cee..2173e0ad7 100644 --- a/core/src/test/java/art/arcane/iris/pack/datapack/export/compile/object/ObjectStageTest.java +++ b/core/src/test/java/art/arcane/iris/pack/datapack/export/compile/object/ObjectStageTest.java @@ -129,87 +129,6 @@ public class ObjectStageTest { } } - @Test - public void proceduralTreesExportAsTemplates() throws Exception { - File pack = pack(); - CompatTestPlatform.write(pack, "biomes/plains.json", """ - {"name":"Plains","proceduralObjects":{"trees":[{"name":"field-oak","chance":0.5,"density":2,"variants":2,"seed":7, - "trunk":"minecraft:oak_log","leaves":"minecraft:oak_leaves","heightMin":5,"heightMax":7}]}} - """); - IrisData data = IrisData.openRuntime(pack); - try { - ExportIr ir = compile(data, DataVersion.V26_3, true); - - JsonArray plains = features(ir, "plains"); - assertEquals(1, plains.get(GenerationStep.VEGETAL_DECORATION.ordinal()).getAsJsonArray().size()); - long templates = ir.binaryResources().stream() - .filter(template -> template.path().contains("/procedural/") && template.path().contains("field-oak")) - .count(); - assertTrue("procedural templates: " + templates, templates >= 2); - } finally { - data.close(); - } - } - - @Test - public void proceduralTreeRootsReachDownToTheTerrain() throws Exception { - File pack = pack(); - CompatTestPlatform.write(pack, "biomes/plains.json", """ - {"name":"Plains","proceduralObjects":{"trees":[{"name":"field-oak","chance":0.5,"density":2,"variants":2,"seed":7, - "trunk":"minecraft:oak_log","leaves":"minecraft:oak_leaves","heightMin":5,"heightMax":7,"rootStyle":"TAPROOT","rootDepth":3}]}} - """); - IrisData data = IrisData.openRuntime(pack); - try { - ExportIr ir = compile(data, DataVersion.V26_3, true); - - String placedId = features(ir, "plains").get(GenerationStep.VEGETAL_DECORATION.ordinal()).getAsJsonArray().get(0).getAsString(); - JsonObject placed = json(ir, "data/iris_export/worldgen/placed_feature/" + placedId.substring(NAMESPACE.length() + 1) + ".json"); - String featureId = placed.get("feature").getAsString(); - JsonObject feature = json(ir, "data/iris_export/worldgen/feature/" + featureId.substring(NAMESPACE.length() + 1) + ".json"); - assertEquals("minecraft:weighted_random_selector", feature.get("type").getAsString()); - Set pillars = new HashSet<>(); - for (JsonElement branch : feature.getAsJsonArray("features")) { - JsonObject entry = branch.getAsJsonObject().getAsJsonObject("data"); - JsonArray parts = entry.getAsJsonObject("feature").getAsJsonArray("features"); - for (int index = 1; index < parts.size(); index++) { - pillars.add(parts.get(index).getAsJsonObject().get("feature").getAsString()); - } - } - assertFalse(pillars.isEmpty()); - for (String pillar : pillars) { - assertTrue(pillar, paths(ir).contains("data/iris_export/worldgen/feature/" + pillar.substring(NAMESPACE.length() + 1) + ".json")); - } - } finally { - data.close(); - } - } - - @Test - public void proceduralObjectsSharedByBiomesShareTemplates() throws Exception { - String procedural = """ - "proceduralObjects":{"trees":[{"name":"field-oak","chance":0.5,"density":2,"variants":2,"seed":7, - "trunk":"minecraft:oak_log","leaves":"minecraft:oak_leaves","heightMin":5,"heightMax":7}]}"""; - File pack = pack(); - CompatTestPlatform.write(pack, "biomes/plains.json", "{\"name\":\"Plains\"," + procedural + "}"); - CompatTestPlatform.write(pack, "biomes/forest.json", "{\"name\":\"Forest\"," + procedural + "}"); - IrisData data = IrisData.openRuntime(pack); - try { - ExportIr ir = compile(data, DataVersion.V26_3, true); - - Set objects = new HashSet<>(); - for (BinaryResource template : ir.binaryResources()) { - if (template.path().contains("field-oak")) { - objects.add(template.path().substring(0, template.path().lastIndexOf('/'))); - } - } - assertEquals(objects.toString(), 2, objects.size()); - assertEquals(1, features(ir, "forest").get(GenerationStep.VEGETAL_DECORATION.ordinal()).getAsJsonArray().size()); - assertEquals(1, features(ir, "plains").get(GenerationStep.VEGETAL_DECORATION.ordinal()).getAsJsonArray().size()); - } finally { - data.close(); - } - } - @Test public void lootBoundPerBiome() throws Exception { File pack = pack(); diff --git a/core/src/test/java/art/arcane/iris/pack/datapack/export/compile/object/ObjectVariantBakerTest.java b/core/src/test/java/art/arcane/iris/pack/datapack/export/compile/object/ObjectVariantBakerTest.java index 57302eb03..a0bd6e8ca 100644 --- a/core/src/test/java/art/arcane/iris/pack/datapack/export/compile/object/ObjectVariantBakerTest.java +++ b/core/src/test/java/art/arcane/iris/pack/datapack/export/compile/object/ObjectVariantBakerTest.java @@ -26,7 +26,7 @@ import static org.junit.Assert.assertTrue; public class ObjectVariantBakerTest { private static final String NAMESPACE = "iris_export"; private static final String LEAVES = "minecraft:oak_leaves[distance=1,persistent=true,waterlogged=false]"; - private static final long RIGHT_ANGLE_GOLDEN = 0x5db739a5b940bf1dL; + private static final long RIGHT_ANGLE_GOLDEN = 0x866dd20fe8a61e19L; @Test public void variantBakingIsDeterministic() throws IOException { @@ -43,8 +43,8 @@ public class ObjectVariantBakerTest { .build(); String id = ObjectVariantBaker.templateId(NAMESPACE, "trees/oak", spec, DataVersion.V26_3); - BakedVariant first = new ObjectVariantBaker().bake(id, new ObjectSource(tree, 0, TreeRoots.NONE), spec); - BakedVariant second = new ObjectVariantBaker().bake(id, new ObjectSource(tree, 0, TreeRoots.NONE), spec); + BakedVariant first = new ObjectVariantBaker().bake(id, new ObjectSource(tree, 0), spec); + BakedVariant second = new ObjectVariantBaker().bake(id, new ObjectSource(tree, 0), spec); assertEquals(first, second); assertEquals(id, ObjectVariantBaker.templateId(NAMESPACE, "trees/oak", spec, DataVersion.V26_3)); @@ -63,7 +63,7 @@ public class ObjectVariantBakerTest { block(0, 1, 0, "minecraft:cave_air"))); BakedVariant variant = new ObjectVariantBaker() - .bake("iris_export:object/rock/a", new ObjectSource(volume, 0, TreeRoots.NONE), VariantSpec.builder().build()); + .bake("iris_export:object/rock/a", new ObjectSource(volume, 0), VariantSpec.builder().build()); assertEquals(List.of("minecraft:stone"), states(variant.volume())); assertEquals(2, variant.volume().sizeX()); @@ -85,7 +85,7 @@ public class ObjectVariantBakerTest { block(2, 3, 2, "minecraft:tube_coral_block"))); BakedVariant variant = new ObjectVariantBaker() - .bake("iris_export:object/reef/a", new ObjectSource(reef, 0, TreeRoots.NONE), VariantSpec.builder().build()); + .bake("iris_export:object/reef/a", new ObjectSource(reef, 0), VariantSpec.builder().build()); Set kept = new HashSet<>(); for (TemplateBlock block : variant.volume().blocks()) { @@ -102,7 +102,7 @@ public class ObjectVariantBakerTest { block(1, 0, 0, "minecraft:oak_stairs[facing=north,half=bottom,shape=straight,waterlogged=false]"))); VariantSpec spec = VariantSpec.builder().rotation(new VariantSpec.Rotation(0, 90, 0)).build(); - BakedVariant variant = new ObjectVariantBaker().bake("iris_export:object/s/a", new ObjectSource(volume, 0, TreeRoots.NONE), spec); + BakedVariant variant = new ObjectVariantBaker().bake("iris_export:object/s/a", new ObjectSource(volume, 0), spec); TemplateBlock stairs = variant.volume().blocks().stream() .filter(block -> block.state().name().equals("minecraft:oak_stairs")).findFirst().orElseThrow(); @@ -118,7 +118,7 @@ public class ObjectVariantBakerTest { block(0, 1, 0, "minecraft:oak_slab[type=bottom,waterlogged=false]"))); VariantSpec spec = VariantSpec.builder().rotation(new VariantSpec.Rotation(180, 0, 0)).build(); - BakedVariant variant = new ObjectVariantBaker().bake("iris_export:object/f/a", new ObjectSource(volume, 0, TreeRoots.NONE), spec); + BakedVariant variant = new ObjectVariantBaker().bake("iris_export:object/f/a", new ObjectSource(volume, 0), spec); TemplateBlock slab = variant.volume().blocks().getFirst(); assertEquals("minecraft:oak_slab", slab.state().name()); @@ -133,7 +133,7 @@ public class ObjectVariantBakerTest { block(1, 1, 1, "minecraft:oak_log[axis=y]"))); VariantSpec scaled = VariantSpec.builder().scale(2).build(); - BakedVariant big = new ObjectVariantBaker().bake("iris_export:object/l/a", new ObjectSource(volume, 0, TreeRoots.NONE), scaled); + BakedVariant big = new ObjectVariantBaker().bake("iris_export:object/l/a", new ObjectSource(volume, 0), scaled); assertEquals(16, big.volume().blocks().size()); assertEquals(4, big.volume().sizeY()); @@ -153,7 +153,7 @@ public class ObjectVariantBakerTest { ObjectEdit half = new ObjectEdit(List.of(VanillaBlockState.parse("minecraft:stone_bricks")), false, List.of(new WeightedState(VanillaBlockState.parse("minecraft:mossy_stone_bricks"), 1)), 0.5); - BakedVariant variant = new ObjectVariantBaker().bake("iris_export:object/floor/a", new ObjectSource(floor, 0, TreeRoots.NONE), + BakedVariant variant = new ObjectVariantBaker().bake("iris_export:object/floor/a", new ObjectSource(floor, 0), VariantSpec.builder().edits(List.of(always, half)).build()); Set names = new HashSet<>(); @@ -170,8 +170,8 @@ public class ObjectVariantBakerTest { @Test public void basesAlignAcrossVariants() { - BakedVariant low = new BakedVariant("iris_export:object/a/low", new TemplateVolume(1, 3, 1, List.of(block(0, 0, 0, "minecraft:stone"))), -2, TreeRoots.NONE); - BakedVariant flat = new BakedVariant("iris_export:object/a/flat", new TemplateVolume(1, 1, 1, List.of(block(0, 0, 0, "minecraft:stone"))), 0, TreeRoots.NONE); + BakedVariant low = new BakedVariant("iris_export:object/a/low", new TemplateVolume(1, 3, 1, List.of(block(0, 0, 0, "minecraft:stone"))), -2); + BakedVariant flat = new BakedVariant("iris_export:object/a/flat", new TemplateVolume(1, 1, 1, List.of(block(0, 0, 0, "minecraft:stone"))), 0); List aligned = ObjectVariantBaker.alignBases(List.of(low, flat)); @@ -183,73 +183,6 @@ public class ObjectVariantBakerTest { assertFalse(aligned.get(1).volume().blocks().isEmpty()); } - @Test - public void rootsSurviveAnUnchangedBake() { - TemplateVolume volume = new TemplateVolume(3, 2, 3, List.of( - block(1, 0, 1, "minecraft:oak_wood[axis=y]"), - block(2, 0, 1, "minecraft:oak_wood[axis=y]"), - block(1, 1, 1, "minecraft:oak_log[axis=y]"))); - TreeRoots roots = new TreeRoots(List.of(block(1, 0, 1, "minecraft:oak_wood[axis=y]"), - block(2, 0, 1, "minecraft:oak_wood[axis=y]")), 3); - - BakedVariant variant = new ObjectVariantBaker() - .bake("iris_export:object/tree/a", new ObjectSource(volume, 0, roots), VariantSpec.builder().build()); - - assertEquals(roots, variant.roots()); - } - - @Test - public void rootsTurnWithTheirBlocks() { - TemplateVolume volume = new TemplateVolume(3, 2, 3, List.of( - block(1, 0, 1, "minecraft:oak_wood[axis=y]"), - block(2, 0, 1, "minecraft:spruce_wood[axis=x]"), - block(1, 1, 1, "minecraft:oak_log[axis=y]"))); - TreeRoots roots = new TreeRoots(List.of(block(2, 0, 1, "minecraft:spruce_wood[axis=x]")), 2); - VariantSpec spec = VariantSpec.builder().rotation(new VariantSpec.Rotation(0, 90, 0)).build(); - - BakedVariant variant = new ObjectVariantBaker().bake("iris_export:object/tree/b", new ObjectSource(volume, 0, roots), spec); - - TemplateBlock moved = variant.volume().blocks().stream() - .filter(block -> block.state().name().equals("minecraft:spruce_wood")).findFirst().orElseThrow(); - assertEquals(1, variant.roots().cells().size()); - TemplateBlock root = variant.roots().cells().getFirst(); - assertEquals(List.of(moved.x(), moved.y(), moved.z()), List.of(root.x(), root.y(), root.z())); - assertEquals("z", root.state().properties().get("axis")); - assertEquals(2, variant.roots().reach()); - } - - @Test - public void scaledRootsKeepTheLowestCellPerColumnAndStretchTheirReach() { - TemplateVolume volume = new TemplateVolume(2, 2, 1, List.of( - block(0, 0, 0, "minecraft:oak_wood[axis=y]"), - block(0, 1, 0, "minecraft:oak_log[axis=y]"), - block(1, 1, 0, "minecraft:oak_log[axis=y]"))); - TreeRoots roots = new TreeRoots(List.of(block(0, 0, 0, "minecraft:oak_wood[axis=y]")), 3); - - BakedVariant variant = new ObjectVariantBaker().bake("iris_export:object/tree/c", new ObjectSource(volume, 0, roots), - VariantSpec.builder().scale(2).build()); - - assertEquals(6, variant.roots().reach()); - assertEquals(4, variant.roots().cells().size()); - for (TemplateBlock cell : variant.roots().cells()) { - assertEquals(0, cell.y()); - assertEquals("minecraft:oak_wood", cell.state().name()); - } - } - - @Test - public void alignedBasesLiftRoots() { - TreeRoots roots = new TreeRoots(List.of(block(0, 0, 0, "minecraft:oak_wood[axis=y]")), 2); - BakedVariant low = new BakedVariant("iris_export:object/r/low", new TemplateVolume(1, 3, 1, List.of(block(0, 0, 0, "minecraft:stone"))), -2, TreeRoots.NONE); - BakedVariant rooted = new BakedVariant("iris_export:object/r/rooted", new TemplateVolume(1, 1, 1, - List.of(block(0, 0, 0, "minecraft:oak_wood[axis=y]"))), 0, roots); - - BakedVariant lifted = ObjectVariantBaker.alignBases(List.of(low, rooted)).get(1); - - assertEquals(2, lifted.roots().cells().getFirst().y()); - assertEquals(2, lifted.roots().reach()); - } - @Test public void diagonalTurnsFillSolidCanopiesWithoutHoles() { for (double degrees : new double[]{45, 135}) { @@ -306,14 +239,13 @@ public class ObjectVariantBakerTest { new TemplateBlock(3, 1, 3, VanillaBlockState.parse("minecraft:chest[facing=east,type=single,waterlogged=false]"), chest), block(1, 3, 1, "minecraft:oak_leaves[distance=1,persistent=false,waterlogged=false]"), block(0, 2, 3, "minecraft:oak_slab[type=bottom,waterlogged=false]"))); - TreeRoots roots = new TreeRoots(List.of(block(0, 0, 0, "minecraft:stone")), 2); StringBuilder layout = new StringBuilder(); for (double scale : new double[]{1, 1.5}) { for (int x = 0; x < 360; x += 90) { for (int y = 0; y < 360; y += 90) { for (int z = 0; z < 360; z += 90) { VariantSpec spec = VariantSpec.builder().scale(scale).rotation(new VariantSpec.Rotation(x, y, z)).build(); - describe(layout, new ObjectVariantBaker().bake("iris_export:object/turn/a", new ObjectSource(volume, -1, roots), spec)); + describe(layout, new ObjectVariantBaker().bake("iris_export:object/turn/a", new ObjectSource(volume, -1), spec)); } } } @@ -344,7 +276,7 @@ public class ObjectVariantBakerTest { } private static BakedVariant turned(TemplateVolume source, VariantSpec.Rotation rotation) { - return new ObjectVariantBaker().bake("iris_export:object/turn/b", new ObjectSource(source, 0, TreeRoots.NONE), + return new ObjectVariantBaker().bake("iris_export:object/turn/b", new ObjectSource(source, 0), VariantSpec.builder().rotation(rotation).build()); } @@ -395,11 +327,6 @@ public class ObjectVariantBakerTest { .append(block.state().canonical()).append(' ') .append(block.nbt() == null ? "-" : block.nbt().getString("id")).append('\n'); } - layout.append("roots reach=").append(variant.roots().reach()).append('\n'); - for (TemplateBlock cell : variant.roots().cells()) { - layout.append(cell.x()).append(',').append(cell.y()).append(',').append(cell.z()).append(' ') - .append(cell.state().canonical()).append('\n'); - } } private static long fnv(CharSequence text) { diff --git a/core/src/test/java/art/arcane/iris/pack/datapack/export/compile/object/PlacementCompilerTest.java b/core/src/test/java/art/arcane/iris/pack/datapack/export/compile/object/PlacementCompilerTest.java index c34573989..a37282e84 100644 --- a/core/src/test/java/art/arcane/iris/pack/datapack/export/compile/object/PlacementCompilerTest.java +++ b/core/src/test/java/art/arcane/iris/pack/datapack/export/compile/object/PlacementCompilerTest.java @@ -98,7 +98,7 @@ public class PlacementCompilerTest { placement.setSurfaceSupportDepth(2); TemplateBlock trunk = new TemplateBlock(4, 0, 4, VanillaBlockState.parse("minecraft:oak_log[axis=y]"), null); TemplateBlock crown = new TemplateBlock(0, 5, 0, VanillaBlockState.parse("minecraft:oak_leaves"), null); - BakedVariant tree = new BakedVariant(NAMESPACE + ":object/tree/v", new TemplateVolume(9, 6, 9, List.of(trunk, crown)), 0, TreeRoots.NONE); + BakedVariant tree = new BakedVariant(NAMESPACE + ":object/tree/v", new TemplateVolume(9, 6, 9, List.of(trunk, crown)), 0); List objects = List.of(new ObjectTemplates("tree", List.of(new TemplateChoice(tree, List.of(0, 1, 2, 3), 1)))); JsonObject support = filters(placed(compiler(DataVersion.V26_3).compile(input(placement, objects, List.of()), new ArrayList<>()))).get(1); @@ -121,7 +121,7 @@ public class PlacementCompilerTest { placement.setSurfaceSupportBuffer(2); placement.setSurfaceSupportDepth(2); TemplateBlock trunk = new TemplateBlock(0, 0, 4, VanillaBlockState.parse("minecraft:spruce_log[axis=y]"), null); - BakedVariant tree = new BakedVariant(NAMESPACE + ":object/tree/v", new TemplateVolume(9, 20, 9, List.of(trunk)), 0, TreeRoots.NONE); + BakedVariant tree = new BakedVariant(NAMESPACE + ":object/tree/v", new TemplateVolume(9, 20, 9, List.of(trunk)), 0); List objects = List.of(new ObjectTemplates("tree", List.of(new TemplateChoice(tree, List.of(0, 1, 2, 3), 1)))); JsonObject support = filters(placed(compiler(DataVersion.V26_3).compile(input(placement, objects, List.of()), new ArrayList<>()))).get(1); @@ -495,7 +495,7 @@ public class PlacementCompilerTest { @Test public void heightScanCoversEveryAllowedQuarter() { TemplateBlock block = new TemplateBlock(0, 0, 0, VanillaBlockState.parse("minecraft:stone"), null); - BakedVariant wall = new BakedVariant(NAMESPACE + ":object/wall/v", new TemplateVolume(5, 4, 9, List.of(block)), 0, TreeRoots.NONE); + BakedVariant wall = new BakedVariant(NAMESPACE + ":object/wall/v", new TemplateVolume(5, 4, 9, List.of(block)), 0); IrisObjectPlacement placement = placement(ObjectPlaceMode.MIN_HEIGHT, 1, 1); JsonObject turning = feature(compiler(DataVersion.V26_3).compile(input(placement, List.of(new ObjectTemplates("wall", @@ -539,112 +539,23 @@ public class PlacementCompilerTest { } @Test - public void groundedTreesExtendRootsToTheTerrain() { - IrisObjectPlacement placement = placement(ObjectPlaceMode.CENTER_HEIGHT, 1, 1); - - CompiledPlacement compiled = compiler(DataVersion.V26_3).compile(tree(placement, rootedTree()), new ArrayList<>()); - - JsonObject feature = feature(compiled, "worldgen/feature/"); - assertEquals("minecraft:weighted_random_selector", feature.get("type").getAsString()); - JsonArray branches = feature.getAsJsonArray("features"); - assertEquals(4, branches.size()); - List rotations = new ArrayList<>(); - List roots = new ArrayList<>(); - List gaps = new ArrayList<>(); - String pillar = null; - for (JsonElement element : branches) { - assertEquals(branches.get(0).getAsJsonObject().get("weight"), element.getAsJsonObject().get("weight")); - JsonObject branch = element.getAsJsonObject().getAsJsonObject("data"); - assertEquals(List.of("minecraft:offset", "minecraft:block_predicate_filter"), types(branch)); - gaps.addAll(boxes(branch.getAsJsonArray("placement").get(1))); - JsonObject overlay = branch.getAsJsonObject("feature"); - assertEquals("minecraft:overlay", overlay.get("type").getAsString()); - JsonArray parts = overlay.getAsJsonArray("features"); - assertEquals(2, parts.size()); - JsonObject template = parts.get(0).getAsJsonObject().getAsJsonObject("feature"); - rotations.add(template.getAsJsonArray("templates").get(0).getAsJsonObject().getAsJsonObject("data") - .getAsJsonArray("rotations").get(0).getAsString()); - JsonObject root = parts.get(1).getAsJsonObject(); - pillar = root.get("feature").getAsString(); - JsonObject offset = root.getAsJsonArray("placement").get(0).getAsJsonObject(); - roots.add(offset.get("x").getAsInt() + "," + offset.get("y").getAsInt() + "," + offset.get("z").getAsInt()); - } - assertEquals(List.of("none", "counterclockwise_90", "180", "clockwise_90"), rotations); - assertEquals(List.of("1,-1,0", "0,-1,-1", "-1,-1,0", "0,-1,1"), roots); - assertEquals(List.of("1,-4,0..1,-1,0", "0,-4,-1..0,-1,-1", "-1,-4,0..-1,-1,0", "0,-4,1..0,-1,1"), gaps); - JsonObject shared = resourceAt(compiled, pillar); - JsonObject gated = shared.getAsJsonArray("features").get(0).getAsJsonObject(); - assertEquals("minecraft:block_predicate_filter", gated.getAsJsonArray("placement").get(0).getAsJsonObject().get("type").getAsString()); - JsonObject column = gated.getAsJsonObject("feature"); - assertEquals("minecraft:single_block_pillar", column.get("type").getAsString()); - assertEquals("down", column.get("direction").getAsString()); - assertEquals("minecraft:spruce_wood", column.getAsJsonObject("block").get("id").getAsString()); - JsonObject cap = column.getAsJsonObject("cap_feature"); - assertEquals("minecraft:simple_block", cap.getAsJsonObject("feature").get("type").getAsString()); - assertEquals(-1, cap.getAsJsonArray("placement").get(0).getAsJsonObject().get("y").getAsInt()); - } - - @Test - public void groundedRotationBranchesKeepTheTemplateOdds() { - BakedVariant turning = rootedTree().getFirst().choices().getFirst().variant(); - BakedVariant fixed = new BakedVariant(NAMESPACE + ":object/tree/fixed", turning.volume(), 0, turning.roots()); - List objects = List.of(new ObjectTemplates("tree", List.of( - new TemplateChoice(turning, List.of(0, 1, 2, 3), 1), - new TemplateChoice(fixed, List.of(2), 1)))); - - JsonObject feature = feature(compiler(DataVersion.V26_3).compile(tree(placement(ObjectPlaceMode.CENTER_HEIGHT, 1, 1), objects), - new ArrayList<>()), "worldgen/feature/"); - - List weights = new ArrayList<>(); - for (JsonElement branch : feature.getAsJsonArray("features")) { - weights.add(branch.getAsJsonObject().get("weight").getAsInt()); - } - assertEquals(List.of(1, 1, 1, 1, 4), weights); - } - - @Test - public void groundedTreesReplaceStiltsWithRoots() { - IrisObjectPlacement placement = placement(ObjectPlaceMode.CENTER_STILT, 1, 1); - - JsonObject feature = feature(compiler(DataVersion.V26_3).compile(tree(placement, rootedTree()), new ArrayList<>()), "worldgen/feature/"); - - for (JsonElement element : feature.getAsJsonArray("features")) { - JsonObject overlay = element.getAsJsonObject().getAsJsonObject("data").getAsJsonObject("feature"); - assertTrue(StageTestPacks.ofType(overlay, "minecraft:cuboid").isEmpty()); - assertEquals(2, overlay.getAsJsonArray("features").size()); - } - } - - @Test - public void forcedTreesKeepTheirBuiltRoots() { - IrisObjectPlacement placement = placement(ObjectPlaceMode.CENTER_HEIGHT, 1, 1); - placement.setForcePlace(true); - - JsonObject feature = feature(compiler(DataVersion.V26_3).compile(tree(placement, rootedTree()), new ArrayList<>()), "worldgen/feature/"); - - assertEquals("minecraft:template", feature.get("type").getAsString()); - } - - @Test - public void rootedHeightScansStayInsideTheFeatureWindow() { + public void heightScansStayInsideTheFeatureWindow() { IrisObjectPlacement placement = placement(ObjectPlaceMode.FAST_MAX_HEIGHT, 1, 1); placement.setTranslate(new IrisObjectTranslate().setX(3).setZ(-3)); - List objects = rootedTree(); + List objects = offsetTree(); CompiledPlacement compiled = compiler(DataVersion.V26_3).compile(tree(placement, objects), new ArrayList<>()); - assertWithinWindow(compiled, objects, "rooted fast max"); + assertWithinWindow(compiled, objects, "fast max"); } - private static List rootedTree() { + private static List offsetTree() { List blocks = new ArrayList<>(); for (int y = 1; y < 4; y++) { blocks.add(new TemplateBlock(2, y, 2, VanillaBlockState.parse("minecraft:oak_log[axis=y]"), null)); } - TemplateBlock root = new TemplateBlock(3, 0, 2, VanillaBlockState.parse("minecraft:spruce_wood[axis=y]"), null); - blocks.add(root); - BakedVariant variant = new BakedVariant(NAMESPACE + ":object/tree/rooted", new TemplateVolume(5, 4, 5, blocks), 0, - new TreeRoots(List.of(root), 3)); + blocks.add(new TemplateBlock(3, 0, 2, VanillaBlockState.parse("minecraft:spruce_wood[axis=y]"), null)); + BakedVariant variant = new BakedVariant(NAMESPACE + ":object/tree/offset", new TemplateVolume(5, 4, 5, blocks), 0); return List.of(new ObjectTemplates("tree", List.of(new TemplateChoice(variant, List.of(0, 1, 2, 3), 1)))); } @@ -669,16 +580,6 @@ public class PlacementCompilerTest { return boxes; } - private static JsonObject resourceAt(CompiledPlacement compiled, String id) { - String path = "/worldgen/feature/" + id.substring(NAMESPACE.length() + 1) + ".json"; - for (JsonResource resource : compiled.resources()) { - if (resource.path().endsWith(path)) { - return resource.json().getAsJsonObject(); - } - } - throw new AssertionError("No resource for " + id); - } - private static List filters(JsonObject placed) { List filters = new ArrayList<>(); for (JsonElement element : placed.getAsJsonArray("placement")) { @@ -892,7 +793,7 @@ public class PlacementCompilerTest { int footprint = footprints[index]; TemplateBlock block = new TemplateBlock(0, 0, 0, VanillaBlockState.parse("minecraft:stone"), null); BakedVariant variant = new BakedVariant(NAMESPACE + ":object/o" + index + "/v" + footprint, - new TemplateVolume(footprint, 4, footprint, List.of(block)), 0, TreeRoots.NONE); + new TemplateVolume(footprint, 4, footprint, List.of(block)), 0); objects.add(new ObjectTemplates("o" + index, List.of(new TemplateChoice(variant, List.of(0, 1, 2, 3), 1)))); } return objects; @@ -906,7 +807,7 @@ public class PlacementCompilerTest { blocks.add(new TemplateBlock(1, y, 1, VanillaBlockState.parse("minecraft:tube_coral_block"), null)); } BakedVariant variant = new BakedVariant(NAMESPACE + ":object/c" + index + "/h" + heights[index], - new TemplateVolume(3, heights[index] + 1, 3, blocks), 0, TreeRoots.NONE); + new TemplateVolume(3, heights[index] + 1, 3, blocks), 0); objects.add(new ObjectTemplates("c" + index, List.of(new TemplateChoice(variant, List.of(0, 1, 2, 3), 1)))); } return objects; diff --git a/core/src/test/java/art/arcane/iris/structure/object/IrisObjectFractionalScalingTest.java b/core/src/test/java/art/arcane/iris/structure/object/IrisObjectFractionalScalingTest.java index bf58ae9e5..448c9f64f 100644 --- a/core/src/test/java/art/arcane/iris/structure/object/IrisObjectFractionalScalingTest.java +++ b/core/src/test/java/art/arcane/iris/structure/object/IrisObjectFractionalScalingTest.java @@ -1,22 +1,15 @@ package art.arcane.iris.structure.object; import art.arcane.iris.generation.block.TileData; -import art.arcane.iris.generation.decoration.tree.TreeBlockCanvas; -import art.arcane.iris.generation.decoration.tree.TreeGrounding; import art.arcane.iris.generation.geometry.IrisBlockVector; import art.arcane.volmlib.nativelib.terrain.NativeBlockState; import art.arcane.volmlib.util.collection.KMap; import art.arcane.volmlib.util.math.Vector3i; import org.junit.Test; -import java.util.List; -import java.util.Set; - import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -122,40 +115,6 @@ public class IrisObjectFractionalScalingTest { assertNotSame(scaledLower.getProperties(), scaledUpper.getProperties()); } - @Test - public void sameMaterialCanopyRolesAndRootContactsFollowTheDominantSourceVoxel() { - NativeBlockState wood = state("minecraft:spruce_wood"); - IrisObject source = layers(wood, wood); - TreeGrounding grounding = TreeGrounding.create(List.of(new TreeGrounding.Root(0, 0, 0, wood)), - 8, Set.of(new TreeBlockCanvas.Vec(0, 1, 0))); - source.setTreeGrounding(grounding); - for (boolean savedOrigin : new boolean[]{false, true}) { - IrisObject scaled = scale(source, 0.75D, savedOrigin); - int bottom = -scaled.getCenter().getY(); - TreeGrounding result = scaled.getTreeGrounding(); - - assertEquals(List.of(new TreeGrounding.Root(0, bottom, 0, wood)), result.roots()); - assertFalse(result.isCanopy(0, bottom, 0)); - assertTrue(result.isCanopy(0, bottom + 1, 0)); - assertEquals(6, result.maxExtension()); - } - assertSame(grounding, source.getTreeGrounding()); - } - - @Test - public void canopyWinningAnUnresolvableRootCollisionDoesNotBecomeAGroundContact() { - NativeBlockState wood = state("minecraft:spruce_wood"); - IrisObject source = layers(wood, wood); - source.setTreeGrounding(TreeGrounding.create(List.of(new TreeGrounding.Root(0, 0, 0, wood)), - 8, Set.of(new TreeBlockCanvas.Vec(0, 1, 0)))); - - IrisObject scaled = source.scaled(0.5D, IrisObjectPlacementScaleInterpolator.NONE); - - assertEquals(1, scaled.getBlocks().size()); - assertTrue(scaled.getTreeGrounding().roots().isEmpty()); - assertTrue(scaled.getTreeGrounding().isCanopy(0, 0, 0)); - } - private static IrisObject layers(NativeBlockState lower, NativeBlockState upper) { IrisObject source = new IrisObject(1, 2, 1); source.setCenter(new Vector3i(0, 0, 0)); diff --git a/core/src/test/java/art/arcane/iris/structure/object/ObjectPlacementBakeTest.java b/core/src/test/java/art/arcane/iris/structure/object/ObjectPlacementBakeTest.java index b699be704..6df4b0043 100644 --- a/core/src/test/java/art/arcane/iris/structure/object/ObjectPlacementBakeTest.java +++ b/core/src/test/java/art/arcane/iris/structure/object/ObjectPlacementBakeTest.java @@ -7,7 +7,6 @@ import art.arcane.iris.pack.datapack.export.VanillaBlockState; import art.arcane.iris.pack.datapack.export.compile.object.BakedVariant; import art.arcane.iris.pack.datapack.export.compile.object.ObjectSource; import art.arcane.iris.pack.datapack.export.compile.object.ObjectVariantBaker; -import art.arcane.iris.pack.datapack.export.compile.object.TreeRoots; import art.arcane.iris.pack.datapack.export.compile.object.VariantSpec; import art.arcane.iris.testsupport.KeyedBlockState; import art.arcane.volmlib.nativelib.terrain.NativeBlockState; @@ -210,8 +209,7 @@ public class ObjectPlacementBakeTest { blocks.add(new TemplateBlock(key.getBlockX() + object.getCenter().getX(), key.getBlockY() + object.getCenter().getY(), key.getBlockZ() + object.getCenter().getZ(), VanillaBlockState.parse(object.getBlocks().get(key).key()), null)); } - ObjectSource source = new ObjectSource(new TemplateVolume(object.getW(), object.getH(), object.getD(), blocks), 0, - TreeRoots.NONE); + ObjectSource source = new ObjectSource(new TemplateVolume(object.getW(), object.getH(), object.getD(), blocks), 0); double[][] angles = {{0D, 45D, 0D}, {0D, 135D, 0D}, {0D, 30D, 0D}, {20D, 45D, 0D}, {0D, 60D, 15D}}; for (double[] angle : angles) { IrisObjectRotation rotation = IrisObjectRotation.of(angle[0], angle[1], angle[2]); diff --git a/core/src/test/java/art/arcane/iris/structure/object/ObjectPlacementGoldenTest.java b/core/src/test/java/art/arcane/iris/structure/object/ObjectPlacementGoldenTest.java index e12a848ea..7884a838e 100644 --- a/core/src/test/java/art/arcane/iris/structure/object/ObjectPlacementGoldenTest.java +++ b/core/src/test/java/art/arcane/iris/structure/object/ObjectPlacementGoldenTest.java @@ -7,8 +7,6 @@ import art.arcane.iris.generation.block.TileData; import art.arcane.iris.generation.cave.CarvingMode; import art.arcane.iris.generation.decoration.IrisStiltSettings; import art.arcane.iris.generation.decoration.IrisVacuumSettings; -import art.arcane.iris.generation.decoration.tree.TreeBlockCanvas; -import art.arcane.iris.generation.decoration.tree.TreeGrounding; import art.arcane.iris.generation.geometry.IrisBlockVector; import art.arcane.iris.generation.noise.IrisGeneratorStyle; import art.arcane.iris.generation.noise.NoiseStyle; @@ -41,12 +39,10 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; import java.util.HashMap; -import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Random; -import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.function.BiConsumer; @@ -65,9 +61,9 @@ public class ObjectPlacementGoldenTest { private static final int OBJECTS = 200; private static final int SEEDS = 5; - private static final long GOLDEN = 0x930e130dc51b6f67L; - private static final long MARKER_GOLDEN = 0x67ae55d574c3894eL; - private static final long HIGH_VARIANT_GOLDEN = 0xdd61791b0f7e4d37L; + private static final long GOLDEN = 0x2cebafdbb128634dL; + private static final long MARKER_GOLDEN = 0x120e4648e9c88721L; + private static final long HIGH_VARIANT_GOLDEN = 0x503f4f34bb07f01aL; private static final List PALETTE = List.of( "minecraft:stone", @@ -384,18 +380,6 @@ public class ObjectPlacementGoldenTest { object.getStates().put(position, new TileData("minecraft:chest", new KMap<>())); } } - if (index % 4 == 1 && !placed.isEmpty()) { - List roots = new ArrayList<>(); - Set canopy = new HashSet<>(); - for (IrisBlockVector position : placed) { - if (random.nextInt(3) == 0) { - canopy.add(new TreeBlockCanvas.Vec(position.getBlockX(), position.getBlockY(), position.getBlockZ())); - } - } - IrisBlockVector root = placed.get(0); - roots.add(new TreeGrounding.Root(root.getBlockX(), -(height / 2), root.getBlockZ(), state("minecraft:oak_log[axis=y]"))); - object.setTreeGrounding(TreeGrounding.create(roots, 4, canopy)); - } return object; } @@ -780,13 +764,6 @@ public class ObjectPlacementGoldenTest { return value == null ? null : type.cast(value); } - @Override - public boolean beginTreeCanopy(BlockPosition position) { - boolean open = IObjectPlacer.super.beginTreeCanopy(position); - record("canopy", position.getX(), position.getY(), position.getZ(), Boolean.toString(open)); - return open; - } - @Override public Engine getEngine() { return engine;