mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 16:25:36 +00:00
PlacedMarker is a sealed type of the markers the host keeps
The open (type, attributes) shape promised markers the host refused at runtime. PackMarker, TreeMaterial and BuriedTreasure make an unkept marker a compile error and remove the shared id strings.
This commit is contained in:
1 parent
32a07bd005
commit
c577b68c00
2 files changed
+30
-9
No files matched your search
@@ -1,17 +1,36 @@
|
||||
package com.volmit.placement;
|
||||
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/** Marker metadata. The position has world X and Z and a Y that is the height above the dimension's bottom
|
||||
* (0 = bottom).
|
||||
/** A mark a placement leaves at a block, of one of the kinds the host keeps. The position has world X and Z and a Y
|
||||
* that is the height above the dimension's bottom (0 = bottom).
|
||||
*/
|
||||
public record PlacedMarker(BlockPosition position, ResourceId type, Map<String, String> attributes) {
|
||||
public PlacedMarker {
|
||||
Objects.requireNonNull(position, "position");
|
||||
Objects.requireNonNull(type, "type");
|
||||
attributes = Map.copyOf(attributes);
|
||||
public sealed interface PlacedMarker permits PlacedMarker.PackMarker, PlacedMarker.TreeMaterial, PlacedMarker.BuriedTreasure {
|
||||
BlockPosition position();
|
||||
|
||||
/** A marker the pack declares, by its key such as {@code spawn/zombie}. */
|
||||
record PackMarker(BlockPosition position, String key) implements PlacedMarker {
|
||||
public PackMarker {
|
||||
Objects.requireNonNull(position, "position");
|
||||
Objects.requireNonNull(key, "key");
|
||||
if (key.isBlank()) {
|
||||
throw new IllegalArgumentException("A pack marker needs a key");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** A block of a tree: the host keeps the block's material so the tree can be felled and grown. */
|
||||
record TreeMaterial(BlockPosition position) implements PlacedMarker {
|
||||
public TreeMaterial {
|
||||
Objects.requireNonNull(position, "position");
|
||||
}
|
||||
}
|
||||
|
||||
/** A buried treasure chest: the host keeps it as a point of interest that treasure maps lead to. */
|
||||
record BuriedTreasure(BlockPosition position) implements PlacedMarker {
|
||||
public BuriedTreasure {
|
||||
Objects.requireNonNull(position, "position");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user