Key settings by feature id, order options as declared and declare stage reach

- Packs write settings under the feature id. @Feature(field) becomes an
  optional alias that only built-in modules may set, so existing pack JSON
  keeps loading; a pack module setting one fails the load. Reserved host
  fields now only constrain aliases. FeatureSchema exposes key and alias.
- Pack snippet names live under their module's folder
  (snippet/<namespace>/<path>/...); snippet names are folder paths.
- OptionsMetadata lists options in declaration order, read from the class
  file, a superclass's first.
- @Ref(PACK_BIOME|PACK_REGION|PACK_OBJECT) fits String only.
- Stage definitions declare reach(blocks) and writesMantle(layers);
  ResolvedGraph.reach() collects the pipeline and per-layer maximum, and
  the load fails on an unregistered or mistyped layer.
This commit is contained in:
piexel committed 2026-10-06 13:59:28 +02:00
1 parent b12e7a8c49
commit a325640d5d
38 files changed
+761 -138

No files matched your search

@@ -1,16 +1,33 @@
package com.volmit;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
/** Maps settings to an ordinary existing JSON field, without an extension wrapper. */
public record FeatureAttachment(String field, Set<Target> targets) {
/** Where settings appear in pack JSON: the targets, and the optional short alias a built-in module
* may set besides the feature id, which is always the JSON key.
*/
public record FeatureAttachment(Optional<String> alias, Set<Target> targets) {
public enum Target { DIMENSION, REGION, BIOME, OBJECT_PLACEMENT }
private static final char NAMESPACE_SEPARATOR = ':';
public FeatureAttachment {
Objects.requireNonNull(field, "field");
if (field.isBlank()) throw new IllegalArgumentException("Field must not be blank");
Objects.requireNonNull(alias, "alias");
alias.ifPresent(FeatureAttachment::requireFieldName);
targets = Set.copyOf(targets);
if (targets.isEmpty()) throw new IllegalArgumentException("At least one target is required");
}
/** Checks a JSON field name that is not a feature id: an alias or a field the host itself uses.
* It is not blank and has no ':', which every feature id has, so the two never collide.
*/
public static String requireFieldName(String name) {
Objects.requireNonNull(name, "name");
if (name.isBlank()) throw new IllegalArgumentException("Field must not be blank");
if (name.indexOf(NAMESPACE_SEPARATOR) >= 0) {
throw new IllegalArgumentException("Field " + name + " contains ':', which only feature ids may contain");
}
return name;
}
}