Validators can read the platform's registries

ValidationContext.platform() hands a validator the ids the running
server registers, keyed by the same Reference a @Ref option names, so
a module checks that a structure, structure set or template pool exists
without reaching into the host. Empty when the host validates without a
platform.
This commit is contained in:
piexel committed 2026-11-06 07:59:37 +01:00
1 parent e8fca6d8c6
commit 806792ebae
2 files changed
+24

No files matched your search

@@ -0,0 +1,16 @@
package com.volmit.resource;
import com.volmit.config.Reference;
import java.util.Set;
/** The ids the running platform has registered, as the server has them, data packs and mods included: the entries a
* {@link com.volmit.config.Ref} option names. Read during validation; ids stay valid until the platform reloads them.
*/
public interface PlatformRegistries {
/** Every id the platform registers under {@code registry}, such as {@code minecraft:village_plains} for
* {@link Reference#STRUCTURE}; empty for a reference that is no platform registry ({@link Reference#STRUCTURE_PREFIX},
* {@link Reference#SPECIAL_ENTITY}, {@link Reference#NOISE_STYLE}) or one the platform lacks.
*/
Set<ResourceId> ids(Reference registry);
}
@@ -2,6 +2,9 @@ package com.volmit.validation;
import com.volmit.config.PackSettings;
import com.volmit.resource.PackResources;
import com.volmit.resource.PlatformRegistries;
import java.util.Optional;
/** The pack one {@link Validator} checks, as the host would load it, and where it reports what it finds. Valid
* only while {@link Validator#validate} runs.
@@ -17,6 +20,11 @@ public interface ValidationContext {
*/
PackSettings settings();
/** The platform's registries as the running server has them; empty when the host validates without a platform,
* such as a build or a data pack compile before the server starts. A check against them is skipped when empty.
*/
Optional<PlatformRegistries> platform();
/** Records {@code problem}. An {@link Severity#ERROR} stops the pack from loading once every validator has run. */
void report(Problem problem);
}