mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 08:44:50 +00:00
Show the biome that placed a structure in dust
Structures start from their origin chunk's biome, cave biome, region or dimension, then reach into neighbouring biomes. Dust on a structure piece now names that owner, found from the structure plan, so it works on chunks generated before this change too. Chest markers that structures record carry the owner as well, and a placement can now be owned by the dimension.
This commit is contained in:
1 parent
ecc08197e8
commit
573e631bb8
32 files changed
+176
-48
No files matched your search
+8
-7
@@ -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) {
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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<ResourceId> structure,
|
||||
Optional<PlacementOwner> owner) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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<String> 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<String> structure, Optional<PlacementMarkers.OwnerKey> owner) {
|
||||
}
|
||||
|
||||
/** The keys of the biomes and regions of the engine's layout that every module says place the object {@code objectKey}. */
|
||||
|
||||
@@ -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) {
|
||||
}
|
||||
}
|
||||
@@ -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)",
|
||||
|
||||
@@ -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)",
|
||||
|
||||
@@ -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)",
|
||||
|
||||
@@ -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)",
|
||||
|
||||
@@ -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 (מעל פני השטח)",
|
||||
|
||||
@@ -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)",
|
||||
|
||||
@@ -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(地表より上)",
|
||||
|
||||
@@ -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(표면 위)",
|
||||
|
||||
@@ -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)",
|
||||
|
||||
@@ -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)",
|
||||
|
||||
@@ -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ą)",
|
||||
|
||||
@@ -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)",
|
||||
|
||||
@@ -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": "Размещено: отделка/объект/наклон (над поверхностью)",
|
||||
|
||||
@@ -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)",
|
||||
|
||||
@@ -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)",
|
||||
|
||||
@@ -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": "由:装饰/物件/斜体(上表面)",
|
||||
|
||||
@@ -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": "由:裝飾/物件/斜體(上表面)",
|
||||
|
||||
@@ -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)",
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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<PlacementOwner> 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<StructurePlacementSettings> 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<PlacementOwner> declaringEntry(SettingsStack<StructurePlacementSettings> 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<PlacementOwner> 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<StructurePlacement> placements, StructurePlacement placement) {
|
||||
return placements.stream().anyMatch(declared -> declared == placement);
|
||||
}
|
||||
|
||||
private static Optional<StructurePlacementSettings> 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<ResourceId> caveBiomeAt(RunningWorld running, int blockX, int blockZ) {
|
||||
TerrainSampler layout = running.layout();
|
||||
ResourceId surfaceBiome = layout.surfaceBiome(blockX, blockZ);
|
||||
Optional<ResourceId> 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) {
|
||||
|
||||
+6
-1
@@ -81,12 +81,17 @@ public final class StructurePiecesAt implements ObjectsAt {
|
||||
}
|
||||
Optional<PlacementRecord> 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<PlacementRecord> pieceCovering(PackWorld world, IrisStructureLocator.ResolvedPlacement resolved,
|
||||
int x, int blockY, int z) {
|
||||
List<AssembledPiece> pieces = resolved.pieces();
|
||||
|
||||
+18
-8
@@ -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<AssembledPiece> 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<PlacementOwner> owner) {
|
||||
}
|
||||
|
||||
/** What placing the piece object {@code objectKey} records beside its blocks; null without a structure or object. */
|
||||
|
||||
Reference in new issue
Block a user