mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 00:04:42 +00:00
- 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.
34 lines
1.3 KiB
Java
34 lines
1.3 KiB
Java
package com.volmit;
|
|
|
|
import java.util.Objects;
|
|
import java.util.Optional;
|
|
import java.util.Set;
|
|
|
|
/** 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(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;
|
|
}
|
|
}
|