diff --git a/adapters/modded-common/src/main/java/art/arcane/iris/modded/command/ModdedDustRevealer.java b/adapters/modded-common/src/main/java/art/arcane/iris/modded/command/ModdedDustRevealer.java index 7f87847be..5aa39af24 100644 --- a/adapters/modded-common/src/main/java/art/arcane/iris/modded/command/ModdedDustRevealer.java +++ b/adapters/modded-common/src/main/java/art/arcane/iris/modded/command/ModdedDustRevealer.java @@ -33,7 +33,6 @@ import art.arcane.iris.modded.ModdedEngineBootstrap; import art.arcane.iris.modded.ModdedScheduler; import art.arcane.iris.util.project.context.IrisContext; import art.arcane.volmlib.util.localization.MessageArgument; -import com.volmit.config.Level; import net.minecraft.ChatFormatting; import net.minecraft.core.BlockPos; import net.minecraft.core.Holder; @@ -296,9 +295,9 @@ public final class ModdedDustRevealer { ? IrisLanguage.plain(RuntimeUiMessages.DUST_NONE) : objectKey) ), false)); - PlacementMarkers.OwnerKey owner = objectKey == null ? null : safe( - "object owner lookup at " + coordinates(pos), - () -> engine.getObjectPlacementOwner(x, relativeY, z)); + PlacementMarkers.OwnerKey owner = objectKey != null + ? safe("object owner lookup at " + coordinates(pos), () -> engine.getObjectPlacementOwner(x, relativeY, z)) + : structurePiece == null ? null : structurePiece.owner().orElse(null); if (owner != null) { lines.add(new DustLine(ownerLine(owner), true)); } @@ -401,9 +400,11 @@ public final class ModdedDustRevealer { } static String ownerLine(PlacementMarkers.OwnerKey owner) { - return owner.level() == Level.REGION - ? IrisLanguage.plain(RuntimeUiMessages.DUST_OBJECT_FROM_REGION, MessageArgument.untrusted("region", owner.key())) - : IrisLanguage.plain(RuntimeUiMessages.DUST_OBJECT_FROM_BIOME, MessageArgument.untrusted("biome", owner.key())); + return switch (owner.level()) { + case REGION -> IrisLanguage.plain(RuntimeUiMessages.DUST_OBJECT_FROM_REGION, MessageArgument.untrusted("region", owner.key())); + case DIMENSION -> IrisLanguage.plain(RuntimeUiMessages.DUST_OBJECT_FROM_DIMENSION, MessageArgument.untrusted("dimension", owner.key())); + default -> IrisLanguage.plain(RuntimeUiMessages.DUST_OBJECT_FROM_BIOME, MessageArgument.untrusted("biome", owner.key())); + }; } static String structurePieceLine(ModuleServices.PlannedPlacement structurePiece) { diff --git a/api/README.md b/api/README.md index 9c23c0e36..ea19bc9f5 100644 --- a/api/README.md +++ b/api/README.md @@ -295,7 +295,7 @@ if (!outcome.isPlaced()) { carved space, fluid, the structures nearby and the placement recorded at a block (`recordPlacement`, `placementAt`; `RunningWorld.placementAt` reads it back later, such as for the loot of a placed object). A recorded placement is a `PlacementRecord`: the object's id, the module's number for this placement of it, for a piece of a structure the - structure's id, and the `PlacementOwner`, the biome or region whose settings placed it. A module may wrap the terrain to hold or filter writes; a mantle stage gets one for its invocation from + structure's id, and the `PlacementOwner`, the biome, region or dimension whose settings placed it. A module may wrap the terrain to hold or filter writes; a mantle stage gets one for its invocation from `MantleGenerationContext.placementTerrain()`. - `clearBlock(x, y, z)` takes a block a placement wrote back, so the terrain shows through; the block entity, placement record and markers kept beside it stay until `clearAttached(x, y, z)` takes them back, whether or not a block is still diff --git a/api/api/src/main/java/com/volmit/placement/PlacementOwner.java b/api/api/src/main/java/com/volmit/placement/PlacementOwner.java index a4ced07b9..b1a2a17f7 100644 --- a/api/api/src/main/java/com/volmit/placement/PlacementOwner.java +++ b/api/api/src/main/java/com/volmit/placement/PlacementOwner.java @@ -6,18 +6,18 @@ import com.volmit.resource.ResourceId; import java.util.Objects; /** - * The biome or region whose own settings placed an object. An object reaches past the column it was placed from, so - * the biome or region at one of its blocks can be another than the one that placed it. + * The layout entry whose own settings placed an object or a structure: a biome, a region or the dimension. A placement + * reaches past the column it was placed from, so the biome or region at one of its blocks can be another than its owner. * - * @param level {@link Level#BIOME} or {@link Level#REGION} - * @param source the biome or region, as an id + * @param level {@link Level#BIOME}, {@link Level#REGION} or {@link Level#DIMENSION} + * @param source the biome, region or dimension, as an id */ public record PlacementOwner(Level level, ResourceId source) { public PlacementOwner { Objects.requireNonNull(level, "level"); Objects.requireNonNull(source, "source"); - if (level != Level.BIOME && level != Level.REGION) { - throw new IllegalArgumentException("A placement is owned by a biome or a region, not " + level); + if (level == Level.PLACEMENT) { + throw new IllegalArgumentException("A placement is owned by a biome, a region or the dimension, not by a placement"); } } diff --git a/api/api/src/main/java/com/volmit/placement/PlacementRecord.java b/api/api/src/main/java/com/volmit/placement/PlacementRecord.java index 533fcbb2a..c31aa483c 100644 --- a/api/api/src/main/java/com/volmit/placement/PlacementRecord.java +++ b/api/api/src/main/java/com/volmit/placement/PlacementRecord.java @@ -9,14 +9,14 @@ import java.util.Optional; * What a module recorded beside a block when it placed an object there ({@link PlacementTerrain#recordPlacement}), and * what later placements and services read back ({@link PlacementTerrain#placementAt}, * {@link com.volmit.world.RunningWorld#placementAt}): which object stands there, which placement of it that was, for a - * piece of a structure which structure, and which biome or region placed it. + * piece of a structure which structure, and which biome, region or dimension placed it. * * @param object the pack object, or the name the module gave an object it made itself, as an id * @param placementId the number the placing module gave this placement, which tells it apart from other placements of the * same object; the module picks it, the host keeps it as it is * @param structure the structure the object is a piece of; empty for an object placed on its own - * @param owner the biome or region whose settings placed the object; empty when no layout entry did, such as for a - * structure piece or a grown sapling + * @param owner the biome, region or dimension whose settings placed the object, or placed the structure it is a + * piece of; empty when no layout entry did, such as for a grown sapling */ public record PlacementRecord(ResourceId object, int placementId, Optional structure, Optional owner) { diff --git a/api/api/src/test/java/com/volmit/ItemAndEntityValuesTest.java b/api/api/src/test/java/com/volmit/ItemAndEntityValuesTest.java index 82e9190ef..6e204e1c3 100644 --- a/api/api/src/test/java/com/volmit/ItemAndEntityValuesTest.java +++ b/api/api/src/test/java/com/volmit/ItemAndEntityValuesTest.java @@ -106,7 +106,7 @@ class ItemAndEntityValuesTest { assertEquals(Optional.empty(), PlacementRecord.of(oak, 7).owner()); assertEquals(Optional.of(PlacementOwner.biome(forest)), PlacementRecord.of(oak, 7).ownedBy(PlacementOwner.biome(forest)).owner()); assertEquals(Level.REGION, PlacementOwner.region(forest).level()); - assertThrows(IllegalArgumentException.class, () -> new PlacementOwner(Level.DIMENSION, forest)); + assertThrows(IllegalArgumentException.class, () -> new PlacementOwner(Level.PLACEMENT, forest)); } @Test diff --git a/core/src/main/java/art/arcane/iris/core/edit/DustRevealer.java b/core/src/main/java/art/arcane/iris/core/edit/DustRevealer.java index 616df4990..541d920a7 100644 --- a/core/src/main/java/art/arcane/iris/core/edit/DustRevealer.java +++ b/core/src/main/java/art/arcane/iris/core/edit/DustRevealer.java @@ -32,7 +32,6 @@ import art.arcane.iris.engine.object.world.region.IrisRegion; import art.arcane.iris.engine.platform.PlatformChunkGenerator; import art.arcane.iris.util.common.format.C; import art.arcane.volmlib.util.collection.KList; -import com.volmit.config.Level; import art.arcane.volmlib.util.math.BlockPosition; import art.arcane.volmlib.util.math.M; import art.arcane.volmlib.util.math.RNG; @@ -234,7 +233,9 @@ public class DustRevealer { objectKey == null ? IrisLanguage.text(RuntimeUiMessages.DUST_NONE) : objectKey ) ), false)); - PlacementMarkers.OwnerKey owner = objectKey == null ? null : safe(() -> engine.getObjectPlacementOwner(x, relativeY, z)); + PlacementMarkers.OwnerKey owner = objectKey != null + ? safe(() -> engine.getObjectPlacementOwner(x, relativeY, z)) + : structurePiece == null ? null : structurePiece.owner().orElse(null); if (owner != null) { lines.add(new DustLine(ownerLine(owner), true)); } @@ -309,9 +310,11 @@ public class DustRevealer { } private static String ownerLine(PlacementMarkers.OwnerKey owner) { - return owner.level() == Level.REGION - ? IrisLanguage.text(RuntimeUiMessages.DUST_OBJECT_FROM_REGION, MessageArgument.untrusted("region", owner.key())) - : IrisLanguage.text(RuntimeUiMessages.DUST_OBJECT_FROM_BIOME, MessageArgument.untrusted("biome", owner.key())); + return switch (owner.level()) { + case REGION -> IrisLanguage.text(RuntimeUiMessages.DUST_OBJECT_FROM_REGION, MessageArgument.untrusted("region", owner.key())); + case DIMENSION -> IrisLanguage.text(RuntimeUiMessages.DUST_OBJECT_FROM_DIMENSION, MessageArgument.untrusted("dimension", owner.key())); + default -> IrisLanguage.text(RuntimeUiMessages.DUST_OBJECT_FROM_BIOME, MessageArgument.untrusted("biome", owner.key())); + }; } private static String findColumnObject(Engine engine, int x, int relativeY, int z, int minHeight) { diff --git a/core/src/main/java/art/arcane/iris/core/localization/RuntimeUiMessages.java b/core/src/main/java/art/arcane/iris/core/localization/RuntimeUiMessages.java index 641b495cd..760066cba 100644 --- a/core/src/main/java/art/arcane/iris/core/localization/RuntimeUiMessages.java +++ b/core/src/main/java/art/arcane/iris/core/localization/RuntimeUiMessages.java @@ -79,6 +79,7 @@ public final class RuntimeUiMessages { public static final TextKey DUST_PLACED_BY_STRUCTURE_PIECE = text("iris.runtime.dust.placed_by.structure_piece"); public static final TextKey DUST_OBJECT_FROM_BIOME = text("iris.runtime.dust.object_from.biome"); public static final TextKey DUST_OBJECT_FROM_REGION = text("iris.runtime.dust.object_from.region"); + public static final TextKey DUST_OBJECT_FROM_DIMENSION = text("iris.runtime.dust.object_from.dimension"); 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"); diff --git a/core/src/main/java/art/arcane/iris/core/modules/ModuleServices.java b/core/src/main/java/art/arcane/iris/core/modules/ModuleServices.java index 8321a1003..107879713 100644 --- a/core/src/main/java/art/arcane/iris/core/modules/ModuleServices.java +++ b/core/src/main/java/art/arcane/iris/core/modules/ModuleServices.java @@ -133,14 +133,18 @@ public final class ModuleServices { if (planned.isPresent()) { return planned.map(record -> new PlannedPlacement( resources.keyOf(PackResources.OBJECTS, record.object()), - record.structure().map(resources::keyOf))); + record.structure().map(resources::keyOf), + record.owner().map(owner -> PlacementMarkers.ownerKeyOf(owner, resources)))); } } 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 structure) { + /** + * A placement a module plans at a block: the object's key, for a structure piece the structure's, and the biome, + * region or dimension that placed it. + */ + public record PlannedPlacement(String object, Optional structure, Optional owner) { } /** The keys of the biomes and regions of the engine's layout that every module says place the object {@code objectKey}. */ diff --git a/core/src/main/java/art/arcane/iris/core/modules/PlacementMarkers.java b/core/src/main/java/art/arcane/iris/core/modules/PlacementMarkers.java index 04537881b..16f3b0159 100644 --- a/core/src/main/java/art/arcane/iris/core/modules/PlacementMarkers.java +++ b/core/src/main/java/art/arcane/iris/core/modules/PlacementMarkers.java @@ -23,7 +23,6 @@ import com.volmit.placement.PlacementOwner; import com.volmit.placement.PlacementRecord; import com.volmit.resource.PackResources; import com.volmit.resource.ResourceId; -import com.volmit.resource.ResourceKind; import java.nio.charset.StandardCharsets; import java.util.Base64; @@ -34,7 +33,7 @@ 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. - * Either form may end in {@code #biome:...} or {@code #region:...}, naming the biome or region that placed the object. + * Either form may end in {@code #biome:...}, {@code #region:...} or {@code #dimension:...}, naming what placed it. * 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. */ @@ -77,12 +76,18 @@ public final class PlacementMarkers { } private static String encodeOwner(PlacementOwner owner, IrisPackResources resources) { - String ownerKey = resources.keyOf(kindOf(owner.level()), owner.source()); - return OWNER_SEPARATOR + owner.level().name().toLowerCase(Locale.ROOT) + OWNER_LEVEL_SEPARATOR + encodeKey(ownerKey); + OwnerKey ownerKey = ownerKeyOf(owner, resources); + return OWNER_SEPARATOR + ownerKey.level().name().toLowerCase(Locale.ROOT) + OWNER_LEVEL_SEPARATOR + encodeKey(ownerKey.key()); } - private static ResourceKind kindOf(Level ownerLevel) { - return ownerLevel == Level.REGION ? PackResources.REGIONS : PackResources.BIOMES; + /** {@code owner} by its pack key. */ + public static OwnerKey ownerKeyOf(PlacementOwner owner, IrisPackResources resources) { + String key = switch (owner.level()) { + case BIOME -> resources.keyOf(PackResources.BIOMES, owner.source()); + case REGION -> resources.keyOf(PackResources.REGIONS, owner.source()); + default -> resources.keyOf(owner.source()); + }; + return new OwnerKey(owner.level(), key); } /** What the text says, or empty for a text that names no placement. */ @@ -119,7 +124,7 @@ public final class PlacementMarkers { try { Level level = Level.valueOf(text.substring(0, levelEnd).toUpperCase(Locale.ROOT)); String key = decodeCanonicalKey(text.substring(levelEnd + 1)); - if (key.isBlank() || (level != Level.BIOME && level != Level.REGION)) { + if (key.isBlank() || level == Level.PLACEMENT) { return null; } return new OwnerKey(level, key); @@ -211,7 +216,7 @@ public final class PlacementMarkers { } } - /** The biome or region that placed an object, by its pack key; {@code level} is {@link Level#BIOME} or {@link Level#REGION}. */ + /** The biome, region or dimension that placed an object or structure, by its pack key. */ public record OwnerKey(Level level, String key) { } } diff --git a/core/src/main/resources/languages/de_DE.json b/core/src/main/resources/languages/de_DE.json index 4c399bf56..c4d525b72 100644 --- a/core/src/main/resources/languages/de_DE.json +++ b/core/src/main/resources/languages/de_DE.json @@ -945,6 +945,7 @@ "iris.runtime.dust.object_at_block": "Objekt @block: {object}", "iris.runtime.dust.object_from.biome": "Platziert von Biom: {biome}", "iris.runtime.dust.object_from.region": "Platziert von Region: {region}", + "iris.runtime.dust.object_from.dimension": "Platziert von Dimension: {dimension}", "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)", diff --git a/core/src/main/resources/languages/es_ES.json b/core/src/main/resources/languages/es_ES.json index acb9557a4..c9fc6ae02 100644 --- a/core/src/main/resources/languages/es_ES.json +++ b/core/src/main/resources/languages/es_ES.json @@ -945,6 +945,7 @@ "iris.runtime.dust.object_at_block": "Objeto @bloque: {object}", "iris.runtime.dust.object_from.biome": "Colocado desde el bioma: {biome}", "iris.runtime.dust.object_from.region": "Colocado desde la región: {region}", + "iris.runtime.dust.object_from.dimension": "Colocado desde la dimensión: {dimension}", "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)", diff --git a/core/src/main/resources/languages/fi_FI.json b/core/src/main/resources/languages/fi_FI.json index 708f1f8b5..cf6dc7473 100644 --- a/core/src/main/resources/languages/fi_FI.json +++ b/core/src/main/resources/languages/fi_FI.json @@ -945,6 +945,7 @@ "iris.runtime.dust.object_at_block": "Kohde @ lohko: {object}", "iris.runtime.dust.object_from.biome": "Sijoittanut biomi: {biome}", "iris.runtime.dust.object_from.region": "Sijoittanut alue: {region}", + "iris.runtime.dust.object_from.dimension": "Sijoittanut ulottuvuus: {dimension}", "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)", diff --git a/core/src/main/resources/languages/fr_FR.json b/core/src/main/resources/languages/fr_FR.json index 0180e7cb3..5ff7b4a49 100644 --- a/core/src/main/resources/languages/fr_FR.json +++ b/core/src/main/resources/languages/fr_FR.json @@ -945,6 +945,7 @@ "iris.runtime.dust.object_at_block": "Objet @bloc : {object}", "iris.runtime.dust.object_from.biome": "Placé par le biome : {biome}", "iris.runtime.dust.object_from.region": "Placé par la région : {region}", + "iris.runtime.dust.object_from.dimension": "Placé par la dimension : {dimension}", "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)", diff --git a/core/src/main/resources/languages/he_IL.json b/core/src/main/resources/languages/he_IL.json index dd77c04a0..fdf534324 100644 --- a/core/src/main/resources/languages/he_IL.json +++ b/core/src/main/resources/languages/he_IL.json @@ -945,6 +945,7 @@ "iris.runtime.dust.object_at_block": "אובייקטים @בלוק: {object}", "iris.runtime.dust.object_from.biome": "הוצב על ידי ביום: {biome}", "iris.runtime.dust.object_from.region": "הוצב על ידי אזור: {region}", + "iris.runtime.dust.object_from.dimension": "הוצב על ידי מימד: {dimension}", "iris.runtime.dust.none": "אף אחד לא", "iris.runtime.dust.placed_by.object_above": "הוצב על ידי: object/stilt '{object}' (מעל פני השטח)", "iris.runtime.dust.placed_by.decoration_above": "הוצב על ידי: decoration/object/stilt (מעל פני השטח)", diff --git a/core/src/main/resources/languages/it_IT.json b/core/src/main/resources/languages/it_IT.json index bee8afccf..43e084b3d 100644 --- a/core/src/main/resources/languages/it_IT.json +++ b/core/src/main/resources/languages/it_IT.json @@ -945,6 +945,7 @@ "iris.runtime.dust.object_at_block": "Oggetto @block: {object}", "iris.runtime.dust.object_from.biome": "Piazzato dal bioma: {biome}", "iris.runtime.dust.object_from.region": "Piazzato dalla regione: {region}", + "iris.runtime.dust.object_from.dimension": "Piazzato dalla dimensione: {dimension}", "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)", diff --git a/core/src/main/resources/languages/ja-JP.json b/core/src/main/resources/languages/ja-JP.json index c2f9f2f76..e6df3a137 100644 --- a/core/src/main/resources/languages/ja-JP.json +++ b/core/src/main/resources/languages/ja-JP.json @@ -945,6 +945,7 @@ "iris.runtime.dust.object_at_block": "このブロックのオブジェクト: {object}", "iris.runtime.dust.object_from.biome": "配置元バイオーム: {biome}", "iris.runtime.dust.object_from.region": "配置元リージョン: {region}", + "iris.runtime.dust.object_from.dimension": "配置元ディメンション: {dimension}", "iris.runtime.dust.none": "なし", "iris.runtime.dust.placed_by.object_above": "配置元: object/stilt '{object}'(地表より上)", "iris.runtime.dust.placed_by.decoration_above": "配置元: decoration/object/stilt(地表より上)", diff --git a/core/src/main/resources/languages/ko_KR.json b/core/src/main/resources/languages/ko_KR.json index 454d27bc2..762d4f488 100644 --- a/core/src/main/resources/languages/ko_KR.json +++ b/core/src/main/resources/languages/ko_KR.json @@ -945,6 +945,7 @@ "iris.runtime.dust.object_at_block": "오브젝트 @block: {object}", "iris.runtime.dust.object_from.biome": "배치한 바이옴: {biome}", "iris.runtime.dust.object_from.region": "배치한 지역: {region}", + "iris.runtime.dust.object_from.dimension": "배치한 차원: {dimension}", "iris.runtime.dust.none": "없음", "iris.runtime.dust.placed_by.object_above": "배치 원인: object/stilt '{object}'(표면 위)", "iris.runtime.dust.placed_by.decoration_above": "배치 원인: decoration/object/stilt(표면 위)", diff --git a/core/src/main/resources/languages/lt_LT.json b/core/src/main/resources/languages/lt_LT.json index d997264bd..731d8700f 100644 --- a/core/src/main/resources/languages/lt_LT.json +++ b/core/src/main/resources/languages/lt_LT.json @@ -945,6 +945,7 @@ "iris.runtime.dust.object_at_block": "Objektas @ block: {object}", "iris.runtime.dust.object_from.biome": "Pastatė biomas: {biome}", "iris.runtime.dust.object_from.region": "Pastatė regionas: {region}", + "iris.runtime.dust.object_from.dimension": "Pastatė dimensija: {dimension}", "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)", diff --git a/core/src/main/resources/languages/nl_NL.json b/core/src/main/resources/languages/nl_NL.json index 45069e8a8..1a08b8a1f 100644 --- a/core/src/main/resources/languages/nl_NL.json +++ b/core/src/main/resources/languages/nl_NL.json @@ -945,6 +945,7 @@ "iris.runtime.dust.object_at_block": "Object-@blok: {object}", "iris.runtime.dust.object_from.biome": "Geplaatst door bioom: {biome}", "iris.runtime.dust.object_from.region": "Geplaatst door regio: {region}", + "iris.runtime.dust.object_from.dimension": "Geplaatst door dimensie: {dimension}", "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)", diff --git a/core/src/main/resources/languages/pl_PL.json b/core/src/main/resources/languages/pl_PL.json index fd4f98bab..ce86d75d7 100644 --- a/core/src/main/resources/languages/pl_PL.json +++ b/core/src/main/resources/languages/pl_PL.json @@ -945,6 +945,7 @@ "iris.runtime.dust.object_at_block": "Obiekt @ block: {object}", "iris.runtime.dust.object_from.biome": "Umieszczony przez biom: {biome}", "iris.runtime.dust.object_from.region": "Umieszczony przez region: {region}", + "iris.runtime.dust.object_from.dimension": "Umieszczony przez wymiar: {dimension}", "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ą)", diff --git a/core/src/main/resources/languages/pt_PT.json b/core/src/main/resources/languages/pt_PT.json index 000692410..3d2d9f7f0 100644 --- a/core/src/main/resources/languages/pt_PT.json +++ b/core/src/main/resources/languages/pt_PT.json @@ -945,6 +945,7 @@ "iris.runtime.dust.object_at_block": "Objecto @ block: {object}", "iris.runtime.dust.object_from.biome": "Colocado pelo bioma: {biome}", "iris.runtime.dust.object_from.region": "Colocado pela região: {region}", + "iris.runtime.dust.object_from.dimension": "Colocado pela dimensão: {dimension}", "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)", diff --git a/core/src/main/resources/languages/ru_RU.json b/core/src/main/resources/languages/ru_RU.json index 728e90b5c..f5d788035 100644 --- a/core/src/main/resources/languages/ru_RU.json +++ b/core/src/main/resources/languages/ru_RU.json @@ -945,6 +945,7 @@ "iris.runtime.dust.object_at_block": "Объект @block: {object}", "iris.runtime.dust.object_from.biome": "Размещён биомом: {biome}", "iris.runtime.dust.object_from.region": "Размещён регионом: {region}", + "iris.runtime.dust.object_from.dimension": "Размещён измерением: {dimension}", "iris.runtime.dust.none": "ни одного", "iris.runtime.dust.placed_by.object_above": "Помещение: объект/наклон{object}(над поверхностью)", "iris.runtime.dust.placed_by.decoration_above": "Размещено: отделка/объект/наклон (над поверхностью)", diff --git a/core/src/main/resources/languages/tr_TR.json b/core/src/main/resources/languages/tr_TR.json index fc343e717..ee4945204 100644 --- a/core/src/main/resources/languages/tr_TR.json +++ b/core/src/main/resources/languages/tr_TR.json @@ -945,6 +945,7 @@ "iris.runtime.dust.object_at_block": "Object @block : {object}", "iris.runtime.dust.object_from.biome": "Yerleştiren biyom: {biome}", "iris.runtime.dust.object_from.region": "Yerleştiren bölge: {region}", + "iris.runtime.dust.object_from.dimension": "Yerleştiren boyut: {dimension}", "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)", diff --git a/core/src/main/resources/languages/vi_VI.json b/core/src/main/resources/languages/vi_VI.json index 7be8021a3..0b07077c7 100644 --- a/core/src/main/resources/languages/vi_VI.json +++ b/core/src/main/resources/languages/vi_VI.json @@ -945,6 +945,7 @@ "iris.runtime.dust.object_at_block": "Đối tượng {object}", "iris.runtime.dust.object_from.biome": "Được đặt bởi quần xã: {biome}", "iris.runtime.dust.object_from.region": "Được đặt bởi vùng: {region}", + "iris.runtime.dust.object_from.dimension": "Được đặt bởi chiều không gian: {dimension}", "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)", diff --git a/core/src/main/resources/languages/zh_CN.json b/core/src/main/resources/languages/zh_CN.json index 753daa5e4..5d743cdba 100644 --- a/core/src/main/resources/languages/zh_CN.json +++ b/core/src/main/resources/languages/zh_CN.json @@ -945,6 +945,7 @@ "iris.runtime.dust.object_at_block": "对象@ 方块: {object}", "iris.runtime.dust.object_from.biome": "放置来源群系: {biome}", "iris.runtime.dust.object_from.region": "放置来源区域: {region}", + "iris.runtime.dust.object_from.dimension": "放置来源维度: {dimension}", "iris.runtime.dust.none": "无", "iris.runtime.dust.placed_by.object_above": "位置: 对象/斜体 '{object}'(以上表面)", "iris.runtime.dust.placed_by.decoration_above": "由:装饰/物件/斜体(上表面)", diff --git a/core/src/main/resources/languages/zh_TW.json b/core/src/main/resources/languages/zh_TW.json index 656c9500f..ca5bbe969 100644 --- a/core/src/main/resources/languages/zh_TW.json +++ b/core/src/main/resources/languages/zh_TW.json @@ -945,6 +945,7 @@ "iris.runtime.dust.object_at_block": "物件@ 方塊: {object}", "iris.runtime.dust.object_from.biome": "放置來源生態域: {biome}", "iris.runtime.dust.object_from.region": "放置來源區域: {region}", + "iris.runtime.dust.object_from.dimension": "放置來源維度: {dimension}", "iris.runtime.dust.none": "無", "iris.runtime.dust.placed_by.object_above": "位置: 物件/斜體 '{object}'(以上表面)", "iris.runtime.dust.placed_by.decoration_above": "由:裝飾/物件/斜體(上表面)", diff --git a/core/src/main/resources/messages/en_US.json b/core/src/main/resources/messages/en_US.json index bbab4c561..35e2158a4 100644 --- a/core/src/main/resources/messages/en_US.json +++ b/core/src/main/resources/messages/en_US.json @@ -945,6 +945,7 @@ "iris.runtime.dust.object_at_block": "Object @block: {object}", "iris.runtime.dust.object_from.biome": "Placed from biome: {biome}", "iris.runtime.dust.object_from.region": "Placed from region: {region}", + "iris.runtime.dust.object_from.dimension": "Placed from dimension: {dimension}", "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)", diff --git a/core/src/test/java/art/arcane/iris/core/modules/PlacementMarkersTest.java b/core/src/test/java/art/arcane/iris/core/modules/PlacementMarkersTest.java index 31afbb36f..5f2255186 100644 --- a/core/src/test/java/art/arcane/iris/core/modules/PlacementMarkersTest.java +++ b/core/src/test/java/art/arcane/iris/core/modules/PlacementMarkersTest.java @@ -54,14 +54,26 @@ public class PlacementMarkersTest { assertEquals("trees/oak@7", PlacementMarkers.decode(biomeMarker).placementKey()); } + @Test + public void aStructurePlacedByTheDimensionReadsBack() { + IrisPackResources resources = resources(); + PlacementRecord piece = PlacementRecord.ofPiece(resources.idOf("pieces/room"), 918273, resources.idOf("structures/ruins")) + .ownedBy(new PlacementOwner(Level.DIMENSION, resources.idOf("natureplanet"))); + + String marker = PlacementMarkers.encode(piece, resources); + + assertEquals(Optional.of(piece), PlacementMarkers.recordOf(marker, resources)); + assertEquals(new PlacementMarkers.OwnerKey(Level.DIMENSION, "natureplanet"), PlacementMarkers.decode(marker).owner()); + } + @Test public void anEndThatNamesNoOwnerLeavesTheMarkerAsItWas() { PlacementMarkers.Decoded hashInKey = PlacementMarkers.decode("trees/oak#2@7"); - PlacementMarkers.Decoded dimensionOwner = PlacementMarkers.decode("trees/oak@7#dimension:Zm9yZXN0"); + PlacementMarkers.Decoded placementOwner = PlacementMarkers.decode("trees/oak@7#placement:Zm9yZXN0"); assertEquals("trees/oak#2", hashInKey.objectKey()); assertNull(hashInKey.owner()); - assertNull(dimensionOwner); + assertNull(placementOwner); } @Test diff --git a/core/src/test/java/art/arcane/iris/engine/framework/StructurePlacementScopeTest.java b/core/src/test/java/art/arcane/iris/engine/framework/StructurePlacementScopeTest.java index c33151786..819068421 100644 --- a/core/src/test/java/art/arcane/iris/engine/framework/StructurePlacementScopeTest.java +++ b/core/src/test/java/art/arcane/iris/engine/framework/StructurePlacementScopeTest.java @@ -2,6 +2,8 @@ package art.arcane.iris.engine.framework; import art.arcane.iris.builtin.structure.StructureAnchorMode; import art.arcane.iris.builtin.structure.StructurePlacement; +import com.volmit.config.Level; +import com.volmit.placement.PlacementOwner; import com.volmit.resource.ResourceId; import com.volmit.world.BiomeSample; import org.junit.Test; @@ -42,6 +44,31 @@ public class StructurePlacementScopeTest { assertFalse(placements.contains(invalidCaveScopePlacement)); } + @Test + public void theOwnerIsTheFirstLevelThatNamesThePlacement() { + StructurePlacement surfacePlacement = new StructurePlacement(); + StructurePlacement cavePlacement = placement("anchor", StructureAnchorMode.CAVE_FLOOR); + StructurePlacement regionPlacement = new StructurePlacement(); + StructurePlacement dimensionPlacement = new StructurePlacement(); + StructurePlacement undeclared = new StructurePlacement(); + StructureTestWorld world = new StructureTestWorld() + .biome(StructureTestWorld.SURFACE_BIOME, surfacePlacement) + .biome(CAVE_BIOME, cavePlacement) + .region(StructureTestWorld.REGION, regionPlacement, surfacePlacement) + .dimension(dimensionPlacement, cavePlacement) + .biomes((x, y, z) -> new BiomeSample( + StructureTestWorld.REGION, StructureTestWorld.SURFACE_BIOME, Optional.of(CAVE_BIOME))); + + assertEquals(Optional.of(PlacementOwner.biome(StructureTestWorld.SURFACE_BIOME)), + StructurePlacementScope.ownerOf(world, surfacePlacement, 0, 0)); + assertEquals(Optional.of(PlacementOwner.biome(CAVE_BIOME)), StructurePlacementScope.ownerOf(world, cavePlacement, 0, 0)); + assertEquals(Optional.of(PlacementOwner.region(StructureTestWorld.REGION)), + StructurePlacementScope.ownerOf(world, regionPlacement, 0, 0)); + assertEquals(Optional.of(new PlacementOwner(Level.DIMENSION, StructureTestWorld.DIMENSION)), + StructurePlacementScope.ownerOf(world, dimensionPlacement, 0, 0)); + assertEquals(Optional.empty(), StructurePlacementScope.ownerOf(world, undeclared, 0, 0)); + } + @Test public void dimensionOnlyPlacementsDoNotResolveBiomeScopes() { StructurePlacement dimensionPlacement = new StructurePlacement(); diff --git a/module/src/main/java/art/arcane/iris/engine/framework/StructurePlacementScope.java b/module/src/main/java/art/arcane/iris/engine/framework/StructurePlacementScope.java index b5df5742c..7ab037ab2 100644 --- a/module/src/main/java/art/arcane/iris/engine/framework/StructurePlacementScope.java +++ b/module/src/main/java/art/arcane/iris/engine/framework/StructurePlacementScope.java @@ -6,6 +6,7 @@ import art.arcane.iris.engine.framework.structure.StructureWorld; import com.volmit.config.FeatureSettings; import com.volmit.config.Level; import com.volmit.config.SettingsStack; +import com.volmit.placement.PlacementOwner; import com.volmit.resource.ResourceId; import com.volmit.world.PackWorld; import com.volmit.world.RunningWorld; @@ -62,13 +63,54 @@ public final class StructurePlacementScope { } } + /** + * The biome, cave biome, region or dimension whose settings make {@link #placementsAt} name {@code placement} for + * the chunk, looked for in the order that adds them; empty when none of them declares it. + */ + public static Optional ownerOf(PackWorld world, StructurePlacement placement, int chunkX, int chunkZ) { + RunningWorld running = StructureWorld.running(world); + int blockX = (chunkX << 4) + CHUNK_CENTER_OFFSET_BLOCKS; + int blockZ = (chunkZ << 4) + CHUNK_CENTER_OFFSET_BLOCKS; + SettingsStack declared = running.settings().at(StructurePlacementSettings.class, blockX, blockZ); + return declaringEntry(declared, Level.BIOME, placement) + .or(() -> declaringCaveBiome(running, blockX, blockZ, placement)) + .or(() -> declaringEntry(declared, Level.REGION, placement)) + .or(() -> declaringEntry(declared, Level.DIMENSION, placement)); + } + + private static Optional declaringEntry(SettingsStack declared, Level level, + StructurePlacement placement) { + return declared.entries().stream() + .filter(entry -> entry.level() == level && declares(entry.value().placements(), placement)) + .findFirst() + .map(entry -> new PlacementOwner(level, entry.source())); + } + + private static Optional declaringCaveBiome(RunningWorld running, int blockX, int blockZ, + StructurePlacement placement) { + if (!placement.resolvedAnchor().isCave()) { + return Optional.empty(); + } + return caveBiomeAt(running, blockX, blockZ) + .filter(cave -> declares(placementsOf(running.settings().declaredBy(cave, StructurePlacementSettings.class)), placement)) + .map(PlacementOwner::biome); + } + + private static boolean declares(List placements, StructurePlacement placement) { + return placements.stream().anyMatch(declared -> declared == placement); + } + private static Optional caveBiomeSettings(RunningWorld running, int blockX, int blockZ) { + FeatureSettings settings = running.settings(); + return caveBiomeAt(running, blockX, blockZ).flatMap(cave -> settings.declaredBy(cave, StructurePlacementSettings.class)); + } + + /** The column's cave biome, when it is another than its surface biome. */ + private static Optional caveBiomeAt(RunningWorld running, int blockX, int blockZ) { TerrainSampler layout = running.layout(); ResourceId surfaceBiome = layout.surfaceBiome(blockX, blockZ); - Optional caveBiome = layout.caveBiome(blockX, layout.bounds().minY(), blockZ) + return layout.caveBiome(blockX, layout.bounds().minY(), blockZ) .filter(cave -> !cave.equals(surfaceBiome)); - FeatureSettings settings = running.settings(); - return caveBiome.flatMap(cave -> settings.declaredBy(cave, StructurePlacementSettings.class)); } private static ScopeIndex buildScopeIndex(PackWorld world) { diff --git a/module/src/main/java/art/arcane/iris/engine/mantle/components/StructurePiecesAt.java b/module/src/main/java/art/arcane/iris/engine/mantle/components/StructurePiecesAt.java index 027910d4d..6db575073 100644 --- a/module/src/main/java/art/arcane/iris/engine/mantle/components/StructurePiecesAt.java +++ b/module/src/main/java/art/arcane/iris/engine/mantle/components/StructurePiecesAt.java @@ -81,12 +81,17 @@ public final class StructurePiecesAt implements ObjectsAt { } Optional piece = pieceCovering(world, resolved, x, blockY, z); if (piece.isPresent()) { - return piece; + return piece.map(record -> ownedByOrigin(world, placement, originChunkX, originChunkZ, record)); } } return Optional.empty(); } + private static PlacementRecord ownedByOrigin(PackWorld world, StructurePlacement placement, int originChunkX, int originChunkZ, + PlacementRecord piece) { + return StructurePlacementScope.ownerOf(world, placement, originChunkX, originChunkZ).map(piece::ownedBy).orElse(piece); + } + private static Optional pieceCovering(PackWorld world, IrisStructureLocator.ResolvedPlacement resolved, int x, int blockY, int z) { List pieces = resolved.pieces(); diff --git a/module/src/main/java/art/arcane/iris/engine/mantle/components/StructurePlacing.java b/module/src/main/java/art/arcane/iris/engine/mantle/components/StructurePlacing.java index ffbf0c5da..84c5a0c99 100644 --- a/module/src/main/java/art/arcane/iris/engine/mantle/components/StructurePlacing.java +++ b/module/src/main/java/art/arcane/iris/engine/mantle/components/StructurePlacing.java @@ -57,6 +57,7 @@ import com.volmit.noise.NoiseStyle; import com.volmit.object.ObjectBlock; import com.volmit.object.PlaceableObject; import com.volmit.placement.PlacementOutcome; +import com.volmit.placement.PlacementOwner; import com.volmit.placement.PlacementRecord; import com.volmit.placement.PlacementTerrain; import com.volmit.config.PackSettings; @@ -118,6 +119,7 @@ public class StructurePlacing { } String key = resolved.structureKey(); + StructureOrigin origin = new StructureOrigin(key, StructurePlacementScope.ownerOf(world, placement, cx, cz)); StructureStamp stamp = resolved.stamp(); KList pieces = resolvedPiecesOrNull(resolved, cx, cz); if (pieces == null) { @@ -151,7 +153,7 @@ public class StructurePlacing { ? null : new ColumnHeights(0); boolean supportNonOccluding = stilt != null && stilt.supportNonOccluding(); if (samplesPieceHeight(placement, stamp, pieces)) { - if (placeObject(context, key, stamp, pieces.getFirst(), mode, true, + if (placeObject(context, origin, stamp, pieces.getFirst(), mode, true, foundationColumns, supportNonOccluding) == REJECTED_PIECE) { failedPieces++; } @@ -159,7 +161,7 @@ public class StructurePlacing { ObjectPlaceMode pieceMode = placement.isAnchoredUnderground() && mode.placeMode().has(PlaceTrait.CAVE_ANCHORED) ? mode : ObjectPlaceMode.STRUCTURE_PIECE; for (AssembledPiece p : pieces) { - if (placeObject(context, key, stamp, p, pieceMode, false, + if (placeObject(context, origin, stamp, p, pieceMode, false, foundationColumns, supportNonOccluding) == REJECTED_PIECE) { failedPieces++; } @@ -560,7 +562,7 @@ public class StructurePlacing { return placement.loot(loot); } - private int placeObject(MantleStageContext context, String structureKey, StructureStamp stamp, AssembledPiece p, + private int placeObject(MantleStageContext context, StructureOrigin origin, StructureStamp stamp, AssembledPiece p, ObjectPlaceMode mode, boolean sampledHeight, ColumnHeights foundationColumns, boolean supportNonOccluding) { PlaceableObject object = objectOf(p); @@ -581,16 +583,16 @@ public class StructurePlacing { if (!outcome.isPlaced()) { return REJECTED_PIECE; } - recordPieceBlocks(terrain, run, structureKey, p, objectKey, foundationColumns, supportNonOccluding); + recordPieceBlocks(terrain, run, origin, p, objectKey, foundationColumns, supportNonOccluding); return run.anchorY().orElseThrow(() -> new IllegalStateException( "The placement graph placed " + objectKey + " without anchoring it")); } /** Notes each block the piece wrote as a base cell of the foundation, and marks its storage blocks as the structure's. */ - private void recordPieceBlocks(PlacementTerrain terrain, ObjectRun run, String structureKey, AssembledPiece piece, + private void recordPieceBlocks(PlacementTerrain terrain, ObjectRun run, StructureOrigin origin, AssembledPiece piece, String objectKey, ColumnHeights foundationColumns, boolean supportNonOccluding) { BlockRegistry blocks = world.resources().blocks(); - PlacementRecord record = structurePlacementRecord(structureKey, piece, objectKey); + PlacementRecord record = structurePlacementRecord(origin, piece, objectKey); for (BlockPosition position : run.objectBlocks()) { BlockState state = terrain.get(position.x(), position.y(), position.z()); StructureFoundationPlanner.recordBaseCell( @@ -621,8 +623,16 @@ public class StructurePlacing { return hash & Integer.MAX_VALUE; } - private PlacementRecord structurePlacementRecord(String structureKey, AssembledPiece piece, String objectKey) { - return pieceRecord(world.resources(), structureKey, piece, objectKey); + private PlacementRecord structurePlacementRecord(StructureOrigin origin, AssembledPiece piece, String objectKey) { + PlacementRecord record = pieceRecord(world.resources(), origin.structureKey(), piece, objectKey); + if (record == null || origin.owner().isEmpty()) { + return record; + } + return record.ownedBy(origin.owner().get()); + } + + /** The structure a placement placed, and the biome, region or dimension whose settings placed it. */ + private record StructureOrigin(String structureKey, Optional owner) { } /** What placing the piece object {@code objectKey} records beside its blocks; null without a structure or object. */