Show decorators, snippets and ground cover in the studio

Decorators get their own pattern view from the decorant module: each
biome's decorators from above, placed where their own noise allows.

The Palettes and Decorators views list the pack's snippet files in a
Snippets group, with the biomes that use each one, and mark entries
read from a snippet. PackResources gains snippetOf and snippets so a
module can tell where a settings value came from.

The 3D world draws what stands on the ground, such as grass and
flowers, as the block's own model. A plugin block that is solid on the
server but shown to players as a plant no longer counts as ground.
This commit is contained in:
piexel committed 2026-11-12 04:09:20 +01:00
1 parent 67063b02d7
commit 55f6a06f9f
30 files changed
+1172 -71

No files matched your search

@@ -76,6 +76,21 @@ public interface PackResources {
return List.of();
}
/** The snippet file the pack's settings read {@code value} from, and which of its entries; empty for a value
* the pack wrote in place. {@code value} is the very object the settings hold, such as one entry of a list option
* whose type has {@link com.volmit.config.Snippet}. Empty by default.
*/
default Optional<PackSnippet.Source> snippetOf(Object value) {
return Optional.empty();
}
/** The pack's snippet files for {@code type}, a class with {@link com.volmit.config.Snippet}, in path order, used by
* the pack's settings or not, so that a tool can list them all. Empty by default.
*/
default <T> List<PackSnippet<T>> snippets(Class<T> type) {
return List.of();
}
/** {@link #find} for a resource that must exist: a missing one throws NoSuchElementException naming kind and id. */
default <T> T require(ResourceKind<T> kind, ResourceId id) {
return find(kind, id).orElseThrow(() -> new NoSuchElementException("Missing " + kind.id() + " resource: " + id));
@@ -0,0 +1,32 @@
package com.volmit.resource;
import java.util.List;
import java.util.Objects;
/**
* One snippet file of a pack, read as the type its folder holds.
*
* @param path the file below the type's snippet folder, without {@code .json}, such as {@code meadow/flowers}
* @param entries what the file holds: one entry, or several when it holds a list; none when it could not be read
*/
public record PackSnippet<T>(String path, List<T> entries) {
public PackSnippet {
Objects.requireNonNull(path, "path");
entries = List.copyOf(entries);
}
/**
* Where in the pack's snippet files a settings value was read from.
*
* @param path the file, as {@link PackSnippet#path()}
* @param entry which of the file's {@link PackSnippet#entries()} the value is, from 0
*/
public record Source(String path, int entry) {
public Source {
Objects.requireNonNull(path, "path");
if (entry < 0) {
throw new IllegalArgumentException("A snippet file's entries count from 0, not " + entry);
}
}
}
}