mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 16:25:36 +00:00
Merge branch 'wave2/e2'
This commit is contained in:
commit
1707bb95f6
12 files changed
+131
-3
No files matched your search
@@ -0,0 +1,19 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.volmit.example.held;
|
||||
|
||||
import com.volmit.FeatureRegistry;
|
||||
import com.volmit.IrisModule;
|
||||
import com.volmit.ModuleInfo;
|
||||
import com.volmit.stage.StageGraph;
|
||||
|
||||
/** 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 install(StageGraph graph) {}
|
||||
|
||||
@Override
|
||||
public void register(FeatureRegistry registry) {
|
||||
registry.registerHeldType(ClampSettings.class);
|
||||
registry.registerHeldType(ClampSettings.class);
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,8 @@ import com.volmit.FeatureAttachment.Target;
|
||||
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;
|
||||
@@ -365,6 +367,30 @@ class PackSchemaTest {
|
||||
assertThrows(IllegalArgumentException.class, () -> NO_BUILT_INS.describingHostTypesIn("not a package"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void builtInModulesDescribeTheClassesTheHostsClassesHold() {
|
||||
var schema = schemaOf(pack("held"), ModuleHost.of(List.<com.volmit.IrisModule>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,
|
||||
"public void register(com.volmit.FeatureRegistry registry) { registry.registerHeldType(pack.flora.Clamp.class); }", NO_STAGES)
|
||||
.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(IllegalArgumentException.class, () -> LoadedPack.load(pack, NO_BUILT_INS));
|
||||
assertTrue(failure.getMessage().contains("Held type pack.flora.Clamp") && failure.getMessage().contains("only built-in modules"),
|
||||
failure.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void packModulesCannotUseHostTypes() {
|
||||
var host = NO_BUILT_INS.exposing(HOST_TYPES).describingHostTypesIn(HOST_TYPES);
|
||||
|
||||
Reference in new issue
Block a user