mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-29 09:15:27 +00:00
Cut dead and duplicate tooling found by the tooling audit
Map modes OBJECT_LOAD, DECORATOR_LOAD and LAYER_LOAD with BiomeMaxes and the runtime and hotloader code that fed them; the placement scans in Engine.getObjectPlacement and the PlacedObject.placement field nobody read; Engine.hasObjectPlacement (find uses ModuleServices.objectPlacers); the object section of /iris studio objects and the layer lines of /iris studio profile; the package obfuscation, which wrote object names the exported JSON never used; the modded packager and its command; the removed-field nags for fluidBodies, surfaceOpeningClearance and caveProfile water fields; the IrisMod resource family and the Gson reader only it needed; the test-only ObjectPlacements helpers; WorldObjectPlacer; Interpolated.CAVE_RESULTS; DeserializationProbe.
This commit is contained in:
1 parent
3e8c22422f
commit
3022c54a43
63 files changed
+62
-871
No files matched your search
@@ -35,7 +35,6 @@ public class DiagnosticSeverityPolicyTest {
|
||||
assertLoggedWith("engine/object/compatibility/IrisCompat.java", "Can't find block data for ", "warnOnce");
|
||||
assertLoggedWith("engine/data/cache/AtomicCacheFailureReporting.java", "Atomic cache supplier failed: %s: %s", "warnOnce");
|
||||
assertLoggedWith("engine/IrisComplex.java", "Failed to sample interpolated biome bounds", "warnOnce");
|
||||
assertLoggedWith("engine/framework/placer/WorldObjectPlacer.java", "Tried to place custom block at", "warnOnce");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+14
-17
@@ -31,7 +31,6 @@ import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.spi.PlatformRegistries;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.IrisModule;
|
||||
@@ -76,7 +75,7 @@ public class ObjectPlacementModuleSettingsTest {
|
||||
|
||||
private IrisData data;
|
||||
private LoadedPack pack;
|
||||
private Gson gson;
|
||||
private ModuleSettingsDecoder decoder;
|
||||
|
||||
@Feature(id = "example:glow", name = "Glow", key = "glow", targets = Level.PLACEMENT)
|
||||
public static final class GlowSettings implements IrisFeature {
|
||||
@@ -102,11 +101,6 @@ public class ObjectPlacementModuleSettingsTest {
|
||||
}
|
||||
}
|
||||
|
||||
/** Holds placements the way a biome does. */
|
||||
private static final class Holder {
|
||||
private List<ObjectPlacement> objects;
|
||||
}
|
||||
|
||||
@Before
|
||||
public void loadPack() throws IOException {
|
||||
IrisPlatforms.unbind();
|
||||
@@ -120,8 +114,7 @@ public class ObjectPlacementModuleSettingsTest {
|
||||
|
||||
data = mock(IrisData.class);
|
||||
pack = BuiltInPack.serve(data, folder, List.of(new GlowModule()));
|
||||
ModuleSettingsDecoder decoder = new ModuleSettingsDecoder(pack.catalog(), folder.getRoot().toPath(), Gson::new);
|
||||
gson = new GsonBuilder().registerTypeAdapterFactory(new ObjectPlacementSettingsReader(() -> decoder)).create();
|
||||
decoder = new ModuleSettingsDecoder(pack.catalog(), folder.getRoot().toPath(), Gson::new);
|
||||
}
|
||||
|
||||
@After
|
||||
@@ -131,17 +124,17 @@ public class ObjectPlacementModuleSettingsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void decodesTheSettingsOfEveryNestedPlacement() {
|
||||
Holder holder = gson.fromJson("{\"objects\": [{\"place\": [\"tree\"], \"glow\": {\"block\": \"minecraft:sea_lantern\"}},"
|
||||
+ " {\"place\": [\"rock\"]}]}", Holder.class);
|
||||
public void decodesTheSettingsOfAPlacement() {
|
||||
ObjectPlacement declaring = decode("{\"place\": [\"tree\"], \"glow\": {\"block\": \"minecraft:sea_lantern\"}}");
|
||||
ObjectPlacement silent = decode("{\"place\": [\"rock\"]}");
|
||||
|
||||
assertEquals("minecraft:sea_lantern", moduleSettings(holder.objects.get(0)).find(GlowSettings.class).orElseThrow().block);
|
||||
assertSame(ModuleSettings.NONE, moduleSettings(holder.objects.get(1)));
|
||||
assertEquals("minecraft:sea_lantern", moduleSettings(declaring).find(GlowSettings.class).orElseThrow().block);
|
||||
assertSame(ModuleSettings.NONE, moduleSettings(silent));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void copiesOfAPlacementKeepItsSettings() {
|
||||
ObjectPlacement placement = gson.fromJson("{\"place\": [\"tree\"], \"glow\": {}}", ObjectPlacement.class);
|
||||
ObjectPlacement placement = decode("{\"place\": [\"tree\"], \"glow\": {}}");
|
||||
|
||||
assertSame(moduleSettings(placement), moduleSettings(placement.toBuilder().place(List.of("rock")).build()));
|
||||
}
|
||||
@@ -151,13 +144,17 @@ public class ObjectPlacementModuleSettingsTest {
|
||||
IObjectPlacer declaring = placer();
|
||||
IObjectPlacer silent = placer();
|
||||
|
||||
place(gson.fromJson("{\"glow\": {}}", ObjectPlacement.class), declaring);
|
||||
place(gson.fromJson("{}", ObjectPlacement.class), silent);
|
||||
place(decode("{\"glow\": {}}"), declaring);
|
||||
place(decode("{}"), silent);
|
||||
|
||||
verify(declaring).set(eq(0), eq(SURFACE_Y + 1), eq(0), any());
|
||||
verify(silent, never()).set(eq(0), eq(SURFACE_Y + 1), eq(0), any());
|
||||
}
|
||||
|
||||
private ObjectPlacement decode(String json) {
|
||||
return decoder.decodeResource(ObjectPlacement.class, json);
|
||||
}
|
||||
|
||||
private ModuleSettings moduleSettings(ObjectPlacement placement) {
|
||||
return IrisPlacementForm.of(placement, data).moduleSettings();
|
||||
}
|
||||
|
||||
@@ -37,11 +37,11 @@ public class PackExportClosureTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Source guard: both packagers must export the ambient-spawning graph. Spawner and marker
|
||||
* Source guard: the packager must export the ambient-spawning graph. Spawner and marker
|
||||
* folders were silently omitted from exports, leaving dangling entitySpawners references.
|
||||
*/
|
||||
@Test
|
||||
public void bothPackagersExportSpawnersMarkersAndTheFullEntityGraph() throws Exception {
|
||||
public void thePackagerExportsSpawnersMarkersAndTheFullEntityGraph() throws Exception {
|
||||
String bukkit = Files.readString(Path.of(
|
||||
"src/main/java/art/arcane/iris/core/project/IrisPackageCompiler.java")).replace("\r\n", "\n");
|
||||
assertTrue("Bukkit packager must export region objects alongside biome objects",
|
||||
@@ -54,15 +54,5 @@ public class PackExportClosureTest {
|
||||
bukkitValidation >= 0
|
||||
&& bukkitValidation < bukkit.indexOf("IrisData.openRuntime(project.getPath())")
|
||||
&& bukkitValidation < bukkit.indexOf("IO.delete(folder)"));
|
||||
|
||||
String modded = Files.readString(Path.of(
|
||||
"../adapters/modded-common/src/main/java/art/arcane/iris/modded/command/ModdedStudioCommands.java")).replace("\r\n", "\n");
|
||||
assertTrue("modded packager must write the spawn and loot resources the settings reference",
|
||||
modded.contains("moduleResources.writeTo(folder, true)"));
|
||||
assertTrue("modded packager must export the placements' references", modded.contains("moduleResources.follow(ObjectPlacements.all(region))"));
|
||||
assertTrue("modded packager must export region objects", modded.contains("ObjectPlacements.all(region)"));
|
||||
int moddedValidation = modded.indexOf("PackValidator.validateForPackaging(packFolder)");
|
||||
assertTrue("modded packager must validate before mutating package state",
|
||||
moddedValidation >= 0 && moddedValidation < modded.indexOf("IO.delete(folder)"));
|
||||
}
|
||||
}
|
||||
@@ -47,18 +47,6 @@ public class PackValidatorSurfaceSupportTest {
|
||||
assertTrue(errors.contains("Biome 'plains'.objects[0].requireSurfaceSupport must be a boolean."));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rejectsRemovedSurfaceOpeningClearanceField() throws Exception {
|
||||
File pack = temporaryFolder.newFolder("pack");
|
||||
write(pack, "regions/forests.json",
|
||||
"{\"objects\":[{\"place\":[\"a\"],\"surfaceOpeningClearance\":3}]}");
|
||||
|
||||
assertEquals(List.of(
|
||||
"Region 'forests'.objects[0] declares removed field 'surfaceOpeningClearance'. "
|
||||
+ "Use surfaceSupportBuffer instead."
|
||||
), PackObjectSurfaceValidator.validateObjectSurfaceSupport(pack));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void surfaceSupportErrorsBlockFullPackValidation() throws Exception {
|
||||
File pack = temporaryFolder.newFolder("pack");
|
||||
|
||||
-18
@@ -2,19 +2,11 @@ package art.arcane.iris.engine.object.mod;
|
||||
|
||||
import art.arcane.iris.builtin.prepare.SlopeClip;
|
||||
import art.arcane.iris.builtin.validate.ObjectLimit;
|
||||
import art.arcane.iris.engine.object.mod.IrisMod;
|
||||
import art.arcane.iris.engine.object.mod.IrisModNoiseStyleReplacer;
|
||||
import art.arcane.iris.engine.object.mod.IrisModObjectReplacer;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.annotations.ArrayType;
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.RegistryListResource;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
public class SchemaMetadataCorrectionsTest {
|
||||
@Test
|
||||
@@ -30,19 +22,9 @@ public class SchemaMetadataCorrectionsTest {
|
||||
|
||||
@Test
|
||||
public void correctedTypesDescribeTheSchemaTheyExpose() {
|
||||
assertEquals("Represents a pack modification schema", IrisMod.class.getAnnotation(Desc.class).value());
|
||||
assertEquals("Limits object placement by minimum and maximum world height",
|
||||
ObjectLimit.class.getAnnotation(com.volmit.config.Desc.class).value());
|
||||
assertEquals("Limits placement to a minimum and maximum terrain slope",
|
||||
SlopeClip.class.getAnnotation(com.volmit.config.Desc.class).value());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void modReplacerMetadataUsesItsActualTypes() throws Exception {
|
||||
Field noiseFind = IrisModNoiseStyleReplacer.class.getDeclaredField("find");
|
||||
Field objectReplace = IrisModObjectReplacer.class.getDeclaredField("replace");
|
||||
|
||||
assertFalse(noiseFind.isAnnotationPresent(ArrayType.class));
|
||||
assertEquals(IrisObject.class, objectReplace.getAnnotation(RegistryListResource.class).value());
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -177,7 +177,7 @@ public class ObjectPlacementRegressionTest {
|
||||
|
||||
@Test
|
||||
public void collisionCheckUsesTheTransformedBounds() {
|
||||
PlacedObject forbidden = new PlacedObject(null, object("forbidden"), 1, 0, 0);
|
||||
PlacedObject forbidden = new PlacedObject(object("forbidden"), 1, 0, 0);
|
||||
when(engine.getObjectPlacement(anyInt(), anyInt(), anyInt())).thenAnswer(invocation -> {
|
||||
int x = invocation.getArgument(0);
|
||||
int y = invocation.getArgument(1);
|
||||
@@ -602,7 +602,7 @@ public class ObjectPlacementRegressionTest {
|
||||
|
||||
@Test
|
||||
public void collisionRejectionPrecedesBoreAndAllowedObjectsOverrideForbiddenOnes() {
|
||||
PlacedObject forbidden = new PlacedObject(null, object("forbidden"), 1, 0, 0);
|
||||
PlacedObject forbidden = new PlacedObject(object("forbidden"), 1, 0, 0);
|
||||
when(engine.getObjectPlacement(anyInt(), anyInt(), anyInt())).thenReturn(forbidden);
|
||||
RecordingPlacer placer = new RecordingPlacer(engine);
|
||||
ObjectPlacement.Builder config = placement().bore(true).forbiddenCollisions(List.of("forbidden"));
|
||||
|
||||
@@ -2,21 +2,16 @@ package art.arcane.iris.engine.object.placement;
|
||||
|
||||
import art.arcane.iris.builtin.objects.ObjectPlacement;
|
||||
import art.arcane.iris.builtin.objects.ObjectSettings;
|
||||
import art.arcane.iris.builtin.objects.RequireSurfaceSupportSettings;
|
||||
import art.arcane.iris.builtin.objects.SurfaceSupportBufferSettings;
|
||||
import art.arcane.iris.builtin.objects.UpperObjectsSettings;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.core.modules.BuiltInPack;
|
||||
import art.arcane.iris.engine.object.TestSettings;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||
import com.google.gson.Gson;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
@@ -44,31 +39,6 @@ public class ObjectPlacementsTest {
|
||||
|
||||
assertEquals(3, ObjectPlacements.all(biome).size());
|
||||
assertEquals(2, ObjectPlacements.all(biome).get(0).density());
|
||||
assertEquals(List.of("hut", "rift"), ObjectPlacements.surface(biome).stream().map(p -> p.place().get(0)).toList());
|
||||
assertEquals(List.of("cave/crystal", "rift"), ObjectPlacements.carving(biome).stream().map(p -> p.place().get(0)).toList());
|
||||
assertSame(ObjectPlacements.all(biome).get(0), ObjectPlacements.all(biome).get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aDimensionThatDeclaresNothingKeepsIrisDefaults() {
|
||||
IrisDimension dimension = new IrisDimension();
|
||||
|
||||
assertFalse(ObjectPlacements.upperObjects(dimension));
|
||||
assertFalse(ObjectPlacements.upperObjectsForced(dimension));
|
||||
assertTrue(ObjectPlacements.requiresSurfaceSupport(dimension));
|
||||
assertEquals(2, ObjectPlacements.surfaceSupportBuffer(dimension));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aDimensionTellsWhatItDeclares() {
|
||||
IrisDimension dimension = new IrisDimension();
|
||||
dimension.setModuleSettings(BuiltInPack.settings(
|
||||
TestSettings.of(UpperObjectsSettings.class, "{\"enabled\":true}"),
|
||||
TestSettings.of(RequireSurfaceSupportSettings.class, "{\"require\":false}"),
|
||||
TestSettings.of(SurfaceSupportBufferSettings.class, "{\"buffer\":6}")));
|
||||
|
||||
assertTrue(ObjectPlacements.upperObjects(dimension));
|
||||
assertFalse(ObjectPlacements.requiresSurfaceSupport(dimension));
|
||||
assertEquals(6, ObjectPlacements.surfaceSupportBuffer(dimension));
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@ package art.arcane.iris.purity;
|
||||
import art.arcane.iris.engine.object.image.IrisImage;
|
||||
import art.arcane.iris.engine.object.image.IrisImageMap;
|
||||
import art.arcane.iris.engine.object.material.IrisBlockData;
|
||||
import art.arcane.iris.engine.object.mod.IrisMod;
|
||||
import art.arcane.iris.engine.object.noise.expression.IrisExpression;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.prefab.LegacyTileData;
|
||||
@@ -89,8 +88,8 @@ import static org.junit.Assert.fail;
|
||||
public class PackTypeBukkitPurityGateTest {
|
||||
private static final String SNIPPET_DESCRIPTOR = "Lart/arcane/iris/engine/object/annotations/Snippet;";
|
||||
private static final String BUKKIT_INTERNAL_PREFIX = "org/bukkit/";
|
||||
/** Fewer means the scan is broken, not that the pack types moved: the scan finds 38 after batch 7 moved the object settings. */
|
||||
private static final int LEAST_SNIPPET_TYPES = 30;
|
||||
/** Fewer means the scan is broken, not that the pack types moved: the scan finds 29 after batch 8 cut the mod resources. */
|
||||
private static final int LEAST_SNIPPET_TYPES = 20;
|
||||
/** See {@link #theGateStillCatchesAClassThatNeedsBukkit()}. */
|
||||
private static final String BUKKIT_DEPENDENT_CANARY = "art.arcane.iris.engine.object.prefab.BlockStateRotation$Faces";
|
||||
private static final String OBJECT_PACKAGE = "art/arcane/iris/engine/object";
|
||||
@@ -105,7 +104,6 @@ public class PackTypeBukkitPurityGateTest {
|
||||
private static final List<String> GSON_REGISTERED_ROOTS = List.of(
|
||||
"art.arcane.iris.engine.object.world.region.IrisRegion",
|
||||
"art.arcane.iris.engine.object.world.biome.IrisBiome",
|
||||
"art.arcane.iris.engine.object.mod.IrisMod",
|
||||
"art.arcane.iris.engine.object.world.dimension.IrisDimension",
|
||||
"art.arcane.iris.engine.object.terrain.IrisGenerator",
|
||||
"art.arcane.iris.engine.object.material.IrisBlockData",
|
||||
|
||||
Reference in new issue
Block a user