mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 00:34:19 +00:00
Show the biome that placed an object in dust
An object reaches past the chunk whose centre biome placed it, so dust on a block near a biome edge named the neighbouring biome. Placements now record their owning biome or region, and dust shows it as "Placed from biome: ...". Chunks generated before this change carry no owner and show no such line.
This commit is contained in:
1 parent
e550c5c77b
commit
ecc08197e8
29 files changed
+281
-52
No files matched your search
+2
-2
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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<ResourceId> structure) {
|
||||
public record PlacementRecord(ResourceId object, int placementId, Optional<ResourceId> structure,
|
||||
Optional<PlacementOwner> 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));
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user