Show which structure piece a dust-inspected block belongs to

Jigsaw pieces record a placement marker only on storage blocks, so the
dust called every other piece block "decoration/object/stilt". Where no
marker exists, the dust now asks the modules: ObjectsAt.placementAt is
a new default API method, and the structure module answers it by
assembling the starts within structure reach again and returning the
piece whose box holds the block. A lone surface piece takes its height
from the terrain when placed, so only its column has to match.

The Bukkit and modded dust both print "Placed by: structure '<key>'
piece '<object>'", translated in every bundled locale.
This commit is contained in:
piexel committed 2026-11-11 18:05:49 +01:00
1 parent e9b80420de
commit f4821f7b0d
29 files changed
+354 -28

No files matched your search

@@ -21,6 +21,7 @@ package art.arcane.iris.modded.command;
import art.arcane.iris.modded.ModdedIrisLog;
import art.arcane.iris.core.localization.IrisLanguage;
import art.arcane.iris.core.localization.RuntimeUiMessages;
import art.arcane.iris.core.modules.ModuleServices;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.framework.GenerationSessionException;
import art.arcane.iris.engine.framework.GenerationSessionLease;
@@ -253,6 +254,8 @@ public final class ModdedDustRevealer {
String objectKey = safe(
"object lookup at " + coordinates(pos),
() -> engine.getObjectPlacementKey(x, relativeY, z));
ModuleServices.PlannedPlacement structurePiece = objectKey == null
? plannedStructurePiece(engine, pos, x, relativeY, z) : null;
IrisBiome surfaceBiome = safe(
"surface biome lookup at " + x + ", " + z,
() -> engine.getSurfaceBiome(x, z));
@@ -279,8 +282,9 @@ public final class ModdedDustRevealer {
), false));
if (offset != null && surfaceY != null) {
lines.add(new DustLine(positionLine(offset, surfaceY), true));
lines.add(new DustLine(
placementLine(offset, surfaceRelative, relativeY, objectKey), true));
lines.add(new DustLine(structurePiece != null
? structurePieceLine(structurePiece)
: placementLine(offset, surfaceRelative, relativeY, objectKey), true));
}
lines.add(new DustLine(IrisLanguage.plain(
RuntimeUiMessages.DUST_OBJECT_AT_BLOCK,
@@ -290,7 +294,7 @@ public final class ModdedDustRevealer {
? IrisLanguage.plain(RuntimeUiMessages.DUST_NONE)
: objectKey)
), false));
if (objectKey == null) {
if (objectKey == null && structurePiece == null) {
String columnObject = findColumnObject(engine, x, relativeY, z, minHeight);
lines.add(new DustLine(IrisLanguage.plain(
columnObject == null
@@ -388,6 +392,21 @@ public final class ModdedDustRevealer {
MessageArgument.trusted("depth", Math.max(0, surfaceRelative - relativeY)));
}
static String structurePieceLine(ModuleServices.PlannedPlacement structurePiece) {
return IrisLanguage.plain(
RuntimeUiMessages.DUST_PLACED_BY_STRUCTURE_PIECE,
MessageArgument.untrusted("structure", structurePiece.structure().orElseThrow()),
MessageArgument.untrusted("object", structurePiece.object()));
}
/** The structure piece a module plans at the block, where generation recorded none; null when no piece covers it. */
private static ModuleServices.PlannedPlacement plannedStructurePiece(Engine engine, BlockPos pos, int x, int relativeY, int z) {
ModuleServices.PlannedPlacement planned = safe(
"structure piece lookup at " + coordinates(pos),
() -> ModuleServices.plannedPlacementAt(engine, x, relativeY, z).orElse(null));
return planned != null && planned.structure().isPresent() ? planned : null;
}
private static String findColumnObject(Engine engine, int x, int relativeY,
int z, int minHeight) {
int maxRelativeY = engine.getMaxHeight() - minHeight - 1;
@@ -1,8 +1,10 @@
package com.volmit.service;
import com.volmit.placement.PlacementRecord;
import com.volmit.resource.ResourceId;
import com.volmit.world.PackWorld;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
/** Which pack objects a module places, predicted without generating anything. The host's object search and its
@@ -26,6 +28,17 @@ public interface ObjectsAt {
*/
PlacedBy placedBy(PackWorld world, ResourceId object);
/**
* The placement this module plans to cover the block at {@code worldX}, {@code y}, {@code worldZ}, as
* {@link com.volmit.placement.PlacementTerrain#recordPlacement} would record it, predicted without generating
* anything. Y is the height above the dimension's bottom. The host's block inspection asks for it where generation
* recorded nothing at the block ({@link com.volmit.world.RunningWorld#placementAt}). Like {@link #objectsAt}, it is
* a prediction. Empty when the module plans nothing there.
*/
default Optional<PlacementRecord> placementAt(PackWorld world, int worldX, int y, int worldZ) {
return Optional.empty();
}
/** Layout entries that place an object, by their pack ids. */
record PlacedBy(Set<ResourceId> biomes, Set<ResourceId> regions) {
public static final PlacedBy NOTHING = new PlacedBy(Set.of(), Set.of());
@@ -22,6 +22,7 @@ import art.arcane.iris.platform.bukkit.BukkitPlatform;
import art.arcane.iris.spi.IrisLogging;
import art.arcane.iris.core.localization.IrisLanguage;
import art.arcane.iris.core.localization.RuntimeUiMessages;
import art.arcane.iris.core.modules.ModuleServices;
import art.arcane.iris.core.nms.INMS;
import art.arcane.iris.core.tools.IrisToolbelt;
import art.arcane.iris.engine.framework.Engine;
@@ -196,8 +197,16 @@ public class DustRevealer {
), true));
}
ModuleServices.PlannedPlacement structurePiece = objectKey == null
? plannedStructurePiece(engine, x, relativeY, z) : null;
String placedBy;
if (offset > 0) {
if (structurePiece != null) {
placedBy = IrisLanguage.text(
RuntimeUiMessages.DUST_PLACED_BY_STRUCTURE_PIECE,
MessageArgument.untrusted("structure", structurePiece.structure().orElseThrow()),
MessageArgument.untrusted("object", structurePiece.object())
);
} else if (offset > 0) {
placedBy = objectKey != null
? IrisLanguage.text(
RuntimeUiMessages.DUST_PLACED_BY_OBJECT_ABOVE,
@@ -223,7 +232,7 @@ public class DustRevealer {
objectKey == null ? IrisLanguage.text(RuntimeUiMessages.DUST_NONE) : objectKey
)
), false));
if (objectKey == null) {
if (objectKey == null && structurePiece == null) {
String columnObject = findColumnObject(engine, x, relativeY, z, minHeight);
lines.add(new DustLine(IrisLanguage.text(
columnObject == null
@@ -336,6 +345,12 @@ public class DustRevealer {
}
}
/** The structure piece a module plans at the block, where generation recorded none; null when no piece covers it. */
private static ModuleServices.PlannedPlacement plannedStructurePiece(Engine engine, int x, int relativeY, int z) {
ModuleServices.PlannedPlacement planned = safe(() -> ModuleServices.plannedPlacementAt(engine, x, relativeY, z).orElse(null));
return planned != null && planned.structure().isPresent() ? planned : null;
}
private static <T> T safe(Supplier<T> supplier) {
try {
return supplier.get();
@@ -76,6 +76,7 @@ public final class RuntimeUiMessages {
public static final TextKey DUST_PLACED_BY_DECORATION_ABOVE = text("iris.runtime.dust.placed_by.decoration_above");
public static final TextKey DUST_PLACED_BY_BURIED_OBJECT = text("iris.runtime.dust.placed_by.buried_object");
public static final TextKey DUST_PLACED_BY_TERRAIN = text("iris.runtime.dust.placed_by.terrain");
public static final TextKey DUST_PLACED_BY_STRUCTURE_PIECE = text("iris.runtime.dust.placed_by.structure_piece");
public static final TextKey DUST_COLUMN_OBJECT = text("iris.runtime.dust.column_object");
public static final TextKey DUST_COLUMN_OBJECT_NONE = text("iris.runtime.dust.column_object_none");
public static final TextKey DUST_COLUMN_NONE = text("iris.runtime.dust.column_none");
@@ -24,6 +24,7 @@ import com.volmit.host.FeatureCatalog;
import com.volmit.host.ServiceRegistration;
import com.volmit.entity.EntitySpec;
import com.volmit.item.ItemDrop;
import com.volmit.placement.PlacementRecord;
import com.volmit.resource.PackResources;
import com.volmit.resource.ResourceId;
import com.volmit.service.AmbientEffects;
@@ -121,6 +122,27 @@ public final class ModuleServices {
return keys;
}
/**
* The object, and the structure it is a piece of, that a module plans at the block, as pack keys; empty when none
* plans one. Y is the height above the dimension's bottom.
*/
public static Optional<PlannedPlacement> plannedPlacementAt(Engine engine, int x, int y, int z) {
IrisPackResources resources = engine.getData().getPackResources();
for (Provider<ObjectsAt> provider : providers(engine, ObjectsAt.class)) {
Optional<PlacementRecord> planned = provider.service().placementAt(provider.world(), x, y, z);
if (planned.isPresent()) {
return planned.map(record -> new PlannedPlacement(
resources.keyOf(PackResources.OBJECTS, record.object()),
record.structure().map(resources::keyOf)));
}
}
return Optional.empty();
}
/** A placement a module plans at a block: the object's key and, for a structure piece, the structure's. */
public record PlannedPlacement(String object, Optional<String> structure) {
}
/** The keys of the biomes and regions of the engine's layout that every module says place the object {@code objectKey}. */
public static ObjectPlacers objectPlacers(Engine engine, String objectKey) {
IrisPackResources resources = engine.getData().getPackResources();
@@ -946,6 +946,7 @@
"iris.runtime.dust.none": "keine",
"iris.runtime.dust.placed_by.object_above": "Platziert von: Objekt / Stelze '{object}' (über der Oberfläche)",
"iris.runtime.dust.placed_by.decoration_above": "Platziert von: Dekoration/Objekt/Stelze (über der Oberfläche)",
"iris.runtime.dust.placed_by.structure_piece": "Platziert von: Struktur '{structure}', Teil '{object}'",
"iris.runtime.dust.placed_by.buried_object": "Platziert von: begrabenes Objekt '{object}'",
"iris.runtime.dust.placed_by.terrain": "Platziert von: Geländeschicht (Tiefe {depth} unter der Oberfläche)",
"iris.runtime.dust.column_object": "Spaltenobjekt: {object} -> Dieser Block ist wahrscheinlich die Stelze dieses Objekts",
@@ -946,6 +946,7 @@
"iris.runtime.dust.none": "ninguno",
"iris.runtime.dust.placed_by.object_above": "Colocado por: objeto/pilar '{object}' (sobre la superficie)",
"iris.runtime.dust.placed_by.decoration_above": "Colocado por: decoración/objeto/pilar (sobre la superficie)",
"iris.runtime.dust.placed_by.structure_piece": "Colocado por: estructura '{structure}', pieza '{object}'",
"iris.runtime.dust.placed_by.buried_object": "Colocado por: objeto enterrado '{object}'",
"iris.runtime.dust.placed_by.terrain": "Colocado por: capa de terreno (profundidad {depth} bajo la superficie)",
"iris.runtime.dust.column_object": "Objeto de la columna: {object} -> este bloque probablemente sea el pilar de ese objeto",
@@ -946,6 +946,7 @@
"iris.runtime.dust.none": "ei yhtään",
"iris.runtime.dust.placed_by.object_above": "Sijaitsee: esine/kallistus '{object}\" (pinnan yläpuolella)",
"iris.runtime.dust.placed_by.decoration_above": "Sijaitsee: sisustus/objekti/kalleus (pinnan yläpuolella)",
"iris.runtime.dust.placed_by.structure_piece": "Sijaitsee: rakennelma '{structure}', osa '{object}'",
"iris.runtime.dust.placed_by.buried_object": "Paikka: haudattu esine '{object}'",
"iris.runtime.dust.placed_by.terrain": "Sijaitsee: maastokerros (syvyys {depth} pinnan alla)",
"iris.runtime.dust.column_object": "Sarake: {object} -> Tämä lohko on todennäköisesti objektin puujuurta",
@@ -946,6 +946,7 @@
"iris.runtime.dust.none": "aucune",
"iris.runtime.dust.placed_by.object_above": "Placé par : objet/pilotis '{object}' (au-dessus de la surface)",
"iris.runtime.dust.placed_by.decoration_above": "Placé par : décoration/objet/pilotis (au-dessus de la surface)",
"iris.runtime.dust.placed_by.structure_piece": "Placé par : structure '{structure}', pièce '{object}'",
"iris.runtime.dust.placed_by.buried_object": "Placé par : objet enterré '{object}'",
"iris.runtime.dust.placed_by.terrain": "Placé par : couche de terrain (profondeur {depth} sous la surface)",
"iris.runtime.dust.column_object": "Objet de la colonne : {object} -> ce bloc est probablement le pilotis de cet objet",
@@ -946,6 +946,7 @@
"iris.runtime.dust.none": "אף אחד לא",
"iris.runtime.dust.placed_by.object_above": "הוצב על ידי: object/stilt '{object}' (מעל פני השטח)",
"iris.runtime.dust.placed_by.decoration_above": "הוצב על ידי: decoration/object/stilt (מעל פני השטח)",
"iris.runtime.dust.placed_by.structure_piece": "הוצב על ידי: מבנה '{structure}', חלק '{object}'",
"iris.runtime.dust.placed_by.buried_object": "מקום: קבור אובייקט{object}'",
"iris.runtime.dust.placed_by.terrain": "מיקום: שכבת שטח (מעמיקה {depth} מתחת לפני השטח)",
"iris.runtime.dust.column_object": "עמוד: {object} -> בלוק זה הוא כנראה המבצר של האובייקט",
@@ -946,6 +946,7 @@
"iris.runtime.dust.none": "Nessuno",
"iris.runtime.dust.placed_by.object_above": "Posizionato da: oggetto/pilastro '{object}' (sopra la superficie)",
"iris.runtime.dust.placed_by.decoration_above": "Posizionato da: decorazione/oggetto/pilastro (sopra la superficie)",
"iris.runtime.dust.placed_by.structure_piece": "Posizionato da: struttura '{structure}', pezzo '{object}'",
"iris.runtime.dust.placed_by.buried_object": "Posizionato da: oggetto sepolto '{object}'",
"iris.runtime.dust.placed_by.terrain": "Posizionato da: strato terreno (profondità {depth} sotto superficie)",
"iris.runtime.dust.column_object": "Oggetto della colonna: {object} -> questo blocco è probabilmente il pilastro dell'oggetto",
@@ -946,6 +946,7 @@
"iris.runtime.dust.none": "なし",
"iris.runtime.dust.placed_by.object_above": "配置元: object/stilt '{object}'(地表より上)",
"iris.runtime.dust.placed_by.decoration_above": "配置元: decoration/object/stilt(地表より上)",
"iris.runtime.dust.placed_by.structure_piece": "配置元: 構造物 '{structure}' のパーツ '{object}'",
"iris.runtime.dust.placed_by.buried_object": "配置元: 埋設オブジェクト '{object}'",
"iris.runtime.dust.placed_by.terrain": "配置元: 地形レイヤー(地表からの深さ {depth})",
"iris.runtime.dust.column_object": "列のオブジェクト: {object} -> このブロックはそのオブジェクトの支柱である可能性があります",
@@ -946,6 +946,7 @@
"iris.runtime.dust.none": "없음",
"iris.runtime.dust.placed_by.object_above": "배치 원인: object/stilt '{object}'(표면 위)",
"iris.runtime.dust.placed_by.decoration_above": "배치 원인: decoration/object/stilt(표면 위)",
"iris.runtime.dust.placed_by.structure_piece": "배치 원인: 구조물 '{structure}' 부품 '{object}'",
"iris.runtime.dust.placed_by.buried_object": "에 의해 장소: 매장된 개체 '{object}'",
"iris.runtime.dust.placed_by.terrain": "에 의해 배치: 지형 층 (깊이 {depth} 표면의 밑에)",
"iris.runtime.dust.column_object": "란 목표: {object} -> 이 블록은 객체의 stilt가 될 가능성이 있습니다.",
@@ -946,6 +946,7 @@
"iris.runtime.dust.none": "nėra",
"iris.runtime.dust.placed_by.object_above": "Pateikta: objektas / stilt \"{object}\"(virš paviršiaus)",
"iris.runtime.dust.placed_by.decoration_above": "Pateikta: dekoravimas / objektas / stilt (virš paviršiaus)",
"iris.runtime.dust.placed_by.structure_piece": "Pateikta: struktūra '{structure}', dalis '{object}'",
"iris.runtime.dust.placed_by.buried_object": "Vieta: palaidotas objektas \"{object}'",
"iris.runtime.dust.placed_by.terrain": "Vieta: reljefo sluoksnis (gylis {depth} žemiau paviršiaus)",
"iris.runtime.dust.column_object": "Stulpelių objektas: {object} -> šis blokas yra tikėtina, kad objekto stilt",
@@ -946,6 +946,7 @@
"iris.runtime.dust.none": "geen",
"iris.runtime.dust.placed_by.object_above": "Geplaatst door: object/stilt '{object}\" (boven)",
"iris.runtime.dust.placed_by.decoration_above": "Geplaatst door: decoratie/object/stilt (bovenzijde)",
"iris.runtime.dust.placed_by.structure_piece": "Geplaatst door: structuur '{structure}', onderdeel '{object}'",
"iris.runtime.dust.placed_by.buried_object": "Geplaatst door: begraven voorwerp '{object}'",
"iris.runtime.dust.placed_by.terrain": "Geplaatst door: terreinlaag (diepte {depth} onder de oppervlakte)",
"iris.runtime.dust.column_object": "Kolom object: {object} -> dit blok is waarschijnlijk de schuif van het object",
@@ -946,6 +946,7 @@
"iris.runtime.dust.none": "brak",
"iris.runtime.dust.placed_by.object_above": "Umieszczone przez: obiekt / stilt '{object}\"(nad powierzchnią)",
"iris.runtime.dust.placed_by.decoration_above": "Umieszczone przez: dekoracje / obiekt / stilt (nad powierzchnią)",
"iris.runtime.dust.placed_by.structure_piece": "Umieszczone przez: struktura '{structure}', element '{object}'",
"iris.runtime.dust.placed_by.buried_object": "Umieszczone przez: zakopany obiekt \"{object}'",
"iris.runtime.dust.placed_by.terrain": "Umieszczone przez: warstwa terenu (głębokość {depth} poniżej powierzchni)",
"iris.runtime.dust.column_object": "Obiekt kolumny: {object} -> Ten blok jest prawdopodobny.",
@@ -946,6 +946,7 @@
"iris.runtime.dust.none": "nenhum",
"iris.runtime.dust.placed_by.object_above": "Colocado por: objeto/tilt '{object}« (superfície superior)",
"iris.runtime.dust.placed_by.decoration_above": "Colocado por: decoração/objeto/tilt (superfície superior)",
"iris.runtime.dust.placed_by.structure_piece": "Colocado por: estrutura '{structure}', peça '{object}'",
"iris.runtime.dust.placed_by.buried_object": "Colocado por: objeto enterrado '{object}'",
"iris.runtime.dust.placed_by.terrain": "Colocado por: camada de terreno (profundidade {depth} abaixo da superfície)",
"iris.runtime.dust.column_object": "Objeto da coluna: {object} -> este bloco é provável que o objeto",
@@ -946,6 +946,7 @@
"iris.runtime.dust.none": "ни одного",
"iris.runtime.dust.placed_by.object_above": "Помещение: объект/наклон{object}(над поверхностью)",
"iris.runtime.dust.placed_by.decoration_above": "Размещено: отделка/объект/наклон (над поверхностью)",
"iris.runtime.dust.placed_by.structure_piece": "Помещение: структура '{structure}', деталь '{object}'",
"iris.runtime.dust.placed_by.buried_object": "Местонахождение: Захороненный объект{object}'",
"iris.runtime.dust.placed_by.terrain": "Расположено: слой местности (глубина {depth} ниже поверхности)",
"iris.runtime.dust.column_object": "Объект колонки: {object} -> Этот блок, вероятно, является сваями объекта",
@@ -946,6 +946,7 @@
"iris.runtime.dust.none": "Hiçbir kimse hiçbir şey yok",
"iris.runtime.dust.placed_by.object_above": "Tarafından Yeri: nesne /{object}\" (üstünde yüzeyi)",
"iris.runtime.dust.placed_by.decoration_above": "Yer: dekorasyon/object /stilt (üstünde yüzeyi)",
"iris.runtime.dust.placed_by.structure_piece": "Tarafından Yeri: yapı '{structure}', parça '{object}'",
"iris.runtime.dust.placed_by.buried_object": "Yere: gömülü nesne{object}'",
"iris.runtime.dust.placed_by.terrain": "yerleştirildi by: terrain layer (depth {depth} aşağıda yüzey)",
"iris.runtime.dust.column_object": "Köşe nesnesi: {object} -> Bu blok muhtemelen nesnenin stiltünün",
@@ -946,6 +946,7 @@
"iris.runtime.dust.none": "không có",
"iris.runtime.dust.placed_by.object_above": "Được đặt bởi đối tượng/ giây{object}' (mặt trên)",
"iris.runtime.dust.placed_by.decoration_above": "Đặt theo: trang trí/ thu hút/ Linh tinh (mặt đất)",
"iris.runtime.dust.placed_by.structure_piece": "Được đặt bởi công trình '{structure}', phần '{object}'",
"iris.runtime.dust.placed_by.buried_object": "Đặt theo: đối tượng đã chôn{object}'",
"iris.runtime.dust.placed_by.terrain": "Đặt theo lớp địa hình ( thâm tím {depth} dưới bề mặt)",
"iris.runtime.dust.column_object": "Đối tượng cột: {object} -> khối này có khả năng mà đối tượng của Stilt",
@@ -946,6 +946,7 @@
"iris.runtime.dust.none": "无",
"iris.runtime.dust.placed_by.object_above": "位置: 对象/斜体 '{object}'(以上表面)",
"iris.runtime.dust.placed_by.decoration_above": "由:装饰/物件/斜体(上表面)",
"iris.runtime.dust.placed_by.structure_piece": "位置: 结构 '{structure}' 的部件 '{object}'",
"iris.runtime.dust.placed_by.buried_object": "由: 掩埋对象 '{object}'",
"iris.runtime.dust.placed_by.terrain": "地形层(深度){depth}(低于表面)",
"iris.runtime.dust.column_object": "列对象 : {object} -> 此块可能是天体的斜体",
@@ -946,6 +946,7 @@
"iris.runtime.dust.none": "無",
"iris.runtime.dust.placed_by.object_above": "位置: 物件/斜體 '{object}'(以上表面)",
"iris.runtime.dust.placed_by.decoration_above": "由:裝飾/物件/斜體(上表面)",
"iris.runtime.dust.placed_by.structure_piece": "位置: 結構 '{structure}' 的部件 '{object}'",
"iris.runtime.dust.placed_by.buried_object": "由: 掩埋物件 '{object}'",
"iris.runtime.dust.placed_by.terrain": "地形層(深度){depth}(低於表面)",
"iris.runtime.dust.column_object": "列物件 : {object} -> 此塊可能是天體的斜體",
@@ -946,6 +946,7 @@
"iris.runtime.dust.none": "none",
"iris.runtime.dust.placed_by.object_above": "Placed by: object/stilt '{object}' (above surface)",
"iris.runtime.dust.placed_by.decoration_above": "Placed by: decoration/object/stilt (above surface)",
"iris.runtime.dust.placed_by.structure_piece": "Placed by: structure '{structure}' piece '{object}'",
"iris.runtime.dust.placed_by.buried_object": "Placed by: buried object '{object}'",
"iris.runtime.dust.placed_by.terrain": "Placed by: terrain layer (depth {depth} below surface)",
"iris.runtime.dust.column_object": "Column object: {object} -> this block is likely that object's stilt",
@@ -22,7 +22,9 @@ 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.ObjectLocating;
import art.arcane.iris.engine.mantle.components.StructureModule;
import art.arcane.iris.engine.mantle.components.StructurePiecesAt;
import com.volmit.IrisModule;
import com.volmit.geometry.BlockPosition;
import com.volmit.host.FeatureCatalog;
@@ -48,8 +50,11 @@ public class BuiltInServicesTest {
private static final FeatureCatalog BUILT_INS = ModuleResourceFixture.catalogOf(BuiltInPack.allBuiltIns().toArray(IrisModule[]::new));
@Test
public void objectsTellWhichObjectsAChunkGets() {
assertEquals(1, BUILT_INS.services(ObjectsAt.class).size());
public void objectsAndStructurePiecesTellWhatTheyPlace() {
List<ObjectsAt> providers = BUILT_INS.services(ObjectsAt.class);
assertEquals(2, providers.size());
assertTrue(providers.stream().anyMatch(ObjectLocating.class::isInstance));
assertTrue(providers.stream().anyMatch(StructurePiecesAt.class::isInstance));
}
@Test
@@ -0,0 +1,118 @@
package art.arcane.iris.engine.framework;
import art.arcane.iris.builtin.structure.StructureDistribution;
import art.arcane.iris.builtin.structure.StructurePlacement;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.core.modules.ModuleResourceFixture;
import art.arcane.iris.engine.framework.structure.JigsawStructureAssembly;
import art.arcane.iris.engine.framework.structure.StructureResources;
import art.arcane.iris.engine.framework.structure.assembly.AssembledPiece;
import art.arcane.iris.engine.mantle.components.StructureModule;
import art.arcane.iris.engine.mantle.components.StructurePiecesAt;
import art.arcane.iris.engine.object.TestSettings;
import art.arcane.iris.engine.object.structure.IrisStructure;
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece;
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPieceEntry;
import art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPool;
import art.arcane.iris.modules.jigsaw.JigsawModule;
import com.volmit.host.ModuleLogs;
import com.volmit.object.PlaceableObject;
import com.volmit.placement.PlacementRecord;
import org.junit.Test;
import java.util.Optional;
import static art.arcane.iris.engine.framework.StructurePlacementFixtures.withAdded;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
/** The structure piece iris:structure plans at a block, for block inspection where generation recorded nothing. */
public class StructurePiecesAtTest {
private static final String STRUCTURE = "test:ruin";
private static final int CHUNKS_SEARCHED = 64;
@Test
public void theBlockOfAPlannedPieceNamesThePieceAndItsStructure() {
StructureTestWorld world = worldWithStructures();
AssembledPiece piece = firstStartedPiece(world);
Optional<PlacementRecord> planned = new StructurePiecesAt().placementAt(
world, piece.minX(), heightAboveBottom(world, piece.minY()), piece.minZ());
assertTrue(planned.isPresent());
assertEquals(Optional.of(world.resources().idOf(STRUCTURE)), planned.get().structure());
assertEquals(piece.object(), planned.get().object());
}
@Test
public void aBlockNoPieceCoversHasNoPlannedPlacement() {
StructureTestWorld world = worldWithStructures();
AssembledPiece piece = firstStartedPiece(world);
int besideXInTheSameChunk = (piece.minX() & ~15) | ((piece.minX() + 8) & 15);
assertFalse(new StructurePiecesAt().placementAt(
world, besideXInTheSameChunk, heightAboveBottom(world, piece.minY()), piece.minZ()).isPresent());
}
private static int heightAboveBottom(StructureTestWorld world, int worldY) {
return worldY - world.minWorldY();
}
/** The piece of the first structure that starts in a chunk along the X axis from chunk 0, 0. */
private static AssembledPiece firstStartedPiece(StructureTestWorld world) {
StructurePlacement placement = world.dimensionPlacements().get(0);
for (int chunkX = 0; chunkX < CHUNKS_SEARCHED; chunkX++) {
IrisStructureLocator.ResolvedPlacement resolved = IrisStructureLocator.resolvePlacement(world, placement, chunkX, 0);
if (resolved != null) {
return resolved.pieces().getFirst();
}
}
throw new AssertionError("No structure starts within " + CHUNKS_SEARCHED + " chunks");
}
/** A world whose one placement starts structures of a single 1x1x1 piece at the highest density. */
private static StructureTestWorld worldWithStructures() {
IrisData data = mock(IrisData.class);
ModuleResourceFixture.serveModules(data, new JigsawModule(), new StructureModule());
IrisStructure structure = new IrisStructure();
ModuleResourceFixture.of(data).resource(StructureResources.STRUCTURES, STRUCTURE, structure);
registerSinglePieceGraph(data, structure);
StructurePlacement placement = new StructurePlacement();
withAdded(placement, "structures", STRUCTURE);
TestSettings.with(placement, "distribution", StructureDistribution.DENSITY);
TestSettings.with(placement, "density", 1D);
TestSettings.with(placement, "minHeight", -2032);
TestSettings.with(placement, "maxHeight", 2032);
return new StructureTestWorld()
.resources(data.getPackResources())
.assembling(new JigsawStructureAssembly(ModuleLogs.discarding()))
.highest((x, z) -> 128)
.fluidHeight(63)
.placementSeed(new SeedManager(77L).getMantle())
.minY(-64)
.height(384)
.dimension(placement);
}
private static void registerSinglePieceGraph(IrisData data, IrisStructure structure) {
String poolKey = STRUCTURE + "/start";
String pieceKey = STRUCTURE + "/piece";
String objectKey = STRUCTURE + "/object";
structure.setStartPool(poolKey);
IrisJigsawPool pool = new IrisJigsawPool();
pool.getPieces().add(new IrisJigsawPieceEntry().setPiece(pieceKey).setWeight(1));
IrisJigsawPiece piece = new IrisJigsawPiece();
piece.setObject(objectKey);
ModuleResourceFixture.of(data).object(objectKey, 1, 1, 1);
PlaceableObject object = mock(PlaceableObject.class);
when(object.name()).thenReturn(objectKey);
when(data.getPackResources().objects().object(data.getPackResources().idOf(objectKey))).thenReturn(Optional.of(object));
ModuleResourceFixture.of(data).resource(StructureResources.POOLS, poolKey, pool);
ModuleResourceFixture.of(data).resource(StructureResources.PIECES, pieceKey, piece);
}
}
+1
View File
@@ -143,6 +143,7 @@ include art/arcane/iris/modules/floating/**
jar structure
module art.arcane.iris.engine.mantle.components.StructureModule
include art/arcane/iris/engine/mantle/components/StructurePlacing*.class
include art/arcane/iris/engine/mantle/components/StructurePiecesAt*.class
include art/arcane/iris/engine/mantle/components/StructureCarvingFootprint*.class
include art/arcane/iris/engine/mantle/components/StructureCarveEnvelope*.class
include art/arcane/iris/engine/mantle/components/StructureFoundationPlanner*.class
@@ -29,6 +29,7 @@ import com.volmit.IrisModule;
import com.volmit.ModuleInfo;
import com.volmit.ModuleLog;
import com.volmit.ModuleSetup;
import com.volmit.service.ObjectsAt;
import com.volmit.service.StructureLocator;
import com.volmit.service.VanillaStructures;
import com.volmit.stage.MantleStageContext;
@@ -37,9 +38,10 @@ import com.volmit.stage.MantleStageContext;
* Module {@code iris:structure}: where structures go and how they meet the terrain. It owns the structure placements a
* pack declares, the mantle stage that places the structures starting in each chunk, the locator that finds them, the
* answers about the platform's own structures ({@link StructureVanillaStructures}: the dimension's
* {@code importedStructures} settings disable, move, fit and set them up, and the pack's placements replace them, place
* opt-in {@code importedStructures} settings import, disable, move, fit and set them up, and the pack's placements replace them, place
* them alongside, start them where their {@code nativeStructures} grids say and fit them into the terrain), the checks of
* the placements, and the {@code /iris module structure} commands.
* the placements, the piece planned at a block for block inspection ({@link StructurePiecesAt}), and the
* {@code /iris module structure} commands.
* <p>
* It gets the pieces of a structure only from the {@link art.arcane.iris.engine.framework.structure.assembly.StructureAssembly}
* providers of the pack's modules, such as {@code iris:jigsaw}, and knows none of them.
@@ -63,6 +65,7 @@ public final class StructureModule implements IrisModule {
registry.registerValidator(new StructureValidator());
registry.registerService(StructureLocator.class, new StructureLocating());
registry.registerService(VanillaStructures.class, new StructureVanillaStructures());
registry.registerService(ObjectsAt.class, new StructurePiecesAt());
setup.tooling().registerCommand(StructureCommands.root());
}
@@ -0,0 +1,111 @@
/*
* 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.mantle.components;
import art.arcane.iris.builtin.structure.StructurePlacement;
import art.arcane.iris.engine.framework.IrisStructureLocator;
import art.arcane.iris.engine.framework.StructurePlacementScope;
import art.arcane.iris.engine.framework.structure.assembly.AssembledPiece;
import com.volmit.object.PlaceableObject;
import com.volmit.placement.PlacementRecord;
import com.volmit.resource.ResourceId;
import com.volmit.service.ObjectsAt;
import com.volmit.world.PackWorld;
import java.util.List;
import java.util.Optional;
import java.util.Set;
/**
* Which structure piece {@code iris:structure} plans at a block, for the host's block inspection. Generation records
* only the storage blocks of a piece ({@link StructurePlacing}), so this assembles the starts within structure reach of
* the block again and answers with the piece whose box holds it. A lone surface piece takes its height from the
* terrain when it is placed, so for it only the column has to match. The module predicts no objects per chunk.
*/
public final class StructurePiecesAt implements ObjectsAt {
private static final int BLOCKS_PER_CHUNK_SHIFT = 4;
@Override
public Set<ResourceId> objectsAt(PackWorld world, int chunkX, int chunkZ) {
return Set.of();
}
@Override
public PlacedBy placedBy(PackWorld world, ResourceId object) {
return PlacedBy.NOTHING;
}
@Override
public Optional<PlacementRecord> placementAt(PackWorld world, int worldX, int y, int worldZ) {
int blockY = y + world.minWorldY();
int reachChunks = (StructurePlacing.reach(world.settings()) >> BLOCKS_PER_CHUNK_SHIFT) + 1;
int chunkX = worldX >> BLOCKS_PER_CHUNK_SHIFT;
int chunkZ = worldZ >> BLOCKS_PER_CHUNK_SHIFT;
for (int originX = chunkX - reachChunks; originX <= chunkX + reachChunks; originX++) {
for (int originZ = chunkZ - reachChunks; originZ <= chunkZ + reachChunks; originZ++) {
Optional<PlacementRecord> piece = pieceStartedIn(world, originX, originZ, worldX, blockY, worldZ);
if (piece.isPresent()) {
return piece;
}
}
}
return Optional.empty();
}
private static Optional<PlacementRecord> pieceStartedIn(PackWorld world, int originChunkX, int originChunkZ,
int x, int blockY, int z) {
for (StructurePlacement placement : StructurePlacementScope.placementsAt(world, originChunkX, originChunkZ)) {
if (!placement.hasIrisStructures()) {
continue;
}
IrisStructureLocator.ResolvedPlacement resolved =
IrisStructureLocator.resolvePlacement(world, placement, originChunkX, originChunkZ);
if (resolved == null || resolved.pieces() == null) {
continue;
}
Optional<PlacementRecord> piece = pieceCovering(world, resolved, x, blockY, z);
if (piece.isPresent()) {
return piece;
}
}
return Optional.empty();
}
private static Optional<PlacementRecord> pieceCovering(PackWorld world, IrisStructureLocator.ResolvedPlacement resolved,
int x, int blockY, int z) {
List<AssembledPiece> pieces = resolved.pieces();
boolean heightPlanned = !StructurePlacing.samplesPieceHeight(resolved.placement(), resolved.stamp(), pieces);
for (AssembledPiece piece : pieces) {
if (covers(piece, x, blockY, z, heightPlanned)) {
return Optional.ofNullable(recordOf(world, resolved.structureKey(), piece));
}
}
return Optional.empty();
}
private static boolean covers(AssembledPiece piece, int x, int blockY, int z, boolean heightPlanned) {
boolean inColumn = x >= piece.minX() && x <= piece.maxX() && z >= piece.minZ() && z <= piece.maxZ();
return inColumn && (!heightPlanned || (blockY >= piece.minY() && blockY <= piece.maxY()));
}
private static PlacementRecord recordOf(PackWorld world, String structureKey, AssembledPiece piece) {
String objectKey = world.resources().objects().object(piece.object()).map(PlaceableObject::name).orElse(null);
return StructurePlacing.pieceRecord(world.resources(), structureKey, piece, objectKey);
}
}
@@ -150,30 +150,16 @@ public class StructurePlacing {
ColumnHeights foundationColumns = stilt == null
? null : new ColumnHeights(0);
boolean supportNonOccluding = stilt != null && stilt.supportNonOccluding();
if (placement.isAnchoredUnderground()) {
ObjectPlaceMode undergroundMode = mode.placeMode().has(PlaceTrait.CAVE_ANCHORED)
? mode : ObjectPlaceMode.STRUCTURE_PIECE;
for (AssembledPiece p : pieces) {
if (placeObject(context, key, stamp, p, undergroundMode, false,
foundationColumns, supportNonOccluding) == REJECTED_PIECE) {
failedPieces++;
}
}
} else if (mode.placeMode().has(PlaceTrait.FREE_HEIGHT)) {
for (AssembledPiece p : pieces) {
if (placeObject(context, key, stamp, p, ObjectPlaceMode.STRUCTURE_PIECE, false,
foundationColumns, supportNonOccluding) == REJECTED_PIECE) {
failedPieces++;
}
}
} else if (pieces.size() == 1) {
if (samplesPieceHeight(placement, stamp, pieces)) {
if (placeObject(context, key, stamp, pieces.getFirst(), mode, true,
foundationColumns, supportNonOccluding) == REJECTED_PIECE) {
failedPieces++;
}
} else {
ObjectPlaceMode pieceMode = placement.isAnchoredUnderground() && mode.placeMode().has(PlaceTrait.CAVE_ANCHORED)
? mode : ObjectPlaceMode.STRUCTURE_PIECE;
for (AssembledPiece p : pieces) {
if (placeObject(context, key, stamp, p, ObjectPlaceMode.STRUCTURE_PIECE, false,
if (placeObject(context, key, stamp, p, pieceMode, false,
foundationColumns, supportNonOccluding) == REJECTED_PIECE) {
failedPieces++;
}
@@ -636,14 +622,28 @@ public class StructurePlacing {
}
private PlacementRecord structurePlacementRecord(String structureKey, AssembledPiece piece, String objectKey) {
return pieceRecord(world.resources(), structureKey, piece, objectKey);
}
/** What placing the piece object {@code objectKey} records beside its blocks; null without a structure or object. */
static PlacementRecord pieceRecord(PackResources pack, String structureKey, AssembledPiece piece, String objectKey) {
if (structureKey == null || structureKey.isBlank() || objectKey == null || objectKey.isBlank()) {
return null;
}
PackResources pack = world.resources();
int placementId = structurePlacementId(structureKey, objectKey, piece.x(), piece.y(), piece.z());
return PlacementRecord.ofPiece(pack.idOf(objectKey), placementId, pack.idOf(structureKey));
}
/**
* Whether the placement samples the height of its pieces from the terrain when it places them, rather than placing
* them at their planned height: a lone surface piece without free height.
*/
static boolean samplesPieceHeight(StructurePlacement placement, StructureStamp stamp, List<AssembledPiece> pieces) {
return !placement.isAnchoredUnderground()
&& !stamp.placeMode().placeMode().has(PlaceTrait.FREE_HEIGHT)
&& pieces.size() == 1;
}
/** How far, in blocks along X and Z, placements may write beyond their chunk. */
public static int reach(PackSettings settings) {
PackResources pack = settings.resources();