mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 16:25:36 +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
+1
-1
@@ -46,7 +46,7 @@ types that carry them and lists what the Iris adapter still owes.
|
||||
| Dense chunk output | `Hunk<T>`, `GenerationContext.blocks`, reference `ArrayHunk<T>` |
|
||||
| Positions, boxes and faces | `com.volmit.geometry`: `BlockPosition`, `BlockBox`, `BlockFace` |
|
||||
| Sparse geometry | `GeneratedObject` |
|
||||
| Studio views of what a module builds | `com.volmit.tooling`: `ModuleSetup.tooling()` (`ToolingRegistry.registerView`), sealed `StudioView` (`SceneView` with `SceneEntry`, `BakeRun` (`Stage`), `BlockParts`, `PatternView` with `PatternEntry`, `PatternArea`, `BlockPattern`), `EditableSceneView` (`SceneFile`, `SceneCreation`, `NodeGraph`, `GraphNode` with `Link`, `NodeSettings`, `Edits`, `Addition`), `JsonText`, `JsonPath` (`Key`, `Index`), host `StudioViewRegistration` |
|
||||
| Studio views of what a module builds | `com.volmit.tooling`: `ModuleSetup.tooling()` (`ToolingRegistry.registerView`), sealed `StudioView` (`SceneView` with `SceneEntry`, `SceneRequest`, `SceneSizes`, `BakeRun` (`Stage`), `BlockParts`, `PatternView` with `PatternEntry`, `PatternArea`, `BlockPattern`), `EditableSceneView` (`SceneFile`, `SceneCreation`, `NodeGraph`, `GraphNode` with `Link`, `NodeSettings`, `Edits`, `Addition`), `JsonText`, `JsonPath` (`Key`, `Index`), host `StudioViewRegistration` |
|
||||
| Commands of a module | `com.volmit.tooling`: `ToolingRegistry.registerCommand`, immutable `Command` (`named`, `alias`, `describe`, `child`, `argument`, `runs`, `openToEveryone`), typed `Argument` (`word`, `text`, `integer`, `decimal`, `flag`, `choice`, `resource`, `registered`, `reading` with `Argument.Reader`, `orElse`, `suggesting`), `CommandAction`, `CommandContext` (`get`, `sender`, `pack`, `world`, `platform`, `platformStructures`), plain-text `Sender` (with `player()`), `PlatformStructures` (`templates`, `template` answering `StructureTemplate`, `structures`, `structureSets`, `jigsaw` answering `JigsawStructureInfo`, `pool` answering `TemplatePool` with `Member`, `Element`, `ConnectorSource`, `Connectors` and `JigsawConnector`, `supportsCapture`, `openCaptureArea` answering a closable `CaptureArea` whose `capture` answers `CapturedStructure`; `TemplateBlock`; readers throw `StructureAccessException`), `ToolPack` (`edit` with `PackEdit`, `outputFolder`, `objects` with `ObjectCodec`, `worlds`, `services`), host `CommandRegistration` in `FeatureCatalog.commands()` |
|
||||
| Worlds a tool opens | `com.volmit.tooling.world`, exposed to pack modules by host `ExposedPackages`: `ToolWorlds` (`open`, `find`) with `ToolWorldSpec`, `ChunkPainter` and `ChunkCanvas`, `ToolWorld` (`players`, `owns`, `run`, `call`, `block`, `blockEntity`, `setBlock`, `loaded`, `repaint`, `close`), `ToolPlayer` (`targetBlock`, `teleport`, `creative`, `message`, `actionBar`, `sound`, `sidebar`, `particles`, `give` answering whether the item fitted, `held`, `openMenu`), `ToolWorldDenied` (what `open` completes with when the host refuses for a reason the user can fix; a tool reports the message and logs no stack trace), `ToolText` with `TextColor` (styled text, spans in a colour with bold, italic and strikethrough: item names and lore, menu titles, sidebar, chat and action bar; the host shows each span in its colour and style, an empty sidebar title keeps the platform's, and an item read back has plain text), `ToolItem`, `ToolMenu` with `MenuButton` and `MenuClick`, `Particle`, `ToolWorldListener` (`entered`, `left`, `teleported` for every arrival other than walking, at the time of the teleport, `moved`, `sneakToggled`, `used` with `ToolUse`, `blockChanging` with `BlockChange.Cause` and `BlockChange.changed`, `containerChanged` for a closed container inventory or a furnace or brewing stand that started, `command`, `chunkLoaded`, `closeRefusal`, `closing`, `closed`), `com.volmit.geometry.ChunkPos`; a tool world takes the pack's studio slot, so the host asks `closeRefusal` before it closes the world for another studio, the studio close command or a server stop, and waits for `closing` when another studio replaces it; every Y is the world's own; implemented by each platform adapter (Bukkit, and the modded adapters on the server thread) |
|
||||
| Buffered placement writes | `PlacementRequest`, `PlacementAccess`, host-owned `PlacementEdit` |
|
||||
|
||||
+8
-4
@@ -522,13 +522,16 @@ final class RuinScenes implements SceneView {
|
||||
return List.of(new SceneEntry("arch", "Arch", Optional.empty(), 1));
|
||||
}
|
||||
|
||||
public Optional<GeneratedObject> scene(PackWorld world, String key, int variant) {
|
||||
return world.resources().objects().object(world.resources().idOf("ruins/" + key)).map(PlaceableObject::geometry);
|
||||
public Optional<GeneratedObject> scene(PackWorld world, SceneRequest request) {
|
||||
return world.resources().objects().object(world.resources().idOf("ruins/" + request.key())).map(PlaceableObject::geometry);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
- A `SceneView` lists entries (`SceneEntry`) and gives each variant's blocks as a `GeneratedObject`, drawn in 3D. A
|
||||
- A `SceneView` lists entries (`SceneEntry`) and gives the blocks of the scene a `SceneRequest` names (an entry's key
|
||||
and variant) as a `GeneratedObject`, drawn in 3D. A view whose scenes are a square of the world, such as the Caves
|
||||
view, returns `SceneSizes` from `sizes()`. The studio then offers those sizes and puts the chosen one in the
|
||||
request. A
|
||||
`PatternView` lists entries (`PatternEntry`) and gives the blocks one lays over a `PatternArea` at a depth as a
|
||||
`BlockPattern`, drawn from above. `StudioView` is sealed to these two kinds: the studio draws nothing else.
|
||||
- A `SceneView` whose entries are baked from settings says so (`isBaked`) and times a bake on request (`timeBake`, a
|
||||
@@ -547,7 +550,8 @@ final class RuinScenes implements SceneView {
|
||||
settings (`NodeSettings`, shown as the pack's schema describes their type), the nodes it holds and the `Edits` the
|
||||
studio may make (a child list to move nodes into, whether it moves, the `Addition`s it offers). Places in the file
|
||||
are `JsonPath`s of `Key` and `Index` steps. The studio writes the file itself, rewriting only what changes; the
|
||||
view never writes. A view whose entries the studio may create and delete returns a `SceneCreation` from
|
||||
view never writes. A view whose file reads as one node of settings returns false from `showsNodes()`, and the
|
||||
studio shows that node's settings beside the scene instead of a graph. A view whose entries the studio may create and delete returns a `SceneCreation` from
|
||||
`creation()`: the resource kind of its files, the starter JSON of a new entry and the text other files name an
|
||||
entry by; the studio does the writing, listing of uses and trashing.
|
||||
- Absent values are empty, never blank or `-1`: an entry without a group, a node that draws no part of the scene
|
||||
|
||||
@@ -21,6 +21,14 @@ public interface EditableSceneView extends SceneView {
|
||||
*/
|
||||
NodeGraph graph(PackWorld world, String key, JsonText text);
|
||||
|
||||
/**
|
||||
* Whether the studio shows the file's graph as nodes under the scene, which is the default. A view whose file reads
|
||||
* as one node of settings says no, and the studio shows those settings beside the scene instead.
|
||||
*/
|
||||
default boolean showsNodes() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/** How the studio creates and removes entries of this view; empty when it may not, which is the default. */
|
||||
default Optional<SceneCreation> creation() {
|
||||
return Optional.empty();
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.volmit.tooling;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.OptionalInt;
|
||||
|
||||
/**
|
||||
* Which scene of a {@link SceneView} the studio asks for.
|
||||
*
|
||||
* @param key the entry, as {@link SceneEntry#key()} names it
|
||||
* @param variant from 0 to the entry's {@link SceneEntry#variants()}, exclusive
|
||||
* @param size how many blocks across to build the scene, one of the view's {@link SceneView#sizes()}; empty when the
|
||||
* view has none
|
||||
*/
|
||||
public record SceneRequest(String key, int variant, OptionalInt size) {
|
||||
public SceneRequest {
|
||||
Objects.requireNonNull(key, "key");
|
||||
Objects.requireNonNull(size, "size");
|
||||
}
|
||||
|
||||
public static SceneRequest of(String key, int variant) {
|
||||
return new SceneRequest(key, variant, OptionalInt.empty());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.volmit.tooling;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* The sizes a {@link SceneView} builds its scenes at, which the studio lets one choose between.
|
||||
*
|
||||
* @param blocksAcross each size, as how many blocks across the scene is, smallest first
|
||||
* @param opening the size the studio shows first, one of {@code blocksAcross}
|
||||
*/
|
||||
public record SceneSizes(List<Integer> blocksAcross, int opening) {
|
||||
public SceneSizes {
|
||||
blocksAcross = List.copyOf(Objects.requireNonNull(blocksAcross, "blocksAcross"));
|
||||
if (blocksAcross.isEmpty()) {
|
||||
throw new IllegalArgumentException("Scene sizes need at least one size");
|
||||
}
|
||||
for (int at = 0; at < blocksAcross.size(); at++) {
|
||||
if (blocksAcross.get(at) < 1) {
|
||||
throw new IllegalArgumentException("A scene is at least 1 block across, not " + blocksAcross.get(at));
|
||||
}
|
||||
if (at > 0 && blocksAcross.get(at) <= blocksAcross.get(at - 1)) {
|
||||
throw new IllegalArgumentException("Scene sizes go from smallest to largest: " + blocksAcross);
|
||||
}
|
||||
}
|
||||
if (!blocksAcross.contains(opening)) {
|
||||
throw new IllegalArgumentException("The opening size " + opening + " is not one of " + blocksAcross);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean offers(int size) {
|
||||
return blocksAcross.contains(size);
|
||||
}
|
||||
}
|
||||
@@ -15,12 +15,18 @@ public non-sealed interface SceneView extends StudioView {
|
||||
List<SceneEntry> entries(PackWorld world);
|
||||
|
||||
/**
|
||||
* The blocks of one variant of the entry named {@code key}, its anchor where the studio centres the scene; empty
|
||||
* when the pack has no such entry, or the entry has fewer variants.
|
||||
*
|
||||
* @param variant from 0 to the entry's {@link SceneEntry#variants()}, exclusive
|
||||
* The blocks of the scene {@code request} names, its anchor where the studio centres the scene; empty when the pack
|
||||
* has no such entry, or the entry has fewer variants.
|
||||
*/
|
||||
Optional<GeneratedObject> scene(PackWorld world, String key, int variant);
|
||||
Optional<GeneratedObject> scene(PackWorld world, SceneRequest request);
|
||||
|
||||
/**
|
||||
* The sizes the studio lets one build every scene at, such as a square of the world a view carves; empty when each
|
||||
* entry has a size of its own, which is the default.
|
||||
*/
|
||||
default Optional<SceneSizes> sizes() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
/** Whether the entries are built from parts the studio can pick out of the scene, which {@link #parts} tells apart. */
|
||||
default boolean hasParts() {
|
||||
@@ -32,7 +38,7 @@ public non-sealed interface SceneView extends StudioView {
|
||||
* was built. Asked off the server's threads; empty when the view has no parts, the pack has no such entry, or the
|
||||
* entry has fewer variants.
|
||||
*/
|
||||
default Optional<BlockParts> parts(PackWorld world, String key, int variant) {
|
||||
default Optional<BlockParts> parts(PackWorld world, SceneRequest request) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ class BakeRunTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<GeneratedObject> scene(PackWorld world, String key, int variant) {
|
||||
public Optional<GeneratedObject> scene(PackWorld world, SceneRequest request) {
|
||||
return Optional.empty();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -67,12 +67,12 @@ class BlockPartsTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<GeneratedObject> scene(PackWorld world, String key, int variant) {
|
||||
public Optional<GeneratedObject> scene(PackWorld world, SceneRequest request) {
|
||||
return Optional.empty();
|
||||
}
|
||||
};
|
||||
|
||||
assertFalse(plain.hasParts());
|
||||
assertTrue(plain.parts(null, "any", 0).isEmpty());
|
||||
assertTrue(plain.parts(null, SceneRequest.of("any", 0)).isEmpty());
|
||||
}
|
||||
}
|
||||
@@ -204,7 +204,7 @@ class ModuleRegistryTest {
|
||||
public String label() { return id; }
|
||||
public String description() { return id; }
|
||||
public List<com.volmit.tooling.SceneEntry> entries(com.volmit.world.PackWorld world) { return List.of(); }
|
||||
public Optional<com.volmit.object.GeneratedObject> scene(com.volmit.world.PackWorld world, String key, int variant) {
|
||||
public Optional<com.volmit.object.GeneratedObject> scene(com.volmit.world.PackWorld world, com.volmit.tooling.SceneRequest request) {
|
||||
return Optional.empty();
|
||||
}
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user