From 7bc9f21f504ffb29c45ea6816e4197193b455031 Mon Sep 17 00:00:00 2001 From: piexel Date: Fri, 6 Nov 2026 06:37:34 +0100 Subject: [PATCH] Write typed markers with an exhaustive switch; drop MantleMarkerTypes The marker ids no longer need a copy in core or a test keeping it equal to the module's. --- .../iris/core/modules/MantleMarkerTypes.java | 50 ------------------- .../iris/core/modules/PlacerTerrain.java | 12 ++--- .../core/modules/MantleMarkerTypesTest.java | 31 ------------ 3 files changed, 4 insertions(+), 89 deletions(-) delete mode 100644 core/src/main/java/art/arcane/iris/core/modules/MantleMarkerTypes.java delete mode 100644 core/src/test/java/art/arcane/iris/core/modules/MantleMarkerTypesTest.java diff --git a/core/src/main/java/art/arcane/iris/core/modules/MantleMarkerTypes.java b/core/src/main/java/art/arcane/iris/core/modules/MantleMarkerTypes.java deleted file mode 100644 index 224668c17..000000000 --- a/core/src/main/java/art/arcane/iris/core/modules/MantleMarkerTypes.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Iris is a World Generator for Minecraft Servers - * Copyright (c) 2026 Arcane Arts (Volmit Software) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package art.arcane.iris.core.modules; - -import com.volmit.placement.PlacedMarker; -import com.volmit.resource.ResourceId; - -/** - * The marker types Iris keeps in its mantle when a placement marks a block ({@link PlacedMarker#type()}); a marker of - * any other type is rejected. The built-in modules mark with these ids, and Iris knows them as ids only. - */ -final class MantleMarkerTypes { - /** A marker the pack declares by name, kept as a pack marker; its name is the {@link #PACK_MARKER_NAME} attribute. */ - static final ResourceId PACK_MARKER = ResourceId.parse("iris:marker"); - static final String PACK_MARKER_NAME = "marker"; - /** A block of a tree, kept as the block's tree material for felling and growth. */ - static final ResourceId TREE_MATERIAL = ResourceId.parse("iris:tree_material"); - /** A buried treasure chest, kept as a structure point of interest. */ - static final ResourceId BURIED_TREASURE = ResourceId.parse("iris:buried_treasure"); - - private MantleMarkerTypes() { - } - - /** The name of the pack marker {@code marker} is. */ - static String packMarkerName(PlacedMarker marker) { - String name = marker.attributes().get(PACK_MARKER_NAME); - if (!marker.type().equals(PACK_MARKER) || name == null) { - throw new IllegalArgumentException("Iris keeps markers of type " + PACK_MARKER + " with a \"" + PACK_MARKER_NAME - + "\" attribute, " + TREE_MATERIAL + " and " + BURIED_TREASURE + " only, not " + marker.type() + " " - + marker.attributes()); - } - return name; - } -} diff --git a/core/src/main/java/art/arcane/iris/core/modules/PlacerTerrain.java b/core/src/main/java/art/arcane/iris/core/modules/PlacerTerrain.java index eedede61b..428601a1b 100644 --- a/core/src/main/java/art/arcane/iris/core/modules/PlacerTerrain.java +++ b/core/src/main/java/art/arcane/iris/core/modules/PlacerTerrain.java @@ -187,15 +187,11 @@ final class PlacerTerrain implements PlacementTerrain { int x = position.x(); int y = position.y(); int z = position.z(); - if (marker.type().equals(MantleMarkerTypes.TREE_MATERIAL)) { - placer.setData(x, y, z, TreeBlockMaterial.of(placer.get(x, y, z))); - return; + switch (marker) { + case PlacedMarker.TreeMaterial ignored -> placer.setData(x, y, z, TreeBlockMaterial.of(placer.get(x, y, z))); + case PlacedMarker.BuriedTreasure ignored -> placer.setData(x, y, z, MatterStructurePOI.BURIED_TREASURE); + case PlacedMarker.PackMarker pack -> placer.setData(x, y, z, new MatterMarker(pack.key())); } - if (marker.type().equals(MantleMarkerTypes.BURIED_TREASURE)) { - placer.setData(x, y, z, MatterStructurePOI.BURIED_TREASURE); - return; - } - placer.setData(x, y, z, new MatterMarker(MantleMarkerTypes.packMarkerName(marker))); } /** Resolved by the platform bound now, so a rebound platform never answers with another's states. */ diff --git a/core/src/test/java/art/arcane/iris/core/modules/MantleMarkerTypesTest.java b/core/src/test/java/art/arcane/iris/core/modules/MantleMarkerTypesTest.java deleted file mode 100644 index 5bda46b40..000000000 --- a/core/src/test/java/art/arcane/iris/core/modules/MantleMarkerTypesTest.java +++ /dev/null @@ -1,31 +0,0 @@ -package art.arcane.iris.core.modules; - -import art.arcane.iris.builtin.blocks.ObjectMarkers; -import com.volmit.geometry.BlockPosition; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThrows; - -/** Iris keeps the marker ids the built-in modules mark with, without reading their classes. */ -public class MantleMarkerTypesTest { - private static final BlockPosition SPOT = new BlockPosition(1, 2, 3); - - @Test - public void theTypesAreTheOnesTheBuiltInModulesMarkWith() { - assertEquals(ObjectMarkers.TYPE, MantleMarkerTypes.PACK_MARKER); - assertEquals(ObjectMarkers.MARKER_ATTRIBUTE, MantleMarkerTypes.PACK_MARKER_NAME); - assertEquals(ObjectMarkers.TREE_MATERIAL, MantleMarkerTypes.TREE_MATERIAL); - assertEquals(ObjectMarkers.BURIED_TREASURE, MantleMarkerTypes.BURIED_TREASURE); - } - - @Test - public void aPackMarkerGivesItsName() { - assertEquals("spawn/zombie", MantleMarkerTypes.packMarkerName(ObjectMarkers.of(SPOT, "spawn/zombie"))); - } - - @Test - public void aMarkerOfAnotherTypeIsRejected() { - assertThrows(IllegalArgumentException.class, () -> MantleMarkerTypes.packMarkerName(ObjectMarkers.treeMaterial(SPOT))); - } -}