mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 16:54:04 +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
@@ -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();
|
||||
|
||||
Reference in new issue
Block a user