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:
piexel committed 2026-11-12 17:29:31 +01:00
1 parent ecc08197e8
commit 573e631bb8
32 files changed
+176 -48

No files matched your search

+1 -1
View File
@@ -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