mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-30 09:44:24 +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
@@ -300,6 +300,8 @@ if (!outcome.isPlaced()) {
|
|||||||
- `input` is what the module hands its own placement stages (`PlacementContext.input(type)`); other modules' stages do
|
- `input` is what the module hands its own placement stages (`PlacementContext.input(type)`); other modules' stages do
|
||||||
not know its type. The area bounds what the placement may write, widened by the reach of the pack's placement stages.
|
not know its type. The area bounds what the placement may write, widened by the reach of the pack's placement stages.
|
||||||
- A placement commits whole or not at all: blocks, then markers, and only when no stage rejected and none threw.
|
- A placement commits whole or not at all: blocks, then markers, and only when no stage rejected and none threw.
|
||||||
|
- A marker is one of the kinds the host keeps, a `PlacedMarker`: `PackMarker` (a marker the pack declares, by key),
|
||||||
|
`TreeMaterial` (a tree block, for felling and growth) or `BuriedTreasure` (a chest treasure maps lead to).
|
||||||
- A rotated object turns its blocks with `BlockRegistry.rotate(state, turn)`: the `BlockTurn` says where the rotation
|
- A rotated object turns its blocks with `BlockRegistry.rotate(state, turn)`: the `BlockTurn` says where the rotation
|
||||||
moves a direction, and the platform turns the state's facing, axis or rotation to the nearest it has. `merge`,
|
moves a direction, and the platform turns the state's facing, axis or rotation to the nearest it has. `merge`,
|
||||||
`withPropertyIfAccepted` and `matches` change and compare states the way the platform does (`BlockState.withProperty`
|
`withPropertyIfAccepted` and `matches` change and compare states the way the platform does (`BlockState.withProperty`
|
||||||
|
|||||||
@@ -1,17 +1,36 @@
|
|||||||
package com.volmit.placement;
|
package com.volmit.placement;
|
||||||
|
|
||||||
import com.volmit.resource.ResourceId;
|
|
||||||
import com.volmit.geometry.BlockPosition;
|
import com.volmit.geometry.BlockPosition;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
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
|
/** 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
|
||||||
* (0 = bottom).
|
* that is the height above the dimension's bottom (0 = bottom).
|
||||||
*/
|
*/
|
||||||
public record PlacedMarker(BlockPosition position, ResourceId type, Map<String, String> attributes) {
|
public sealed interface PlacedMarker permits PlacedMarker.PackMarker, PlacedMarker.TreeMaterial, PlacedMarker.BuriedTreasure {
|
||||||
public PlacedMarker {
|
BlockPosition position();
|
||||||
Objects.requireNonNull(position, "position");
|
|
||||||
Objects.requireNonNull(type, "type");
|
/** A marker the pack declares, by its key such as {@code spawn/zombie}. */
|
||||||
attributes = Map.copyOf(attributes);
|
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