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 b3452820b..7f87847be 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 @@ -22,6 +22,7 @@ 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.core.modules.PlacementMarkers; import art.arcane.iris.engine.framework.Engine; import art.arcane.iris.engine.framework.GenerationSessionException; import art.arcane.iris.engine.framework.GenerationSessionLease; @@ -32,6 +33,7 @@ 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; @@ -294,6 +296,12 @@ 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)); + if (owner != null) { + lines.add(new DustLine(ownerLine(owner), true)); + } if (objectKey == null && structurePiece == null) { String columnObject = findColumnObject(engine, x, relativeY, z, minHeight); lines.add(new DustLine(IrisLanguage.plain( @@ -392,6 +400,12 @@ public final class ModdedDustRevealer { MessageArgument.trusted("depth", Math.max(0, surfaceRelative - relativeY))); } + 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())); + } + static String structurePieceLine(ModuleServices.PlannedPlacement structurePiece) { return IrisLanguage.plain( RuntimeUiMessages.DUST_PLACED_BY_STRUCTURE_PIECE, diff --git a/api/README.md b/api/README.md index c4862e2f4..9c23c0e36 100644 --- a/api/README.md +++ b/api/README.md @@ -294,8 +294,8 @@ if (!outcome.isPlaced()) { - `PlacementTerrain` is the world the placement reads and the host writes into once it commits: heights, blocks, 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 and, for a piece of a structure, the - structure's id. A module may wrap the terrain to hold or filter writes; a mantle stage gets one for its invocation from + `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 `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 new file mode 100644 index 000000000..a4ced07b9 --- /dev/null +++ b/api/api/src/main/java/com/volmit/placement/PlacementOwner.java @@ -0,0 +1,31 @@ +package com.volmit.placement; + +import com.volmit.config.Level; +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. + * + * @param level {@link Level#BIOME} or {@link Level#REGION} + * @param source the biome or region, 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); + } + } + + public static PlacementOwner biome(ResourceId biome) { + return new PlacementOwner(Level.BIOME, biome); + } + + public static PlacementOwner region(ResourceId region) { + return new PlacementOwner(Level.REGION, region); + } +} 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 4fbe0b758..533fcbb2a 100644 --- a/api/api/src/main/java/com/volmit/placement/PlacementRecord.java +++ b/api/api/src/main/java/com/volmit/placement/PlacementRecord.java @@ -8,27 +8,36 @@ 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 and, for a - * piece of a structure, which structure. + * {@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. * * @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 */ -public record PlacementRecord(ResourceId object, int placementId, Optional structure) { +public record PlacementRecord(ResourceId object, int placementId, Optional structure, + Optional owner) { public PlacementRecord { Objects.requireNonNull(object, "object"); Objects.requireNonNull(structure, "structure"); + Objects.requireNonNull(owner, "owner"); } /** An object placed on its own. */ public static PlacementRecord of(ResourceId object, int placementId) { - return new PlacementRecord(object, placementId, Optional.empty()); + return new PlacementRecord(object, placementId, Optional.empty(), Optional.empty()); } /** A piece of {@code structure}. */ public static PlacementRecord ofPiece(ResourceId object, int placementId, ResourceId structure) { - return new PlacementRecord(object, placementId, Optional.of(structure)); + return new PlacementRecord(object, placementId, Optional.of(structure), Optional.empty()); + } + + /** This record, placed by {@code owner}. */ + public PlacementRecord ownedBy(PlacementOwner owner) { + return new PlacementRecord(object, placementId, structure, Optional.of(owner)); } } diff --git a/api/api/src/test/java/com/volmit/ItemAndEntityValuesTest.java b/api/api/src/test/java/com/volmit/ItemAndEntityValuesTest.java index e1760e609..82e9190ef 100644 --- a/api/api/src/test/java/com/volmit/ItemAndEntityValuesTest.java +++ b/api/api/src/test/java/com/volmit/ItemAndEntityValuesTest.java @@ -4,6 +4,8 @@ import com.volmit.entity.EntitySpec; import com.volmit.geometry.BlockPosition; import com.volmit.item.ItemDrop; import com.volmit.item.ItemEnchantment; +import com.volmit.config.Level; +import com.volmit.placement.PlacementOwner; import com.volmit.placement.PlacementRecord; import com.volmit.resource.ContentKey; import com.volmit.resource.ResourceId; @@ -92,8 +94,19 @@ class ItemAndEntityValuesTest { assertEquals(Optional.empty(), PlacementRecord.of(oak, 7).structure()); assertEquals(Optional.of(village), PlacementRecord.ofPiece(oak, 7, village).structure()); - assertEquals(PlacementRecord.of(oak, 7), new PlacementRecord(oak, 7, Optional.empty())); - assertThrows(NullPointerException.class, () -> new PlacementRecord(null, 7, Optional.empty())); + assertEquals(PlacementRecord.of(oak, 7), new PlacementRecord(oak, 7, Optional.empty(), Optional.empty())); + assertThrows(NullPointerException.class, () -> new PlacementRecord(null, 7, Optional.empty(), Optional.empty())); + } + + @Test + void aPlacementRecordNamesTheBiomeOrRegionThatPlacedIt() { + ResourceId oak = ResourceId.parse("overworld:trees/oak"); + ResourceId forest = ResourceId.parse("overworld:forest"); + + 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)); } @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 d3b9277d2..616df4990 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 @@ -23,6 +23,7 @@ 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.modules.PlacementMarkers; import art.arcane.iris.core.nms.INMS; import art.arcane.iris.core.tools.IrisToolbelt; import art.arcane.iris.engine.framework.Engine; @@ -31,6 +32,7 @@ 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; @@ -232,6 +234,10 @@ public class DustRevealer { objectKey == null ? IrisLanguage.text(RuntimeUiMessages.DUST_NONE) : objectKey ) ), false)); + PlacementMarkers.OwnerKey owner = objectKey == null ? null : safe(() -> engine.getObjectPlacementOwner(x, relativeY, z)); + if (owner != null) { + lines.add(new DustLine(ownerLine(owner), true)); + } if (objectKey == null && structurePiece == null) { String columnObject = findColumnObject(engine, x, relativeY, z, minHeight); lines.add(new DustLine(IrisLanguage.text( @@ -302,6 +308,12 @@ public class DustRevealer { sendCopyButton(sender, payload.toString()); } + 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())); + } + private static String findColumnObject(Engine engine, int x, int relativeY, int z, int minHeight) { for (int dy = 1; dy <= 64; dy++) { if (relativeY + dy >= 0) { 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 fc9a345fa..641b495cd 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 @@ -77,7 +77,9 @@ public final class RuntimeUiMessages { 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_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_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"); public static final TextKey DUST_COLUMN_ABOVE = text("iris.runtime.dust.column.above"); 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 f2aa1f16c..04537881b 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 @@ -18,18 +18,23 @@ package art.arcane.iris.core.modules; +import com.volmit.config.Level; +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; +import java.util.Locale; 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. + * Either form may end in {@code #biome:...} or {@code #region:...}, naming the biome or region that placed the object. * 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. */ @@ -37,6 +42,8 @@ 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 static final char OWNER_SEPARATOR = '#'; + private static final char OWNER_LEVEL_SEPARATOR = ':'; private PlacementMarkers() { } @@ -56,8 +63,12 @@ public final class PlacementMarkers { + ":" + encodeKey(normalizedStructureKey); } - /** The text of {@code record}, with the pack keys of its object and structure. */ + /** The text of {@code record}, with the pack keys of its object, structure and owner. */ public static String encode(PlacementRecord record, IrisPackResources resources) { + return encodePlacement(record, resources) + record.owner().map(owner -> encodeOwner(owner, resources)).orElse(""); + } + + private static String encodePlacement(PlacementRecord record, IrisPackResources resources) { String objectKey = resources.keyOf(PackResources.OBJECTS, record.object()); if (record.structure().isEmpty()) { return encode(objectKey, record.placementId()); @@ -65,6 +76,15 @@ public final class PlacementMarkers { return encodeStructure(objectKey, record.placementId(), resources.keyOf(record.structure().get())); } + 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); + } + + private static ResourceKind kindOf(Level ownerLevel) { + return ownerLevel == Level.REGION ? PackResources.REGIONS : PackResources.BIOMES; + } + /** What the text says, or empty for a text that names no placement. */ public static Optional recordOf(String marker, IrisPackResources resources) { Decoded decoded = decode(marker); @@ -75,13 +95,40 @@ public final class PlacementMarkers { Optional structure = decoded.structureAware() ? Optional.of(resources.idOf(decoded.structureKey())) : Optional.empty(); - return Optional.of(new PlacementRecord(object, decoded.placementId(), structure)); + Optional owner = Optional.ofNullable(decoded.owner()) + .map(ownerKey -> new PlacementOwner(ownerKey.level(), resources.idOf(ownerKey.key()))); + return Optional.of(new PlacementRecord(object, decoded.placementId(), structure, owner)); } public static Decoded decode(String marker) { if (marker == null || marker.isBlank()) { return null; } + int ownerStart = marker.lastIndexOf(OWNER_SEPARATOR); + OwnerKey owner = ownerStart > 0 ? decodeOwner(marker.substring(ownerStart + 1)) : null; + Decoded placement = decodePlacement(owner == null ? marker : marker.substring(0, ownerStart)); + return placement == null || owner == null ? placement : placement.ownedBy(owner); + } + + /** The owner a text's end names, or null when the end names none. */ + private static OwnerKey decodeOwner(String text) { + int levelEnd = text.indexOf(OWNER_LEVEL_SEPARATOR); + if (levelEnd <= 0) { + return null; + } + 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)) { + return null; + } + return new OwnerKey(level, key); + } catch (IllegalArgumentException exception) { + return null; + } + } + + private static Decoded decodePlacement(String marker) { if (marker.startsWith(FAMILY_PREFIX)) { return decodeStructure(marker); } @@ -103,7 +150,7 @@ public final class PlacementMarkers { if (objectKey.isBlank() || structureKey.isBlank()) { return null; } - return new Decoded(objectKey, placementId, structureKey); + return new Decoded(objectKey, placementId, structureKey, null); } catch (IllegalArgumentException exception) { return null; } @@ -119,7 +166,7 @@ public final class PlacementMarkers { return null; } try { - return new Decoded(objectKey, Integer.parseInt(marker.substring(separator + 1)), null); + return new Decoded(objectKey, Integer.parseInt(marker.substring(separator + 1)), null, null); } catch (NumberFormatException exception) { return null; } @@ -145,10 +192,26 @@ public final class PlacementMarkers { 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) { + /** + * A placement text read as pack keys; {@code structureKey} is null for an object placed on its own, {@code owner} + * null when the text names no biome or region that placed it. + */ + public record Decoded(String objectKey, int placementId, String structureKey, OwnerKey owner) { public boolean structureAware() { return structureKey != null; } + + /** The object and placement as {@code key@id}, the form the block inspection tools show. */ + public String placementKey() { + return objectKey + PLACEMENT_SEPARATOR + placementId; + } + + Decoded ownedBy(OwnerKey placedBy) { + return new Decoded(objectKey, placementId, structureKey, placedBy); + } + } + + /** The biome or region that placed an object, by its pack key; {@code level} is {@link Level#BIOME} or {@link Level#REGION}. */ + public record OwnerKey(Level level, String key) { } } diff --git a/core/src/main/java/art/arcane/iris/engine/framework/Engine.java b/core/src/main/java/art/arcane/iris/engine/framework/Engine.java index b3d88814b..699103355 100644 --- a/core/src/main/java/art/arcane/iris/engine/framework/Engine.java +++ b/core/src/main/java/art/arcane/iris/engine/framework/Engine.java @@ -427,10 +427,24 @@ public interface Engine extends DataProvider, Fallible, BlockUpdater, Renderer, return o.getObject().getLoadKey() + "@" + o.getId(); } + String raw = getObjectPlacementMarker(x, y, z); + if (raw == null || raw.isEmpty()) { + return null; + } + PlacementMarkers.Decoded marker = PlacementMarkers.decode(raw); + return marker == null ? raw : marker.placementKey(); + } + + /** The biome or region that placed the object at the block; null when no object is there or its placement names none. */ + default PlacementMarkers.OwnerKey getObjectPlacementOwner(int x, int y, int z) { + PlacementMarkers.Decoded marker = PlacementMarkers.decode(getObjectPlacementMarker(x, y, z)); + return marker == null ? null : marker.owner(); + } + + private String getObjectPlacementMarker(int x, int y, int z) { MantleChunk chunk = getMantle().getMantle().getChunk(x >> 4, z >> 4).use(); try { - String raw = chunk.get(x & 15, y, z & 15, String.class); - return (raw == null || raw.isEmpty()) ? null : raw; + return chunk.get(x & 15, y, z & 15, String.class); } finally { chunk.release(); } diff --git a/core/src/main/resources/languages/de_DE.json b/core/src/main/resources/languages/de_DE.json index 1760df0cf..4c399bf56 100644 --- a/core/src/main/resources/languages/de_DE.json +++ b/core/src/main/resources/languages/de_DE.json @@ -943,6 +943,8 @@ "iris.runtime.dust.position.below": "Position: {offset} unter der Oberfläche (Oberflächen-Y={surfaceY})", "iris.runtime.dust.position.at": "Position: an der Oberfläche (Y={surfaceY})", "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.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 82c153392..acb9557a4 100644 --- a/core/src/main/resources/languages/es_ES.json +++ b/core/src/main/resources/languages/es_ES.json @@ -943,6 +943,8 @@ "iris.runtime.dust.position.below": "Posición: {offset} bajo la superficie (Y de superficie={surfaceY})", "iris.runtime.dust.position.at": "Posición: en la superficie (Y={surfaceY})", "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.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 135aa9451..708f1f8b5 100644 --- a/core/src/main/resources/languages/fi_FI.json +++ b/core/src/main/resources/languages/fi_FI.json @@ -943,6 +943,8 @@ "iris.runtime.dust.position.below": "Sijainti: {offset} pinnan alla (pinta Y ={surfaceY})", "iris.runtime.dust.position.at": "Sijainti: pinnalla (Y ={surfaceY})", "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.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 e4a96ed34..0180e7cb3 100644 --- a/core/src/main/resources/languages/fr_FR.json +++ b/core/src/main/resources/languages/fr_FR.json @@ -943,6 +943,8 @@ "iris.runtime.dust.position.below": "Position : {offset} sous la surface (Y de surface={surfaceY})", "iris.runtime.dust.position.at": "Position : à la surface (Y={surfaceY})", "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.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 9c97c42c8..dd77c04a0 100644 --- a/core/src/main/resources/languages/he_IL.json +++ b/core/src/main/resources/languages/he_IL.json @@ -943,6 +943,8 @@ "iris.runtime.dust.position.below": "מיקום: {offset} מתחת לפני השטח (surface Y={surfaceY})", "iris.runtime.dust.position.at": "מיקום: על פני השטח (Y={surfaceY})", "iris.runtime.dust.object_at_block": "אובייקטים @בלוק: {object}", + "iris.runtime.dust.object_from.biome": "הוצב על ידי ביום: {biome}", + "iris.runtime.dust.object_from.region": "הוצב על ידי אזור: {region}", "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 2cc74e022..bee8afccf 100644 --- a/core/src/main/resources/languages/it_IT.json +++ b/core/src/main/resources/languages/it_IT.json @@ -943,6 +943,8 @@ "iris.runtime.dust.position.below": "Posizione: {offset} sotto la superficie (superficie Y={surfaceY})", "iris.runtime.dust.position.at": "Posizione: in superficie (Y={surfaceY})", "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.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 d5e7578b3..c2f9f2f76 100644 --- a/core/src/main/resources/languages/ja-JP.json +++ b/core/src/main/resources/languages/ja-JP.json @@ -943,6 +943,8 @@ "iris.runtime.dust.position.below": "位置: 地表より {offset} 下(地表 Y={surfaceY})", "iris.runtime.dust.position.at": "位置: 地表(Y={surfaceY})", "iris.runtime.dust.object_at_block": "このブロックのオブジェクト: {object}", + "iris.runtime.dust.object_from.biome": "配置元バイオーム: {biome}", + "iris.runtime.dust.object_from.region": "配置元リージョン: {region}", "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 5a369f9e0..454d27bc2 100644 --- a/core/src/main/resources/languages/ko_KR.json +++ b/core/src/main/resources/languages/ko_KR.json @@ -943,6 +943,8 @@ "iris.runtime.dust.position.below": "위치: {offset} 표면의 밑에 (표면 Y={surfaceY})", "iris.runtime.dust.position.at": "위치: 표면에 (Y={surfaceY})", "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.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 9a71f095c..d997264bd 100644 --- a/core/src/main/resources/languages/lt_LT.json +++ b/core/src/main/resources/languages/lt_LT.json @@ -943,6 +943,8 @@ "iris.runtime.dust.position.below": "Pareigos: {offset} po paviršiumi (paviršius Y ={surfaceY})", "iris.runtime.dust.position.at": "Padėtis: paviršiuje (Y ={surfaceY})", "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.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 9b8317ade..45069e8a8 100644 --- a/core/src/main/resources/languages/nl_NL.json +++ b/core/src/main/resources/languages/nl_NL.json @@ -943,6 +943,8 @@ "iris.runtime.dust.position.below": "Positie: {offset} onder het oppervlak (oppervlakte Y={surfaceY})", "iris.runtime.dust.position.at": "Positie: aan het oppervlak (Y={surfaceY})", "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.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 816c26401..fd4f98bab 100644 --- a/core/src/main/resources/languages/pl_PL.json +++ b/core/src/main/resources/languages/pl_PL.json @@ -943,6 +943,8 @@ "iris.runtime.dust.position.below": "Pozycja: {offset} poniżej powierzchni (powierzchnia Y ={surfaceY})", "iris.runtime.dust.position.at": "Położenie: na powierzchni (Y ={surfaceY})", "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.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 b6970cfbf..000692410 100644 --- a/core/src/main/resources/languages/pt_PT.json +++ b/core/src/main/resources/languages/pt_PT.json @@ -943,6 +943,8 @@ "iris.runtime.dust.position.below": "Posição: {offset} abaixo da superfície (superfície Y={surfaceY})", "iris.runtime.dust.position.at": "Posição: à superfície (Y={surfaceY})", "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.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 8f9898960..728e90b5c 100644 --- a/core/src/main/resources/languages/ru_RU.json +++ b/core/src/main/resources/languages/ru_RU.json @@ -943,6 +943,8 @@ "iris.runtime.dust.position.below": "Должность: {offset} ниже поверхности (поверхность Y ={surfaceY})", "iris.runtime.dust.position.at": "Положение: на поверхности (Y ={surfaceY})", "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.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 605d59375..fc343e717 100644 --- a/core/src/main/resources/languages/tr_TR.json +++ b/core/src/main/resources/languages/tr_TR.json @@ -943,6 +943,8 @@ "iris.runtime.dust.position.below": "Pozisyon: {offset} Aşağıdaki yüzey (surface Y={surfaceY})", "iris.runtime.dust.position.at": "Pozisyon: Yüzeyde (Y={surfaceY})", "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.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 d38f5dca5..7be8021a3 100644 --- a/core/src/main/resources/languages/vi_VI.json +++ b/core/src/main/resources/languages/vi_VI.json @@ -943,6 +943,8 @@ "iris.runtime.dust.position.below": "Vị trí: {offset} Bên dưới bề mặt (mặt đất Y={surfaceY})", "iris.runtime.dust.position.at": "Vị trí: tại bề mặt (Y={surfaceY})", "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.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 74ac36570..753daa5e4 100644 --- a/core/src/main/resources/languages/zh_CN.json +++ b/core/src/main/resources/languages/zh_CN.json @@ -943,6 +943,8 @@ "iris.runtime.dust.position.below": "位置 : {offset} 低于表面(表Y={surfaceY})", "iris.runtime.dust.position.at": "位置:在表面(Y={surfaceY})", "iris.runtime.dust.object_at_block": "对象@ 方块: {object}", + "iris.runtime.dust.object_from.biome": "放置来源群系: {biome}", + "iris.runtime.dust.object_from.region": "放置来源区域: {region}", "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 c94fa08bf..656c9500f 100644 --- a/core/src/main/resources/languages/zh_TW.json +++ b/core/src/main/resources/languages/zh_TW.json @@ -943,6 +943,8 @@ "iris.runtime.dust.position.below": "位置 : {offset} 低於表面(表Y={surfaceY})", "iris.runtime.dust.position.at": "位置:在表面(Y={surfaceY})", "iris.runtime.dust.object_at_block": "物件@ 方塊: {object}", + "iris.runtime.dust.object_from.biome": "放置來源生態域: {biome}", + "iris.runtime.dust.object_from.region": "放置來源區域: {region}", "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 c6b5e8147..bbab4c561 100644 --- a/core/src/main/resources/messages/en_US.json +++ b/core/src/main/resources/messages/en_US.json @@ -943,6 +943,8 @@ "iris.runtime.dust.position.below": "Position: {offset} below surface (surface Y={surfaceY})", "iris.runtime.dust.position.at": "Position: at surface (Y={surfaceY})", "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.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 ae2dd37f6..31afbb36f 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 @@ -1,6 +1,8 @@ package art.arcane.iris.core.modules; import art.arcane.iris.core.loader.IrisData; +import com.volmit.config.Level; +import com.volmit.placement.PlacementOwner; import com.volmit.placement.PlacementRecord; import org.junit.Test; @@ -35,6 +37,33 @@ public class PlacementMarkersTest { assertEquals(Optional.of(record), PlacementMarkers.recordOf(marker, resources)); } + @Test + public void theBiomeOrRegionThatPlacedAnObjectReadsBack() { + IrisPackResources resources = resources(); + PlacementRecord fromBiome = PlacementRecord.of(resources.idOf("trees/oak"), 7) + .ownedBy(PlacementOwner.biome(resources.idOf("forest/birch"))); + PlacementRecord pieceFromRegion = PlacementRecord.ofPiece(resources.idOf("pieces/room"), 918273, resources.idOf("structures/village")) + .ownedBy(PlacementOwner.region(resources.idOf("plains"))); + + String biomeMarker = PlacementMarkers.encode(fromBiome, resources); + String regionMarker = PlacementMarkers.encode(pieceFromRegion, resources); + + assertEquals(Optional.of(fromBiome), PlacementMarkers.recordOf(biomeMarker, resources)); + assertEquals(Optional.of(pieceFromRegion), PlacementMarkers.recordOf(regionMarker, resources)); + assertEquals(new PlacementMarkers.OwnerKey(Level.BIOME, "forest/birch"), PlacementMarkers.decode(biomeMarker).owner()); + assertEquals("trees/oak@7", PlacementMarkers.decode(biomeMarker).placementKey()); + } + + @Test + public void anEndThatNamesNoOwnerLeavesTheMarkerAsItWas() { + PlacementMarkers.Decoded hashInKey = PlacementMarkers.decode("trees/oak#2@7"); + PlacementMarkers.Decoded dimensionOwner = PlacementMarkers.decode("trees/oak@7#dimension:Zm9yZXN0"); + + assertEquals("trees/oak#2", hashInKey.objectKey()); + assertNull(hashInKey.owner()); + assertNull(dimensionOwner); + } + @Test public void textThatNamesNoPlacementIsNoRecord() { IrisPackResources resources = resources(); diff --git a/module/src/main/java/art/arcane/iris/engine/mantle/components/ChunkObjectPlacing.java b/module/src/main/java/art/arcane/iris/engine/mantle/components/ChunkObjectPlacing.java index 97a85bd79..9314d32a6 100644 --- a/module/src/main/java/art/arcane/iris/engine/mantle/components/ChunkObjectPlacing.java +++ b/module/src/main/java/art/arcane/iris/engine/mantle/components/ChunkObjectPlacing.java @@ -45,10 +45,12 @@ import com.volmit.generation.GenerationFailures; import com.volmit.object.PlaceableObject; import com.volmit.resource.ResourceId; import com.volmit.stage.MantleStageContext; +import com.volmit.placement.PlacementOwner; import com.volmit.placement.PlacementRecord; import com.volmit.world.TerrainSampler; import java.util.List; +import java.util.Locale; import java.util.Optional; import java.util.OptionalInt; @@ -223,19 +225,22 @@ final class ChunkObjectPlacing { CaveProfile biomeCaveProfile = caves.resolve(column.profiles().cave(), column.profiles().region()); CaveProfile regionCaveProfile = caves.resolve(column.profiles().region(), column.profiles().cave()); CaveAnchors anchors = newAnchors(); - placeSurfaceScope(tally, "biome-surface", surfaceObjects(column.objects().surface()), column.surface().toString()); - placeCaveScope(tally, "biome-cave", carvingObjects(column.objects().cave()), biomeCaveProfile, column.cave(), column.cave().toString(), anchors); - placeSurfaceScope(tally, "region-surface", surfaceObjects(column.objects().region()), column.region().toString()); - placeCaveScope(tally, "region-cave", carvingObjects(column.objects().region()), regionCaveProfile, null, column.region().toString(), anchors); + PlacementOwner surfaceBiome = PlacementOwner.biome(column.surface()); + PlacementOwner region = PlacementOwner.region(column.region()); + placeSurfaceScope(tally, "biome-surface", surfaceObjects(column.objects().surface()), surfaceBiome); + placeCaveScope(tally, "biome-cave", carvingObjects(column.objects().cave()), biomeCaveProfile, column.cave(), + PlacementOwner.biome(column.cave()), anchors); + placeSurfaceScope(tally, "region-surface", surfaceObjects(column.objects().region()), region); + placeCaveScope(tally, "region-cave", carvingObjects(column.objects().region()), regionCaveProfile, null, region, anchors); return tally; } - private void placeSurfaceScope(Tally tally, String scope, List placements, String ownerName) { + private void placeSurfaceScope(Tally tally, String scope, List placements, PlacementOwner owner) { for (ObjectPlacement placement : placements) { tally.checked(scope); try { if (placement.isSeparated()) { - placeSeparatedObject(tally, placement, scope); + placeSeparatedObject(tally, placement, scope, owner); continue; } boolean passes = rng.chance(separation.chanceAt(placement, centerX, centerZ) + rng.d(-CHANCE_JITTER, CHANCE_JITTER)); @@ -244,16 +249,16 @@ final class ChunkObjectPlacing { continue; } tally.triggered(scope); - placeObject(tally, placement, scope); + placeObject(tally, placement, scope, owner); } catch (Throwable failure) { - skipObjectPlacement("object", "in " + ownerKind(scope) + " " + ownerName, placement, failure); + skipObjectPlacement("object", "in " + describe(owner), placement, failure); tally.errors++; } } } /** Places the one object the chunk's candidate stands for, when no closer candidate of a lower rank outranks it. */ - private void placeSeparatedObject(Tally tally, ObjectPlacement placement, String scope) { + private void placeSeparatedObject(Tally tally, ObjectPlacement placement, String scope, PlacementOwner owner) { Optional kept = separation.keptCandidate(chunkX, chunkZ, placement, context.settings()); traceChance(scope, kept.isPresent(), placement); if (kept.isEmpty()) { @@ -268,11 +273,11 @@ final class ChunkObjectPlacing { traceNullObject(scope, 0, 1, placement); return; } - placeOnSurfaceAt(tally, placement, scope, picked.get(), candidate.x(), candidate.z(), candidate.rng(), 0, 1); + placeOnSurfaceAt(tally, placement, scope, owner, picked.get(), candidate.x(), candidate.z(), candidate.rng(), 0, 1); } private void placeCaveScope(Tally tally, String scope, List placements, CaveProfile profile, - ResourceId expectedCaveBiome, String ownerName, CaveAnchors anchors) { + ResourceId expectedCaveBiome, PlacementOwner owner, CaveAnchors anchors) { for (ObjectPlacement placement : placements) { tally.checked(scope); boolean passes = rng.chance(placement.chance()); @@ -282,23 +287,23 @@ final class ChunkObjectPlacing { } tally.triggered(scope); try { - placeCaveObject(tally, placement, profile, scope, expectedCaveBiome, anchors); + placeCaveObject(tally, placement, profile, scope, owner, expectedCaveBiome, anchors); } catch (Throwable failure) { - skipObjectPlacement("cave object", "in " + ownerKind(scope) + " " + ownerName, placement, failure); + skipObjectPlacement("cave object", "in " + describe(owner), placement, failure); tally.errors++; } } } - private static String ownerKind(String scope) { - return scope.startsWith("biome") ? "biome" : "region"; + private static String describe(PlacementOwner owner) { + return owner.level().name().toLowerCase(Locale.ROOT) + " " + owner.source(); } private void skipObjectPlacement(String kind, String where, ObjectPlacement placement, Throwable failure) { GenerationFailures.skipPlacement(log, failure, kind, String.join(", ", placement.place()), where); } - private void placeObject(Tally tally, ObjectPlacement placement, String scope) { + private void placeObject(Tally tally, ObjectPlacement placement, String scope, PlacementOwner owner) { int blockX = context.originX(); int blockZ = context.originZ(); int density = objects.density(placement, blockX, blockZ); @@ -312,12 +317,12 @@ final class ChunkObjectPlacing { } int x = rng.i(blockX, blockX + CHUNK_WIDTH_BLOCKS); int z = rng.i(blockZ, blockZ + CHUNK_WIDTH_BLOCKS); - placeOnSurfaceAt(tally, placement, scope, picked.get(), x, z, rng, i, density); + placeOnSurfaceAt(tally, placement, scope, owner, picked.get(), x, z, rng, i, density); } } - private void placeOnSurfaceAt(Tally tally, ObjectPlacement placement, String scope, PlaceableObject object, int x, int z, - RNG placingRng, int densityIndex, int density) { + private void placeOnSurfaceAt(Tally tally, ObjectPlacement placement, String scope, PlacementOwner owner, PlaceableObject object, + int x, int z, RNG placingRng, int densityIndex, int density) { PlacementChanges changes = effective.forSurface(placement, object); boolean treePlacement = isTreePlacement(object, placement); int id = placingRng.i(0, Integer.MAX_VALUE); @@ -327,7 +332,7 @@ final class ChunkObjectPlacing { + " densityIndex=" + densityIndex + " xx=" + x + " zz=" + z + " mode=" + placement.mode()); } try { - PlacementTags tags = tags(object, id, "surface", treePlacement, placement); + PlacementTags tags = tags(object, id, "surface", treePlacement, placement, owner); int result = chunk.placeOnSurface(object, x, z, placement, changes, tags, goldenTag); if (result >= 0) { tally.placed++; @@ -342,7 +347,7 @@ final class ChunkObjectPlacing { } } - private void placeCaveObject(Tally tally, ObjectPlacement placement, CaveProfile profile, String scope, + private void placeCaveObject(Tally tally, ObjectPlacement placement, CaveProfile profile, String scope, PlacementOwner owner, ResourceId expectedCaveBiome, CaveAnchors anchors) { int minX = context.originX(); int minZ = context.originZ(); @@ -367,7 +372,7 @@ final class ChunkObjectPlacing { int id = rng.i(0, Integer.MAX_VALUE); PlacementChanges changes = effective.forCave(placement, object, profile); try { - PlacementTags tags = tags(object, id, "cave", isTreePlacement(object, placement), placement); + PlacementTags tags = tags(object, id, "cave", isTreePlacement(object, placement), placement, owner); CavePlacement contained = chunk.placeInCave(object, anchor.x(), anchor.y(), anchor.z(), placement, changes, search.minDepthBelowSurface(), tags, null); tallyCave(tally, contained, scope, object, placement, i, density, search, anchor); @@ -412,29 +417,29 @@ final class ChunkObjectPlacing { return; } boolean forcePlace = upperObjectsForced(); - biome.ifPresent(declared -> placeUpperScope(declared, "upper-biome-surface", "biome", forcePlace)); - region.ifPresent(declared -> placeUpperScope(declared, "upper-region-surface", "region", forcePlace)); + biome.ifPresent(declared -> placeUpperScope(declared, "upper-biome-surface", forcePlace)); + region.ifPresent(declared -> placeUpperScope(declared, "upper-region-surface", forcePlace)); } private static Optional> levelEntry(SettingsStack declared, Level level) { return declared.entries().stream().filter(entry -> entry.level() == level).findFirst(); } - private void placeUpperScope(Entry declared, String scope, String kind, boolean forcePlace) { - String ownerKey = declared.source().toString(); + private void placeUpperScope(Entry declared, String scope, boolean forcePlace) { + PlacementOwner owner = new PlacementOwner(declared.level(), declared.source()); for (ObjectPlacement placement : surfaceObjects(declared.value())) { if (!rng.chance(placement.chance() + rng.d(-CHANCE_JITTER, CHANCE_JITTER))) { continue; } try { - placeUpperObject(placement, forcePlace, scope); + placeUpperObject(placement, forcePlace, scope, owner); } catch (Throwable failure) { - skipObjectPlacement("upper-dimension object", "in " + kind + " " + ownerKey, placement, failure); + skipObjectPlacement("upper-dimension object", "in " + describe(owner), placement, failure); } } } - private void placeUpperObject(ObjectPlacement placement, boolean forcePlace, String scope) { + private void placeUpperObject(ObjectPlacement placement, boolean forcePlace, String scope, PlacementOwner owner) { int minX = context.originX(); int minZ = context.originZ(); int density = objects.density(placement, minX, minZ); @@ -461,7 +466,7 @@ final class ChunkObjectPlacing { if (forcePlace) { changes = changes.withForcePlace(true); } - PlacementTags tags = tags(object, id, "upper", isTreePlacement(object, placement), placement); + PlacementTags tags = tags(object, id, "upper", isTreePlacement(object, placement), placement, owner); int result = chunk.placeUpper(object, x, anchorY, z, placement, changes, tags); if (traceRegen) { log.debug("Upper object placement: chunk=" + chunkX + "," + chunkZ + " scope=" + scope + " object=" + object.name() + " anchorY=" @@ -470,12 +475,13 @@ final class ChunkObjectPlacing { } } - private PlacementTags tags(PlaceableObject object, int id, String context, boolean treePlacement, ObjectPlacement placement) { + private PlacementTags tags(PlaceableObject object, int id, String context, boolean treePlacement, ObjectPlacement placement, + PlacementOwner owner) { boolean buriedTreasure = placement.isDolphinTarget() && placement.underwater(); - return new PlacementTags(placementMarker(object, id, context), treePlacement, buriedTreasure); + return new PlacementTags(placementMarker(object, id, context, owner), treePlacement, buriedTreasure); } - private PlacementRecord placementMarker(PlaceableObject object, int id, String context) { + private PlacementRecord placementMarker(PlaceableObject object, int id, String context, PlacementOwner owner) { String key = object == null ? null : object.name(); if (key == null || key.isEmpty() || key.equals("null")) { String fingerprint = context + "|" + (object == null ? "" : object.getClass().getSimpleName()); @@ -483,7 +489,7 @@ final class ChunkObjectPlacing { + "This would previously produce 'Couldn't find Object: null' warnings on chunk reload."); return null; } - return PlacementRecord.of(this.context.world().resources().idOf(key), id); + return PlacementRecord.of(this.context.world().resources().idOf(key), id).ownedBy(owner); } /** Objects in {@code trees/} are trees, procedural ones in {@code procedural/trees/} too, and so is anything a placement grows from saplings. */