diff --git a/CONTRACTS.md b/CONTRACTS.md index 24ab32818..c917f026b 100644 --- a/CONTRACTS.md +++ b/CONTRACTS.md @@ -26,7 +26,7 @@ types that carry them and lists what the Iris adapter still owes. | Annotated settings | `IrisFeature`, `@Feature` (id, short JSON `key`, optional `root`), config annotations, host `OptionsMetadata`, `LinkedBiomes` (`treeBiomes`, `usedBiomes`: pack biomes the settings bring into the layout) | | Host facades for the host's own modules | `PackWorld.extension(type)`, `InvocationContext.extension(type)`, `PackSettings.extension(type)` (each an `Optional`, empty by default) | | Area a stage writes | `reach(blocks)`, `reach(PackReach)`, `writesMantle(...)` on stage definitions, `PackSettings`, host `StageReach`, `ResolvedStage.reachBlocks`, `PipelineReach` | -| Settings described for studio | `@Desc`, `@Required`, `@MinNumber`, `@MaxNumber`, `@MinItems`, `@Snippet`, `@Ref`/`Reference`, `FeatureRegistry.registerSettings`, `FeatureRegistry.registerHeldType`, host `FeatureCatalog.heldTypes()`, host `LoadedPack.schema()` (`PackSchema`, `FeatureSchema`, `ObjectType`, `SchemaOption`, `ValueKind` with `HostKind`), `ModuleHost.describingHostTypesIn` | +| Settings described for studio | `@Desc`, `@Required`, `@MinNumber`, `@MaxNumber`, `@MinItems`, `@Snippet`, `@Ref`/`Reference`, `FeatureRegistry.registerSettings`, host `LoadedPack.schema()` (`PackSchema`, `FeatureSchema`, `ObjectType`, `SchemaOption`, `ValueKind` with `HostKind`), `ModuleHost.describingHostTypesIn` | | Geometry and mantle registration | `FeatureRegistry`, host `ModuleRegistry`, `FeatureCatalog` | | Block states and palettes | `BlockState`, `BlockRegistry` (`resolve(BlockSpec)`, `find(key)`, `blockEntity`, `hasTrait`, `oreFor`), `BlockTrait`, `BlockPalette`, `BlockSpec`, `PaletteSpec` and `PaletteSampler` (`BlockRegistry.palette`) | | Noise from pack-described styles | `NoiseStyle`, `StyledRange`, `PackResources.noise()`, `NoiseFactory`, `NoiseSampler` | @@ -108,8 +108,8 @@ running Iris is the pack publisher's responsibility. `ConfiguredSettings.placement(...)`; the chunk and mantle runners collect a chunk's settings themselves. - Name the packages of the classes Iris describes itself with `ModuleHost.describingHostTypesIn(...)`, - decode them as Iris does, and render each `HostKind` with Iris's own description of the class. These, and - `registerHeldType`, are deprecated for removal: transitional, until the cut-over. + decode them as Iris does, and render each `HostKind` with Iris's own description of the class. These are + deprecated for removal: transitional, until the cut-over. - Back each module's log with the host's own: `ModuleHost.loggingTo(logger)` where `logger` writes `DEBUG` only when the host's debug setting is on and writes an `ERROR` with a cause as the host reports its own failures. Implement `PackWorld.log()` (the host's own log) and hand services a world scoped to the provider's module diff --git a/DESIGN.md b/DESIGN.md index a0663b840..8df04b037 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -718,12 +718,6 @@ core engine is modules as well. The host's own JSON fields are not in it; no key inlined copy, so a class used in many places is described once, and a class that contains itself, directly or through others, ends the walk at its own name. Two different classes with one name fail the load; only a built-in class and a pack class can collide that way. -- Modules may also register a class that Iris's own classes hold (`registerHeldType`, `FeatureCatalog.heldTypes()`; - deprecated for removal, transitional until the cut-over): - it is described like any settings class reachable from a feature, but no `FeatureSchema` names it. This is for - settings that live in a host class until their feature owns them, such as the clamp of an object placement. The class - must be loaded by the host: a built-in module's, or one of a package the host exposes (the built-ins jar's modules - register the classes of `art.arcane.iris.builtin`); a class from the registering pack module's own jar fails the load. - A `SchemaOption` per field that `OptionsMetadata` selects, which means instance fields that are not transient, inherited ones included, in declaration order. Each has its name, `ValueKind`, `@Desc`, `@Required`, `@MinNumber`/`@MaxNumber`, `@MinItems` and the default value. @@ -1274,7 +1268,7 @@ API now: `world.running()`, `world.seed(purpose)`, `TerrainSampler`, `FeatureSet through Iris's placers, and the loot of what was placed. Objects are named by the string keys placements hold, and the API has no object model. It goes when the API describes a placeable object and its placement. - **`ObjectPlacement`** with `ObjectShape`, `PlacementSettings` and `PlacementTerrain` (invocation). The object being placed, - read from Iris's `IrisObjectPlacement`, and the terrain questions of Iris's placers (carved, structure volumes, the object + read from the module's own `objects.ObjectPlacement` settings, and the terrain questions of Iris's placers (carved, structure volumes, the object already at a block). Its surface noise (`PlaneNoise`, `SurfaceWarp`) is Iris's own simplex and warp with a cache, which no API noise reproduces value for value, so existing worlds would move. It goes with `ObjectHost`. - **`FloatingHost`** (world). Island height comes from Iris's biome generators and island tops are painted by Iris's biome diff --git a/README.md b/README.md index e5f53e86a..4d1893b8a 100644 --- a/README.md +++ b/README.md @@ -564,11 +564,6 @@ public final class FloraSettings implements IrisFeature { that no stage names, such as ones read only through `FeatureSettings.at(...)`, are registered with `setup.registry().registerSettings(WindSettings.class, GustSettings.class)` in `setup`. Their feature id follows the module id like any other, and once registered, other modules may name them in `when(...)`. -- A class of a built-in module that Iris's own classes hold, such as the clamp field of an object placement, is - registered with `registry.registerHeldType(Clamp.class)`, so studio describes it from the class (as an - `ObjectType`, with no feature). Only built-in modules may; a pack module's class can never be a field of an Iris class. - `registerHeldType` (with `HeldTypeRegistration` and `FeatureCatalog.heldTypes()`) is deprecated for removal: - transitional, until the cut-over. A load error names the field, the settings and the module: diff --git a/api/src/main/java/com/volmit/FeatureRegistry.java b/api/src/main/java/com/volmit/FeatureRegistry.java index 68c4fbb71..894cb8683 100644 --- a/api/src/main/java/com/volmit/FeatureRegistry.java +++ b/api/src/main/java/com/volmit/FeatureRegistry.java @@ -34,19 +34,6 @@ public interface FeatureRegistry { */ void registerSettings(Class... settingsTypes); - /** Describes a class that Iris's own classes hold, such as the clamp of an object placement, so studio shows - * its fields as this class declares them. The class must be one the host loads: a built-in module's class, or a - * class of a package the host exposes to pack modules (a pack module's own classes could never be a field of - * one of the host's classes, so registering one fails the load). The host reads the class - * with its fields in pack JSON, and the class follows the rules of settings classes. Registering a class twice - * changes nothing. - * - * @deprecated Transitional, until the cut-over: only while Iris's own classes still hold built-in module types. - * Removed once they do not. - */ - @Deprecated(forRemoval = true) - void registerHeldType(Class type); - /** Declares a kind of pack resource this module reads: the JSON files under the kind's folder, served through * {@link com.volmit.resource.PackResources} by the kind's type and described for studio from its class like * settings. The pack load fails when another kind has the same id, type or folder, or the folder is one the diff --git a/host/src/main/java/com/volmit/host/FeatureCatalog.java b/host/src/main/java/com/volmit/host/FeatureCatalog.java index 4d4ec1051..b62a513c9 100644 --- a/host/src/main/java/com/volmit/host/FeatureCatalog.java +++ b/host/src/main/java/com/volmit/host/FeatureCatalog.java @@ -18,7 +18,6 @@ import java.util.stream.Collectors; * nothing depends on discovery. Factory, codec, validator, hook and provider implementations must themselves obey their * concurrency contracts. */ -@SuppressWarnings("removal") // held types are transitional, until the cut-over public final class FeatureCatalog { /** Services are asked for on the generation hot path, so each type's annotation is read once. */ private static final ClassValue SERVICE_PROVIDERS = new ClassValue<>() { @@ -37,7 +36,6 @@ public final class FeatureCatalog { private final Map, ObjectRegistration> objects; private final Map> mantle; private final List resourceKinds; - private final List heldTypes; private final List validators; private final List lifecycles; private final Map, List> registrationsByService; @@ -48,7 +46,6 @@ public final class FeatureCatalog { Map, ObjectRegistration> objects, Map> mantle, Collection resourceKinds, - Collection heldTypes, List validators, List lifecycles, List services) { @@ -56,7 +53,6 @@ public final class FeatureCatalog { this.objects = Map.copyOf(objects); this.mantle = Map.copyOf(mantle); this.resourceKinds = sorted(resourceKinds, registration -> registration.kind().id()); - this.heldTypes = sorted(heldTypes, registration -> registration.type().getName()); this.validators = inModuleOrder(validators, ValidatorRegistration::module); this.lifecycles = inModuleOrder(lifecycles, LifecycleRegistration::module); this.registrationsByService = byService(inModuleOrder(services, ServiceRegistration::module)); @@ -81,15 +77,6 @@ public final class FeatureCatalog { return resourceKinds; } - /** The classes built-in modules described because Iris's own classes hold them, by class name. - * - * @deprecated Transitional, until the cut-over; see {@link com.volmit.FeatureRegistry#registerHeldType}. - */ - @Deprecated(forRemoval = true) - public List heldTypes() { - return heldTypes; - } - /** The validators modules registered, by module id, each module's in the order it registered them. */ public List validators() { return validators; diff --git a/host/src/main/java/com/volmit/host/HeldTypeRegistration.java b/host/src/main/java/com/volmit/host/HeldTypeRegistration.java deleted file mode 100644 index a7ea69916..000000000 --- a/host/src/main/java/com/volmit/host/HeldTypeRegistration.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.volmit.host; - -import java.util.Objects; - -/** A class of a built-in module that Iris's own classes hold, and the module that registered it. - * - * @deprecated Transitional, until the cut-over; see {@link com.volmit.FeatureRegistry#registerHeldType}. - */ -@Deprecated(forRemoval = true) -public record HeldTypeRegistration(Class type, DiscoveredModule module) { - public HeldTypeRegistration { - Objects.requireNonNull(type, "type"); - Objects.requireNonNull(module, "module"); - } - - @Override - public String toString() { - return "held type " + type.getName() + " of module " + module; - } -} diff --git a/host/src/main/java/com/volmit/host/ModuleRegistry.java b/host/src/main/java/com/volmit/host/ModuleRegistry.java index 8c1c12b75..a4bce3c32 100644 --- a/host/src/main/java/com/volmit/host/ModuleRegistry.java +++ b/host/src/main/java/com/volmit/host/ModuleRegistry.java @@ -33,7 +33,6 @@ import java.util.Set; * invalidates the host's whole build. This does not decode JSON, discover modules or instantiate * settings. */ -@SuppressWarnings("removal") // held types are transitional, until the cut-over public final class ModuleRegistry implements FeatureRegistry { private final Map, FeatureDescriptor> settings = new HashMap<>(); private final Map, ObjectRegistration> objects = new HashMap<>(); @@ -43,7 +42,6 @@ public final class ModuleRegistry implements FeatureRegistry { private final Set> registeredByOwner = new HashSet<>(); private final Map keyClaimants = new HashMap<>(); private final Map resourceKinds = new HashMap<>(); - private final Map, HeldTypeRegistration> heldTypes = new HashMap<>(); private final List validators = new ArrayList<>(); private final List lifecycles = new ArrayList<>(); private final List services = new ArrayList<>(); @@ -120,20 +118,6 @@ public final class ModuleRegistry implements FeatureRegistry { registeredByOwner.add(settingsType); } - /** @deprecated Transitional, until the cut-over; see {@link FeatureRegistry#registerHeldType}. */ - @Override - @Deprecated(forRemoval = true) - public void registerHeldType(Class type) { - checkOpen(); - Objects.requireNonNull(type, "type"); - requireRegistering("Held type " + type.getName()); - if (registering.source() != DiscoveredModule.Source.HOST && type.getClassLoader() == registering.module().getClass().getClassLoader()) { - throw new IllegalArgumentException("Held type " + type.getName() + " of module " + registering + " is a class of the pack module's" - + " own jar; only a class the host loads, such as one of an exposed package, can be held by Iris's own classes"); - } - heldTypes.putIfAbsent(type, new HeldTypeRegistration(type, registering)); - } - @Override public void registerResourceKind(ResourceKind kind) { checkOpen(); @@ -200,8 +184,7 @@ public final class ModuleRegistry implements FeatureRegistry { public FeatureCatalog freeze() { if (catalog == null) { - catalog = new FeatureCatalog(settings, objects, mantle, resourceKinds.values(), heldTypes.values(), - validators, lifecycles, services); + catalog = new FeatureCatalog(settings, objects, mantle, resourceKinds.values(), validators, lifecycles, services); } return catalog; } diff --git a/host/src/main/java/com/volmit/host/PackSchemaBuilder.java b/host/src/main/java/com/volmit/host/PackSchemaBuilder.java index 80c894d0c..7e2c97ee0 100644 --- a/host/src/main/java/com/volmit/host/PackSchemaBuilder.java +++ b/host/src/main/java/com/volmit/host/PackSchemaBuilder.java @@ -24,7 +24,7 @@ import java.util.stream.Stream; * naming a kind nobody has, a class without a usable no-argument constructor, a snippet name used twice, a pack * class's snippet name outside its module's path, or a pack module's resource kind read into a host type. */ -@SuppressWarnings("removal") // held types and host kinds are transitional, until the cut-over +@SuppressWarnings("removal") // host kinds are transitional, until the cut-over final class PackSchemaBuilder { private static final Pattern SNIPPET_NAME = Pattern.compile("[a-z0-9_.-]+(/[a-z0-9_.-]+)*"); private static final Pattern RELATIVE_SEGMENT = Pattern.compile("(^|/)\\.\\.?(/|$)"); @@ -48,7 +48,6 @@ final class PackSchemaBuilder { private PackSchema describe(FeatureCatalog catalog) { var features = catalogued(catalog).map(this::draft).toList(); var resources = catalog.resourceKinds().stream().map(this::describe).toList(); - catalog.heldTypes().forEach(this::draft); requireUniqueSnippets(); var types = completeTypes(); return new PackSchema(features.stream().map(feature -> feature.complete(types)).toList(), resources, @@ -99,10 +98,6 @@ final class PackSchemaBuilder { return Stream.concat(settings, objects).sorted(Comparator.comparing(catalogued -> catalogued.descriptor().id())); } - private void draft(HeldTypeRegistration held) { - drafts.settings(SchemaSource.heldType(held)); - } - private FeatureDraft draft(Catalogued catalogued) { var owner = ownerOf(catalogued.descriptor()); drafts.settings(SchemaSource.settings(catalogued.descriptor(), owner)); diff --git a/host/src/main/java/com/volmit/host/SchemaSource.java b/host/src/main/java/com/volmit/host/SchemaSource.java index 86c1fe289..6b825a4cc 100644 --- a/host/src/main/java/com/volmit/host/SchemaSource.java +++ b/host/src/main/java/com/volmit/host/SchemaSource.java @@ -7,7 +7,6 @@ import com.volmit.resource.ResourceKind; * @param subject what reached the class, such as {@code settings example:flora} * @param type the class the subject is read into */ -@SuppressWarnings("removal") // held types are transitional, until the cut-over record SchemaSource(String subject, Class type, DiscoveredModule module) { static SchemaSource settings(FeatureDescriptor feature, DiscoveredModule module) { return new SchemaSource("settings " + feature.id(), feature.type(), module); @@ -17,10 +16,6 @@ record SchemaSource(String subject, Class type, DiscoveredModule module) { return new SchemaSource("resource kind " + kind.id(), kind.type(), module); } - static SchemaSource heldType(HeldTypeRegistration held) { - return new SchemaSource("held type " + held.type().getName(), held.type(), held.module()); - } - @Override public String toString() { return subject + " (module " + module + ")"; diff --git a/host/src/test/java/com/volmit/example/held/ClampSettings.java b/host/src/test/java/com/volmit/example/held/ClampSettings.java deleted file mode 100644 index 4e0cb53ea..000000000 --- a/host/src/test/java/com/volmit/example/held/ClampSettings.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.volmit.example.held; - -import com.volmit.config.Desc; -import com.volmit.config.MaxNumber; -import com.volmit.config.MinNumber; -import com.volmit.config.Snippet; - -@Snippet("clamp") -@Desc("Limits a placement by height") -public final class ClampSettings { - @MinNumber(-2048) - @MaxNumber(2048) - @Desc("The lowest height") - private int minimumHeight = -2048; - - public int minimumHeight() { - return minimumHeight; - } -} diff --git a/host/src/test/java/com/volmit/example/held/HeldModule.java b/host/src/test/java/com/volmit/example/held/HeldModule.java deleted file mode 100644 index 7d6e3123e..000000000 --- a/host/src/test/java/com/volmit/example/held/HeldModule.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.volmit.example.held; - -import com.volmit.IrisModule; -import com.volmit.ModuleInfo; -import com.volmit.ModuleSetup; - -/** A built-in module whose settings class is held by a class of the host, not by a feature. */ -public final class HeldModule implements IrisModule { - @Override - public ModuleInfo info() { - return ModuleInfo.of("iris:held", "Held", "test"); - } - - @Override - public void setup(ModuleSetup setup) { - setup.registry().registerHeldType(ClampSettings.class); - setup.registry().registerHeldType(ClampSettings.class); - } -} diff --git a/host/src/test/java/com/volmit/host/PackSchemaTest.java b/host/src/test/java/com/volmit/host/PackSchemaTest.java index bd4431e20..45347ff09 100644 --- a/host/src/test/java/com/volmit/host/PackSchemaTest.java +++ b/host/src/test/java/com/volmit/host/PackSchemaTest.java @@ -4,8 +4,6 @@ import com.volmit.config.Level; import com.volmit.config.Reference; import com.volmit.example.chunk.GrassModule; import com.volmit.example.chunk.TerrainModule; -import com.volmit.example.held.ClampSettings; -import com.volmit.example.held.HeldModule; import com.volmit.example.hosttypes.Palette; import com.volmit.example.placement.PlacementModules; import com.volmit.example.terrain.LayersModule; @@ -364,43 +362,6 @@ class PackSchemaTest { assertThrows(IllegalArgumentException.class, () -> NO_BUILT_INS.describingHostTypesIn("not a package")); } - @Test - void builtInModulesDescribeTheClassesTheHostsClassesHold() { - var schema = schemaOf(pack("held"), ModuleHost.of(List.of(new HeldModule()))); - - assertEquals(List.of(), schema.features()); - assertEquals(new ObjectType(ClampSettings.class.getName(), "Limits a placement by height", Optional.of("clamp"), - List.of(new SchemaOption("minimumHeight", new IntegerKind(), "The lowest height", false, OptionalDouble.of(-2048), - OptionalDouble.of(2048), OptionalInt.empty(), Optional.of(-2048L)))), schema.type(ClampSettings.class.getName())); - assertEquals(List.of(ClampSettings.class.getName()), schema.snippets().stream().map(ObjectType::name).toList()); - } - - @Test - void packModulesCannotRegisterHeldTypes() { - var jar = module("pack.flora.FloraModule", FLORA, - NO_MEMBERS, "registry.registerHeldType(pack.flora.Clamp.class);") - .source("pack.flora.Clamp", "package pack.flora; public final class Clamp { private int minimum; }"); - var pack = pack("held-by-pack"); - jar.writeInto(pack, "flora.jar"); - - var failure = assertThrows(ModuleLoadException.class, () -> LoadedPack.load(pack, NO_BUILT_INS)); - assertTrue(failure.getMessage().contains("Held type pack.flora.Clamp") && failure.getMessage().contains("own jar"), - failure.getMessage()); - } - - @Test - void packModulesMayDescribeAHostClassOfAnExposedPackage() { - var jar = module("pack.flora.FloraModule", FLORA, - NO_MEMBERS, "registry.registerHeldType(com.volmit.example.held.ClampSettings.class);") - .compileAgainstHostOf(ClampSettings.class); - var pack = pack("held-exposed"); - jar.writeInto(pack, "flora.jar"); - - var schema = LoadedPack.load(pack, NO_BUILT_INS.exposing("com.volmit.example.held")).schema(); - - assertEquals("Limits a placement by height", schema.type(ClampSettings.class.getName()).description()); - } - @Test void packModulesCannotUseHostTypes() { var host = NO_BUILT_INS.exposing(HOST_TYPES).describingHostTypesIn(HOST_TYPES);