mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 00:34:19 +00:00
Let the object model stand on the api: turn, scale, paste, records
Core turns objects with ObjectTurn and BlockTurn and scales with ScaleMethod, so the object model no longer reads the modules' ObjectRotation and ScaleInterpolation; /iris object paste writes the turned blocks with IrisObject.paste instead of running a placement. IrisObject takes no ObjectPlacement; the structure placers call ModuleObjectPlacement directly. IrisPlacements reads the run's name and JSON, the placement type comes from the module, placements are stored as PlacementMarkers texts and read back as PlacementRecords, the marker ids are Iris's own, the loot shuffle seed and the protected floor come from the modules, entity knobs are EntitySpec fields, and entity key completion is one handler by kind id. The entity pin is retaken with the old print proven to hash to the old number.
This commit is contained in:
1 parent
3022c54a43
commit
40436352bf
68 files changed
+1190
-427
No files matched your search
+6
-8
@@ -18,7 +18,6 @@
|
||||
|
||||
package art.arcane.iris.core.commands;
|
||||
|
||||
import art.arcane.iris.builtin.objects.ObjectPlacement;
|
||||
import art.arcane.iris.Iris;
|
||||
import art.arcane.iris.platform.bukkit.BukkitPlatform;
|
||||
import art.arcane.iris.core.link.WorldEditLink;
|
||||
@@ -35,8 +34,8 @@ import art.arcane.iris.core.tools.TreePlausibilizeBatch;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.placement.IObjectPlacer;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||
import art.arcane.iris.builtin.objects.ScaleInterpolation;
|
||||
import art.arcane.iris.builtin.prepare.ObjectRotation;
|
||||
import art.arcane.iris.engine.object.prefab.ObjectTurn;
|
||||
import com.volmit.object.ScaleMethod;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.prefab.TileData;
|
||||
import art.arcane.iris.platform.bukkit.BukkitBlockState;
|
||||
@@ -54,7 +53,6 @@ import art.arcane.iris.util.common.director.specialhandlers.ObjectHandler;
|
||||
import art.arcane.iris.util.common.director.specialhandlers.ObjectTargetHandler;
|
||||
import art.arcane.iris.util.common.format.C;
|
||||
import art.arcane.iris.util.common.math.Direction;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
@@ -561,7 +559,7 @@ public class CommandObject implements DirectorExecutor {
|
||||
scale = maxScale;
|
||||
}
|
||||
|
||||
ObjectPlacement placement = ObjectPlacement.builder().rotation(ObjectRotation.of(0, rotate, 0)).build();
|
||||
ObjectTurn turn = ObjectTurn.of(0, rotate, 0);
|
||||
|
||||
VolmitSender commandSender = sender();
|
||||
Player player = player();
|
||||
@@ -578,13 +576,13 @@ public class CommandObject implements DirectorExecutor {
|
||||
Map<Block, BlockData> futureChanges = new HashMap<>();
|
||||
|
||||
if (scale != 1) {
|
||||
o = o.scaled(scale, ScaleInterpolation.TRICUBIC);
|
||||
o = o.scaled(scale, ScaleMethod.TRICUBIC);
|
||||
}
|
||||
|
||||
// Block writes must run on the thread owning the target chunk; the undo log stays global.
|
||||
final IrisObject placed = o;
|
||||
if (!J.runAt(block, () -> {
|
||||
placed.place(block.getBlockX(), block.getBlockY() + (int) placed.getCenter().getY(), block.getBlockZ(), createPlacer(block.getWorld(), futureChanges, null), placement, new RNG(), null);
|
||||
placed.paste(block.getBlockX(), block.getBlockY() + (int) placed.getCenter().getY(), block.getBlockZ(), createPlacer(block.getWorld(), futureChanges, null), turn);
|
||||
J.runGlobal(() -> Iris.service(ObjectSVC.class).addChanges(futureChanges));
|
||||
|
||||
if (!edit) {
|
||||
@@ -593,7 +591,7 @@ public class CommandObject implements DirectorExecutor {
|
||||
}
|
||||
|
||||
onPlayerThread(player, () -> {
|
||||
ObjectPasteBounds bounds = ObjectPasteBounds.resolve(placed, placement.rotation(), block.getBlockX(),
|
||||
ObjectPasteBounds bounds = ObjectPasteBounds.resolve(placed, turn, block.getBlockX(),
|
||||
block.getBlockY() + placed.getCenter().getBlockY(), block.getBlockZ());
|
||||
Location minimum = new Location(block.getWorld(), bounds.minX(), bounds.minY(), bounds.minZ());
|
||||
Location maximum = new Location(block.getWorld(), bounds.maxX(), bounds.maxY(), bounds.maxZ());
|
||||
|
||||
+4
-2
@@ -22,6 +22,8 @@ import art.arcane.iris.core.modules.StructureAssemblies;
|
||||
import art.arcane.iris.engine.framework.structure.StructureResources;
|
||||
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||
import art.arcane.iris.builtin.objects.ObjectPlacement;
|
||||
import art.arcane.iris.core.modules.ModuleObjectPlacement;
|
||||
import art.arcane.iris.engine.mantle.components.StructurePlacing;
|
||||
import art.arcane.iris.Iris;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.core.structure.BulkStructureImporter;
|
||||
@@ -363,11 +365,11 @@ public class CommandStructure implements DirectorExecutor {
|
||||
for (PlacedStructurePiece p : pieces) {
|
||||
ObjectPlacement config = ObjectPlacement.builder()
|
||||
.mode(ObjectPlaceMode.STRUCTURE_PIECE)
|
||||
.rotation(p.getRotation())
|
||||
.rotation(StructurePlacing.moduleRotation(p.getRotation()))
|
||||
.place(List.of(p.getObject().getLoadKey()))
|
||||
.edit(s.getEdit())
|
||||
.build();
|
||||
p.getObject().place(p.getX(), p.getY(), p.getZ(), placer, config, rng, null, null, data);
|
||||
ModuleObjectPlacement.place(p.getObject(), p.getX(), p.getY(), p.getZ(), placer, config, rng, null, null, data);
|
||||
}
|
||||
int blockChanges = 0;
|
||||
for (Map.Entry<Block, BlockData> entry : future.entrySet()) {
|
||||
|
||||
+4
-4
@@ -1,7 +1,7 @@
|
||||
package art.arcane.iris.core.commands;
|
||||
|
||||
import art.arcane.iris.builtin.prepare.ObjectRotation;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.prefab.ObjectTurn;
|
||||
import art.arcane.volmlib.util.math.IrisBlockVector;
|
||||
|
||||
import java.util.Objects;
|
||||
@@ -9,13 +9,13 @@ import java.util.Objects;
|
||||
record ObjectPasteBounds(int minX, int minY, int minZ, int maxX, int maxY, int maxZ) {
|
||||
static ObjectPasteBounds resolve(
|
||||
IrisObject object,
|
||||
ObjectRotation rotation,
|
||||
ObjectTurn turn,
|
||||
int anchorX,
|
||||
int anchorY,
|
||||
int anchorZ
|
||||
) {
|
||||
IrisObject placedObject = Objects.requireNonNull(object, "object");
|
||||
ObjectRotation placementRotation = Objects.requireNonNull(rotation, "rotation");
|
||||
ObjectTurn pastedTurn = Objects.requireNonNull(turn, "turn");
|
||||
int[] xOffsets = {
|
||||
-placedObject.getCenter().getBlockX(),
|
||||
placedObject.getW() - 1 - placedObject.getCenter().getBlockX()
|
||||
@@ -38,7 +38,7 @@ record ObjectPasteBounds(int minX, int minY, int minZ, int maxX, int maxY, int m
|
||||
for (int xOffset : xOffsets) {
|
||||
for (int yOffset : yOffsets) {
|
||||
for (int zOffset : zOffsets) {
|
||||
IrisBlockVector transformed = placementRotation.rotate(new IrisBlockVector(xOffset, yOffset, zOffset));
|
||||
IrisBlockVector transformed = pastedTurn.rotate(new IrisBlockVector(xOffset, yOffset, zOffset));
|
||||
int worldX = anchorX + (int) Math.round(transformed.getX());
|
||||
int worldY = anchorY + (int) Math.round(transformed.getY());
|
||||
int worldZ = anchorZ + (int) Math.round(transformed.getZ());
|
||||
|
||||
+2
-2
@@ -8,7 +8,7 @@ import art.arcane.iris.core.service.tree.TreeDefinitionIndex;
|
||||
import art.arcane.iris.core.service.tree.TreeMarkerTraversal;
|
||||
import art.arcane.iris.core.tools.IrisToolbelt;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.builtin.structure.StructurePlacementMarker;
|
||||
import art.arcane.iris.core.modules.PlacementMarkers;
|
||||
import art.arcane.iris.engine.framework.TreeBlockMaterial;
|
||||
import art.arcane.iris.engine.platform.PlatformChunkGenerator;
|
||||
import org.bukkit.GameMode;
|
||||
@@ -67,7 +67,7 @@ final class TreeProvenance {
|
||||
int maximumY = world.getMaxHeight();
|
||||
int relativeY = block.getY() - minimumY;
|
||||
String marker = markerAt(engine, minimumY, block.getX(), block.getY(), block.getZ());
|
||||
StructurePlacementMarker.Decoded decoded = StructurePlacementMarker.decode(marker);
|
||||
PlacementMarkers.Decoded decoded = PlacementMarkers.decode(marker);
|
||||
if (decoded == null || decoded.structureAware()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package art.arcane.iris.core.commands;
|
||||
|
||||
import art.arcane.iris.builtin.prepare.ObjectRotation;
|
||||
import art.arcane.iris.engine.object.prefab.ObjectTurn;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -48,6 +48,6 @@ public class ObjectPasteBoundsTest {
|
||||
|
||||
private ObjectPasteBounds resolve(int rotation) {
|
||||
IrisObject object = new IrisObject(4, 3, 2);
|
||||
return ObjectPasteBounds.resolve(object, ObjectRotation.of(0, rotation, 0), ANCHOR_X, ANCHOR_Y, ANCHOR_Z);
|
||||
return ObjectPasteBounds.resolve(object, ObjectTurn.of(0, rotation, 0), ANCHOR_X, ANCHOR_Y, ANCHOR_Z);
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ package art.arcane.iris.modded;
|
||||
import art.arcane.iris.core.content.ContentLoot;
|
||||
import art.arcane.iris.core.content.ContentServices;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.builtin.loot.LootResolver;
|
||||
import art.arcane.iris.core.modules.ModuleServices;
|
||||
import art.arcane.iris.spi.IrisLogging;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.mantle.runtime.MantleChunk;
|
||||
@@ -45,7 +45,11 @@ import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
import com.volmit.service.Loot;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public final class ModdedLootApplier {
|
||||
@@ -91,7 +95,14 @@ public final class ModdedLootApplier {
|
||||
}
|
||||
}
|
||||
|
||||
fillContainer(container, items, LootResolver.containerRng(engine.getSeedManager().getLoot(), pos.getX(), pos.getY(), pos.getZ()));
|
||||
fillContainer(container, items, shuffleRandom(engine, pos));
|
||||
}
|
||||
|
||||
/** The random the container's slots are shuffled with: the modules' seed for the container, else one of the spot alone. */
|
||||
private static RNG shuffleRandom(Engine engine, BlockPos pos) {
|
||||
Loot.Site site = new Loot.Site(new BlockPosition(pos.getX(), pos.getY() - engine.getMinHeight(), pos.getZ()),
|
||||
Optional.empty(), false, false);
|
||||
return new RNG(ModuleServices.lootShuffleSeed(engine, site).orElse(pos.asLong()));
|
||||
}
|
||||
|
||||
private static LootTable nativeTable(ServerLevel level, String name) {
|
||||
|
||||
+3
-5
@@ -18,20 +18,18 @@
|
||||
|
||||
package art.arcane.iris.modded.command;
|
||||
|
||||
import art.arcane.iris.builtin.objects.ObjectPlacement;
|
||||
import art.arcane.iris.modded.ModdedIrisLog;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.core.tools.TreePlausibilizeBatch;
|
||||
import art.arcane.iris.core.tools.TreePlausibilizer;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.builtin.prepare.ObjectRotation;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.prefab.ObjectTurn;
|
||||
import art.arcane.iris.engine.object.prefab.TileData;
|
||||
import art.arcane.iris.modded.ModdedBlockState;
|
||||
import art.arcane.iris.modded.ModdedTileData;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.util.common.scheduling.J;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.mojang.brigadier.arguments.IntegerArgumentType;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
@@ -411,10 +409,10 @@ public final class ModdedObjectCommands {
|
||||
target = blockHit.getBlockPos().above();
|
||||
}
|
||||
|
||||
ObjectPlacement placement = ObjectPlacement.builder().rotation(ObjectRotation.of(0, rotation, 0)).build();
|
||||
ObjectTurn turn = ObjectTurn.of(0, rotation, 0);
|
||||
ModdedObjectPlacer placer = new ModdedObjectPlacer(level, engine);
|
||||
try {
|
||||
object.place(target.getX(), target.getY() + object.getCenter().getY(), target.getZ(), placer, placement, new RNG(), null);
|
||||
object.paste(target.getX(), target.getY() + object.getCenter().getY(), target.getZ(), placer, turn);
|
||||
} catch (Throwable e) {
|
||||
ModdedIrisLog.error("Iris paste failed for {}", key, e);
|
||||
ModdedObjectUndo.record(player == null ? ModdedObjectUndo.CONSOLE : player.getUUID(), level, placer.undoSnapshot());
|
||||
|
||||
+4
-2
@@ -22,6 +22,8 @@ import art.arcane.iris.core.modules.StructureAssemblies;
|
||||
import art.arcane.iris.engine.framework.structure.StructureResources;
|
||||
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||
import art.arcane.iris.builtin.objects.ObjectPlacement;
|
||||
import art.arcane.iris.core.modules.ModuleObjectPlacement;
|
||||
import art.arcane.iris.engine.mantle.components.StructurePlacing;
|
||||
import art.arcane.iris.modded.ModdedIrisLog;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.core.structure.StructureIndexService;
|
||||
@@ -205,11 +207,11 @@ public final class ModdedStructureCommands {
|
||||
for (PlacedStructurePiece piece : pieces) {
|
||||
ObjectPlacement config = ObjectPlacement.builder()
|
||||
.mode(ObjectPlaceMode.STRUCTURE_PIECE)
|
||||
.rotation(piece.getRotation())
|
||||
.rotation(StructurePlacing.moduleRotation(piece.getRotation()))
|
||||
.place(List.of(piece.getObject().getLoadKey()))
|
||||
.edit(structure.getEdit())
|
||||
.build();
|
||||
piece.getObject().place(piece.getX(), piece.getY(), piece.getZ(), placer, config, rng, null, null, data);
|
||||
ModuleObjectPlacement.place(piece.getObject(), piece.getX(), piece.getY(), piece.getZ(), placer, config, rng, null, null, data);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
ModdedIrisLog.error("Iris structure place failed for {}", key, e);
|
||||
|
||||
+2
-2
@@ -5,7 +5,7 @@ import art.arcane.iris.core.IrisSettings;
|
||||
import art.arcane.iris.core.service.tree.TreeDefinitionIndex;
|
||||
import art.arcane.iris.core.service.tree.TreeMarkerTraversal;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.builtin.structure.StructurePlacementMarker;
|
||||
import art.arcane.iris.core.modules.PlacementMarkers;
|
||||
import art.arcane.iris.engine.framework.TreeBlockMaterial;
|
||||
import art.arcane.iris.modded.ModdedBlockBreakHandler;
|
||||
import art.arcane.iris.modded.ModdedBlockState;
|
||||
@@ -110,7 +110,7 @@ public final class ModdedTreeFellerService implements ModdedTickableService {
|
||||
}
|
||||
int minimumY = level.getMinY();
|
||||
String marker = markerAt(engine, minimumY, position);
|
||||
StructurePlacementMarker.Decoded decoded = StructurePlacementMarker.decode(marker);
|
||||
PlacementMarkers.Decoded decoded = PlacementMarkers.decode(marker);
|
||||
if (decoded == null || decoded.structureAware()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package art.arcane.iris.core.content;
|
||||
|
||||
import art.arcane.iris.builtin.spawn.IrisEntityExtras;
|
||||
import art.arcane.iris.core.modules.IrisPackResources;
|
||||
import art.arcane.iris.core.modules.ModuleServices;
|
||||
import art.arcane.iris.core.modules.PlatformBlockStates;
|
||||
@@ -161,18 +160,18 @@ public final class ContentServices {
|
||||
* {@link #tableItems} for them again.
|
||||
*/
|
||||
private static ContentEntity entityOf(EntitySpec spec) {
|
||||
IrisEntityExtras extras = spec.extension(IrisEntityExtras.class).orElse(IrisEntityExtras.NONE);
|
||||
String type = spec.type() instanceof ContentKey.Registered registered ? registered.id().toString() : "";
|
||||
String provided = spec.type() instanceof ContentKey.Provided mob ? mob.toString() : "";
|
||||
return new ContentEntity(type, provided, extras.reason().orElse(null),
|
||||
return new ContentEntity(type, provided, spec.arrival().reason().orElse(null),
|
||||
spec.appearance().customName().orElse(""), flagsOf(spec),
|
||||
equipmentOf(spec.equipment()), spec.company().passengers().stream().map(ContentServices::entityOf).toList(),
|
||||
spec.attributes().stream().map(ContentServices::attributeOf).toList(),
|
||||
spec.drops().lootTables().stream().map(ResourceId::path).toList(), spec.drops().shuffleSeed(),
|
||||
spec.company().leashHolder().map(ContentServices::entityOf).orElse(null),
|
||||
spec.arrival().effect().map(ContentServices::spawnEffectOf).orElse(null),
|
||||
extras.riseOutOfGround(), extras.pandaMainGene().orElse(null), extras.pandaHiddenGene().orElse(null),
|
||||
extras.applySettingsToProvidedMob(), spec.arrival().commands().stream().map(ContentServices::commandOf).toList());
|
||||
spec.arrival().risesFromGround(), spec.appearance().pandaMainGene().orElse(null),
|
||||
spec.appearance().pandaHiddenGene().orElse(null),
|
||||
spec.adjustsProvidedMob(), spec.arrival().commands().stream().map(ContentServices::commandOf).toList());
|
||||
}
|
||||
|
||||
private static ContentEntity.Flags flagsOf(EntitySpec spec) {
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
|
||||
package art.arcane.iris.core.modules;
|
||||
|
||||
import art.arcane.iris.builtin.prepare.ObjectRotation;
|
||||
import art.arcane.iris.engine.object.prefab.BlockStateRotation;
|
||||
import art.arcane.iris.engine.object.prefab.ObjectTurn;
|
||||
import art.arcane.iris.spi.IrisPlatforms;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.volmlib.util.math.IrisBlockVector;
|
||||
@@ -37,7 +37,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Transforms geometry with the rotation Iris places objects with ({@link ObjectRotation}, its axis order
|
||||
* Transforms geometry with the rotation Iris places objects with ({@link ObjectTurn}, its axis order
|
||||
* included) about the anchor, turning block states with the object so stairs and logs face the way it does.
|
||||
* Mirrors come first, as {@link ObjectTransform} says: an X or Z mirror flips positions about the anchor and
|
||||
* mirrors block states through the platform's own mirror, so stairs and doors face the mirrored way. A Y mirror
|
||||
@@ -48,7 +48,6 @@ import java.util.Map;
|
||||
*/
|
||||
final class IrisObjectTransformer implements ObjectTransformer {
|
||||
private static final double NO_SCALE = 1D;
|
||||
private static final int NO_SPIN = 0;
|
||||
|
||||
@Override
|
||||
public GeneratedObject transform(GeneratedObject object, ObjectTransform transform) {
|
||||
@@ -101,7 +100,7 @@ final class IrisObjectTransformer implements ObjectTransformer {
|
||||
private final boolean mirrorX;
|
||||
private final boolean mirrorY;
|
||||
private final boolean mirrorZ;
|
||||
private final ObjectRotation rotation;
|
||||
private final ObjectTurn rotation;
|
||||
private final PlatformBlockStates states = new PlatformBlockStates(key -> IrisPlatforms.get().registries().block(key));
|
||||
|
||||
Turn(BlockPosition anchor, ObjectTransform transform) {
|
||||
@@ -109,7 +108,7 @@ final class IrisObjectTransformer implements ObjectTransformer {
|
||||
this.mirrorX = transform.mirrorX();
|
||||
this.mirrorY = transform.mirrorY();
|
||||
this.mirrorZ = transform.mirrorZ();
|
||||
this.rotation = ObjectRotation.of(transform.rotationX(), transform.rotationY(), transform.rotationZ());
|
||||
this.rotation = ObjectTurn.of(transform.rotationX(), transform.rotationY(), transform.rotationZ());
|
||||
}
|
||||
|
||||
BlockPosition position(BlockPosition local) {
|
||||
@@ -123,13 +122,13 @@ final class IrisObjectTransformer implements ObjectTransformer {
|
||||
if (mirrorZ) {
|
||||
offset.setZ(-offset.getZ());
|
||||
}
|
||||
IrisBlockVector turned = rotation.rotate(offset, NO_SPIN, NO_SPIN, NO_SPIN);
|
||||
IrisBlockVector turned = rotation.rotate(offset);
|
||||
return new BlockPosition(anchor.x() + (int) Math.round(turned.getX()), anchor.y() + (int) Math.round(turned.getY()),
|
||||
anchor.z() + (int) Math.round(turned.getZ()));
|
||||
}
|
||||
|
||||
com.volmit.block.BlockState state(ObjectBlock block) {
|
||||
return states.toApi(BlockStateRotation.rotate(rotation, mirrored(states.toPlatform(block.state())), NO_SPIN, NO_SPIN, NO_SPIN));
|
||||
return states.toApi(BlockStateRotation.rotate(rotation, mirrored(states.toPlatform(block.state()))));
|
||||
}
|
||||
|
||||
private PlatformBlockState mirrored(PlatformBlockState state) {
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package art.arcane.iris.core.modules;
|
||||
|
||||
import art.arcane.iris.builtin.objects.ScaleInterpolation;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
@@ -80,7 +79,7 @@ final class IrisPackObjects implements PackObjects {
|
||||
if (engine == null) {
|
||||
throw new IllegalStateException("Scaling " + object.name() + " needs the world the pack generates, and it has none");
|
||||
}
|
||||
return ScaledObjects.scaled(irisObject(object), factor, ScaleInterpolation.valueOf(method.name()), engine);
|
||||
return ScaledObjects.scaled(irisObject(object), factor, method, engine);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,10 +18,8 @@
|
||||
|
||||
package art.arcane.iris.core.modules;
|
||||
|
||||
import art.arcane.iris.builtin.objects.ObjectRun;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.placement.IrisPlacementForm;
|
||||
import com.volmit.config.FeatureSettings;
|
||||
import com.volmit.geometry.BlockBox;
|
||||
import com.volmit.host.LoadedPack;
|
||||
@@ -42,12 +40,11 @@ import java.util.function.Supplier;
|
||||
* blocks as the stages' inputs. Without an engine, such as for a studio paste, the stages have no terrain to sample and
|
||||
* no mantle.
|
||||
* <p>
|
||||
* The placement settings the stages read are those of the placed object's placement when the run's input is an
|
||||
* {@link ObjectRun}, which Iris's built-in stages and Iris's own placements pass; other inputs place with none.
|
||||
* The placement-level settings the stages read are those the run's {@link PlacementRun#settings()} declares, and the run's
|
||||
* name names their source.
|
||||
*/
|
||||
final class IrisPlacements implements Placements {
|
||||
private static final String OBJECT_KIND = "object";
|
||||
private static final String UNNAMED_PLACEMENT = "placement";
|
||||
|
||||
private final IrisData data;
|
||||
private final Engine engine;
|
||||
@@ -66,8 +63,10 @@ final class IrisPlacements implements Placements {
|
||||
ResolvedGraph graph = pack.placement();
|
||||
BlockBox area = widened(run.area(), graph.reach().blocks());
|
||||
PackResourceIds ids = new PackResourceIds(data.getDataFolder());
|
||||
ResourceId source = ids.of(OBJECT_KIND, placedName(run));
|
||||
ModuleSettings placementSettings = placementSettingsOf(run);
|
||||
ResourceId source = ids.of(OBJECT_KIND, run.name());
|
||||
ModuleSettings placementSettings = run.settings()
|
||||
.map(json -> data.getModules().settings().decodePlacement(json))
|
||||
.orElse(ModuleSettings.NONE);
|
||||
TerrainEdit edit = new TerrainEdit(run.terrain(), area, () -> mantle(area, pack));
|
||||
IrisPlacementInputs inputs = new IrisPlacementInputs(terrain(ids, area),
|
||||
new PlacementModuleSettings(worldSettings(ids), placementSettings, source),
|
||||
@@ -81,17 +80,6 @@ final class IrisPlacements implements Placements {
|
||||
area.maxZ() + blocks);
|
||||
}
|
||||
|
||||
private static String placedName(PlacementRun run) {
|
||||
return run.input() instanceof ObjectRun objectRun ? objectRun.object().name() : UNNAMED_PLACEMENT;
|
||||
}
|
||||
|
||||
private ModuleSettings placementSettingsOf(PlacementRun run) {
|
||||
if (!(run.input() instanceof ObjectRun objectRun)) {
|
||||
return ModuleSettings.NONE;
|
||||
}
|
||||
return IrisPlacementForm.of(objectRun.settings(), data).moduleSettings();
|
||||
}
|
||||
|
||||
private TerrainSampler terrain(PackResourceIds ids, BlockBox area) {
|
||||
if (engine == null) {
|
||||
return IrisPlacementInputs.noTerrain(area);
|
||||
|
||||
@@ -27,6 +27,7 @@ import art.arcane.volmlib.util.matter.Matter;
|
||||
import art.arcane.volmlib.util.matter.slices.MarkerMatter;
|
||||
import com.volmit.config.FeatureSettings;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
import com.volmit.placement.PlacementRecord;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.world.RunningWorld;
|
||||
import com.volmit.world.TerrainSampler;
|
||||
@@ -113,11 +114,11 @@ final class IrisRunningWorld implements RunningWorld {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<String> placementAt(int worldX, int y, int worldZ) {
|
||||
public Optional<PlacementRecord> placementAt(int worldX, int y, int worldZ) {
|
||||
MantleChunk<Matter> chunk = engine.getMantle().getMantle().getChunk(worldX >> 4, worldZ >> 4).use();
|
||||
try {
|
||||
String recorded = chunk.get(worldX & 15, y, worldZ & 15, String.class);
|
||||
return recorded == null || recorded.isEmpty() ? Optional.empty() : Optional.of(recorded);
|
||||
return PlacementMarkers.recordOf(recorded, engine.getData().getPackResources());
|
||||
} finally {
|
||||
chunk.release();
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import art.arcane.iris.engine.mantle.components.StructurePlacing;
|
||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||
import com.volmit.ModuleLog;
|
||||
import com.volmit.generation.InvocationContext;
|
||||
import com.volmit.resource.ResourceId;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
@@ -51,8 +52,9 @@ final class IrisStructureHost implements StructureHost {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<List<String>> lootTables(String structureKey) {
|
||||
IrisStructure structure = StructureResources.structure(engine.getData().getPackResources(), structureKey);
|
||||
public Optional<List<String>> lootTables(ResourceId structureId) {
|
||||
IrisPackResources resources = engine.getData().getPackResources();
|
||||
IrisStructure structure = StructureResources.structure(resources, resources.keyOf(structureId));
|
||||
if (structure == null) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.core.modules;
|
||||
|
||||
import com.volmit.placement.PlacedMarker;
|
||||
import com.volmit.resource.ResourceId;
|
||||
|
||||
/**
|
||||
* The marker types Iris keeps in its mantle when a placement marks a block ({@link PlacedMarker#type()}); a marker of
|
||||
* any other type is rejected. The built-in modules mark with these ids, and Iris knows them as ids only.
|
||||
*/
|
||||
final class MantleMarkerTypes {
|
||||
/** A marker the pack declares by name, kept as a pack marker; its name is the {@link #PACK_MARKER_NAME} attribute. */
|
||||
static final ResourceId PACK_MARKER = ResourceId.parse("iris:marker");
|
||||
static final String PACK_MARKER_NAME = "marker";
|
||||
/** A block of a tree, kept as the block's tree material for felling and growth. */
|
||||
static final ResourceId TREE_MATERIAL = ResourceId.parse("iris:tree_material");
|
||||
/** A buried treasure chest, kept as a structure point of interest. */
|
||||
static final ResourceId BURIED_TREASURE = ResourceId.parse("iris:buried_treasure");
|
||||
|
||||
private MantleMarkerTypes() {
|
||||
}
|
||||
|
||||
/** The name of the pack marker {@code marker} is. */
|
||||
static String packMarkerName(PlacedMarker marker) {
|
||||
String name = marker.attributes().get(PACK_MARKER_NAME);
|
||||
if (!marker.type().equals(PACK_MARKER) || name == null) {
|
||||
throw new IllegalArgumentException("Iris keeps markers of type " + PACK_MARKER + " with a \"" + PACK_MARKER_NAME
|
||||
+ "\" attribute, " + TREE_MATERIAL + " and " + BURIED_TREASURE + " only, not " + marker.type() + " "
|
||||
+ marker.attributes());
|
||||
}
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,7 @@ import com.volmit.service.EntitySpawns;
|
||||
import com.volmit.service.LocateResult;
|
||||
import com.volmit.service.Loot;
|
||||
import com.volmit.service.ObjectsAt;
|
||||
import com.volmit.service.ProtectedFloor;
|
||||
import com.volmit.service.SaplingGrowth;
|
||||
import com.volmit.service.StructureLocator;
|
||||
import com.volmit.service.VanillaFeatures;
|
||||
@@ -43,6 +44,7 @@ import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
import java.util.OptionalLong;
|
||||
import java.util.Set;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
@@ -88,6 +90,19 @@ public final class ModuleServices {
|
||||
.orElseGet(() -> new CaveBiomeAnswers(owner, null, owner.getGeneration().world())));
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the module that shapes the terrain keeps the lowest layer of the engine's world for itself, so the engine
|
||||
* discards the blocks others write there. Asked once for the world and kept; no provider keeps nothing.
|
||||
*/
|
||||
public static boolean protectsFloor(Engine engine) {
|
||||
return engine.getGeneration().state(FloorProtection.class, owner -> new FloorProtection(
|
||||
providers(owner, ProtectedFloor.class).stream()
|
||||
.anyMatch(provider -> provider.service().protectsFloor(provider.world())))).protectsFloor();
|
||||
}
|
||||
|
||||
private record FloorProtection(boolean protectsFloor) {
|
||||
}
|
||||
|
||||
/** What the modules say about the platform's own placed features in the engine's world, kept for the world. */
|
||||
public static VanillaFeatureAnswers vanillaFeatures(Engine engine) {
|
||||
return engine.getGeneration().state(VanillaFeatureAnswers.class, owner -> new VanillaFeatureAnswers(
|
||||
@@ -136,6 +151,17 @@ public final class ModuleServices {
|
||||
return tables;
|
||||
}
|
||||
|
||||
/** The seed to shuffle the slots of the container at {@code site} with: the first the modules give; empty when none does. */
|
||||
public static OptionalLong lootShuffleSeed(Engine engine, Loot.Site site) {
|
||||
for (Provider<Loot> provider : providers(engine, Loot.class)) {
|
||||
OptionalLong seed = provider.service().shuffleSeed(provider.world(), site);
|
||||
if (seed.isPresent()) {
|
||||
return seed;
|
||||
}
|
||||
}
|
||||
return OptionalLong.empty();
|
||||
}
|
||||
|
||||
/** The items loot table {@code table} gives at {@code site}, from the module that knows the table. */
|
||||
public static List<ItemDrop> lootItems(Engine engine, Loot.Site site, ResourceId table) {
|
||||
List<ItemDrop> items = new ArrayList<>();
|
||||
|
||||
@@ -52,6 +52,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Stream;
|
||||
@@ -73,9 +74,11 @@ public final class ModuleSettingsDecoder {
|
||||
private static final String SNIPPET_PREFIX = "snippet/";
|
||||
private static final String SNIPPET_FOLDER = "snippet";
|
||||
private static final String JSON_EXTENSION = ".json";
|
||||
private static final String PLACEMENT_RESOURCE = "object placement";
|
||||
|
||||
private final Map<Level, List<FeatureDescriptor<?>>> settings = new EnumMap<>(Level.class);
|
||||
private final Map<Level, Set<String>> keys = new EnumMap<>(Level.class);
|
||||
private final Map<String, ModuleSettings> placementSettings = new ConcurrentHashMap<>();
|
||||
private final Path packFolder;
|
||||
private final Gson gson;
|
||||
private final Supplier<Gson> irisGson;
|
||||
@@ -123,6 +126,16 @@ public final class ModuleSettingsDecoder {
|
||||
return ModuleSettings.of(values);
|
||||
}
|
||||
|
||||
/**
|
||||
* The settings the object placement written as {@code json} declares at {@link Level#PLACEMENT}. A placement is placed
|
||||
* many times and always reads the same, so each text is decoded once for as long as the decoder lives.
|
||||
*
|
||||
* @throws IllegalArgumentException when a value does not decode into its settings type
|
||||
*/
|
||||
public ModuleSettings decodePlacement(String json) {
|
||||
return placementSettings.computeIfAbsent(json, text -> decode(Level.PLACEMENT, new JSONObject(text), PLACEMENT_RESOURCE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the JSON of a module resource file into a new {@code type}, created with its no-argument constructor so an
|
||||
* omitted option keeps its default. Iris's own classes, which built-in resource kinds may read into, are read by
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package art.arcane.iris.core.modules;
|
||||
|
||||
import art.arcane.iris.builtin.objects.ObjectPlacement;
|
||||
import art.arcane.iris.core.loader.JsonFieldNames;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||
@@ -31,14 +30,15 @@ import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Which Iris class holds the JSON of each attachment target that module settings can appear in.
|
||||
* Which Iris class holds the JSON of each attachment target that module settings can appear in. The JSON of an object
|
||||
* placement is held by the type the module that places objects declares ({@code FeatureRegistry.registerPlacementType}),
|
||||
* not by a class of Iris.
|
||||
*/
|
||||
public final class ModuleTargets {
|
||||
private static final Map<Level, Class<?>> HOLDERS = Map.of(
|
||||
Level.DIMENSION, IrisDimension.class,
|
||||
Level.REGION, IrisRegion.class,
|
||||
Level.BIOME, IrisBiome.class,
|
||||
Level.PLACEMENT, ObjectPlacement.class);
|
||||
Level.BIOME, IrisBiome.class);
|
||||
|
||||
private ModuleTargets() {
|
||||
}
|
||||
@@ -51,14 +51,6 @@ public final class ModuleTargets {
|
||||
.findFirst();
|
||||
}
|
||||
|
||||
/** The target whose JSON an object of the class named {@code typeName} is, for module types such as a placement. */
|
||||
public static Optional<Level> ofTypeName(String typeName) {
|
||||
return HOLDERS.entrySet().stream()
|
||||
.filter(entry -> entry.getValue().getName().equals(typeName))
|
||||
.map(Map.Entry::getKey)
|
||||
.findFirst();
|
||||
}
|
||||
|
||||
/** Iris's own JSON fields per target, which no settings key may take. */
|
||||
static Map<Level, Set<String>> reservedFields() {
|
||||
Map<Level, Set<String>> fields = new EnumMap<>(Level.class);
|
||||
|
||||
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.core.modules;
|
||||
|
||||
import com.volmit.placement.PlacementRecord;
|
||||
import com.volmit.resource.PackResources;
|
||||
import com.volmit.resource.ResourceId;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Base64;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* The text Iris keeps beside a placed block in its mantle to say which placement the block belongs to: {@code key@id}
|
||||
* for an object placed on its own, and a delimiter-safe {@code @iris-structure:v1:...} form for a piece of a structure.
|
||||
* Worlds already generated hold these texts, so the forms never change. A module hands Iris a {@link PlacementRecord},
|
||||
* and Iris reads one back from the text with the pack's keys and ids.
|
||||
*/
|
||||
public final class PlacementMarkers {
|
||||
private static final String FAMILY_PREFIX = "@iris-structure:";
|
||||
private static final String VERSION_PREFIX = FAMILY_PREFIX + "v1:";
|
||||
private static final char PLACEMENT_SEPARATOR = '@';
|
||||
|
||||
private PlacementMarkers() {
|
||||
}
|
||||
|
||||
/** The text of an object placed on its own. */
|
||||
public static String encode(String objectKey, int placementId) {
|
||||
return requireKey(objectKey, "objectKey") + PLACEMENT_SEPARATOR + placementId;
|
||||
}
|
||||
|
||||
/** The text of a piece of a structure. */
|
||||
public static String encodeStructure(String objectKey, int placementId, String structureKey) {
|
||||
String normalizedObjectKey = requireKey(objectKey, "objectKey");
|
||||
String normalizedStructureKey = requireKey(structureKey, "structureKey");
|
||||
return VERSION_PREFIX
|
||||
+ encodeKey(normalizedObjectKey)
|
||||
+ ":" + placementId
|
||||
+ ":" + encodeKey(normalizedStructureKey);
|
||||
}
|
||||
|
||||
/** The text of {@code record}, with the pack keys of its object and structure. */
|
||||
public static String encode(PlacementRecord record, IrisPackResources resources) {
|
||||
String objectKey = resources.keyOf(PackResources.OBJECTS, record.object());
|
||||
if (record.structure().isEmpty()) {
|
||||
return encode(objectKey, record.placementId());
|
||||
}
|
||||
return encodeStructure(objectKey, record.placementId(), resources.keyOf(record.structure().get()));
|
||||
}
|
||||
|
||||
/** What the text says, or empty for a text that names no placement. */
|
||||
public static Optional<PlacementRecord> recordOf(String marker, IrisPackResources resources) {
|
||||
Decoded decoded = decode(marker);
|
||||
if (decoded == null) {
|
||||
return Optional.empty();
|
||||
}
|
||||
ResourceId object = resources.idOf(decoded.objectKey());
|
||||
Optional<ResourceId> structure = decoded.structureAware()
|
||||
? Optional.of(resources.idOf(decoded.structureKey()))
|
||||
: Optional.empty();
|
||||
return Optional.of(new PlacementRecord(object, decoded.placementId(), structure));
|
||||
}
|
||||
|
||||
public static Decoded decode(String marker) {
|
||||
if (marker == null || marker.isBlank()) {
|
||||
return null;
|
||||
}
|
||||
if (marker.startsWith(FAMILY_PREFIX)) {
|
||||
return decodeStructure(marker);
|
||||
}
|
||||
return decodeLegacy(marker);
|
||||
}
|
||||
|
||||
private static Decoded decodeStructure(String marker) {
|
||||
if (!marker.startsWith(VERSION_PREFIX)) {
|
||||
return null;
|
||||
}
|
||||
String[] fields = marker.split(":", -1);
|
||||
if (fields.length != 5 || !fields[0].equals("@iris-structure") || !fields[1].equals("v1")) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
String objectKey = decodeCanonicalKey(fields[2]);
|
||||
int placementId = Integer.parseInt(fields[3]);
|
||||
String structureKey = decodeCanonicalKey(fields[4]);
|
||||
if (objectKey.isBlank() || structureKey.isBlank()) {
|
||||
return null;
|
||||
}
|
||||
return new Decoded(objectKey, placementId, structureKey);
|
||||
} catch (IllegalArgumentException exception) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static Decoded decodeLegacy(String marker) {
|
||||
int separator = marker.indexOf(PLACEMENT_SEPARATOR);
|
||||
if (separator <= 0 || separator != marker.lastIndexOf(PLACEMENT_SEPARATOR) || separator == marker.length() - 1) {
|
||||
return null;
|
||||
}
|
||||
String objectKey = marker.substring(0, separator);
|
||||
if (objectKey.isEmpty() || objectKey.equals("null")) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return new Decoded(objectKey, Integer.parseInt(marker.substring(separator + 1)), null);
|
||||
} catch (NumberFormatException exception) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static String requireKey(String key, String name) {
|
||||
String required = Objects.requireNonNull(key, name);
|
||||
if (required.isBlank()) {
|
||||
throw new IllegalArgumentException(name + " must not be blank");
|
||||
}
|
||||
return required;
|
||||
}
|
||||
|
||||
private static String encodeKey(String key) {
|
||||
return Base64.getUrlEncoder().withoutPadding().encodeToString(key.getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
private static String decodeCanonicalKey(String key) {
|
||||
String decoded = new String(Base64.getUrlDecoder().decode(key), StandardCharsets.UTF_8);
|
||||
if (!encodeKey(decoded).equals(key)) {
|
||||
throw new IllegalArgumentException("Non-canonical marker key");
|
||||
}
|
||||
return decoded;
|
||||
}
|
||||
|
||||
/** A placement text read as pack keys; {@code structureKey} is null for an object placed on its own. */
|
||||
public record Decoded(String objectKey, int placementId, String structureKey) {
|
||||
public boolean structureAware() {
|
||||
return structureKey != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package art.arcane.iris.core.modules;
|
||||
|
||||
import art.arcane.iris.builtin.blocks.ObjectMarkers;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.framework.NativeStructureVolume;
|
||||
@@ -34,6 +33,7 @@ import com.volmit.block.BlockState;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
import com.volmit.object.BlockEntityData;
|
||||
import com.volmit.placement.PlacedMarker;
|
||||
import com.volmit.placement.PlacementRecord;
|
||||
import com.volmit.placement.PlacementTerrain;
|
||||
import com.volmit.placement.StructureVolumes;
|
||||
|
||||
@@ -66,8 +66,6 @@ final class PlacerTerrain implements PlacementTerrain {
|
||||
}
|
||||
};
|
||||
|
||||
private static final char PLACEMENT_ID_SEPARATOR = '@';
|
||||
|
||||
private final IObjectPlacer placer;
|
||||
private final IrisData data;
|
||||
private final PlatformBlockStates states = new PlatformBlockStates(PlacerTerrain::platformState);
|
||||
@@ -148,8 +146,8 @@ final class PlacerTerrain implements PlacementTerrain {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recordPlacement(int x, int y, int z, String placement) {
|
||||
placer.setData(x, y, z, placement);
|
||||
public void recordPlacement(int x, int y, int z, PlacementRecord placement) {
|
||||
placer.setData(x, y, z, PlacementMarkers.encode(placement, data.getPackResources()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -158,7 +156,7 @@ final class PlacerTerrain implements PlacementTerrain {
|
||||
* procedural object's, read as no placement, so placements collide with what they collided with before.
|
||||
*/
|
||||
@Override
|
||||
public Optional<String> placementAt(int x, int y, int z) {
|
||||
public Optional<PlacementRecord> placementAt(int x, int y, int z) {
|
||||
Engine engine = data.getEngine();
|
||||
if (engine == null) {
|
||||
throw new IllegalStateException("Object placement requires active Iris data for collision settings.");
|
||||
@@ -167,7 +165,7 @@ final class PlacerTerrain implements PlacementTerrain {
|
||||
if (placed == null || placed.getObject() == null) {
|
||||
return Optional.empty();
|
||||
}
|
||||
return Optional.of(placed.getObject().getLoadKey() + PLACEMENT_ID_SEPARATOR + placed.getId());
|
||||
return Optional.of(PlacementRecord.of(data.getPackResources().idOf(placed.getObject().getLoadKey()), placed.getId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -189,15 +187,15 @@ final class PlacerTerrain implements PlacementTerrain {
|
||||
int x = position.x();
|
||||
int y = position.y();
|
||||
int z = position.z();
|
||||
if (marker.type().equals(ObjectMarkers.TREE_MATERIAL)) {
|
||||
if (marker.type().equals(MantleMarkerTypes.TREE_MATERIAL)) {
|
||||
placer.setData(x, y, z, TreeBlockMaterial.of(placer.get(x, y, z)));
|
||||
return;
|
||||
}
|
||||
if (marker.type().equals(ObjectMarkers.BURIED_TREASURE)) {
|
||||
if (marker.type().equals(MantleMarkerTypes.BURIED_TREASURE)) {
|
||||
placer.setData(x, y, z, MatterStructurePOI.BURIED_TREASURE);
|
||||
return;
|
||||
}
|
||||
placer.setData(x, y, z, new MatterMarker(ObjectMarkers.markerKey(marker)));
|
||||
placer.setData(x, y, z, new MatterMarker(MantleMarkerTypes.packMarkerName(marker)));
|
||||
}
|
||||
|
||||
/** Resolved by the platform bound now, so a rebound platform never answers with another's states. */
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package art.arcane.iris.core.project;
|
||||
|
||||
import art.arcane.iris.core.modules.ModuleTargets;
|
||||
import art.arcane.volmlib.util.json.JSONArray;
|
||||
import art.arcane.volmlib.util.json.JSONObject;
|
||||
import com.volmit.config.Level;
|
||||
@@ -181,7 +180,9 @@ final class ModuleSchemaRenderer {
|
||||
required.put(option.name());
|
||||
}
|
||||
}
|
||||
ModuleTargets.ofTypeName(type.name()).ifPresent(target -> addFeatures(target, properties));
|
||||
if (schema.placementType().filter(type.name()::equals).isPresent()) {
|
||||
addFeatures(Level.PLACEMENT, properties);
|
||||
}
|
||||
object.put("properties", properties);
|
||||
if (required.length() > 0) {
|
||||
object.put("required", required);
|
||||
|
||||
@@ -3,7 +3,7 @@ package art.arcane.iris.core.service;
|
||||
import art.arcane.iris.engine.framework.PlacedStructurePiece;
|
||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConnector;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.builtin.prepare.ObjectRotation;
|
||||
import art.arcane.iris.engine.object.prefab.ObjectTurn;
|
||||
import art.arcane.iris.engine.object.prefab.BlockStateRotation;
|
||||
import art.arcane.iris.spi.IrisLogging;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
@@ -193,10 +193,10 @@ public final class JigsawStudioPreviewRenderer {
|
||||
PlacedStructurePiece piece
|
||||
) throws IOException {
|
||||
IrisObject object = piece.getObject();
|
||||
ObjectRotation rotation = piece.getRotation();
|
||||
ObjectTurn rotation = piece.getRotation();
|
||||
for (Map.Entry<IrisBlockVector, PlatformBlockState> entry : object.getBlocks()) {
|
||||
IrisBlockVector rotated = rotation.rotate(entry.getKey());
|
||||
PlatformBlockState state = BlockStateRotation.rotate(rotation, entry.getValue(), 0, 0, 0);
|
||||
PlatformBlockState state = BlockStateRotation.rotate(rotation, entry.getValue());
|
||||
putState(
|
||||
blocks,
|
||||
new BlockPosition(
|
||||
@@ -213,7 +213,7 @@ public final class JigsawStudioPreviewRenderer {
|
||||
PlacedStructurePiece piece
|
||||
) throws IOException {
|
||||
IrisObject object = piece.getObject();
|
||||
ObjectRotation rotation = piece.getRotation();
|
||||
ObjectTurn rotation = piece.getRotation();
|
||||
if (piece.getPiece().getConnectors() == null) {
|
||||
return;
|
||||
}
|
||||
@@ -227,7 +227,7 @@ public final class JigsawStudioPreviewRenderer {
|
||||
connector.getPosition().getZ() - object.getCenter().getBlockZ());
|
||||
IrisBlockVector rotated = rotation.rotate(signed);
|
||||
PlatformBlockState source = B.getStateOrNull(connector.getFinalState(), false);
|
||||
PlatformBlockState state = source == null ? null : BlockStateRotation.rotate(rotation, source, 0, 0, 0);
|
||||
PlatformBlockState state = source == null ? null : BlockStateRotation.rotate(rotation, source);
|
||||
putState(
|
||||
blocks,
|
||||
new BlockPosition(
|
||||
|
||||
@@ -47,7 +47,7 @@ import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConnector;
|
||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawThemeSet;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.builtin.prepare.ObjectRotation;
|
||||
import art.arcane.iris.engine.object.prefab.ObjectTurn;
|
||||
import art.arcane.iris.engine.object.prefab.BlockStateRotation;
|
||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||
@@ -6287,7 +6287,7 @@ public final class JigsawStudioService implements IrisService, JigsawStudioMenuC
|
||||
int sourceDepth = (quarterTurns & 1) == 0
|
||||
? displayDimensions.depth()
|
||||
: displayDimensions.width();
|
||||
ObjectRotation rotation = ObjectRotation.of(0, -90.0D * quarterTurns, 0);
|
||||
ObjectTurn rotation = ObjectTurn.of(0, -90.0D * quarterTurns, 0);
|
||||
Map<LocalPosition, IrisJigsawConnector> displayed = new HashMap<>(source.getConnectors().size());
|
||||
for (IrisJigsawConnector sourceConnector : source.getConnectors()) {
|
||||
LocalPosition sourcePosition = connectorPosition(sourceConnector, "source piece");
|
||||
@@ -6395,7 +6395,7 @@ public final class JigsawStudioService implements IrisService, JigsawStudioMenuC
|
||||
sourceWidth,
|
||||
captureBounds.dimensions().height(),
|
||||
sourceDepth);
|
||||
ObjectRotation inverseRotation = ObjectRotation.of(0, 90.0D * quarterTurns, 0);
|
||||
ObjectTurn inverseRotation = ObjectTurn.of(0, 90.0D * quarterTurns, 0);
|
||||
List<IrisJigsawConnector> connectors = new ArrayList<>();
|
||||
Set<LocalPosition> capturedBlocks = new HashSet<>();
|
||||
Set<LocalPosition> capturedConnectors = new HashSet<>();
|
||||
@@ -6417,7 +6417,7 @@ public final class JigsawStudioService implements IrisService, JigsawStudioMenuC
|
||||
}
|
||||
PlatformBlockState sourceState = quarterTurns == 0
|
||||
? block.state()
|
||||
: BlockStateRotation.rotate(inverseRotation, block.state(), 0, 0, 0);
|
||||
: BlockStateRotation.rotate(inverseRotation, block.state());
|
||||
if (sourceState == null) {
|
||||
throw new IOException("Captured block state cannot be inverse-rotated at "
|
||||
+ block.x() + "," + block.y() + "," + block.z());
|
||||
@@ -6459,7 +6459,7 @@ public final class JigsawStudioService implements IrisService, JigsawStudioMenuC
|
||||
+ capturedConnector.x() + "," + capturedConnector.y() + ","
|
||||
+ capturedConnector.z());
|
||||
}
|
||||
PlatformBlockState sourceFinalState = BlockStateRotation.rotate(inverseRotation, finalState, 0, 0, 0);
|
||||
PlatformBlockState sourceFinalState = BlockStateRotation.rotate(inverseRotation, finalState);
|
||||
if (sourceFinalState == null) {
|
||||
throw new IOException("Captured connector final state cannot be inverse-rotated at "
|
||||
+ capturedConnector.x() + "," + capturedConnector.y() + ","
|
||||
@@ -6963,7 +6963,7 @@ public final class JigsawStudioService implements IrisService, JigsawStudioMenuC
|
||||
sourceWidth,
|
||||
sourceDepth,
|
||||
quarterTurns);
|
||||
ObjectRotation inverseRotation = ObjectRotation.of(0, 90.0D * quarterTurns, 0);
|
||||
ObjectTurn inverseRotation = ObjectTurn.of(0, 90.0D * quarterTurns, 0);
|
||||
IrisJigsawConnector sourceOriented = CapturedConnector.from(captured).toConnector()
|
||||
.setPosition(new IrisPosition(position.x(), position.y(), position.z()))
|
||||
.setDirection(inverseRotation.rotate(captured.getDirection()))
|
||||
|
||||
@@ -2,7 +2,7 @@ package art.arcane.iris.core.service.tree;
|
||||
|
||||
import art.arcane.iris.core.modules.ModuleServices;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.builtin.structure.StructurePlacementMarker;
|
||||
import art.arcane.iris.core.modules.PlacementMarkers;
|
||||
import com.volmit.resource.PackResources;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.service.SaplingGrowth;
|
||||
@@ -28,7 +28,7 @@ public final class TreeDefinitionIndex {
|
||||
}
|
||||
|
||||
public boolean isTreeMarker(String marker) {
|
||||
StructurePlacementMarker.Decoded decoded = StructurePlacementMarker.decode(marker);
|
||||
PlacementMarkers.Decoded decoded = PlacementMarkers.decode(marker);
|
||||
if (decoded == null || decoded.structureAware()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
package art.arcane.iris.engine.framework;
|
||||
|
||||
import art.arcane.iris.builtin.structure.StructurePlacementMarker;
|
||||
import art.arcane.iris.core.modules.PlacementMarkers;
|
||||
|
||||
|
||||
import art.arcane.iris.core.IrisSettings;
|
||||
@@ -437,7 +437,7 @@ public interface Engine extends DataProvider, Fallible, BlockUpdater, Renderer,
|
||||
return null;
|
||||
}
|
||||
|
||||
StructurePlacementMarker.Decoded marker = StructurePlacementMarker.decode(objectAt);
|
||||
PlacementMarkers.Decoded marker = PlacementMarkers.decode(objectAt);
|
||||
if (marker == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ package art.arcane.iris.engine.framework;
|
||||
|
||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.builtin.prepare.ObjectRotation;
|
||||
import art.arcane.iris.engine.object.prefab.ObjectTurn;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -32,7 +32,7 @@ public class PlacedStructurePiece {
|
||||
private final int x;
|
||||
private final int y;
|
||||
private final int z;
|
||||
private final ObjectRotation rotation;
|
||||
private final ObjectTurn rotation;
|
||||
private final int minX;
|
||||
private final int minY;
|
||||
private final int minZ;
|
||||
|
||||
@@ -38,7 +38,7 @@ import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPieceEntry;
|
||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPool;
|
||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawWorkcellArchetype;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.builtin.prepare.ObjectRotation;
|
||||
import art.arcane.iris.engine.object.prefab.ObjectTurn;
|
||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
||||
import art.arcane.iris.engine.object.structure.IrisStructure;
|
||||
import art.arcane.iris.engine.object.structure.jigsaw.JigsawJoint;
|
||||
@@ -186,7 +186,7 @@ public final class StructureAssembler {
|
||||
}
|
||||
|
||||
int startRotY = startPiece.isRotatable() ? Y_DEGREES[rng.i(Y_DEGREES.length)] : 0;
|
||||
ObjectRotation startRot = ObjectRotation.of(0, startRotY, 0);
|
||||
ObjectTurn startRot = ObjectTurn.of(0, startRotY, 0);
|
||||
PlacedStructurePiece start = build(startPiece, startObject, originX, originY, originZ, startRot);
|
||||
placed.add(start);
|
||||
registerPlacedPiece(consumedConnectors, start, null);
|
||||
@@ -407,7 +407,7 @@ public final class StructureAssembler {
|
||||
IrisDirection needed = connector.facing.reverse();
|
||||
int[] rotations = piece.isRotatable() ? rotationCandidates(connector.joint, rng) : NO_ROTATION;
|
||||
for (int yDeg : rotations) {
|
||||
ObjectRotation rot = ObjectRotation.of(0, yDeg, 0);
|
||||
ObjectTurn rot = ObjectTurn.of(0, yDeg, 0);
|
||||
IrisDirection rotatedFace = rot.rotate(cb.getDirection());
|
||||
if (rotatedFace != needed) {
|
||||
continue;
|
||||
@@ -717,7 +717,7 @@ public final class StructureAssembler {
|
||||
}
|
||||
int[] rotations = piece.isRotatable() ? Y_DEGREES : NO_ROTATION;
|
||||
for (int yDegrees : rotations) {
|
||||
ObjectRotation rotation = ObjectRotation.of(0, yDegrees, 0);
|
||||
ObjectTurn rotation = ObjectTurn.of(0, yDegrees, 0);
|
||||
if (rotation.rotate(connector.getDirection()) != source.facing().reverse()
|
||||
|| source.joint() == JigsawJoint.ALIGNED
|
||||
&& rotation.rotate(connector.getTop()) != source.top()) {
|
||||
@@ -968,7 +968,7 @@ public final class StructureAssembler {
|
||||
throw assemblyFailure("piece expansion queue was unexpectedly empty");
|
||||
}
|
||||
|
||||
private PlacedStructurePiece build(IrisJigsawPiece piece, IrisObject object, int x, int y, int z, ObjectRotation rot) {
|
||||
private PlacedStructurePiece build(IrisJigsawPiece piece, IrisObject object, int x, int y, int z, ObjectTurn rot) {
|
||||
int width = Math.max(1, object.getW());
|
||||
int height = Math.max(1, object.getH());
|
||||
int depth = Math.max(1, object.getD());
|
||||
@@ -998,8 +998,8 @@ public final class StructureAssembler {
|
||||
int localMaxX = localMinX + width - 1;
|
||||
int localMaxY = localMinY + height - 1;
|
||||
int localMaxZ = localMinZ + depth - 1;
|
||||
IrisPosition rotatedMin = rot.rotate(new IrisPosition(localMinX, localMinY, localMinZ), 0, 0, 0);
|
||||
IrisPosition rotatedMax = rot.rotate(new IrisPosition(localMaxX, localMaxY, localMaxZ), 0, 0, 0);
|
||||
IrisPosition rotatedMin = rot.rotate(new IrisPosition(localMinX, localMinY, localMinZ));
|
||||
IrisPosition rotatedMax = rot.rotate(new IrisPosition(localMaxX, localMaxY, localMaxZ));
|
||||
int minX = Math.min(rotatedMin.getX(), rotatedMax.getX());
|
||||
int minY = Math.min(rotatedMin.getY(), rotatedMax.getY());
|
||||
int minZ = Math.min(rotatedMin.getZ(), rotatedMax.getZ());
|
||||
@@ -1048,7 +1048,7 @@ public final class StructureAssembler {
|
||||
private IrisPosition connectorOffset(
|
||||
IrisObject object,
|
||||
IrisJigsawConnector connector,
|
||||
ObjectRotation rotation
|
||||
ObjectTurn rotation
|
||||
) {
|
||||
if (structure.resolvedMode() == IrisJigsawMode.PLANAR_JIGSAW) {
|
||||
IrisPosition dimensions = rotatedDimensions(object, rotation);
|
||||
@@ -1065,7 +1065,7 @@ public final class StructureAssembler {
|
||||
connector.getPosition().getX() - center.getX(),
|
||||
connector.getPosition().getY() - center.getY(),
|
||||
connector.getPosition().getZ() - center.getZ());
|
||||
return rotation.rotate(relative, 0, 0, 0);
|
||||
return rotation.rotate(relative);
|
||||
}
|
||||
|
||||
private IrisPosition logicalCenter(PlacedStructurePiece piece) {
|
||||
@@ -1079,7 +1079,7 @@ public final class StructureAssembler {
|
||||
piece.getZ() - offset.getZ());
|
||||
}
|
||||
|
||||
private IrisPosition rotatedDimensions(IrisObject object, ObjectRotation rotation) {
|
||||
private IrisPosition rotatedDimensions(IrisObject object, ObjectTurn rotation) {
|
||||
int width = Math.max(1, object.getW());
|
||||
int height = Math.max(1, object.getH());
|
||||
int depth = Math.max(1, object.getD());
|
||||
@@ -1088,7 +1088,7 @@ public final class StructureAssembler {
|
||||
: new IrisPosition(depth, height, width);
|
||||
}
|
||||
|
||||
private IrisPosition planarPlacementOffset(IrisObject object, ObjectRotation rotation) {
|
||||
private IrisPosition planarPlacementOffset(IrisObject object, ObjectTurn rotation) {
|
||||
int width = Math.max(1, object.getW());
|
||||
int depth = Math.max(1, object.getD());
|
||||
return switch (quarterTurns(rotation)) {
|
||||
@@ -1103,7 +1103,7 @@ public final class StructureAssembler {
|
||||
};
|
||||
}
|
||||
|
||||
private int quarterTurns(ObjectRotation rotation) {
|
||||
private int quarterTurns(ObjectTurn rotation) {
|
||||
return switch (rotation.rotate(IrisDirection.NORTH_NEGATIVE_Z)) {
|
||||
case NORTH_NEGATIVE_Z -> 0;
|
||||
case WEST_NEGATIVE_X -> 1;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
package art.arcane.iris.engine.mantle;
|
||||
|
||||
|
||||
import art.arcane.iris.builtin.terrain.BedrockSettings;
|
||||
import art.arcane.iris.core.modules.ModuleServices;
|
||||
import art.arcane.iris.engine.object.noise.IrisGeneratorStyle;
|
||||
import art.arcane.iris.spi.IrisLogging;
|
||||
import art.arcane.iris.util.project.matter.TileWrapper;
|
||||
@@ -43,7 +43,10 @@ import art.arcane.volmlib.util.matter.MatterCavern;
|
||||
import art.arcane.volmlib.util.matter.MatterSlice;
|
||||
import art.arcane.iris.util.project.noise.CNG;
|
||||
import art.arcane.iris.util.common.scheduling.J;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.util.common.data.B;
|
||||
import org.bukkit.util.Vector;
|
||||
@@ -64,6 +67,9 @@ public class MantleWriter implements IObjectPlacer, AutoCloseable {
|
||||
private final int z;
|
||||
private final int windowSide;
|
||||
private final AtomicReferenceArray<MantleChunk<Matter>> window;
|
||||
@Getter(AccessLevel.NONE)
|
||||
@Setter(AccessLevel.NONE)
|
||||
private transient volatile Boolean floorProtected;
|
||||
|
||||
public MantleWriter(EngineMantle engineMantle, Mantle<Matter> mantle, int x, int z, int radius, boolean multicore) {
|
||||
this(engineMantle, mantle, x, z, radius, radius * 2, multicore);
|
||||
@@ -187,6 +193,16 @@ public class MantleWriter implements IObjectPlacer, AutoCloseable {
|
||||
(int) Math.round(style.warp(rng, data, z, -y, z, x)), t);
|
||||
}
|
||||
|
||||
/** Whether the terrain module keeps the lowest layer, asked of the modules the first time a block lands there. */
|
||||
private boolean isFloorProtected() {
|
||||
Boolean known = floorProtected;
|
||||
if (known == null) {
|
||||
known = ModuleServices.protectsFloor(engineMantle.getEngine());
|
||||
floorProtected = known;
|
||||
}
|
||||
return known;
|
||||
}
|
||||
|
||||
public <T> void setData(int x, int y, int z, T t) {
|
||||
if (t == null) {
|
||||
return;
|
||||
@@ -199,7 +215,7 @@ public class MantleWriter implements IObjectPlacer, AutoCloseable {
|
||||
return;
|
||||
}
|
||||
|
||||
if (y == 0 && t instanceof PlatformBlockState && engineMantle.getEngine().getDimension().getModuleSettings().find(BedrockSettings.class).map(BedrockSettings::bedrock).orElse(true)) {
|
||||
if (y == 0 && t instanceof PlatformBlockState && isFloorProtected()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@ package art.arcane.iris.engine.mantle.components;
|
||||
|
||||
import art.arcane.iris.engine.framework.PlacedStructurePiece;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.builtin.prepare.ObjectRotation;
|
||||
import art.arcane.iris.engine.object.prefab.ObjectTurn;
|
||||
import art.arcane.iris.util.common.data.B;
|
||||
import art.arcane.volmlib.util.math.IrisBlockVector;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
@@ -191,7 +191,7 @@ public final class StructureCarvingFootprint {
|
||||
continue;
|
||||
}
|
||||
IrisObject object = piece.getObject();
|
||||
ObjectRotation rotation = piece.getRotation();
|
||||
ObjectTurn rotation = piece.getRotation();
|
||||
if (object == null || rotation == null || object.getBlocks() == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -22,12 +22,15 @@ import art.arcane.iris.builtin.anchor.PlaceTrait;
|
||||
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||
import art.arcane.iris.engine.framework.structure.StructureResources;
|
||||
import art.arcane.iris.builtin.objects.ObjectPlacement;
|
||||
import art.arcane.iris.builtin.prepare.ObjectRotation;
|
||||
import art.arcane.iris.core.IrisSettings;
|
||||
import art.arcane.iris.core.modules.ModuleObjectPlacement;
|
||||
import art.arcane.iris.engine.object.prefab.ObjectTurn;
|
||||
import art.arcane.volmlib.util.cache.CacheKey;
|
||||
import art.arcane.iris.engine.framework.IrisStructureLocator;
|
||||
import art.arcane.iris.engine.framework.PlacedStructurePiece;
|
||||
import art.arcane.iris.engine.framework.StructurePlacementScope;
|
||||
import art.arcane.iris.builtin.structure.StructurePlacementMarker;
|
||||
import art.arcane.iris.core.modules.PlacementMarkers;
|
||||
import art.arcane.iris.engine.framework.TreeBlockMaterial;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.builtin.loot.ObjectLoot;
|
||||
@@ -455,7 +458,7 @@ public class StructurePlacing {
|
||||
|
||||
private void clearMarkerOwnedObject(MantleWriter writer, String marker,
|
||||
ObjectMarkerBounds intersections, int worldHeight) {
|
||||
StructurePlacementMarker.Decoded decoded = StructurePlacementMarker.decode(marker);
|
||||
PlacementMarkers.Decoded decoded = PlacementMarkers.decode(marker);
|
||||
if (decoded == null) {
|
||||
return;
|
||||
}
|
||||
@@ -498,7 +501,7 @@ public class StructurePlacing {
|
||||
}
|
||||
|
||||
static boolean isOrdinaryObjectMarker(String marker) {
|
||||
StructurePlacementMarker.Decoded decoded = StructurePlacementMarker.decode(marker);
|
||||
PlacementMarkers.Decoded decoded = PlacementMarkers.decode(marker);
|
||||
return decoded != null && !decoded.structureAware();
|
||||
}
|
||||
|
||||
@@ -562,7 +565,7 @@ public class StructurePlacing {
|
||||
boolean supportNonOccluding) {
|
||||
IrisObject object = p.getObject();
|
||||
String objectKey = object.getLoadKey();
|
||||
ObjectPlacement.Builder builder = lootPlacementBuilder(structure, objectKey).mode(mode).rotation(p.getRotation());
|
||||
ObjectPlacement.Builder builder = lootPlacementBuilder(structure, objectKey).mode(mode).rotation(moduleRotation(p.getRotation()));
|
||||
if (!structure.getEdit().isEmpty()) {
|
||||
builder.edit(structure.getEdit());
|
||||
}
|
||||
@@ -572,14 +575,19 @@ public class StructurePlacing {
|
||||
ObjectPlacement config = builder.build();
|
||||
int placeY = (y == -1) ? -1 : y - engine.getMinHeight();
|
||||
String marker = structurePlacementMarker(structure, p, objectKey);
|
||||
return object.place(p.getX(), placeY, p.getZ(), writer, config, rng, (position, state) -> {
|
||||
return ModuleObjectPlacement.place(object, p.getX(), placeY, p.getZ(), writer, config, rng, (position, state) -> {
|
||||
StructureFoundationPlanner.recordBaseCell(
|
||||
foundationColumns, position.getX(), position.getY(), position.getZ(), state,
|
||||
supportNonOccluding);
|
||||
if (marker != null && shouldWriteStructureMarker(state)) {
|
||||
writer.setData(position.getX(), position.getY(), position.getZ(), marker);
|
||||
}
|
||||
}, null, engine.getData());
|
||||
}, null, engine.getData()).heightOrRejected();
|
||||
}
|
||||
|
||||
/** The placement rotation that turns a placed piece the way {@code turn} does. */
|
||||
public static ObjectRotation moduleRotation(ObjectTurn turn) {
|
||||
return ObjectRotation.of(turn.xDegrees(), turn.yDegrees(), turn.zDegrees());
|
||||
}
|
||||
|
||||
static boolean shouldWriteStructureMarker(PlatformBlockState state) {
|
||||
@@ -602,7 +610,7 @@ public class StructurePlacing {
|
||||
return null;
|
||||
}
|
||||
int placementId = structurePlacementId(structureKey, objectKey, piece.getX(), piece.getY(), piece.getZ());
|
||||
return StructurePlacementMarker.encodeStructure(objectKey, placementId, structureKey);
|
||||
return PlacementMarkers.encodeStructure(objectKey, placementId, structureKey);
|
||||
}
|
||||
|
||||
/** How far, in blocks along X and Z, placements may write beyond their chunk. */
|
||||
|
||||
@@ -29,9 +29,7 @@ import art.arcane.iris.engine.object.noise.IrisNoiseGenerator;
|
||||
import art.arcane.iris.engine.object.noise.IrisStyledRange;
|
||||
import art.arcane.iris.util.project.noise.CNG;
|
||||
import art.arcane.volmlib.util.cache.LazyBoundedCache;
|
||||
import art.arcane.volmlib.util.json.JSONObject;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.config.Level;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
@@ -79,7 +77,7 @@ public final class IrisPlacementForm {
|
||||
if (placement.json() == null) {
|
||||
return ModuleSettings.NONE;
|
||||
}
|
||||
return data.getModules().settings().decode(Level.PLACEMENT, new JSONObject(placement.json()), "object placement");
|
||||
return data.getModules().settings().decodePlacement(placement.json());
|
||||
}
|
||||
|
||||
/** The settings the pack's modules declare on the placement. */
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package art.arcane.iris.engine.object.prefab;
|
||||
|
||||
import art.arcane.iris.builtin.prepare.ObjectRotation;
|
||||
import art.arcane.iris.platform.bukkit.BukkitBlockState;
|
||||
import art.arcane.iris.spi.IrisLogging;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
@@ -44,12 +43,10 @@ import java.util.Set;
|
||||
|
||||
/**
|
||||
* Turns a platform block state with an object: the facing, axis and connections of stairs, logs, walls and wires follow
|
||||
* the {@link BlockTurn} that turns the object's directions, such as an {@link ObjectRotation}'s. A platform other than
|
||||
* the {@link BlockTurn} that turns the object's directions, such as an {@link ObjectTurn}'s. A platform other than
|
||||
* Bukkit binds its own {@link StateRotator}.
|
||||
*/
|
||||
public final class BlockStateRotation {
|
||||
private static final double QUARTER_TURN_DEGREES = 90D;
|
||||
private static final double FULL_TURN_DEGREES = 360D;
|
||||
private static volatile StateRotator platformRotator = null;
|
||||
|
||||
/** How a platform turns its own block states. */
|
||||
@@ -76,15 +73,12 @@ public final class BlockStateRotation {
|
||||
platformRotator = rotator;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@code state} turned by {@code rotation}, spun by the given degrees counted in whole quarter turns; null when a
|
||||
* block that cannot face the new way is dropped.
|
||||
*/
|
||||
public static PlatformBlockState rotate(ObjectRotation rotation, PlatformBlockState state, int spinX, int spinY, int spinZ) {
|
||||
if (!rotation.canRotate()) {
|
||||
/** {@code state} turned by {@code turn}; null when a block that cannot face the new way is dropped. */
|
||||
public static PlatformBlockState rotate(ObjectTurn turn, PlatformBlockState state) {
|
||||
if (!turn.canRotate()) {
|
||||
return state;
|
||||
}
|
||||
return rotate(turnOf(rotation, spinX, spinY, spinZ), state);
|
||||
return rotate(turn.blockTurn(), state);
|
||||
}
|
||||
|
||||
/** {@code state} turned by {@code turn}; null when a block that cannot face the new way is dropped. */
|
||||
@@ -104,17 +98,6 @@ public final class BlockStateRotation {
|
||||
return rotated == null ? null : BukkitBlockState.of(rotated);
|
||||
}
|
||||
|
||||
/** The directions {@code rotation} turns, spun by the given degrees counted in whole quarter turns. */
|
||||
public static BlockTurn turnOf(ObjectRotation rotation, int spinXDegrees, int spinYDegrees, int spinZDegrees) {
|
||||
int spinX = wholeQuarterTurns(spinXDegrees);
|
||||
int spinY = wholeQuarterTurns(spinYDegrees);
|
||||
int spinZ = wholeQuarterTurns(spinZDegrees);
|
||||
return (x, y, z) -> {
|
||||
IrisBlockVector turned = rotation.rotate(new IrisBlockVector(x, y, z), spinX, spinY, spinZ);
|
||||
return new BlockTurn.Direction(turned.getX(), turned.getY(), turned.getZ());
|
||||
};
|
||||
}
|
||||
|
||||
/** {@code direction} turned by {@code turn}. */
|
||||
public static IrisBlockVector turned(BlockTurn turn, double x, double y, double z) {
|
||||
BlockTurn.Direction direction = turn.turn(x, y, z);
|
||||
@@ -130,14 +113,6 @@ public final class BlockStateRotation {
|
||||
|| data instanceof RedstoneWire;
|
||||
}
|
||||
|
||||
/** {@code data}, changed in place, turned by {@code rotation} in whole quarter turns; null when it cannot face the new way. */
|
||||
public static BlockData rotate(ObjectRotation rotation, BlockData data, int spinXDegrees, int spinYDegrees, int spinZDegrees) {
|
||||
if (!rotation.canRotate()) {
|
||||
return data;
|
||||
}
|
||||
return rotate(turnOf(rotation, spinXDegrees, spinYDegrees, spinZDegrees), data);
|
||||
}
|
||||
|
||||
/** {@code data}, changed in place, turned by {@code turn}; null when it cannot face the new way. */
|
||||
public static BlockData rotate(BlockTurn turn, BlockData data) {
|
||||
BlockData d = data;
|
||||
@@ -222,10 +197,6 @@ public final class BlockStateRotation {
|
||||
return d;
|
||||
}
|
||||
|
||||
private static int wholeQuarterTurns(int degrees) {
|
||||
return (int) (QUARTER_TURN_DEGREES * (Math.ceil(Math.abs((degrees % FULL_TURN_DEGREES) / QUARTER_TURN_DEGREES))));
|
||||
}
|
||||
|
||||
private static BlockFace faceOf(IrisBlockVector v) {
|
||||
int x = (int) Math.round(v.getX());
|
||||
int y = (int) Math.round(v.getY());
|
||||
|
||||
@@ -19,14 +19,9 @@
|
||||
package art.arcane.iris.engine.object.prefab;
|
||||
|
||||
import com.volmit.object.PlaceableObject;
|
||||
import art.arcane.iris.builtin.objects.ScaleInterpolation;
|
||||
import art.arcane.iris.builtin.prepare.ObjectRotation;
|
||||
import com.volmit.object.ScaleMethod;
|
||||
import art.arcane.iris.engine.object.placement.IObjectPlacer;
|
||||
import art.arcane.iris.builtin.objects.ObjectPlacement;
|
||||
import art.arcane.iris.engine.object.terrain.carving.CarveResult;
|
||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.core.modules.ModuleObjectPlacement;
|
||||
import art.arcane.iris.core.modules.ObjectGeometry;
|
||||
import art.arcane.iris.core.loader.IrisRegistrant;
|
||||
import art.arcane.volmlib.util.cache.AtomicCache;
|
||||
@@ -41,8 +36,6 @@ import art.arcane.volmlib.util.math.IrisVector;
|
||||
import art.arcane.volmlib.util.math.Vector3i;
|
||||
import art.arcane.iris.util.common.plugin.VolmitSender;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.BlockPosition;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.object.GeneratedObject;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
@@ -60,7 +53,6 @@ import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
/**
|
||||
* A voxel volume loaded from a .iob file. Instances are loader cached and shared across generation threads, so all
|
||||
@@ -68,8 +60,8 @@ import java.util.function.BiConsumer;
|
||||
* <p>
|
||||
* The heavy behaviour lives in package-private collaborators that read this state directly:
|
||||
* {@link IrisObjectIO} (binary persistence), {@link IrisObjectShaping} (boring, shrinkwrap, block classification),
|
||||
* {@link IrisObjectTransforms} (rotation, scaling, interpolated upscaling) and {@link ModuleObjectPlacement}
|
||||
* (world placement).
|
||||
* {@link IrisObjectTransforms} (rotation, scaling, interpolated upscaling). Placing an object in a world with the
|
||||
* pack's placement rules is the placement stages' job, not this class's.
|
||||
*/
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@@ -260,25 +252,37 @@ public class IrisObject extends IrisRegistrant implements PlaceableObject {
|
||||
forgetDerivedShapes();
|
||||
}
|
||||
|
||||
public int place(int x, int z, IObjectPlacer placer, ObjectPlacement config, RNG rng, IrisData rdata) {
|
||||
return place(x, -1, z, placer, config, rng, rdata);
|
||||
}
|
||||
|
||||
public int place(int x, int z, IObjectPlacer placer, ObjectPlacement config, RNG rng, CarveResult c, IrisData rdata) {
|
||||
return place(x, -1, z, placer, config, rng, null, c, rdata);
|
||||
}
|
||||
|
||||
public int place(int x, int yv, int z, IObjectPlacer placer, ObjectPlacement config, RNG rng, IrisData rdata) {
|
||||
return place(x, yv, z, placer, config, rng, null, null, rdata);
|
||||
}
|
||||
|
||||
public int place(Location loc, IObjectPlacer placer, ObjectPlacement config, RNG rng, IrisData rdata) {
|
||||
return place(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), placer, config, rng, rdata);
|
||||
}
|
||||
|
||||
/** The height the object was placed at, or -1 when the placement rejected it. */
|
||||
public int place(int x, int yv, int z, IObjectPlacer oplacer, ObjectPlacement config, RNG rng, BiConsumer<BlockPosition, PlatformBlockState> listener, CarveResult c, IrisData rdata) {
|
||||
return ModuleObjectPlacement.place(this, x, yv, z, oplacer, config, rng, listener, c, rdata).heightOrRejected();
|
||||
/**
|
||||
* Writes the object's blocks and their block entities around ({@code x}, {@code y}, {@code z}) turned by {@code turn},
|
||||
* with no placement rule: the object's own offsets count from that spot, air is left out, and a block that cannot
|
||||
* face the new way is dropped. This is what a paste does; placement rules belong to the placement stages.
|
||||
*
|
||||
* @return how many blocks were written
|
||||
*/
|
||||
public int paste(int x, int y, int z, IObjectPlacer placer, ObjectTurn turn) {
|
||||
int written = 0;
|
||||
readLock.lock();
|
||||
try {
|
||||
for (var entry : blocks) {
|
||||
PlatformBlockState state = BlockStateRotation.rotate(turn, entry.getValue());
|
||||
if (state == null || state.isAir()) {
|
||||
continue;
|
||||
}
|
||||
IrisBlockVector turned = turn.rotate(entry.getKey());
|
||||
int blockX = x + (int) Math.round(turned.getX());
|
||||
int blockY = y + (int) Math.round(turned.getY());
|
||||
int blockZ = z + (int) Math.round(turned.getZ());
|
||||
placer.set(blockX, blockY, blockZ, state);
|
||||
TileData tile = states.get(entry.getKey());
|
||||
if (tile != null) {
|
||||
placer.setTile(blockX, blockY, blockZ, tile);
|
||||
}
|
||||
written++;
|
||||
}
|
||||
} finally {
|
||||
readLock.unlock();
|
||||
}
|
||||
return written;
|
||||
}
|
||||
|
||||
/** This object as IrisApi geometry, read once until its blocks change. */
|
||||
@@ -320,11 +324,11 @@ public class IrisObject extends IrisRegistrant implements PlaceableObject {
|
||||
});
|
||||
}
|
||||
|
||||
public IrisObject rotateCopy(ObjectRotation rt) {
|
||||
return IrisObjectTransforms.rotateCopy(this, rt);
|
||||
public IrisObject rotateCopy(ObjectTurn turn) {
|
||||
return IrisObjectTransforms.rotateCopy(this, turn);
|
||||
}
|
||||
|
||||
public IrisObject scaled(double scale, ScaleInterpolation interpolation) {
|
||||
public IrisObject scaled(double scale, ScaleMethod interpolation) {
|
||||
return IrisObjectTransforms.scaled(this, scale, interpolation);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,8 +18,7 @@
|
||||
|
||||
package art.arcane.iris.engine.object.prefab;
|
||||
|
||||
import art.arcane.iris.builtin.objects.ScaleInterpolation;
|
||||
import art.arcane.iris.builtin.prepare.ObjectRotation;
|
||||
import com.volmit.object.ScaleMethod;
|
||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.util.common.data.B;
|
||||
@@ -40,25 +39,25 @@ final class IrisObjectTransforms {
|
||||
private IrisObjectTransforms() {
|
||||
}
|
||||
|
||||
static IrisObject rotateCopy(IrisObject self, ObjectRotation rt) {
|
||||
static IrisObject rotateCopy(IrisObject self, ObjectTurn turn) {
|
||||
IrisObject copy = self.copy();
|
||||
rotate(copy, rt, 0, 0, 0);
|
||||
rotate(copy, turn);
|
||||
return copy;
|
||||
}
|
||||
|
||||
static void rotate(IrisObject self, ObjectRotation r, int spinx, int spiny, int spinz) {
|
||||
static void rotate(IrisObject self, ObjectTurn turn) {
|
||||
self.writeLock.lock();
|
||||
try {
|
||||
VectorMap<PlatformBlockState> d = new VectorMap<>();
|
||||
|
||||
for (var entry : self.blocks) {
|
||||
d.put(r.rotate(entry.getKey(), spinx, spiny, spinz), BlockStateRotation.rotate(r, entry.getValue(), spinx, spiny, spinz));
|
||||
d.put(turn.rotate(entry.getKey()), BlockStateRotation.rotate(turn, entry.getValue()));
|
||||
}
|
||||
|
||||
VectorMap<TileData> dx = new VectorMap<>();
|
||||
|
||||
for (var entry : self.states) {
|
||||
dx.put(r.rotate(entry.getKey(), spinx, spiny, spinz), entry.getValue());
|
||||
dx.put(turn.rotate(entry.getKey()), entry.getValue());
|
||||
}
|
||||
|
||||
self.blocks = d;
|
||||
@@ -70,9 +69,9 @@ final class IrisObjectTransforms {
|
||||
}
|
||||
}
|
||||
|
||||
static IrisObject scaled(IrisObject self, double scale, ScaleInterpolation interpolation) {
|
||||
static IrisObject scaled(IrisObject self, double scale, ScaleMethod interpolation) {
|
||||
if (interpolation == null) {
|
||||
interpolation = ScaleInterpolation.NONE;
|
||||
interpolation = ScaleMethod.NONE;
|
||||
}
|
||||
IrisVector sm1 = new IrisVector(scale - 1, scale - 1, scale - 1);
|
||||
scale = Math.max(0.001, Math.min(50, scale));
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.prefab;
|
||||
|
||||
import art.arcane.iris.engine.object.value.IrisDirection;
|
||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
||||
import art.arcane.volmlib.util.math.IrisBlockVector;
|
||||
import com.volmit.block.BlockTurn;
|
||||
|
||||
/**
|
||||
* How Iris's object model turns an object by fixed angles: positions turn around X, then Z, then Y, and an axis turned by
|
||||
* a multiple of a quarter turn swaps coordinates exactly instead of turning by an angle. The same turn as the built-in
|
||||
* modules' placement rotation locked to these angles, kept in core so the object model does not read module settings.
|
||||
*
|
||||
* @param xDegrees degrees around X; 0 for none
|
||||
* @param yDegrees degrees around Y; 0 for none
|
||||
* @param zDegrees degrees around Z; 0 for none
|
||||
*/
|
||||
public record ObjectTurn(double xDegrees, double yDegrees, double zDegrees) {
|
||||
public static final ObjectTurn NONE = new ObjectTurn(0, 0, 0);
|
||||
|
||||
private static final double QUARTER_TURN_DEGREES = 90;
|
||||
private static final double HALF_TURN_DEGREES = 180;
|
||||
private static final double THREE_QUARTER_TURN_DEGREES = 270;
|
||||
private static final double FULL_TURN_DEGREES = 360;
|
||||
|
||||
public static ObjectTurn of(double xDegrees, double yDegrees, double zDegrees) {
|
||||
return new ObjectTurn(xDegrees, yDegrees, zDegrees);
|
||||
}
|
||||
|
||||
public boolean canRotate() {
|
||||
return xDegrees != 0 || yDegrees != 0 || zDegrees != 0;
|
||||
}
|
||||
|
||||
/** The directions this turn turns, for the facing, axis and connections of block states. */
|
||||
public BlockTurn blockTurn() {
|
||||
return (x, y, z) -> {
|
||||
IrisBlockVector turned = rotate(new IrisBlockVector(x, y, z));
|
||||
return new BlockTurn.Direction(turned.getX(), turned.getY(), turned.getZ());
|
||||
};
|
||||
}
|
||||
|
||||
/** {@code position} turned around X, then Z, then Y; a copy unless nothing turns. */
|
||||
public IrisBlockVector rotate(IrisBlockVector position) {
|
||||
if (!canRotate()) {
|
||||
return position;
|
||||
}
|
||||
IrisBlockVector turned = position.clone();
|
||||
if (xDegrees != 0) {
|
||||
turnAroundX(turned);
|
||||
}
|
||||
if (zDegrees != 0) {
|
||||
turnAroundZ(turned);
|
||||
}
|
||||
if (yDegrees != 0) {
|
||||
turnAroundY(turned);
|
||||
}
|
||||
return turned;
|
||||
}
|
||||
|
||||
public IrisPosition rotate(IrisPosition position) {
|
||||
IrisBlockVector turned = rotate(new IrisBlockVector(position.getX(), position.getY(), position.getZ()));
|
||||
return new IrisPosition(turned.getBlockX(), turned.getBlockY(), turned.getBlockZ());
|
||||
}
|
||||
|
||||
/** The direction closest to {@code direction} turned by this turn. */
|
||||
public IrisDirection rotate(IrisDirection direction) {
|
||||
IrisBlockVector turned = rotate(new IrisBlockVector(direction.x(), direction.y(), direction.z()));
|
||||
double closestDistance = Double.MAX_VALUE;
|
||||
IrisDirection closest = null;
|
||||
for (IrisDirection candidate : IrisDirection.values()) {
|
||||
double distance = new IrisBlockVector(candidate.x(), candidate.y(), candidate.z()).distance(turned);
|
||||
if (distance < closestDistance) {
|
||||
closestDistance = distance;
|
||||
closest = candidate;
|
||||
}
|
||||
}
|
||||
return closest;
|
||||
}
|
||||
|
||||
private void turnAroundX(IrisBlockVector v) {
|
||||
if (Math.abs(xDegrees) % FULL_TURN_DEGREES == HALF_TURN_DEGREES) {
|
||||
v.setZ(-v.getZ());
|
||||
v.setY(-v.getY());
|
||||
} else if (isQuarterTurn(xDegrees)) {
|
||||
double z = v.getZ();
|
||||
v.setZ(v.getY());
|
||||
v.setY(-z);
|
||||
} else if (isThreeQuarterTurn(xDegrees)) {
|
||||
double z = v.getZ();
|
||||
v.setZ(-v.getY());
|
||||
v.setY(z);
|
||||
} else {
|
||||
v.rotateAroundX(radians(xDegrees));
|
||||
}
|
||||
}
|
||||
|
||||
private void turnAroundZ(IrisBlockVector v) {
|
||||
if (Math.abs(zDegrees) % FULL_TURN_DEGREES == HALF_TURN_DEGREES) {
|
||||
v.setY(-v.getY());
|
||||
v.setX(-v.getX());
|
||||
} else if (isQuarterTurn(zDegrees)) {
|
||||
double y = v.getY();
|
||||
v.setY(v.getX());
|
||||
v.setX(-y);
|
||||
} else if (isThreeQuarterTurn(zDegrees)) {
|
||||
double y = v.getY();
|
||||
v.setY(-v.getX());
|
||||
v.setX(y);
|
||||
} else {
|
||||
v.rotateAroundZ(radians(zDegrees));
|
||||
}
|
||||
}
|
||||
|
||||
private void turnAroundY(IrisBlockVector v) {
|
||||
if (Math.abs(yDegrees) % FULL_TURN_DEGREES == HALF_TURN_DEGREES) {
|
||||
v.setX(-v.getX());
|
||||
v.setZ(-v.getZ());
|
||||
} else if (isQuarterTurn(yDegrees)) {
|
||||
double x = v.getX();
|
||||
v.setX(v.getZ());
|
||||
v.setZ(-x);
|
||||
} else if (isThreeQuarterTurn(yDegrees)) {
|
||||
double x = v.getX();
|
||||
v.setX(-v.getZ());
|
||||
v.setZ(x);
|
||||
} else {
|
||||
v.rotateAroundY(radians(yDegrees));
|
||||
}
|
||||
}
|
||||
|
||||
/** The angle in radians a turn by {@code degrees} not on a quarter turn uses: whole degrees, rounded up, without the sign. */
|
||||
private static double radians(double degrees) {
|
||||
return Math.toRadians(Math.ceil(Math.abs(degrees % FULL_TURN_DEGREES)));
|
||||
}
|
||||
|
||||
private static boolean isQuarterTurn(double angle) {
|
||||
return angle % FULL_TURN_DEGREES == QUARTER_TURN_DEGREES || angle % FULL_TURN_DEGREES == -THREE_QUARTER_TURN_DEGREES;
|
||||
}
|
||||
|
||||
private static boolean isThreeQuarterTurn(double angle) {
|
||||
return angle == -QUARTER_TURN_DEGREES || angle % FULL_TURN_DEGREES == THREE_QUARTER_TURN_DEGREES;
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@
|
||||
package art.arcane.iris.engine.object.prefab;
|
||||
|
||||
import art.arcane.iris.builtin.objects.ObjectScale;
|
||||
import art.arcane.iris.builtin.objects.ScaleInterpolation;
|
||||
import com.volmit.object.ScaleMethod;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.volmlib.util.math.Vector3i;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
@@ -50,7 +50,7 @@ public final class ScaledObjects {
|
||||
* {@code origin} scaled by {@code factor} with {@code interpolation}, even by a factor of 1, which interpolation may
|
||||
* still change; built once per origin, factor and interpolation.
|
||||
*/
|
||||
public static IrisObject scaled(IrisObject origin, double factor, ScaleInterpolation interpolation, Engine engine) {
|
||||
public static IrisObject scaled(IrisObject origin, double factor, ScaleMethod interpolation, Engine engine) {
|
||||
return cachedVariant(new ScaleRequest(factor, factor, factor, NO_VARIATIONS, interpolation), 0, origin, engine);
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ public final class ScaledObjects {
|
||||
}
|
||||
|
||||
record ScaleRequest(double size, double minimumScale, double maximumScale, int variations,
|
||||
ScaleInterpolation interpolation) {
|
||||
ScaleMethod interpolation) {
|
||||
boolean shouldScale() {
|
||||
if (size != 1D) {
|
||||
return true;
|
||||
|
||||
@@ -38,7 +38,6 @@ import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.M;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import art.arcane.volmlib.util.scheduling.PrecisionStopwatch;
|
||||
import art.arcane.iris.builtin.spawn.IrisEntityExtras;
|
||||
import com.volmit.entity.EntitySpec;
|
||||
import com.volmit.item.ItemAttribute;
|
||||
import com.volmit.resource.ContentKey;
|
||||
@@ -104,18 +103,18 @@ public final class BukkitEntitySpawner {
|
||||
if (!Chunks.isSafe(at)) {
|
||||
return null;
|
||||
}
|
||||
IrisEntityExtras extras = spec.extension(IrisEntityExtras.class).orElse(IrisEntityExtras.NONE);
|
||||
if (extras.riseOutOfGround()) {
|
||||
boolean risesFromGround = spec.arrival().risesFromGround();
|
||||
if (risesFromGround) {
|
||||
at = startBelowGroundWhenWatched(at);
|
||||
}
|
||||
|
||||
Entity ee = doSpawn(spec, extras, at);
|
||||
Entity ee = doSpawn(spec, at);
|
||||
|
||||
if (ee == null && !Chunks.isSafe(at)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (spec.type() instanceof ContentKey.Provided && !extras.applySettingsToProvidedMob()) {
|
||||
if (spec.type() instanceof ContentKey.Provided && !spec.adjustsProvidedMob()) {
|
||||
return ee;
|
||||
}
|
||||
|
||||
@@ -146,8 +145,8 @@ public final class BukkitEntitySpawner {
|
||||
}
|
||||
|
||||
if (e instanceof Panda panda) {
|
||||
panda.setMainGene(resolveGene(extras.pandaMainGene().orElse(null)));
|
||||
panda.setHiddenGene(resolveGene(extras.pandaHiddenGene().orElse(null)));
|
||||
panda.setMainGene(resolveGene(spec.appearance().pandaMainGene().orElse(null)));
|
||||
panda.setHiddenGene(resolveGene(spec.appearance().pandaHiddenGene().orElse(null)));
|
||||
}
|
||||
|
||||
if (e instanceof Villager villager) {
|
||||
@@ -165,7 +164,7 @@ public final class BukkitEntitySpawner {
|
||||
|
||||
Location riseFrom = at;
|
||||
J.runEntity(e, () -> {
|
||||
if (extras.riseOutOfGround() && e instanceof LivingEntity living && Chunks.hasPlayersNearby(riseFrom)) {
|
||||
if (risesFromGround && e instanceof LivingEntity living && Chunks.hasPlayersNearby(riseFrom)) {
|
||||
riseOutOfGround(e, living, riseFrom);
|
||||
}
|
||||
});
|
||||
@@ -293,7 +292,7 @@ public final class BukkitEntitySpawner {
|
||||
EntityRiseSVC.clearStamp(entity);
|
||||
}
|
||||
|
||||
private static Entity doSpawn(EntitySpec spec, IrisEntityExtras extras, Location at) {
|
||||
private static Entity doSpawn(EntitySpec spec, Location at) {
|
||||
if (!Chunks.isSafe(at)) {
|
||||
return null;
|
||||
}
|
||||
@@ -308,7 +307,7 @@ public final class BukkitEntitySpawner {
|
||||
AtomicReference<Entity> ae = new AtomicReference<>();
|
||||
|
||||
try {
|
||||
if (!J.runAt(at, () -> ae.set(doSpawn(spec, extras, at)))) {
|
||||
if (!J.runAt(at, () -> ae.set(doSpawn(spec, at)))) {
|
||||
return null;
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
@@ -331,7 +330,7 @@ public final class BukkitEntitySpawner {
|
||||
return IrisServices.get(ExternalDataSVC.class).spawnMob(at, new Identifier(mob.provider(), mob.name()));
|
||||
}
|
||||
|
||||
return BukkitPlatform.spawnEntity(at, bukkitType(spec), bukkitReason(extras));
|
||||
return BukkitPlatform.spawnEntity(at, bukkitType(spec), bukkitReason(spec));
|
||||
}
|
||||
|
||||
/** The platform's entity type of the spec, unknown for a provider's mob or a type the platform lacks. */
|
||||
@@ -343,8 +342,8 @@ public final class BukkitEntitySpawner {
|
||||
return entityType == null ? EntityType.UNKNOWN : entityType;
|
||||
}
|
||||
|
||||
private static CreatureSpawnEvent.SpawnReason bukkitReason(IrisEntityExtras extras) {
|
||||
String reason = extras.reason().orElse("");
|
||||
private static CreatureSpawnEvent.SpawnReason bukkitReason(EntitySpec spec) {
|
||||
String reason = spec.arrival().reason().orElse("");
|
||||
if (reason.isBlank()) {
|
||||
return CreatureSpawnEvent.SpawnReason.NATURAL;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ import art.arcane.iris.engine.framework.GenerationSessionLease;
|
||||
import art.arcane.iris.engine.framework.Locator;
|
||||
import art.arcane.iris.core.modules.ModuleServices;
|
||||
import art.arcane.iris.core.modules.PlatformBlockStates;
|
||||
import art.arcane.iris.builtin.loot.LootResolver;
|
||||
import art.arcane.iris.platform.bukkit.BukkitItemStacks;
|
||||
import art.arcane.iris.engine.framework.WrongEngineBroException;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
@@ -444,7 +443,7 @@ public final class EngineBukkitOps {
|
||||
inv.addItem(i);
|
||||
}
|
||||
|
||||
scramble(engine, inv, LootResolver.containerRng(engine.getSeedManager().getLoot(), x, y, z));
|
||||
scrambleAsModulesSay(engine, inv, x, y, z);
|
||||
};
|
||||
|
||||
LootMutationTask task = new LootMutationTask(world, x >> 4, z >> 4, mutation);
|
||||
@@ -468,10 +467,16 @@ public final class EngineBukkitOps {
|
||||
inv.addItem(i);
|
||||
}
|
||||
|
||||
scramble(engine, inv, LootResolver.containerRng(engine.getSeedManager().getLoot(), x, y, z));
|
||||
scrambleAsModulesSay(engine, inv, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
/** Shuffles the container's slots with the seed the modules give for the container at the spot; unshuffled when none does. */
|
||||
private static void scrambleAsModulesSay(Engine engine, Inventory inv, int x, int y, int z) {
|
||||
Loot.Site site = new Loot.Site(new BlockPosition(x, y - engine.getMinHeight(), z), Optional.empty(), false, false);
|
||||
ModuleServices.lootShuffleSeed(engine, site).ifPresent(seed -> scramble(engine, inv, new RNG(seed)));
|
||||
}
|
||||
|
||||
/** The items of {@code tables} at the spot, in the tables' order: the modules' for pack tables, the platform's own for platform tables. */
|
||||
private static List<ItemStack> lootItems(Engine engine, boolean debug, List<Loot.Source> tables, World world, int x, int y, int z) {
|
||||
Loot.Site site = new Loot.Site(new BlockPosition(x, y - engine.getMinHeight(), z), Optional.empty(), false, debug);
|
||||
|
||||
+8
-8
@@ -20,7 +20,7 @@ import art.arcane.iris.engine.object.value.IrisDirection;
|
||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConnector;
|
||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.builtin.prepare.ObjectRotation;
|
||||
import art.arcane.iris.engine.object.prefab.ObjectTurn;
|
||||
import art.arcane.iris.engine.object.prefab.BlockStateRotation;
|
||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
||||
import art.arcane.iris.engine.object.structure.jigsaw.JigsawJoint;
|
||||
@@ -463,7 +463,7 @@ public final class JigsawStudioGenerator extends EnginedStudioGenerator {
|
||||
"object '" + variant.objectKey() + "' does not fit workcell '" + workcell.stableId() + "'");
|
||||
}
|
||||
|
||||
ObjectRotation rotation = ObjectRotation.of(0, -90.0D * quarterTurns, 0);
|
||||
ObjectTurn rotation = ObjectTurn.of(0, -90.0D * quarterTurns, 0);
|
||||
List<RenderedBlock> blocks = renderBlocks(object, dimensions, quarterTurns, rotation);
|
||||
if (blocks == null) {
|
||||
return RenderedBay.invalid(
|
||||
@@ -482,7 +482,7 @@ public final class JigsawStudioGenerator extends EnginedStudioGenerator {
|
||||
IrisObject object,
|
||||
JigsawStudioCellDimensions dimensions,
|
||||
int quarterTurns,
|
||||
ObjectRotation rotation
|
||||
ObjectTurn rotation
|
||||
) {
|
||||
VectorMap<PlatformBlockState> sourceBlocks = object.getBlocks();
|
||||
VectorMap<TileData> sourceTiles = object.getStates();
|
||||
@@ -514,7 +514,7 @@ public final class JigsawStudioGenerator extends EnginedStudioGenerator {
|
||||
}
|
||||
PlatformBlockState blockState = quarterTurns == 0
|
||||
? entry.getValue()
|
||||
: BlockStateRotation.rotate(rotation, entry.getValue(), 0, 0, 0);
|
||||
: BlockStateRotation.rotate(rotation, entry.getValue());
|
||||
if (blockState == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -534,7 +534,7 @@ public final class JigsawStudioGenerator extends EnginedStudioGenerator {
|
||||
IrisObject object,
|
||||
JigsawStudioCellDimensions dimensions,
|
||||
int quarterTurns,
|
||||
ObjectRotation rotation
|
||||
ObjectTurn rotation
|
||||
) {
|
||||
KList<IrisJigsawConnector> sourceConnectors = piece.getConnectors();
|
||||
if (sourceConnectors == null) {
|
||||
@@ -603,7 +603,7 @@ public final class JigsawStudioGenerator extends EnginedStudioGenerator {
|
||||
|
||||
private static String rotatedFinalState(
|
||||
String finalState,
|
||||
ObjectRotation rotation,
|
||||
ObjectTurn rotation,
|
||||
int quarterTurns
|
||||
) {
|
||||
PlatformBlockState state = B.getStateOrNull(finalState, false);
|
||||
@@ -613,7 +613,7 @@ public final class JigsawStudioGenerator extends EnginedStudioGenerator {
|
||||
if (quarterTurns == 0) {
|
||||
return state.key();
|
||||
}
|
||||
PlatformBlockState rotated = BlockStateRotation.rotate(rotation, state, 0, 0, 0);
|
||||
PlatformBlockState rotated = BlockStateRotation.rotate(rotation, state);
|
||||
return rotated == null ? null : rotated.key();
|
||||
}
|
||||
|
||||
@@ -922,7 +922,7 @@ public final class JigsawStudioGenerator extends EnginedStudioGenerator {
|
||||
|
||||
@FunctionalInterface
|
||||
interface FinalStateRenderer {
|
||||
String render(String finalState, ObjectRotation rotation, int quarterTurns);
|
||||
String render(String finalState, ObjectTurn rotation, int quarterTurns);
|
||||
}
|
||||
|
||||
record RotatedPosition(int x, int y, int z) {
|
||||
|
||||
+5
-56
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
* 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
|
||||
@@ -18,64 +18,13 @@
|
||||
|
||||
package art.arcane.iris.util.common.director.specialhandlers;
|
||||
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.core.modules.PackModulesException;
|
||||
import art.arcane.iris.core.pack.PackDirectoryResolver;
|
||||
import art.arcane.iris.spi.IrisPlatforms;
|
||||
import art.arcane.iris.util.common.director.DirectorParameterHandler;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.director.exceptions.DirectorParsingException;
|
||||
import com.volmit.resource.ResourceId;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/** The key of an entity of a pack: the open pack's, then those of the packs in the packs folder. */
|
||||
public final class EntityKeyHandler implements DirectorParameterHandler<String> {
|
||||
// iris:spawn's entity kind, named by id: its constant and its class ship only in the built-ins jar, which the
|
||||
// plugin's own classes cannot reach.
|
||||
public final class EntityKeyHandler extends PackResourceKeyHandler {
|
||||
private static final ResourceId ENTITIES = ResourceId.parse("iris:spawn/entity");
|
||||
|
||||
@Override
|
||||
public KList<String> getPossibilities() {
|
||||
Set<String> keys = new LinkedHashSet<>();
|
||||
IrisData activeData = data();
|
||||
if (activeData != null) {
|
||||
addEntityKeys(keys, activeData);
|
||||
}
|
||||
for (File pack : PackDirectoryResolver.listVisiblePackDirectories(
|
||||
IrisPlatforms.get().packsFolder())) {
|
||||
addEntityKeys(keys, IrisData.get(pack));
|
||||
}
|
||||
return new KList<>(keys);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(String value) {
|
||||
return value == null ? "" : value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String parse(String input, boolean force) throws DirectorParsingException {
|
||||
for (String option : getPossibilities(input)) {
|
||||
if (option.equalsIgnoreCase(input)) {
|
||||
return option;
|
||||
}
|
||||
}
|
||||
throw new DirectorParsingException("Unable to find Entity \"" + input + "\"");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> type) {
|
||||
return type == String.class;
|
||||
}
|
||||
|
||||
/** A pack whose modules fail to load has no entities to offer; its failure was reported when it loaded. */
|
||||
private static void addEntityKeys(Set<String> keys, IrisData data) {
|
||||
try {
|
||||
data.getPackResources().ids(ENTITIES).forEach(id -> keys.add(id.path()));
|
||||
} catch (PackModulesException ignored) {
|
||||
}
|
||||
public EntityKeyHandler() {
|
||||
super(ENTITIES, "Entity");
|
||||
}
|
||||
}
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.util.common.director.specialhandlers;
|
||||
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.core.modules.PackModulesException;
|
||||
import art.arcane.iris.core.pack.PackDirectoryResolver;
|
||||
import art.arcane.iris.spi.IrisPlatforms;
|
||||
import art.arcane.iris.util.common.director.DirectorParameterHandler;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.director.exceptions.DirectorParsingException;
|
||||
import com.volmit.resource.ResourceId;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* The keys of one kind of pack resources a module declares, named by the kind's id, offered to a command parameter: the
|
||||
* open pack's, then those of the packs in the packs folder. A subclass names the kind and what a command calls one of
|
||||
* its resources; Iris needs no class of the module for it.
|
||||
*/
|
||||
public abstract class PackResourceKeyHandler implements DirectorParameterHandler<String> {
|
||||
private final ResourceId kind;
|
||||
private final String noun;
|
||||
|
||||
/**
|
||||
* @param kind the kind's id, such as {@code iris:spawn/entity}
|
||||
* @param noun what the kind's resources are called in the error for a key that no pack has, such as {@code Entity}
|
||||
*/
|
||||
protected PackResourceKeyHandler(ResourceId kind, String noun) {
|
||||
this.kind = kind;
|
||||
this.noun = noun;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KList<String> getPossibilities() {
|
||||
Set<String> keys = new LinkedHashSet<>();
|
||||
IrisData activeData = data();
|
||||
if (activeData != null) {
|
||||
addKeys(keys, activeData);
|
||||
}
|
||||
for (File pack : PackDirectoryResolver.listVisiblePackDirectories(
|
||||
IrisPlatforms.get().packsFolder())) {
|
||||
addKeys(keys, IrisData.get(pack));
|
||||
}
|
||||
return new KList<>(keys);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(String value) {
|
||||
return value == null ? "" : value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String parse(String input, boolean force) throws DirectorParsingException {
|
||||
for (String option : getPossibilities(input)) {
|
||||
if (option.equalsIgnoreCase(input)) {
|
||||
return option;
|
||||
}
|
||||
}
|
||||
throw new DirectorParsingException("Unable to find " + noun + " \"" + input + "\"");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> type) {
|
||||
return type == String.class;
|
||||
}
|
||||
|
||||
/** A pack whose modules fail to load has no resources to offer; its failure was reported when it loaded. */
|
||||
private void addKeys(Set<String> keys, IrisData data) {
|
||||
try {
|
||||
data.getPackResources().ids(kind).forEach(id -> keys.add(id.path()));
|
||||
} catch (PackModulesException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
-48
@@ -1,48 +0,0 @@
|
||||
package art.arcane.iris.builtin.structure;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class StructurePlacementMarkerTest {
|
||||
@Test
|
||||
public void structureMarkerRoundTripsDelimiterSafeKeys() {
|
||||
String objectKey = "pieces/room@east:alpha/樹";
|
||||
String structureKey = "structures/village@night:beta/城";
|
||||
|
||||
String encoded = StructurePlacementMarker.encodeStructure(objectKey, 918273, structureKey);
|
||||
StructurePlacementMarker.Decoded decoded = StructurePlacementMarker.decode(encoded);
|
||||
|
||||
assertTrue(encoded.startsWith("@iris-structure:v1:"));
|
||||
assertEquals(objectKey, decoded.objectKey());
|
||||
assertEquals(918273, decoded.placementId());
|
||||
assertEquals(structureKey, decoded.structureKey());
|
||||
assertTrue(decoded.structureAware());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void legacyMarkerDecodesWithoutChangingFields() {
|
||||
StructurePlacementMarker.Decoded decoded = StructurePlacementMarker.decode("objects/oak_tree@42");
|
||||
|
||||
assertEquals("objects/oak_tree", decoded.objectKey());
|
||||
assertEquals(42, decoded.placementId());
|
||||
assertNull(decoded.structureKey());
|
||||
assertFalse(decoded.structureAware());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void malformedAndUnknownMarkersFailSafely() {
|
||||
assertNull(StructurePlacementMarker.decode(null));
|
||||
assertNull(StructurePlacementMarker.decode(""));
|
||||
assertNull(StructurePlacementMarker.decode("objects/oak_tree"));
|
||||
assertNull(StructurePlacementMarker.decode("objects/oak_tree@not-an-id"));
|
||||
assertNull(StructurePlacementMarker.decode("objects/oak_tree@42@extra"));
|
||||
assertNull(StructurePlacementMarker.decode("@iris-structure:v2:b2JqZWN0:42:c3RydWN0dXJl"));
|
||||
assertNull(StructurePlacementMarker.decode("@iris-structure:v1:not%base64:42:c3RydWN0dXJl"));
|
||||
assertNull(StructurePlacementMarker.decode("@iris-structure:v1:b2JqZWN0:42:"));
|
||||
}
|
||||
}
|
||||
@@ -49,6 +49,7 @@ import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.OptionalInt;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
@@ -139,7 +140,10 @@ public class BuiltInGenerationGraphTest {
|
||||
for (Level target : Level.values()) {
|
||||
List<String> keys = pack.schema().fields(target).stream().map(FeatureSchema::key).toList();
|
||||
assertEquals(target + " " + keys, keys.size(), keys.stream().distinct().count());
|
||||
assertTrue(target + " " + keys, keys.stream().noneMatch(ModuleTargets.reservedFields().get(target)::contains));
|
||||
Set<String> fieldsOfIris = target == Level.PLACEMENT
|
||||
? pack.catalog().placementType().orElseThrow().jsonFields()
|
||||
: ModuleTargets.reservedFields().get(target);
|
||||
assertTrue(target + " " + keys, keys.stream().noneMatch(fieldsOfIris::contains));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,22 +18,30 @@
|
||||
|
||||
package art.arcane.iris.core.modules;
|
||||
|
||||
import art.arcane.iris.builtin.IrisSeedPurposes;
|
||||
import art.arcane.iris.builtin.loot.LootResolver;
|
||||
import art.arcane.iris.engine.framework.structure.StructureLocating;
|
||||
import art.arcane.iris.engine.loot.LootGiving;
|
||||
import art.arcane.iris.engine.mantle.components.StructureModule;
|
||||
import com.volmit.IrisModule;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
import com.volmit.host.FeatureCatalog;
|
||||
import com.volmit.host.LifecycleRegistration;
|
||||
import com.volmit.service.BlockDrops;
|
||||
import com.volmit.service.Loot;
|
||||
import com.volmit.service.ObjectsAt;
|
||||
import com.volmit.service.ProtectedFloor;
|
||||
import com.volmit.service.StructureLocator;
|
||||
import com.volmit.world.PackWorld;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/** The services and hooks Iris's built-in modules provide, which Iris core asks instead of their features. */
|
||||
public class BuiltInServicesTest {
|
||||
@@ -51,6 +59,21 @@ public class BuiltInServicesTest {
|
||||
assertTrue(BUILT_INS.services(Loot.class).getFirst() instanceof LootGiving);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void theLootModuleShufflesAContainerWithTheSeedOfItsSpotAtWorldHeight() {
|
||||
PackWorld world = mock(PackWorld.class);
|
||||
when(world.seed(IrisSeedPurposes.LOOT)).thenReturn(99L);
|
||||
when(world.minWorldY()).thenReturn(-64);
|
||||
Loot.Site site = new Loot.Site(new BlockPosition(5, 70, -9), Optional.empty(), false, false);
|
||||
|
||||
assertEquals(LootResolver.containerSeed(99L, 5, 6, -9), new LootGiving().shuffleSeed(world, site).getAsLong());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void theTerrainModuleProtectsTheFloor() {
|
||||
assertEquals(1, BUILT_INS.services(ProtectedFloor.class).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void structuresAreFoundThroughTheStructureModule() {
|
||||
List<StructureLocator> locators = BUILT_INS.services(StructureLocator.class);
|
||||
|
||||
@@ -45,6 +45,7 @@ import art.arcane.volmlib.util.collection.KList;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.config.SettingsStack;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
import com.volmit.placement.PlacementRecord;
|
||||
import com.volmit.world.BiomeKind;
|
||||
import com.volmit.world.PackWorld;
|
||||
import com.volmit.world.RunningWorld;
|
||||
@@ -181,7 +182,8 @@ public class IrisRunningWorldTest {
|
||||
when(chunk.get(X & 15, Y, Z & 15, String.class)).thenReturn("trees/oak@7");
|
||||
when(chunk.get((X + 1) & 15, Y, Z & 15, String.class)).thenReturn("");
|
||||
|
||||
assertEquals(Optional.of("trees/oak@7"), running.placementAt(X, Y, Z));
|
||||
assertEquals(Optional.of(PlacementRecord.of(engine.getData().getPackResources().idOf("trees/oak"), 7)),
|
||||
running.placementAt(X, Y, Z));
|
||||
assertTrue("an empty record is no placement", running.placementAt(X + 1, Y, Z).isEmpty());
|
||||
assertTrue(running.placementAt(X + 2, Y, Z).isEmpty());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package art.arcane.iris.core.modules;
|
||||
|
||||
import art.arcane.iris.builtin.blocks.ObjectMarkers;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
|
||||
/** Iris keeps the marker ids the built-in modules mark with, without reading their classes. */
|
||||
public class MantleMarkerTypesTest {
|
||||
private static final BlockPosition SPOT = new BlockPosition(1, 2, 3);
|
||||
|
||||
@Test
|
||||
public void theTypesAreTheOnesTheBuiltInModulesMarkWith() {
|
||||
assertEquals(ObjectMarkers.TYPE, MantleMarkerTypes.PACK_MARKER);
|
||||
assertEquals(ObjectMarkers.MARKER_ATTRIBUTE, MantleMarkerTypes.PACK_MARKER_NAME);
|
||||
assertEquals(ObjectMarkers.TREE_MATERIAL, MantleMarkerTypes.TREE_MATERIAL);
|
||||
assertEquals(ObjectMarkers.BURIED_TREASURE, MantleMarkerTypes.BURIED_TREASURE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aPackMarkerGivesItsName() {
|
||||
assertEquals("spawn/zombie", MantleMarkerTypes.packMarkerName(ObjectMarkers.of(SPOT, "spawn/zombie")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aMarkerOfAnotherTypeIsRejected() {
|
||||
assertThrows(IllegalArgumentException.class, () -> MantleMarkerTypes.packMarkerName(ObjectMarkers.treeMaterial(SPOT)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package art.arcane.iris.core.modules;
|
||||
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import com.volmit.placement.PlacementRecord;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
public class PlacementMarkersTest {
|
||||
@Test
|
||||
public void aRecordOfAnObjectOnItsOwnIsKeyAtIdAndReadsBack() {
|
||||
IrisPackResources resources = resources();
|
||||
PlacementRecord record = PlacementRecord.of(resources.idOf("trees/oak"), 7);
|
||||
|
||||
String marker = PlacementMarkers.encode(record, resources);
|
||||
|
||||
assertEquals("trees/oak@7", marker);
|
||||
assertEquals(Optional.of(record), PlacementMarkers.recordOf(marker, resources));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aRecordOfAStructurePieceUsesTheDelimiterSafeFormAndReadsBack() {
|
||||
IrisPackResources resources = resources();
|
||||
PlacementRecord record = PlacementRecord.ofPiece(resources.idOf("pieces/room"), 918273, resources.idOf("structures/village"));
|
||||
|
||||
String marker = PlacementMarkers.encode(record, resources);
|
||||
|
||||
assertEquals(PlacementMarkers.encodeStructure("pieces/room", 918273, "structures/village"), marker);
|
||||
assertEquals(Optional.of(record), PlacementMarkers.recordOf(marker, resources));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void textThatNamesNoPlacementIsNoRecord() {
|
||||
IrisPackResources resources = resources();
|
||||
|
||||
assertTrue(PlacementMarkers.recordOf(null, resources).isEmpty());
|
||||
assertTrue(PlacementMarkers.recordOf("", resources).isEmpty());
|
||||
assertTrue(PlacementMarkers.recordOf("objects/oak_tree", resources).isEmpty());
|
||||
}
|
||||
|
||||
private static IrisPackResources resources() {
|
||||
IrisData data = mock(IrisData.class);
|
||||
ModuleResourceFixture.serve(data);
|
||||
return data.getPackResources();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void structureMarkerRoundTripsDelimiterSafeKeys() {
|
||||
String objectKey = "pieces/room@east:alpha/樹";
|
||||
String structureKey = "structures/village@night:beta/城";
|
||||
|
||||
String encoded = PlacementMarkers.encodeStructure(objectKey, 918273, structureKey);
|
||||
PlacementMarkers.Decoded decoded = PlacementMarkers.decode(encoded);
|
||||
|
||||
assertTrue(encoded.startsWith("@iris-structure:v1:"));
|
||||
assertEquals(objectKey, decoded.objectKey());
|
||||
assertEquals(918273, decoded.placementId());
|
||||
assertEquals(structureKey, decoded.structureKey());
|
||||
assertTrue(decoded.structureAware());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void legacyMarkerDecodesWithoutChangingFields() {
|
||||
PlacementMarkers.Decoded decoded = PlacementMarkers.decode("objects/oak_tree@42");
|
||||
|
||||
assertEquals("objects/oak_tree", decoded.objectKey());
|
||||
assertEquals(42, decoded.placementId());
|
||||
assertNull(decoded.structureKey());
|
||||
assertFalse(decoded.structureAware());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void malformedAndUnknownMarkersFailSafely() {
|
||||
assertNull(PlacementMarkers.decode(null));
|
||||
assertNull(PlacementMarkers.decode(""));
|
||||
assertNull(PlacementMarkers.decode("objects/oak_tree"));
|
||||
assertNull(PlacementMarkers.decode("objects/oak_tree@not-an-id"));
|
||||
assertNull(PlacementMarkers.decode("objects/oak_tree@42@extra"));
|
||||
assertNull(PlacementMarkers.decode("@iris-structure:v2:b2JqZWN0:42:c3RydWN0dXJl"));
|
||||
assertNull(PlacementMarkers.decode("@iris-structure:v1:not%base64:42:c3RydWN0dXJl"));
|
||||
assertNull(PlacementMarkers.decode("@iris-structure:v1:b2JqZWN0:42:"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package art.arcane.iris.core.modules;
|
||||
|
||||
import art.arcane.iris.builtin.objects.ObjectPlacement;
|
||||
import art.arcane.iris.core.loader.JsonFieldNames;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/** The fields the object module declares for its placement type are the keys Gson reads, which settings keys may not take. */
|
||||
public class PlacementTypeFieldsTest {
|
||||
@Test
|
||||
public void theDeclaredFieldsAreTheKeysGsonReadsForAPlacement() {
|
||||
assertEquals(JsonFieldNames.of(ObjectPlacement.class), ObjectPlacement.jsonFields());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aSerializedNameAndItsAlternatesAreFields() {
|
||||
assertTrue(ObjectPlacement.jsonFields().contains("forcePlace"));
|
||||
assertTrue(ObjectPlacement.jsonFields().contains("force"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whatIrisKeepsBesideThePlacementIsNoField() {
|
||||
assertTrue(!ObjectPlacement.jsonFields().contains("json"));
|
||||
assertTrue(!ObjectPlacement.jsonFields().contains("hostForm"));
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -5,7 +5,7 @@ import art.arcane.iris.core.runtime.jigsaw.JigsawStudioMode;
|
||||
import art.arcane.iris.engine.framework.PlacedStructurePiece;
|
||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.builtin.prepare.ObjectRotation;
|
||||
import art.arcane.iris.engine.object.prefab.ObjectTurn;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import org.bukkit.World;
|
||||
import org.junit.Test;
|
||||
@@ -31,7 +31,7 @@ public class JigsawStudioPreviewRendererTest {
|
||||
when(stone.key()).thenReturn("minecraft:stone");
|
||||
IrisObject object = new IrisObject(3, 3, 3);
|
||||
object.setUnsigned(2, 1, 0, stone);
|
||||
PlacedStructurePiece piece = piece(object, 100, 70, -40, ObjectRotation.of(0, 0, 0));
|
||||
PlacedStructurePiece piece = piece(object, 100, 70, -40, ObjectTurn.of(0, 0, 0));
|
||||
|
||||
JigsawStudioPreviewRenderer.PreviewPlan plan = JigsawStudioPreviewRenderer.plan(List.of(piece));
|
||||
|
||||
@@ -56,7 +56,7 @@ public class JigsawStudioPreviewRendererTest {
|
||||
object.setUnsigned(0, 0, 0, structureVoid);
|
||||
|
||||
JigsawStudioPreviewRenderer.PreviewPlan plan = JigsawStudioPreviewRenderer.plan(List.of(
|
||||
piece(object, 0, 65, 0, ObjectRotation.of(0, 0, 0))));
|
||||
piece(object, 0, 65, 0, ObjectTurn.of(0, 0, 0))));
|
||||
|
||||
assertTrue(plan.blocks().isEmpty());
|
||||
assertFalse(plan.bounds().isEmpty());
|
||||
@@ -77,7 +77,7 @@ public class JigsawStudioPreviewRendererTest {
|
||||
10,
|
||||
10,
|
||||
10,
|
||||
ObjectRotation.of(0, 0, 0));
|
||||
ObjectTurn.of(0, 0, 0));
|
||||
|
||||
PlacedStructurePiece planar = JigsawStudioService.alignPreviewPieces(
|
||||
List.of(source),
|
||||
@@ -137,7 +137,7 @@ public class JigsawStudioPreviewRendererTest {
|
||||
int x,
|
||||
int y,
|
||||
int z,
|
||||
ObjectRotation rotation
|
||||
ObjectTurn rotation
|
||||
) {
|
||||
int minimumX = x - object.getW() / 2;
|
||||
int minimumY = y - object.getH() / 2;
|
||||
|
||||
@@ -25,7 +25,7 @@ import art.arcane.iris.engine.object.value.IrisDirection;
|
||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConnector;
|
||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.builtin.prepare.ObjectRotation;
|
||||
import art.arcane.iris.engine.object.prefab.ObjectTurn;
|
||||
import art.arcane.iris.engine.object.prefab.BlockStateRotation;
|
||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
||||
import art.arcane.iris.engine.object.structure.jigsaw.JigsawJoint;
|
||||
@@ -818,8 +818,8 @@ public class JigsawStudioServiceCaptureTest {
|
||||
List<JigsawStudioService.ChunkCaptureArea> areas = JigsawStudioService.chunkIntersections(bounds);
|
||||
PlatformBlockState sourceState = BukkitBlockState.of(directionalBlockData(BlockFace.NORTH));
|
||||
for (int quarterTurns = 1; quarterTurns <= 3; quarterTurns++) {
|
||||
ObjectRotation displayRotation = ObjectRotation.of(0, -90.0D * quarterTurns, 0);
|
||||
PlatformBlockState displayedState = BlockStateRotation.rotate(displayRotation, sourceState, 0, 0, 0);
|
||||
ObjectTurn displayRotation = ObjectTurn.of(0, -90.0D * quarterTurns, 0);
|
||||
PlatformBlockState displayedState = BlockStateRotation.rotate(displayRotation, sourceState);
|
||||
IrisDirection displayedDirection = displayRotation.rotate(IrisDirection.NORTH_NEGATIVE_Z);
|
||||
JigsawStudioService.CapturedConnector connector = new JigsawStudioService.CapturedConnector(
|
||||
1,
|
||||
@@ -1059,8 +1059,8 @@ public class JigsawStudioServiceCaptureTest {
|
||||
directionalBlockData(Material.OBSERVER, BlockFace.NORTH));
|
||||
|
||||
for (int quarterTurns = 1; quarterTurns <= 3; quarterTurns++) {
|
||||
ObjectRotation displayRotation = ObjectRotation.of(0, -90.0D * quarterTurns, 0);
|
||||
PlatformBlockState displayedState = BlockStateRotation.rotate(displayRotation, sourceState, 0, 0, 0);
|
||||
ObjectTurn displayRotation = ObjectTurn.of(0, -90.0D * quarterTurns, 0);
|
||||
PlatformBlockState displayedState = BlockStateRotation.rotate(displayRotation, sourceState);
|
||||
JigsawStudioService.CapturedConnector displayedFirst = displayedConnector(
|
||||
sourceFirst,
|
||||
bounds.dimensions(),
|
||||
@@ -1492,7 +1492,7 @@ public class JigsawStudioServiceCaptureTest {
|
||||
IrisJigsawConnector source,
|
||||
JigsawStudioCellDimensions displayDimensions,
|
||||
int displayRotationQuarterTurns,
|
||||
ObjectRotation displayRotation,
|
||||
ObjectTurn displayRotation,
|
||||
String finalState
|
||||
) {
|
||||
IrisPosition displayedPosition = displayedPosition(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package art.arcane.iris.core.service.tree;
|
||||
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.builtin.structure.StructurePlacementMarker;
|
||||
import art.arcane.iris.core.modules.PlacementMarkers;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
||||
@@ -61,7 +61,7 @@ public class TreeDefinitionIndexTest {
|
||||
assertTrue(index.isTreeMarker("procedural/tree/towering-oak#1@4"));
|
||||
assertFalse(index.isTreeMarker("procedural/towering-oak#0@3"));
|
||||
assertFalse(index.isTreeMarker("procedural/tree/towering-oak#2@5"));
|
||||
assertFalse(index.isTreeMarker(StructurePlacementMarker.encodeStructure(
|
||||
assertFalse(index.isTreeMarker(PlacementMarkers.encodeStructure(
|
||||
"trees/oak/giant",
|
||||
1,
|
||||
"village"
|
||||
|
||||
@@ -6,14 +6,29 @@ import art.arcane.iris.builtin.terrain.LayersSettings;
|
||||
import art.arcane.iris.modules.terrain.OreSettings;
|
||||
import art.arcane.iris.engine.modifier.ApiChunk;
|
||||
import art.arcane.iris.engine.object.TestSettings;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.core.modules.BuiltInPack;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.host.LoadedPack;
|
||||
import com.volmit.service.ProtectedFloor;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
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.assertNotEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
/** Terrain fills a column from bedrock to its height with the biome's layers over rock, and the fluid above it up to the fluid height. */
|
||||
public class TerrainModuleTest {
|
||||
@Rule
|
||||
public TemporaryFolder folder = new TemporaryFolder();
|
||||
|
||||
private static final int HEIGHT = 20;
|
||||
private static final int FLUID_HEIGHT = 25;
|
||||
private static final int WORLD_HEIGHT = 64;
|
||||
@@ -95,6 +110,16 @@ public class TerrainModuleTest {
|
||||
assertEquals("nothing between the grounds", ApiChunk.AIR, chunk.get(3, 49, 4));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void theTerrainKeepsTheLowestLayerFromOthersWhileTheDimensionHasBedrock() throws IOException {
|
||||
try (LoadedPack pack = BuiltInPack.serve(mock(IrisData.class), folder, List.of())) {
|
||||
ProtectedFloor floor = pack.catalog().service(ProtectedFloor.class).orElseThrow();
|
||||
|
||||
assertTrue("bedrock is the default", floor.protectsFloor(world().world()));
|
||||
assertFalse(floor.protectsFloor(world().dimensionSettings(TestSettings.of(BedrockSettings.class, "{\"bedrock\": false}")).world()));
|
||||
}
|
||||
}
|
||||
|
||||
private static ApiChunk world() {
|
||||
return new ApiChunk(0, 0, WORLD_HEIGHT).surface((x, z) -> HEIGHT).fluidHeight(FLUID_HEIGHT);
|
||||
}
|
||||
|
||||
+10
-9
@@ -22,6 +22,7 @@ import art.arcane.iris.modules.objects.CaveTransaction;
|
||||
import art.arcane.iris.modules.objects.TerrainTransaction.Commit;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.object.BlockEntityData;
|
||||
import com.volmit.placement.PlacementRecord;
|
||||
import com.volmit.placement.PlacementTerrain;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import org.junit.Test;
|
||||
@@ -30,7 +31,6 @@ import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.inOrder;
|
||||
import static org.mockito.Mockito.mock;
|
||||
@@ -45,6 +45,7 @@ public class CaveTransactionTest {
|
||||
private static final int MIN_DEPTH = 10;
|
||||
private static final BlockState STONE = BlockState.parse("minecraft:stone");
|
||||
private static final BlockState CHEST = BlockState.parse("minecraft:chest");
|
||||
private static final PlacementRecord OBJECT_ONE = PlacementRecord.of(ResourceId.parse("test:object"), 1);
|
||||
|
||||
@Test
|
||||
public void validPlacementCommitsBlocksBlockEntitiesAndRecordsTogether() {
|
||||
@@ -54,18 +55,18 @@ public class CaveTransactionTest {
|
||||
|
||||
transaction.set(4, 30, 7, STONE);
|
||||
transaction.set(4, 31, 7, CHEST, loot);
|
||||
transaction.recordPlacement(4, 30, 7, "object@1");
|
||||
transaction.recordPlacement(4, 30, 7, OBJECT_ONE);
|
||||
|
||||
assertEquals(STONE, transaction.get(4, 30, 7));
|
||||
assertEquals("object@1", transaction.placementAt(4, 30, 7).orElseThrow());
|
||||
assertEquals(OBJECT_ONE, transaction.placementAt(4, 30, 7).orElseThrow());
|
||||
verify(terrain, never()).set(anyInt(), anyInt(), anyInt(), any());
|
||||
verify(terrain, never()).recordPlacement(anyInt(), anyInt(), anyInt(), anyString());
|
||||
verify(terrain, never()).recordPlacement(anyInt(), anyInt(), anyInt(), any());
|
||||
|
||||
assertEquals(Commit.COMMITTED, transaction.commit());
|
||||
org.mockito.InOrder order = inOrder(terrain);
|
||||
order.verify(terrain).set(4, 30, 7, STONE);
|
||||
order.verify(terrain).set(4, 31, 7, CHEST, loot);
|
||||
order.verify(terrain).recordPlacement(4, 30, 7, "object@1");
|
||||
order.verify(terrain).recordPlacement(4, 30, 7, OBJECT_ONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -77,11 +78,11 @@ public class CaveTransactionTest {
|
||||
CaveTransaction transaction = new CaveTransaction(terrain, WORLD_HEIGHT, ANCHOR_Y, MIN_DEPTH);
|
||||
|
||||
transaction.set(4, 30, 7, STONE);
|
||||
transaction.recordPlacement(5, 26, 7, "ghost");
|
||||
transaction.recordPlacement(5, 26, 7, PlacementRecord.of(ResourceId.parse("test:ghost"), 1));
|
||||
|
||||
assertEquals(Commit.REJECTED, transaction.commit());
|
||||
verify(terrain, never()).set(anyInt(), anyInt(), anyInt(), any());
|
||||
verify(terrain, never()).recordPlacement(anyInt(), anyInt(), anyInt(), anyString());
|
||||
verify(terrain, never()).recordPlacement(anyInt(), anyInt(), anyInt(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -93,11 +94,11 @@ public class CaveTransactionTest {
|
||||
CaveTransaction transaction = new CaveTransaction(terrain, WORLD_HEIGHT, ANCHOR_Y, MIN_DEPTH);
|
||||
|
||||
transaction.set(4, 30, 7, STONE);
|
||||
transaction.recordPlacement(5, 25, 7, "outside-cave");
|
||||
transaction.recordPlacement(5, 25, 7, PlacementRecord.of(ResourceId.parse("test:outside-cave"), 1));
|
||||
|
||||
assertEquals(Commit.REJECTED, transaction.commit());
|
||||
verify(terrain, never()).set(anyInt(), anyInt(), anyInt(), any());
|
||||
verify(terrain, never()).recordPlacement(anyInt(), anyInt(), anyInt(), anyString());
|
||||
verify(terrain, never()).recordPlacement(anyInt(), anyInt(), anyInt(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+11
-11
@@ -2,7 +2,7 @@ package art.arcane.iris.engine.mantle.components;
|
||||
|
||||
import art.arcane.iris.engine.framework.PlacedStructurePiece;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.builtin.prepare.ObjectRotation;
|
||||
import art.arcane.iris.engine.object.prefab.ObjectTurn;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.volmlib.util.math.IrisBlockVector;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
@@ -20,7 +20,7 @@ import static org.mockito.Mockito.when;
|
||||
public class StructureCarvingFootprintTest {
|
||||
@Test
|
||||
public void preservesIrregularFootprintInsteadOfFillingItsBoundingBox() {
|
||||
PlacedStructurePiece piece = piece(10, 40, 20, ObjectRotation.of(0, 0, 0),
|
||||
PlacedStructurePiece piece = piece(10, 40, 20, ObjectTurn.of(0, 0, 0),
|
||||
block(0, 0, 0), block(1, 0, 0), block(2, 0, 0),
|
||||
block(0, 0, 1), block(0, 0, 2));
|
||||
|
||||
@@ -39,7 +39,7 @@ public class StructureCarvingFootprintTest {
|
||||
|
||||
@Test
|
||||
public void reportsExactDistanceAndNearestColumnHeights() {
|
||||
PlacedStructurePiece piece = piece(0, 0, 0, ObjectRotation.of(0, 0, 0),
|
||||
PlacedStructurePiece piece = piece(0, 0, 0, ObjectTurn.of(0, 0, 0),
|
||||
block(0, 10, 0), block(0, 12, 0),
|
||||
block(4, 30, 0), block(4, 35, 0));
|
||||
|
||||
@@ -59,9 +59,9 @@ public class StructureCarvingFootprintTest {
|
||||
|
||||
@Test
|
||||
public void rotatesAndMergesOverlappingColumns() {
|
||||
PlacedStructurePiece rotated = piece(10, 20, 30, ObjectRotation.of(0, 90, 0),
|
||||
PlacedStructurePiece rotated = piece(10, 20, 30, ObjectTurn.of(0, 90, 0),
|
||||
block(2, 1, 0));
|
||||
PlacedStructurePiece overlapping = piece(10, 5, 28, ObjectRotation.of(0, 0, 0),
|
||||
PlacedStructurePiece overlapping = piece(10, 5, 28, ObjectTurn.of(0, 0, 0),
|
||||
block(0, 3, 0), block(0, 9, 0));
|
||||
|
||||
StructureCarvingFootprint footprint = StructureCarvingFootprint.from(
|
||||
@@ -83,7 +83,7 @@ public class StructureCarvingFootprintTest {
|
||||
block(0, 2, 0), block(3, 4, 1), block(1, 6, 4), block(5, 8, 5)
|
||||
};
|
||||
PlacedStructurePiece piece = piece(
|
||||
-8, 30, 11, ObjectRotation.of(0, 0, 0), sourceBlocks);
|
||||
-8, 30, 11, ObjectTurn.of(0, 0, 0), sourceBlocks);
|
||||
|
||||
StructureCarvingFootprint footprint = StructureCarvingFootprint.from(pieces(piece), 3);
|
||||
|
||||
@@ -112,10 +112,10 @@ public class StructureCarvingFootprintTest {
|
||||
null, null, 0, 0, 0, null, 0, 0, 0, 0, 0, 0));
|
||||
assertNull(StructureCarvingFootprint.from(invalidPieces, 0));
|
||||
|
||||
PlacedStructurePiece piece = piece(0, 0, 0, ObjectRotation.of(0, 0, 0), block(0, 0, 0));
|
||||
PlacedStructurePiece piece = piece(0, 0, 0, ObjectTurn.of(0, 0, 0), block(0, 0, 0));
|
||||
assertNull(StructureCarvingFootprint.from(pieces(piece), 2, 24));
|
||||
PlacedStructurePiece overflowing = piece(
|
||||
Integer.MAX_VALUE, 0, 0, ObjectRotation.of(0, 0, 0), block(1, 0, 0));
|
||||
Integer.MAX_VALUE, 0, 0, ObjectTurn.of(0, 0, 0), block(1, 0, 0));
|
||||
assertNull(StructureCarvingFootprint.from(pieces(overflowing), 0));
|
||||
|
||||
try {
|
||||
@@ -128,7 +128,7 @@ public class StructureCarvingFootprintTest {
|
||||
|
||||
@Test
|
||||
public void includesTheEntirePaddingBoundary() {
|
||||
PlacedStructurePiece piece = piece(7, 14, -4, ObjectRotation.of(0, 0, 0), block(0, 0, 0));
|
||||
PlacedStructurePiece piece = piece(7, 14, -4, ObjectTurn.of(0, 0, 0), block(0, 0, 0));
|
||||
|
||||
StructureCarvingFootprint footprint = StructureCarvingFootprint.from(pieces(piece), 2, 25);
|
||||
|
||||
@@ -155,7 +155,7 @@ public class StructureCarvingFootprintTest {
|
||||
object.getBlocks().put(new IrisBlockVector(0, 0, 0), solid);
|
||||
object.getBlocks().put(new IrisBlockVector(8, 4, 8), air);
|
||||
PlacedStructurePiece piece = new PlacedStructurePiece(
|
||||
null, object, 10, 20, 30, ObjectRotation.of(0, 0, 0),
|
||||
null, object, 10, 20, 30, ObjectTurn.of(0, 0, 0),
|
||||
10, 20, 30, 18, 24, 38);
|
||||
|
||||
StructureCarvingFootprint footprint = StructureCarvingFootprint.from(pieces(piece), 0);
|
||||
@@ -167,7 +167,7 @@ public class StructureCarvingFootprintTest {
|
||||
assertEquals(30, footprint.maxZ());
|
||||
}
|
||||
|
||||
private static PlacedStructurePiece piece(int x, int y, int z, ObjectRotation rotation,
|
||||
private static PlacedStructurePiece piece(int x, int y, int z, ObjectTurn rotation,
|
||||
int[]... blocks) {
|
||||
IrisObject object = new IrisObject(1, 1, 1);
|
||||
PlatformBlockState state = mock(PlatformBlockState.class);
|
||||
|
||||
+8
-7
@@ -22,6 +22,7 @@ import art.arcane.iris.modules.objects.TerrainTransaction;
|
||||
import art.arcane.iris.modules.objects.TerrainTransaction.Commit;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.object.BlockEntityData;
|
||||
import com.volmit.placement.PlacementRecord;
|
||||
import com.volmit.placement.PlacementTerrain;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import org.junit.Test;
|
||||
@@ -29,7 +30,6 @@ import org.junit.Test;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.inOrder;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
@@ -40,6 +40,7 @@ public class TerrainTransactionTest {
|
||||
private static final BlockState FIRST = BlockState.parse("minecraft:oak_log");
|
||||
private static final BlockState SECOND = BlockState.parse("minecraft:chest");
|
||||
private static final BlockEntityData LOOT = new BlockEntityData(ResourceId.parse("test:chest"), 1, new byte[0]);
|
||||
private static final PlacementRecord TREE = PlacementRecord.of(ResourceId.parse("test:tree"), 7);
|
||||
|
||||
@Test
|
||||
public void unsupportedFinalTerrainRejectsBlocksBlockEntitiesAndRecordsTogether() {
|
||||
@@ -49,13 +50,13 @@ public class TerrainTransactionTest {
|
||||
writeTreeAcrossTheChunkBorder(transaction);
|
||||
|
||||
assertEquals(SECOND, transaction.get(16, 101, 8));
|
||||
assertEquals("tree@7", transaction.placementAt(16, 101, 8).orElseThrow());
|
||||
assertEquals(TREE, transaction.placementAt(16, 101, 8).orElseThrow());
|
||||
verify(terrain, never()).set(anyInt(), anyInt(), anyInt(), any());
|
||||
|
||||
assertEquals(Commit.REJECTED, transaction.commit());
|
||||
verify(terrain, never()).set(anyInt(), anyInt(), anyInt(), any());
|
||||
verify(terrain, never()).set(anyInt(), anyInt(), anyInt(), any(), any());
|
||||
verify(terrain, never()).recordPlacement(anyInt(), anyInt(), anyInt(), anyString());
|
||||
verify(terrain, never()).recordPlacement(anyInt(), anyInt(), anyInt(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -68,9 +69,9 @@ public class TerrainTransactionTest {
|
||||
assertEquals(Commit.COMMITTED, transaction.commit());
|
||||
org.mockito.InOrder order = inOrder(terrain);
|
||||
order.verify(terrain).set(15, 101, 8, FIRST);
|
||||
order.verify(terrain).recordPlacement(15, 101, 8, "tree@7");
|
||||
order.verify(terrain).recordPlacement(15, 101, 8, TREE);
|
||||
order.verify(terrain).set(16, 101, 8, SECOND, LOOT);
|
||||
order.verify(terrain).recordPlacement(16, 101, 8, "tree@7");
|
||||
order.verify(terrain).recordPlacement(16, 101, 8, TREE);
|
||||
|
||||
assertEquals(Commit.EMPTY, transaction.commit());
|
||||
verify(terrain).set(16, 101, 8, SECOND, LOOT);
|
||||
@@ -78,9 +79,9 @@ public class TerrainTransactionTest {
|
||||
|
||||
private static void writeTreeAcrossTheChunkBorder(TerrainTransaction transaction) {
|
||||
transaction.set(15, 101, 8, FIRST);
|
||||
transaction.recordPlacement(15, 101, 8, "tree@7");
|
||||
transaction.recordPlacement(15, 101, 8, TREE);
|
||||
transaction.set(16, 101, 8, SECOND, LOOT);
|
||||
transaction.recordPlacement(16, 101, 8, "tree@7");
|
||||
transaction.recordPlacement(16, 101, 8, TREE);
|
||||
}
|
||||
|
||||
private static TerrainTransaction islandOver(PlacementTerrain terrain, boolean supportsNeighborChunk) {
|
||||
|
||||
+2
-1
@@ -4,6 +4,7 @@ import art.arcane.iris.builtin.carve.CarvingMode;
|
||||
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||
import art.arcane.iris.engine.object.TestSettings;
|
||||
import art.arcane.iris.builtin.prepare.SlopeClip;
|
||||
import art.arcane.iris.core.modules.ModuleObjectPlacement;
|
||||
import art.arcane.iris.engine.object.placement.IObjectPlacer;
|
||||
import art.arcane.iris.builtin.objects.ObjectPlacement;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
@@ -251,7 +252,7 @@ public class IrisObjectSurfaceSupportPlacementTest {
|
||||
}
|
||||
|
||||
private int place(SurfacePlacer placer, ObjectPlacement.Builder placement, int anchorY) {
|
||||
return object().place(0, anchorY, 0, placer, placement.build(), new RNG(1234L), data);
|
||||
return ModuleObjectPlacement.place(object(), 0, anchorY, 0, placer, placement.build(), new RNG(1234L), null, null, data).heightOrRejected();
|
||||
}
|
||||
|
||||
private ObjectPlacement.Builder placement(ObjectPlaceMode mode) {
|
||||
|
||||
+27
-22
@@ -139,7 +139,7 @@ public class ObjectPlacementRegressionTest {
|
||||
IrisObject object = lineObject(3);
|
||||
|
||||
IllegalStateException error = assertThrows(IllegalStateException.class,
|
||||
() -> object.place(0, ANCHOR_Y, 0, placer, placement().build(), new RNG(2L), data));
|
||||
() -> placed(object, 0, ANCHOR_Y, 0, placer, placement().build(), new RNG(2L), data));
|
||||
|
||||
assertTrue(error.getMessage().contains("write failed"));
|
||||
assertEquals(1, placer.writes().size());
|
||||
@@ -154,7 +154,7 @@ public class ObjectPlacementRegressionTest {
|
||||
placement.rotation(ObjectRotation.of(0, 90, 0));
|
||||
placement.translate(ObjectTranslate.of(4, 0, 3, 0));
|
||||
|
||||
int resultY = lineObject(3).place(0, ANCHOR_Y, 0, placer, placement.build(), new RNG(2L), data);
|
||||
int resultY = placed(lineObject(3), 0, ANCHOR_Y, 0, placer, placement.build(), new RNG(2L), data);
|
||||
|
||||
// The object's own blocks replace the bored air below, so only the extension stays air.
|
||||
List<BlockWrite> airWrites = placer.writesOf(keyOf(IrisObject.States.AIR));
|
||||
@@ -170,7 +170,7 @@ public class ObjectPlacementRegressionTest {
|
||||
IrisObject object = new IrisObject(5, 1, 5);
|
||||
object.setUnsigned(2, 0, 2, solid);
|
||||
|
||||
assertEquals(ANCHOR_Y, object.place(0, ANCHOR_Y, 0, placer, placement().bore(true).build(), new RNG(2L), data));
|
||||
assertEquals(ANCHOR_Y, placed(object, 0, ANCHOR_Y, 0, placer, placement().bore(true).build(), new RNG(2L), data));
|
||||
|
||||
assertEquals(24, placer.writesOf(keyOf(IrisObject.States.AIR)).size());
|
||||
}
|
||||
@@ -190,7 +190,7 @@ public class ObjectPlacementRegressionTest {
|
||||
placement.translate(ObjectTranslate.of(4, 0, 0, 0));
|
||||
placement.forbiddenCollisions(List.of("forbidden"));
|
||||
|
||||
int result = lineObject(3).place(0, ANCHOR_Y, 0, placer, placement.build(), new RNG(2L), data);
|
||||
int result = placed(lineObject(3), 0, ANCHOR_Y, 0, placer, placement.build(), new RNG(2L), data);
|
||||
|
||||
assertEquals(-1, result);
|
||||
assertTrue(placer.writes().isEmpty());
|
||||
@@ -203,7 +203,7 @@ public class ObjectPlacementRegressionTest {
|
||||
placement.mode(ObjectPlaceMode.MAX_HEIGHT);
|
||||
placement.rotation(ObjectRotation.of(0, 45, 0));
|
||||
|
||||
boxObject(5, 1, 3).place(0, -1, 0, placer, placement.build(), new RNG(2L), data);
|
||||
placed(boxObject(5, 1, 3), 0, -1, 0, placer, placement.build(), new RNG(2L), data);
|
||||
|
||||
assertTrue(placer.sampledColumns().contains("-2:-2"));
|
||||
assertTrue(placer.sampledColumns().contains("2:2"));
|
||||
@@ -219,7 +219,7 @@ public class ObjectPlacementRegressionTest {
|
||||
ObjectPlacement.Builder placement = placement();
|
||||
placement.snow(0.1);
|
||||
|
||||
object.place(0, ANCHOR_Y, 0, placer, placement.build(), new RNG(2L), data);
|
||||
placed(object, 0, ANCHOR_Y, 0, placer, placement.build(), new RNG(2L), data);
|
||||
|
||||
List<BlockWrite> snowWrites = placer.writesOf(keyOf(IrisObject.States.SNOW_LAYERS[0]));
|
||||
assertEquals(1, snowWrites.size());
|
||||
@@ -238,8 +238,8 @@ public class ObjectPlacementRegressionTest {
|
||||
SmartBoreDebugSettings shown = TestSettings.of(SmartBoreDebugSettings.class, "{\"show\":true}");
|
||||
when(engine.getDimension().getModuleSettings()).thenReturn(BuiltInPack.settings(shown));
|
||||
|
||||
object.place(0, ANCHOR_Y, 0, debug, placement.build(), new RNG(2L), data);
|
||||
object.place(0, ANCHOR_Y, 0, normal, placement.build(), new RNG(2L), data);
|
||||
placed(object, 0, ANCHOR_Y, 0, debug, placement.build(), new RNG(2L), data);
|
||||
placed(object, 0, ANCHOR_Y, 0, normal, placement.build(), new RNG(2L), data);
|
||||
|
||||
PlatformBlockState cachedState = object.getBlocks().get(object.getSigned(0, 0, 0));
|
||||
assertSame(IrisObject.States.VAIR, cachedState);
|
||||
@@ -249,7 +249,7 @@ public class ObjectPlacementRegressionTest {
|
||||
@Test
|
||||
public void placementDataIsRequiredAtTheBoundary() {
|
||||
NullPointerException error = assertThrows(NullPointerException.class,
|
||||
() -> lineObject(1).place(0, ANCHOR_Y, 0, new RecordingPlacer(null), placement().build(), new RNG(2L), null));
|
||||
() -> placed(lineObject(1), 0, ANCHOR_Y, 0, new RecordingPlacer(null), placement().build(), new RNG(2L), null));
|
||||
|
||||
assertEquals("Object placement data is required.", error.getMessage());
|
||||
}
|
||||
@@ -266,7 +266,7 @@ public class ObjectPlacementRegressionTest {
|
||||
config.rotation(ObjectRotation.of(0, 90, 0));
|
||||
config.translate(ObjectTranslate.of(4, 0, 0, 0));
|
||||
|
||||
lineObject(3).place(0, ANCHOR_Y + 4, 0, placer, config.build(), new RNG(2L), data);
|
||||
placed(lineObject(3), 0, ANCHOR_Y + 4, 0, placer, config.build(), new RNG(2L), data);
|
||||
|
||||
// Every bottom column reaches the ground after rotation and translation.
|
||||
for (int z = -5; z <= -3; z++) {
|
||||
@@ -285,7 +285,7 @@ public class ObjectPlacementRegressionTest {
|
||||
config.translate(ObjectTranslate.of(0, 3, 0, 0));
|
||||
config.stiltSettings(TestSettings.of(StiltSettings.class, "{\"organicJitter\":0,\"organicScratch\":0}"));
|
||||
|
||||
boxObject(1, 3, 1).place(0, ANCHOR_Y, 0, placer, config.build(), new RNG(2L), data);
|
||||
placed(boxObject(1, 3, 1), 0, ANCHOR_Y, 0, placer, config.build(), new RNG(2L), data);
|
||||
|
||||
assertEquals(solid.key(), placer.get(0, 82, 0).key());
|
||||
assertEquals(solid.key(), placer.get(0, 89, 0).key());
|
||||
@@ -300,7 +300,7 @@ public class ObjectPlacementRegressionTest {
|
||||
config.mode(ObjectPlaceMode.ORGANIC_STILT);
|
||||
config.stiltSettings(TestSettings.of(StiltSettings.class, "{\"organicJitter\":0,\"organicScratch\":0}"));
|
||||
|
||||
lineObject(1).place(0, ANCHOR_Y, 0, placer, config.build(), new RNG(2L), data);
|
||||
placed(lineObject(1), 0, ANCHOR_Y, 0, placer, config.build(), new RNG(2L), data);
|
||||
|
||||
for (int y = 76; y <= ANCHOR_Y; y++) {
|
||||
assertEquals(solid.key(), placer.get(0, y, 0).key());
|
||||
@@ -313,7 +313,7 @@ public class ObjectPlacementRegressionTest {
|
||||
RecordingPlacer placer = new RecordingPlacer(null);
|
||||
ObjectPlacement.Builder config = placement();
|
||||
config.mode(ObjectPlaceMode.ERODE_STILT);
|
||||
assertEquals(ANCHOR_Y, lineObject(1).place(0, -1, 0, placer, config.build(), new RNG(2L), data));
|
||||
assertEquals(ANCHOR_Y, placed(lineObject(1), 0, -1, 0, placer, config.build(), new RNG(2L), data));
|
||||
assertFalse(placer.writes().isEmpty());
|
||||
}
|
||||
|
||||
@@ -324,7 +324,7 @@ public class ObjectPlacementRegressionTest {
|
||||
RecordingPlacer placer = new RecordingPlacer(null);
|
||||
ObjectPlacement.Builder config = placement();
|
||||
config.mode(mode);
|
||||
assertEquals(ANCHOR_Y, lineObject(1).place(0, ANCHOR_Y, 0, placer, config.build(), new RNG(2L), data));
|
||||
assertEquals(ANCHOR_Y, placed(lineObject(1), 0, ANCHOR_Y, 0, placer, config.build(), new RNG(2L), data));
|
||||
assertTrue(mode.toString(), placer.sampledColumns().isEmpty());
|
||||
}
|
||||
}
|
||||
@@ -335,7 +335,7 @@ public class ObjectPlacementRegressionTest {
|
||||
usePack(List.of(new CapModule(writtenSizes)));
|
||||
RecordingPlacer placer = new RecordingPlacer(engine);
|
||||
|
||||
assertEquals(ANCHOR_Y, lineObject(3).place(0, ANCHOR_Y, 0, placer, placement().build(), new RNG(2L), data));
|
||||
assertEquals(ANCHOR_Y, placed(lineObject(3), 0, ANCHOR_Y, 0, placer, placement().build(), new RNG(2L), data));
|
||||
|
||||
assertEquals(List.of(3), writtenSizes);
|
||||
assertEquals(4, placer.writes().size());
|
||||
@@ -362,7 +362,7 @@ public class ObjectPlacementRegressionTest {
|
||||
ObjectPlacement.Builder config = placement();
|
||||
config.translate(ObjectTranslate.of(0, 0, 3, 0));
|
||||
|
||||
lineObject(1).place(0, ANCHOR_Y, 0, new RecordingPlacer(null), config.build(), rng, data);
|
||||
placed(lineObject(1), 0, ANCHOR_Y, 0, new RecordingPlacer(null), config.build(), rng, data);
|
||||
|
||||
assertEquals(expected.nextLong(), rng.nextLong());
|
||||
}
|
||||
@@ -373,8 +373,8 @@ public class ObjectPlacementRegressionTest {
|
||||
config.translate(ObjectTranslate.of(0, 0, 20, 0));
|
||||
RNG rng = new RNG(91);
|
||||
|
||||
int first = lineObject(1).place(5, ANCHOR_Y, 5, new RecordingPlacer(engine), config.build(), rng, data);
|
||||
int second = lineObject(1).place(5, ANCHOR_Y, 5, new RecordingPlacer(engine), config.build(), new RNG(3), data);
|
||||
int first = placed(lineObject(1), 5, ANCHOR_Y, 5, new RecordingPlacer(engine), config.build(), rng, data);
|
||||
int second = placed(lineObject(1), 5, ANCHOR_Y, 5, new RecordingPlacer(engine), config.build(), new RNG(3), data);
|
||||
|
||||
assertEquals(first, second);
|
||||
assertEquals(new RNG(91).nextLong(), rng.nextLong());
|
||||
@@ -547,7 +547,7 @@ public class ObjectPlacementRegressionTest {
|
||||
RecordingPlacer placer = new RecordingPlacer(null);
|
||||
ObjectPlacement.Builder config = placement();
|
||||
config.fromBottom(true);
|
||||
assertEquals(2, lineObject(1).place(0, -1, 0, placer, config.build(), new RNG(2L), data));
|
||||
assertEquals(2, placed(lineObject(1), 0, -1, 0, placer, config.build(), new RNG(2L), data));
|
||||
assertTrue(placer.sampledColumns().isEmpty());
|
||||
}
|
||||
|
||||
@@ -640,7 +640,7 @@ public class ObjectPlacementRegressionTest {
|
||||
config.translate(ObjectTranslate.of(0, 3, 0, 0));
|
||||
config.vacuumSettings(TestSettings.of(VacuumSettings.class, "{\"radius\":1}"));
|
||||
|
||||
object.place(0, ANCHOR_Y, 0, placer, config.build(), new RNG(2L), data);
|
||||
placed(object, 0, ANCHOR_Y, 0, placer, config.build(), new RNG(2L), data);
|
||||
|
||||
List<BlockWrite> center = placer.writes().stream().filter(write -> write.x() == 0 && write.z() == 0).toList();
|
||||
assertEquals(List.of(82, 81, 83), center.stream().map(BlockWrite::y).toList());
|
||||
@@ -662,7 +662,7 @@ public class ObjectPlacementRegressionTest {
|
||||
RNG rng = new RNG(91);
|
||||
RecordingPlacer placer = new RecordingPlacer(engine);
|
||||
|
||||
assertEquals(-1, lineObject(1).place(0, ANCHOR_Y, 0, placer, config.build(), rng, data));
|
||||
assertEquals(-1, placed(lineObject(1), 0, ANCHOR_Y, 0, placer, config.build(), rng, data));
|
||||
assertEquals(new RNG(91).nextLong(), rng.nextLong());
|
||||
assertTrue(placer.writes().isEmpty());
|
||||
}
|
||||
@@ -680,7 +680,7 @@ public class ObjectPlacementRegressionTest {
|
||||
ObjectRotation original = placement.rotation();
|
||||
RecordingPlacer placer = new RecordingPlacer(engine);
|
||||
|
||||
lineObject(3).place(0, ANCHOR_Y, 0, placer, placement, new RNG(2L), data);
|
||||
placed(lineObject(3), 0, ANCHOR_Y, 0, placer, placement, new RNG(2L), data);
|
||||
|
||||
assertSame(original, placement.rotation());
|
||||
assertEquals(0, original.yAxis().min(), 0);
|
||||
@@ -689,6 +689,11 @@ public class ObjectPlacementRegressionTest {
|
||||
assertEquals(List.of(-1, 0, 1), placer.writes().stream().map(BlockWrite::z).sorted().toList());
|
||||
}
|
||||
|
||||
/** The height {@code object} was placed at, or -1 when the placement rejected it. */
|
||||
private static int placed(IrisObject object, int x, int y, int z, IObjectPlacer placer, ObjectPlacement config, RNG rng, IrisData data) {
|
||||
return ModuleObjectPlacement.place(object, x, y, z, placer, config, rng, null, null, data).heightOrRejected();
|
||||
}
|
||||
|
||||
private ObjectPlacementResult place(ObjectPlacement.Builder config, int y, RecordingPlacer placer, CarveResult cave) {
|
||||
return ModuleObjectPlacement.place(lineObject(1), 0, y, 0, placer, config.build(), new RNG(2L), null, cave, data);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
package art.arcane.iris.engine.object.prefab;
|
||||
|
||||
import art.arcane.iris.engine.object.placement.IObjectPlacer;
|
||||
import art.arcane.iris.spi.IrisPlatform;
|
||||
import art.arcane.iris.spi.IrisPlatforms;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.spi.PlatformRegistries;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/** A paste writes the object's blocks around a spot, turned, with no placement rule. */
|
||||
public class IrisObjectPasteTest {
|
||||
private static final int SPOT_X = 10;
|
||||
private static final int SPOT_Y = 64;
|
||||
private static final int SPOT_Z = 10;
|
||||
|
||||
private PlatformBlockState stone;
|
||||
private PlatformBlockState air;
|
||||
private IObjectPlacer placer;
|
||||
|
||||
@Before
|
||||
public void bindPlatform() {
|
||||
IrisPlatforms.unbind();
|
||||
stone = state("minecraft:stone", false);
|
||||
air = state("minecraft:air", true);
|
||||
PlatformRegistries registries = mock(PlatformRegistries.class);
|
||||
when(registries.block(anyString())).thenAnswer(call -> call.<String>getArgument(0).contains("air") ? air : stone);
|
||||
IrisPlatform platform = mock(IrisPlatform.class);
|
||||
when(platform.registries()).thenReturn(registries);
|
||||
IrisPlatforms.bind(platform);
|
||||
placer = mock(IObjectPlacer.class);
|
||||
}
|
||||
|
||||
@After
|
||||
public void unbindPlatform() {
|
||||
IrisPlatforms.unbind();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writesEveryBlockAroundTheSpotAndLeavesAirOut() {
|
||||
IrisObject object = new IrisObject(3, 1, 1);
|
||||
object.setUnsigned(0, 0, 0, stone);
|
||||
object.setUnsigned(1, 0, 0, stone);
|
||||
object.setUnsigned(2, 0, 0, air);
|
||||
|
||||
int written = object.paste(SPOT_X, SPOT_Y, SPOT_Z, placer, ObjectTurn.NONE);
|
||||
|
||||
assertEquals(2, written);
|
||||
verify(placer).set(SPOT_X + offsetOf(object, 0), SPOT_Y, SPOT_Z, stone);
|
||||
verify(placer).set(SPOT_X + offsetOf(object, 1), SPOT_Y, SPOT_Z, stone);
|
||||
verify(placer, never()).set(anyInt(), anyInt(), anyInt(), eq(air));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aQuarterTurnAboutYSwapsTheOffsets() {
|
||||
IrisObject object = new IrisObject(3, 1, 1);
|
||||
object.setUnsigned(0, 0, 0, stone);
|
||||
object.setUnsigned(2, 0, 0, stone);
|
||||
|
||||
object.paste(SPOT_X, SPOT_Y, SPOT_Z, placer, ObjectTurn.of(0, 90, 0));
|
||||
|
||||
int centre = object.getCenter().getBlockX();
|
||||
verify(placer).set(SPOT_X, SPOT_Y, SPOT_Z + centre, stone);
|
||||
verify(placer).set(SPOT_X, SPOT_Y, SPOT_Z - (2 - centre), stone);
|
||||
verify(placer, never()).setTile(anyInt(), anyInt(), anyInt(), any());
|
||||
}
|
||||
|
||||
/** Where the block set at x = {@code index} lies from the spot: the object's blocks are kept around its centre. */
|
||||
private static int offsetOf(IrisObject object, int index) {
|
||||
return index - object.getCenter().getBlockX();
|
||||
}
|
||||
|
||||
private static PlatformBlockState state(String key, boolean isAir) {
|
||||
PlatformBlockState state = mock(PlatformBlockState.class);
|
||||
when(state.key()).thenReturn(key);
|
||||
when(state.materialKey()).thenReturn(key);
|
||||
when(state.isAir()).thenReturn(isAir);
|
||||
when(state.isSolid()).thenReturn(!isAir);
|
||||
return state;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package art.arcane.iris.engine.object.prefab;
|
||||
|
||||
import art.arcane.iris.builtin.prepare.ObjectRotation;
|
||||
import art.arcane.iris.engine.object.value.IrisDirection;
|
||||
import art.arcane.volmlib.util.math.IrisBlockVector;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/** The core object model turns what the built-in modules' placement rotation locked to the same angles turns. */
|
||||
public class ObjectTurnTest {
|
||||
private static final double[] ANGLES = {0, 90, 180, 270, -90, -180, -270, 360, 45, 30, -45, 135};
|
||||
private static final int[] COORDINATES = {-3, 0, 2};
|
||||
|
||||
@Test
|
||||
public void turnsPositionsLikeTheLockedPlacementRotation() {
|
||||
for (double x : ANGLES) {
|
||||
for (double y : ANGLES) {
|
||||
for (double z : ANGLES) {
|
||||
ObjectTurn turn = ObjectTurn.of(x, y, z);
|
||||
ObjectRotation rotation = ObjectRotation.of(x, y, z);
|
||||
for (int px : COORDINATES) {
|
||||
for (int py : COORDINATES) {
|
||||
for (int pz : COORDINATES) {
|
||||
IrisBlockVector expected = rotation.rotate(new IrisBlockVector(px, py, pz), 0, 0, 0);
|
||||
IrisBlockVector actual = turn.rotate(new IrisBlockVector(px, py, pz));
|
||||
String at = x + "," + y + "," + z + " of " + px + "," + py + "," + pz;
|
||||
assertEquals(at, expected.getX(), actual.getX(), 0D);
|
||||
assertEquals(at, expected.getY(), actual.getY(), 0D);
|
||||
assertEquals(at, expected.getZ(), actual.getZ(), 0D);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void turnsDirectionsLikeTheLockedPlacementRotation() {
|
||||
for (double y : ANGLES) {
|
||||
for (IrisDirection direction : IrisDirection.values()) {
|
||||
assertEquals(y + " " + direction, ObjectRotation.of(0, y, 0).rotate(direction), ObjectTurn.of(0, y, 0).rotate(direction));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aTurnOfNothingHandsBackThePositionItself() {
|
||||
IrisBlockVector position = new IrisBlockVector(1, 2, 3);
|
||||
|
||||
assertFalse(ObjectTurn.NONE.canRotate());
|
||||
assertSame(position, ObjectTurn.NONE.rotate(position));
|
||||
assertTrue(ObjectTurn.of(0, 90, 0).canRotate());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void theBlockTurnTurnsDirections() {
|
||||
com.volmit.block.BlockTurn.Direction north = ObjectTurn.of(0, 90, 0).blockTurn().turn(0, 0, -1);
|
||||
|
||||
assertEquals(-1D, north.x(), 0D);
|
||||
assertEquals(0D, north.y(), 0D);
|
||||
assertEquals(0D, north.z(), 0D);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package art.arcane.iris.engine.object.prefab;
|
||||
|
||||
import art.arcane.iris.builtin.objects.ScaleInterpolation;
|
||||
import com.volmit.object.ScaleMethod;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.framework.EngineGeneration;
|
||||
@@ -33,9 +33,9 @@ public class ScaledObjectsCacheTest {
|
||||
1D,
|
||||
1D,
|
||||
7,
|
||||
ScaleInterpolation.NONE
|
||||
ScaleMethod.NONE
|
||||
);
|
||||
private static final ScaledObjects.ScaleRequest RANGED = new ScaledObjects.ScaleRequest(1D, 1D, 2D, 4, ScaleInterpolation.NONE);
|
||||
private static final ScaledObjects.ScaleRequest RANGED = new ScaledObjects.ScaleRequest(1D, 1D, 2D, 4, ScaleMethod.NONE);
|
||||
|
||||
private Engine engine;
|
||||
|
||||
@@ -229,7 +229,7 @@ public class ScaledObjectsCacheTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IrisObject scaled(double scale, ScaleInterpolation interpolation) {
|
||||
public IrisObject scaled(double scale, ScaleMethod interpolation) {
|
||||
scaleCalls.incrementAndGet();
|
||||
firstScaleEntered.countDown();
|
||||
try {
|
||||
@@ -252,7 +252,7 @@ public class ScaledObjectsCacheTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IrisObject scaled(double scale, ScaleInterpolation interpolation) {
|
||||
public IrisObject scaled(double scale, ScaleMethod interpolation) {
|
||||
scaleCalls.incrementAndGet();
|
||||
return new IrisObject(1_000, 1_000, 1_000);
|
||||
}
|
||||
|
||||
+10
-5
@@ -1,6 +1,7 @@
|
||||
package art.arcane.iris.engine.object.structure.vanilla;
|
||||
|
||||
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||
import art.arcane.iris.core.modules.ModuleObjectPlacement;
|
||||
import art.arcane.iris.engine.object.placement.IObjectPlacer;
|
||||
import art.arcane.iris.builtin.objects.ObjectPlacement;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
@@ -173,13 +174,13 @@ public class NativeStructureObjectVetoTest {
|
||||
volumes(volume(-64, -64, -64, 64, 320, 64));
|
||||
|
||||
RecordingPlacer vetoed = new RecordingPlacer(engine);
|
||||
assertEquals(-1, tree().place(0, SURFACE_Y, 0, vetoed, placement(), new RNG(1234L), data));
|
||||
assertEquals(-1, placed(0, SURFACE_Y, vetoed, placement()));
|
||||
assertTrue(vetoed.written().isEmpty());
|
||||
|
||||
RecordingPlacer exempt = new RecordingPlacer(engine);
|
||||
ObjectPlacement structurePiece = placement().toBuilder().mode(ObjectPlaceMode.STRUCTURE_PIECE).build();
|
||||
|
||||
assertTrue(tree().place(0, SURFACE_Y, 0, exempt, structurePiece, new RNG(1234L), data) >= 0);
|
||||
assertTrue(placed(0, SURFACE_Y, exempt, structurePiece) >= 0);
|
||||
assertFalse(exempt.written().isEmpty());
|
||||
}
|
||||
|
||||
@@ -189,7 +190,7 @@ public class NativeStructureObjectVetoTest {
|
||||
volumes(volume(-64, -64, -64, 64, 320, 64));
|
||||
ObjectPlacement placement = placement().toBuilder().forcePlace(true).build();
|
||||
|
||||
assertEquals(-1, tree().place(0, -1, 0, placer, placement, new RNG(1234L), data));
|
||||
assertEquals(-1, placed(0, -1, placer, placement));
|
||||
assertTrue(placer.written().isEmpty());
|
||||
}
|
||||
|
||||
@@ -199,7 +200,7 @@ public class NativeStructureObjectVetoTest {
|
||||
volumes(volume(-64, -64, -64, 64, 320, 64));
|
||||
ObjectPlacement placement = placement().toBuilder().mode(ObjectPlaceMode.STRUCTURE_PIECE).build();
|
||||
|
||||
assertTrue(tree().place(0, 100, 0, placer, placement, new RNG(1234L), data) >= 0);
|
||||
assertTrue(placed(0, 100, placer, placement) >= 0);
|
||||
assertFalse(placer.written().isEmpty());
|
||||
}
|
||||
|
||||
@@ -228,7 +229,11 @@ public class NativeStructureObjectVetoTest {
|
||||
}
|
||||
|
||||
private int place(RecordingPlacer placer) {
|
||||
return tree().place(0, -1, 0, placer, placement(), new RNG(1234L), data);
|
||||
return placed(0, -1, placer, placement());
|
||||
}
|
||||
|
||||
private int placed(int x, int y, RecordingPlacer placer, ObjectPlacement config) {
|
||||
return ModuleObjectPlacement.place(tree(), x, y, 0, placer, config, new RNG(1234L), null, null, data).heightOrRejected();
|
||||
}
|
||||
|
||||
private ObjectPlacement placement() {
|
||||
|
||||
+2
-2
@@ -24,7 +24,7 @@ import art.arcane.iris.engine.object.value.IrisDirection;
|
||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawConnector;
|
||||
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.builtin.prepare.ObjectRotation;
|
||||
import art.arcane.iris.engine.object.prefab.ObjectTurn;
|
||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
||||
import art.arcane.iris.engine.object.structure.jigsaw.JigsawJoint;
|
||||
import art.arcane.iris.engine.object.prefab.TileData;
|
||||
@@ -569,7 +569,7 @@ public class JigsawStudioGeneratorTest {
|
||||
|
||||
private static String renderFinalState(
|
||||
String finalState,
|
||||
ObjectRotation rotation,
|
||||
ObjectTurn rotation,
|
||||
int quarterTurns
|
||||
) {
|
||||
if (finalState.equals("minecraft:not_a_real_block")) {
|
||||
|
||||
@@ -48,6 +48,9 @@ import static org.mockito.Mockito.when;
|
||||
* texts as {@code ""}, other absent values as {@code null}, tables by key) still hashed to the old number, -819231818.
|
||||
* It was retaken again when the spec was grouped, its keys became ids and content keys and the Iris-only knobs an
|
||||
* extension: the spec printed the old way (flat fields, keys as written, operations by Bukkit name) still hashed to 1441930785.
|
||||
* It was retaken a third time when the five Iris-only knobs left the extension for the spec (the panda genes in the
|
||||
* appearance, the reason and rising out of the ground in the arrival, applying to a provided mob on the spec): the spec
|
||||
* printed the old way (those fields in an {@code IrisEntityExtras} extension, no new fields) still hashed to -847596166.
|
||||
*/
|
||||
public class EntityResolutionPinTest {
|
||||
private static final long STREAM_SEED = 4321L;
|
||||
@@ -84,7 +87,7 @@ public class EntityResolutionPinTest {
|
||||
EntitySpec spec = new EntityResolution(resources, new LootItems(registry, false, log), sky, new EffectTimers(), log)
|
||||
.resolve(entity, new RNG(STREAM_SEED)).orElseThrow();
|
||||
|
||||
assertEquals(-847596166, spec.toString().hashCode());
|
||||
assertEquals(383685705, spec.toString().hashCode());
|
||||
}
|
||||
|
||||
private static ContentKey platformItem(String name) {
|
||||
|
||||
@@ -25,7 +25,6 @@ import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.framework.EngineGeneration;
|
||||
import art.arcane.iris.engine.framework.SeedManager;
|
||||
import art.arcane.iris.builtin.spawn.EntityDefinition;
|
||||
import art.arcane.iris.builtin.spawn.IrisEntityExtras;
|
||||
import art.arcane.iris.builtin.spawn.SpawnMarker;
|
||||
import art.arcane.iris.builtin.spawn.Spawner;
|
||||
import art.arcane.iris.engine.object.TestSettings;
|
||||
@@ -162,14 +161,14 @@ public class EntitySpawningTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aMobOfAnotherProviderIsProvidedByNameWithItsIrisExtras() {
|
||||
public void aMobOfAnotherProviderIsProvidedByNameWithItsSpawnReason() {
|
||||
fixture.resource(SpawnResources.ENTITIES, "king", TestSettings.of(EntityDefinition.class,
|
||||
"{\"type\": \"minecraft:zombie\", \"specialType\": \"MythicMobs:Skeleton King\", \"reason\": \"CUSTOM\"}"));
|
||||
|
||||
EntitySpec spec = new EntitySpawning().entity(world, world.resources().idOf("king")).orElseThrow();
|
||||
|
||||
assertEquals(new ContentKey.Provided("MythicMobs", "Skeleton King"), spec.type());
|
||||
assertEquals(Optional.of("CUSTOM"), spec.extension(IrisEntityExtras.class).orElseThrow().reason());
|
||||
assertEquals(Optional.of("CUSTOM"), spec.arrival().reason());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -80,8 +80,7 @@ import static org.junit.Assert.fail;
|
||||
* deleted) and {@code Particles} (Bukkit registry lookups in a static initializer).
|
||||
* <p>
|
||||
* <b>Deliberately not asserted:</b> method and constructor descriptors. These classes legitimately
|
||||
* expose a Bukkit-typed edge that only the Bukkit adapter calls - {@code BlockStateRotation.rotate(ObjectRotation, BlockData,
|
||||
* ...)}, {@code TileData.toBukkit(Block)} and ~60 more. Method descriptors are resolved at
|
||||
* expose a Bukkit-typed edge that only the Bukkit adapter calls - {@code BlockStateRotation.rotate(BlockTurn, BlockData)}, {@code TileData.toBukkit(Block)} and ~60 more. Method descriptors are resolved at
|
||||
* invocation, never at class load, field walk or equals/hashCode/toString, so they are not a modded
|
||||
* boot hazard. Fields and supertypes are, and both are asserted hard below.
|
||||
*/
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
package art.arcane.iris.probe;
|
||||
|
||||
import art.arcane.iris.builtin.prepare.ObjectRotation;
|
||||
import art.arcane.iris.engine.object.prefab.ObjectTurn;
|
||||
import art.arcane.iris.engine.object.material.BlockDataMergeSupport;
|
||||
import art.arcane.iris.engine.object.prefab.BlockStateRotation;
|
||||
import art.arcane.iris.engine.object.prefab.TileData;
|
||||
@@ -66,11 +66,11 @@ public final class StubPlatform implements IrisPlatform {
|
||||
TileData.bindPlatformFactory(StubTileData::fromProperties);
|
||||
}
|
||||
|
||||
static PlatformBlockState rotateForTest(ObjectRotation rotation, PlatformBlockState state) {
|
||||
static PlatformBlockState rotateForTest(ObjectTurn rotation, PlatformBlockState state) {
|
||||
if (rotation == null || !rotation.canRotate()) {
|
||||
return state;
|
||||
}
|
||||
return rotateState(BlockStateRotation.turnOf(rotation, 0, 0, 0), state);
|
||||
return rotateState(rotation.blockTurn(), state);
|
||||
}
|
||||
|
||||
static PlatformBlockState mergeForTest(PlatformBlockState base, PlatformBlockState update) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package art.arcane.iris.probe;
|
||||
|
||||
import art.arcane.iris.builtin.prepare.ObjectRotation;
|
||||
import art.arcane.iris.engine.object.prefab.ObjectTurn;
|
||||
import art.arcane.iris.spi.IrisPlatforms;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.spi.PlatformFace;
|
||||
@@ -23,7 +23,7 @@ public final class StubPlatformStateTest {
|
||||
|
||||
@Test
|
||||
public void rotatesFacingAxisAndConnectedFaces() {
|
||||
ObjectRotation rotation = ObjectRotation.of(0, 90, 0);
|
||||
ObjectTurn rotation = ObjectTurn.of(0, 90, 0);
|
||||
|
||||
assertEquals("minecraft:oak_stairs[facing=west,half=bottom]",
|
||||
StubPlatform.rotateForTest(rotation, state("minecraft:oak_stairs[facing=north,half=bottom]")).key());
|
||||
|
||||
Reference in new issue
Block a user