mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 00:34:19 +00:00
Show caves as a form with area sizes, and in the 3D world
The Caves view drops its node graph. Each cave file is one form beside the scene, with a section for the cave, its tunnel, its cavern and the pillars. A section the file lacks says "(unset)" and typing a value writes it. EditableSceneView.showsNodes() lets a view ask for this. Scenes can now be built at a size the studio picks. SceneView.sizes() lists them, and scene() and parts() take a SceneRequest with the key, variant and size. Caves offer 64 to 512 blocks across. The preview sends only the carved blocks on the outside of the space, so 512 stays light. The 3D world gets a Caves toggle. It generates the chunks of a 128, 256 or 512 square around the middle of the view and draws every air block under the terrain top, coloured by height band, with a legend.
This commit is contained in:
1 parent
e862a80615
commit
263f5baa3c
28 files changed
+958
-222
No files matched your search
@@ -18,10 +18,8 @@
|
||||
|
||||
package art.arcane.iris.modules.carve;
|
||||
|
||||
import art.arcane.iris.modules.carve.field.CavePart;
|
||||
import com.volmit.tooling.GraphNode;
|
||||
import com.volmit.tooling.GraphNode.Edits;
|
||||
import com.volmit.tooling.GraphNode.Link;
|
||||
import com.volmit.tooling.GraphNode.NodeSettings;
|
||||
import com.volmit.tooling.JsonPath;
|
||||
import com.volmit.tooling.JsonText;
|
||||
@@ -32,50 +30,38 @@ import java.util.OptionalInt;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* A cave file as nodes: the cave with its depth and surface rules, its tunnels, and its caverns with their pillars.
|
||||
* Tunnels and caverns always have a node, written or not, since setting a value of one writes it into the file.
|
||||
* A cave file as one node of settings, a section each for the cave, its tunnels, its caverns and their pillars. Every
|
||||
* section is there, written or not, since setting a value in one writes it into the file.
|
||||
*/
|
||||
final class CaveGraph {
|
||||
private static final String TUNNEL = "tunnel";
|
||||
private static final String CAVERN = "cavern";
|
||||
private static final String PILLARS = "pillars";
|
||||
private static final String UNWRITTEN = " (unset)";
|
||||
private static final String HOLDS = "";
|
||||
private static final Set<String> NO_NODES = Set.of();
|
||||
private static final Set<String> NONE_ELSEWHERE = Set.of();
|
||||
|
||||
private CaveGraph() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param read what the pack read from the file, which tells which parts the scene draws; it may be older than {@code text}
|
||||
* @throws IllegalArgumentException when the file does not hold an object
|
||||
*/
|
||||
static NodeGraph of(String name, JsonText text, Cave read) {
|
||||
/** @throws IllegalArgumentException when the file does not hold an object */
|
||||
static NodeGraph of(String name, JsonText text) {
|
||||
if (!(text.root() instanceof JsonText.Obj root)) {
|
||||
throw new IllegalArgumentException("The file does not hold an object");
|
||||
}
|
||||
JsonPath tunnelPath = JsonPath.ROOT.member(TUNNEL);
|
||||
JsonPath cavernPath = JsonPath.ROOT.member(CAVERN);
|
||||
GraphNode tunnel = partNode("Tunnel", JsonPath.ROOT.member(TUNNEL), root.get(TUNNEL).isPresent(), read.tunnel().isPresent(),
|
||||
CavePart.TUNNEL, new NodeSettings("Tunnel", JsonPath.ROOT.member(TUNNEL), CaveTunnel.class, NO_NODES), List.of());
|
||||
GraphNode pillars = new GraphNode("Pillars", titled("Pillars", hasMember(root, CAVERN, PILLARS)), cavernPath.member(PILLARS),
|
||||
OptionalInt.empty(), List.of(), List.of(new NodeSettings("Pillars", cavernPath.member(PILLARS), CavePillars.class, NO_NODES)),
|
||||
List.of(), Edits.NONE);
|
||||
GraphNode cavern = partNode("Cavern", cavernPath, root.get(CAVERN).isPresent(), read.cavern().isPresent(), CavePart.CAVERN,
|
||||
new NodeSettings("Cavern", cavernPath, CaveCavern.class, Set.of(PILLARS)), List.of(new Link(HOLDS, pillars)));
|
||||
GraphNode cave = new GraphNode("Cave", name, JsonPath.ROOT, OptionalInt.empty(), List.of(),
|
||||
List.of(new NodeSettings("Cave", JsonPath.ROOT, Cave.class, Set.of(TUNNEL, CAVERN))),
|
||||
List.of(new Link(HOLDS, tunnel), new Link(HOLDS, cavern)), Edits.NONE);
|
||||
JsonPath pillarsPath = cavernPath.member(PILLARS);
|
||||
List<NodeSettings> sections = List.of(
|
||||
new NodeSettings("Cave", JsonPath.ROOT, Cave.class, Set.of(TUNNEL, CAVERN)),
|
||||
new NodeSettings(titled("Tunnel", root.get(TUNNEL).isPresent()), tunnelPath, CaveTunnel.class, NONE_ELSEWHERE),
|
||||
new NodeSettings(titled("Cavern", root.get(CAVERN).isPresent()), cavernPath, CaveCavern.class, Set.of(PILLARS)),
|
||||
new NodeSettings(titled("Pillars", hasMember(root, CAVERN, PILLARS)), pillarsPath, CavePillars.class, NONE_ELSEWHERE));
|
||||
GraphNode cave = new GraphNode("Cave", name, JsonPath.ROOT, OptionalInt.empty(), List.of(), sections, List.of(), Edits.NONE);
|
||||
return new NodeGraph(List.of(cave));
|
||||
}
|
||||
|
||||
private static GraphNode partNode(String kind, JsonPath path, boolean written, boolean drawn, CavePart part,
|
||||
NodeSettings settings, List<Link> children) {
|
||||
OptionalInt drawnPart = drawn ? OptionalInt.of(part.ordinal()) : OptionalInt.empty();
|
||||
return new GraphNode(kind, titled(kind, written), path, drawnPart, List.of(), List.of(settings), children, Edits.NONE);
|
||||
}
|
||||
|
||||
private static String titled(String kind, boolean written) {
|
||||
return written ? kind : kind + UNWRITTEN;
|
||||
private static String titled(String section, boolean written) {
|
||||
return written ? section : section + UNWRITTEN;
|
||||
}
|
||||
|
||||
private static boolean hasMember(JsonText.Obj root, String member, String inner) {
|
||||
|
||||
@@ -27,49 +27,46 @@ import com.volmit.geometry.BlockPosition;
|
||||
import com.volmit.object.GeneratedObject;
|
||||
import com.volmit.object.ObjectBlock;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.tooling.BlockParts;
|
||||
import com.volmit.tooling.SceneSizes;
|
||||
import com.volmit.world.PackWorld;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* One cave carved over a square of the world under a flat surface, with the seed the world carves it with: the carved
|
||||
* space drawn as blocks, a colour per part, so the studio shows the shape of the cave instead of the rock around it.
|
||||
* A variant is the same cave somewhere else in the world.
|
||||
* Only the carved blocks on the outside of the space are kept, as the inside could not be seen. A variant is the same
|
||||
* cave somewhere else in the world.
|
||||
*/
|
||||
final class CavePreview {
|
||||
static final int VARIANTS = 4;
|
||||
private static final int AREA_CHUNKS = 8;
|
||||
private static final int AREA_BLOCKS = AREA_CHUNKS * 16;
|
||||
private static final int CHUNK_COLUMNS = 256;
|
||||
static final SceneSizes SIZES = new SceneSizes(List.of(64, 128, 256, 512), 128);
|
||||
/** The surface the preview carves under, in world Y. */
|
||||
static final int SURFACE_WORLD_Y = 96;
|
||||
private static final int CHUNK_BLOCKS = 16;
|
||||
private static final int CHUNK_COLUMNS = CHUNK_BLOCKS * CHUNK_BLOCKS;
|
||||
/** A cave deeper than this under the surface is cut off at the bottom of the preview. */
|
||||
private static final int MAX_DEPTH_BLOCKS = 256;
|
||||
private static final int VARIANT_SPACING_BLOCKS = 4096;
|
||||
private static final byte ROCK = 0;
|
||||
private static final BlockState TUNNEL_BLOCK = new BlockState("minecraft:light_blue_concrete");
|
||||
private static final BlockState CAVERN_BLOCK = new BlockState("minecraft:orange_concrete");
|
||||
private static final int[] FLAT_SURFACE = new int[CHUNK_COLUMNS];
|
||||
private static final double[] LISTED_EVERYWHERE = new double[CHUNK_COLUMNS];
|
||||
private static final boolean[] NOTHING_SEALED = new boolean[CHUNK_COLUMNS];
|
||||
private static final int[][] NEIGHBOURS = {{1, 0, 0}, {-1, 0, 0}, {0, 1, 0}, {0, -1, 0}, {0, 0, 1}, {0, 0, -1}};
|
||||
|
||||
static {
|
||||
Arrays.fill(LISTED_EVERYWHERE, 1D);
|
||||
}
|
||||
|
||||
private final GeneratedObject scene;
|
||||
private final BlockParts parts;
|
||||
|
||||
private CavePreview(GeneratedObject scene, BlockParts parts) {
|
||||
this.scene = scene;
|
||||
this.parts = parts;
|
||||
private CavePreview() {
|
||||
}
|
||||
|
||||
static CavePreview of(PackWorld world, ResourceId id, Cave cave, int variant) {
|
||||
/** @param size how many blocks across the square is, a whole number of chunks */
|
||||
static GeneratedObject of(PackWorld world, ResourceId id, Cave cave, int variant, int size) {
|
||||
int bottomWorldY = Math.max(world.minWorldY(), SURFACE_WORLD_Y - MAX_DEPTH_BLOCKS);
|
||||
int surfaceHeight = SURFACE_WORLD_Y - world.minWorldY();
|
||||
int lowestHeight = bottomWorldY - world.minWorldY();
|
||||
@@ -77,40 +74,74 @@ final class CavePreview {
|
||||
CaveCarver carver = new CaveCarver(cave, world.resources().noise(), seed, world.minWorldY(), surfaceHeight + 1);
|
||||
int[] surface = FLAT_SURFACE.clone();
|
||||
Arrays.fill(surface, surfaceHeight);
|
||||
CarvedSpace carved = new CarvedSpace(size, surfaceHeight - lowestHeight + 1);
|
||||
int originX = variant * VARIANT_SPACING_BLOCKS;
|
||||
Map<BlockPosition, CavePart> carved = new HashMap<>();
|
||||
for (int chunkX = 0; chunkX < AREA_CHUNKS; chunkX++) {
|
||||
for (int chunkZ = 0; chunkZ < AREA_CHUNKS; chunkZ++) {
|
||||
int sceneX = chunkX * 16;
|
||||
int sceneZ = chunkZ * 16;
|
||||
carver.carveByPart(originX + sceneX, sceneZ, surface, LISTED_EVERYWHERE, NOTHING_SEALED, (part, localX, y, localZ) -> {
|
||||
if (y >= lowestHeight) {
|
||||
carved.putIfAbsent(new BlockPosition(sceneX + localX, y - lowestHeight, sceneZ + localZ), part);
|
||||
}
|
||||
});
|
||||
int chunks = size / CHUNK_BLOCKS;
|
||||
for (int chunkX = 0; chunkX < chunks; chunkX++) {
|
||||
for (int chunkZ = 0; chunkZ < chunks; chunkZ++) {
|
||||
int sceneX = chunkX * CHUNK_BLOCKS;
|
||||
int sceneZ = chunkZ * CHUNK_BLOCKS;
|
||||
carver.carveByPart(originX + sceneX, sceneZ, surface, LISTED_EVERYWHERE, NOTHING_SEALED,
|
||||
(part, localX, y, localZ) -> carved.carve(sceneX + localX, y - lowestHeight, sceneZ + localZ, part));
|
||||
}
|
||||
}
|
||||
return new CavePreview(sceneOf(carved, surfaceHeight - lowestHeight + 1), partsOf(carved));
|
||||
return carved.outside();
|
||||
}
|
||||
|
||||
private static GeneratedObject sceneOf(Map<BlockPosition, CavePart> carved, int height) {
|
||||
List<ObjectBlock> blocks = new ArrayList<>(carved.size());
|
||||
carved.forEach((position, part) -> blocks.add(new ObjectBlock(position, part == CavePart.TUNNEL ? TUNNEL_BLOCK : CAVERN_BLOCK)));
|
||||
BlockBox bounds = new BlockBox(0, 0, 0, AREA_BLOCKS, height, AREA_BLOCKS);
|
||||
return new GeneratedObject(bounds, new BlockPosition(AREA_BLOCKS / 2, 0, AREA_BLOCKS / 2), blocks, List.of());
|
||||
}
|
||||
/** The carved blocks of a box, by the part that carved each first. */
|
||||
private static final class CarvedSpace {
|
||||
private final int size;
|
||||
private final int height;
|
||||
private final byte[] parts;
|
||||
|
||||
private static BlockParts partsOf(Map<BlockPosition, CavePart> carved) {
|
||||
Map<BlockPosition, Integer> parts = new HashMap<>(carved.size());
|
||||
carved.forEach((position, part) -> parts.put(position, part.ordinal()));
|
||||
return new BlockParts(parts);
|
||||
}
|
||||
CarvedSpace(int size, int height) {
|
||||
this.size = size;
|
||||
this.height = height;
|
||||
this.parts = new byte[size * height * size];
|
||||
}
|
||||
|
||||
GeneratedObject scene() {
|
||||
return scene;
|
||||
}
|
||||
void carve(int x, int y, int z, CavePart part) {
|
||||
if (y < 0 || y >= height) {
|
||||
return;
|
||||
}
|
||||
int cell = cellOf(x, y, z);
|
||||
if (parts[cell] == ROCK) {
|
||||
parts[cell] = (byte) (part.ordinal() + 1);
|
||||
}
|
||||
}
|
||||
|
||||
BlockParts parts() {
|
||||
return parts;
|
||||
// A carved block is on the outside where a block beside it is rock, or where it touches the box's side.
|
||||
GeneratedObject outside() {
|
||||
List<ObjectBlock> blocks = new ArrayList<>();
|
||||
for (int y = 0; y < height; y++) {
|
||||
for (int z = 0; z < size; z++) {
|
||||
for (int x = 0; x < size; x++) {
|
||||
byte part = parts[cellOf(x, y, z)];
|
||||
if (part != ROCK && touchesRock(x, y, z)) {
|
||||
blocks.add(new ObjectBlock(new BlockPosition(x, y, z), part == CavePart.TUNNEL.ordinal() + 1 ? TUNNEL_BLOCK : CAVERN_BLOCK));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
BlockBox bounds = new BlockBox(0, 0, 0, size, height, size);
|
||||
return new GeneratedObject(bounds, new BlockPosition(size / 2, 0, size / 2), blocks, List.of());
|
||||
}
|
||||
|
||||
private boolean touchesRock(int x, int y, int z) {
|
||||
for (int[] step : NEIGHBOURS) {
|
||||
int nx = x + step[0];
|
||||
int ny = y + step[1];
|
||||
int nz = z + step[2];
|
||||
boolean inside = nx >= 0 && ny >= 0 && nz >= 0 && nx < size && ny < height && nz < size;
|
||||
if (!inside || parts[cellOf(nx, ny, nz)] == ROCK) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private int cellOf(int x, int y, int z) {
|
||||
return (y * size + z) * size + x;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,13 +20,14 @@ package art.arcane.iris.modules.carve;
|
||||
|
||||
import com.volmit.object.GeneratedObject;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.tooling.BlockParts;
|
||||
import com.volmit.tooling.EditableSceneView;
|
||||
import com.volmit.tooling.JsonText;
|
||||
import com.volmit.tooling.NodeGraph;
|
||||
import com.volmit.tooling.SceneCreation;
|
||||
import com.volmit.tooling.SceneEntry;
|
||||
import com.volmit.tooling.SceneFile;
|
||||
import com.volmit.tooling.SceneRequest;
|
||||
import com.volmit.tooling.SceneSizes;
|
||||
import com.volmit.world.PackWorld;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
@@ -35,9 +36,9 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* The studio's Caves view: every cave of the pack's {@code caves/} folder carved over 128 by 128 blocks under a flat
|
||||
* surface, the carved space drawn as blocks so its shape shows. Each variant is the same cave elsewhere in the world.
|
||||
* Each cave's file can be edited as nodes, and the studio redraws the cave as it changes.
|
||||
* The studio's Caves view: every cave of the pack's {@code caves/} folder carved over a square of the world under a
|
||||
* flat surface, the carved space drawn as blocks so its shape shows. Each variant is the same cave elsewhere in the
|
||||
* world. A cave's settings are shown beside it, and the studio redraws the cave as they change.
|
||||
*/
|
||||
public final class CaveScenes implements EditableSceneView {
|
||||
private static final ResourceId ID = ResourceId.parse("iris:carve/caves");
|
||||
@@ -72,18 +73,22 @@ public final class CaveScenes implements EditableSceneView {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<GeneratedObject> scene(PackWorld world, String key, int variant) {
|
||||
return preview(world, key, variant).map(CavePreview::scene);
|
||||
public Optional<SceneSizes> sizes() {
|
||||
return Optional.of(CavePreview.SIZES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasParts() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<BlockParts> parts(PackWorld world, String key, int variant) {
|
||||
return preview(world, key, variant).map(CavePreview::parts);
|
||||
public Optional<GeneratedObject> scene(PackWorld world, SceneRequest request) {
|
||||
int size = request.size().orElse(CavePreview.SIZES.opening());
|
||||
if (request.variant() < 0 || request.variant() >= CavePreview.VARIANTS || !CavePreview.SIZES.offers(size)) {
|
||||
return Optional.empty();
|
||||
}
|
||||
ResourceId id = world.resources().idOf(request.key());
|
||||
Cave cave = CaveResources.cave(world.resources(), id);
|
||||
if (cave == null) {
|
||||
return Optional.empty();
|
||||
}
|
||||
return Optional.of(world.state(Previews.class, ignored -> new Previews()).of(world, new Place(id, request.variant(), size), cave));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -94,11 +99,14 @@ public final class CaveScenes implements EditableSceneView {
|
||||
: Optional.empty();
|
||||
}
|
||||
|
||||
// A file the pack could not read yet draws no parts, so its nodes are shown without part ids.
|
||||
@Override
|
||||
public NodeGraph graph(PackWorld world, String key, JsonText text) {
|
||||
Cave read = Optional.ofNullable(CaveResources.cave(world.resources(), key)).orElseGet(Cave::new);
|
||||
return CaveGraph.of(key.substring(key.lastIndexOf(FOLDER_SEPARATOR) + 1), text, read);
|
||||
return CaveGraph.of(key.substring(key.lastIndexOf(FOLDER_SEPARATOR) + 1), text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showsNodes() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -106,18 +114,6 @@ public final class CaveScenes implements EditableSceneView {
|
||||
return Optional.of(CREATION);
|
||||
}
|
||||
|
||||
private static Optional<CavePreview> preview(PackWorld world, String key, int variant) {
|
||||
if (variant < 0 || variant >= CavePreview.VARIANTS) {
|
||||
return Optional.empty();
|
||||
}
|
||||
ResourceId id = world.resources().idOf(key);
|
||||
Cave cave = CaveResources.cave(world.resources(), id);
|
||||
if (cave == null) {
|
||||
return Optional.empty();
|
||||
}
|
||||
return Optional.of(world.state(Previews.class, ignored -> new Previews()).of(world, id, cave, variant));
|
||||
}
|
||||
|
||||
private static SceneEntry entryOf(ResourceId id) {
|
||||
String path = id.path();
|
||||
int lastSeparator = path.lastIndexOf(FOLDER_SEPARATOR);
|
||||
@@ -126,8 +122,8 @@ public final class CaveScenes implements EditableSceneView {
|
||||
}
|
||||
|
||||
/**
|
||||
* The previews the studio asked for last. It asks for a scene and then its parts, so both come from one carve. A
|
||||
* reload reads the cave into a new object, which keys a new preview.
|
||||
* The scenes the studio asked for last, so stepping back to a size or variant is instant. A reload reads the cave
|
||||
* into a new object, which builds its scenes anew.
|
||||
*/
|
||||
private static final class Previews {
|
||||
private static final int KEPT = 8;
|
||||
@@ -139,25 +135,24 @@ public final class CaveScenes implements EditableSceneView {
|
||||
}
|
||||
};
|
||||
|
||||
CavePreview of(PackWorld world, ResourceId id, Cave cave, int variant) {
|
||||
Place place = new Place(id, variant);
|
||||
GeneratedObject of(PackWorld world, Place place, Cave cave) {
|
||||
synchronized (recent) {
|
||||
Built known = recent.get(place);
|
||||
if (known != null && known.from == cave) {
|
||||
return known.preview;
|
||||
return known.scene;
|
||||
}
|
||||
}
|
||||
CavePreview preview = CavePreview.of(world, id, cave, variant);
|
||||
GeneratedObject scene = CavePreview.of(world, place.cave(), cave, place.variant(), place.size());
|
||||
synchronized (recent) {
|
||||
recent.put(place, new Built(cave, preview));
|
||||
recent.put(place, new Built(cave, scene));
|
||||
}
|
||||
return preview;
|
||||
return scene;
|
||||
}
|
||||
}
|
||||
|
||||
private record Place(ResourceId cave, int variant) {
|
||||
private record Place(ResourceId cave, int variant, int size) {
|
||||
}
|
||||
|
||||
private record Built(Cave from, CavePreview preview) {
|
||||
private record Built(Cave from, GeneratedObject scene) {
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,7 @@ import com.volmit.object.PlaceableObject;
|
||||
import com.volmit.resource.PackResources;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.tooling.SceneEntry;
|
||||
import com.volmit.tooling.SceneRequest;
|
||||
import com.volmit.tooling.SceneView;
|
||||
import com.volmit.world.PackWorld;
|
||||
|
||||
@@ -57,12 +58,12 @@ public final class PackObjectScenes implements SceneView {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<GeneratedObject> scene(PackWorld world, String key, int variant) {
|
||||
if (variant != 0) {
|
||||
public Optional<GeneratedObject> scene(PackWorld world, SceneRequest request) {
|
||||
if (request.variant() != 0) {
|
||||
return Optional.empty();
|
||||
}
|
||||
PackResources resources = world.resources();
|
||||
return resources.objects().object(resources.idOf(key)).map(PlaceableObject::geometry);
|
||||
return resources.objects().object(resources.idOf(request.key())).map(PlaceableObject::geometry);
|
||||
}
|
||||
|
||||
private static SceneEntry entryOf(String key) {
|
||||
|
||||
@@ -34,6 +34,7 @@ import com.volmit.tooling.NodeGraph;
|
||||
import com.volmit.tooling.SceneCreation;
|
||||
import com.volmit.tooling.SceneEntry;
|
||||
import com.volmit.tooling.SceneFile;
|
||||
import com.volmit.tooling.SceneRequest;
|
||||
import com.volmit.world.PackWorld;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -91,9 +92,9 @@ public final class ProceduralObjectScenes implements EditableSceneView {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<GeneratedObject> scene(PackWorld world, String key, int variant) {
|
||||
return ProceduralObjectCatalog.of(world).variants(ProceduralObjectCatalog.KEY_PREFIX + key)
|
||||
.flatMap(variants -> variants.variant(variant))
|
||||
public Optional<GeneratedObject> scene(PackWorld world, SceneRequest request) {
|
||||
return ProceduralObjectCatalog.of(world).variants(ProceduralObjectCatalog.KEY_PREFIX + request.key())
|
||||
.flatMap(variants -> variants.variant(request.variant()))
|
||||
.map(PlaceableObject::geometry);
|
||||
}
|
||||
|
||||
@@ -103,11 +104,11 @@ public final class ProceduralObjectScenes implements EditableSceneView {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<BlockParts> parts(PackWorld world, String key, int variant) {
|
||||
return ProceduralObjectCatalog.of(world).variants(ProceduralObjectCatalog.KEY_PREFIX + key)
|
||||
public Optional<BlockParts> parts(PackWorld world, SceneRequest request) {
|
||||
return ProceduralObjectCatalog.of(world).variants(ProceduralObjectCatalog.KEY_PREFIX + request.key())
|
||||
.filter(ResolvedProceduralObject.class::isInstance)
|
||||
.map(ResolvedProceduralObject.class::cast)
|
||||
.flatMap(resolved -> resolved.variant(variant).map(resolved::parts));
|
||||
.flatMap(resolved -> resolved.variant(request.variant()).map(resolved::parts));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user