Generation probe runs again and exercises plants: stub keys are canonical, plants decorate soil, decorator hooks bound, kinds replace the removed loaders

This commit is contained in:
piexel committed 2026-10-10 08:31:36 +02:00
1 parent 133fb377de
commit bed3f5b9cc
4 files changed
+84 -13

No files matched your search

@@ -18,6 +18,8 @@
package art.arcane.iris.probe;
import art.arcane.iris.engine.loot.LootResources;
import art.arcane.iris.engine.spawn.SpawnResources;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.framework.MeteredCache;
import art.arcane.iris.engine.framework.PreservationRegistry;
@@ -128,7 +130,7 @@ public final class DeserializationProbe {
}
private static void assertEntity(IrisData data) {
IrisEntity entity = data.getEntityLoader().load(ENTITY_KEY);
IrisEntity entity = SpawnResources.entity(data, ENTITY_KEY);
require(entity != null, "entity deserialized");
require("minecraft:panda".equals(entity.getType()), "type round-trips as authored namespaced string");
require("COMMAND".equals(entity.getReason()), "reason retained as string");
@@ -157,7 +159,7 @@ public final class DeserializationProbe {
}
private static void assertSpawner(IrisData data) {
IrisSpawner spawner = data.getSpawnerLoader().load(SPAWNER_KEY);
IrisSpawner spawner = SpawnResources.spawner(data, SPAWNER_KEY);
require(spawner != null, "spawner deserialized");
List<IrisEntitySpawn> spawns = spawner.getSpawns();
require(spawns.size() == 1, "single entity spawn deserialized");
@@ -167,7 +169,7 @@ public final class DeserializationProbe {
}
private static void assertLoot(IrisData data) {
IrisLootTable table = data.getLootLoader().load(LOOT_KEY);
IrisLootTable table = LootResources.table(data, LOOT_KEY);
require(table != null, "loot table deserialized");
require(LOOT_KEY.equals(table.getName()), "loot table name retained");
require(table.getRarity() == 4, "loot table rarity retained");
@@ -0,0 +1,58 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.probe;
import java.util.Set;
/**
* The stub's idea of plants, enough for generation to exercise what Iris does with them: grasses, ferns, flowers,
* saplings and mushrooms are foliage and decorations that stand only on soil, and vines hang. Minecraft knows many
* more; the probe only needs the common ones a pack decorates with.
*/
final class StubPlants {
private static final Set<String> PLANTS = Set.of(
"minecraft:short_grass", "minecraft:tall_grass", "minecraft:fern", "minecraft:large_fern",
"minecraft:dandelion", "minecraft:poppy", "minecraft:blue_orchid", "minecraft:allium",
"minecraft:azure_bluet", "minecraft:oxeye_daisy", "minecraft:cornflower", "minecraft:lily_of_the_valley",
"minecraft:sunflower", "minecraft:lilac", "minecraft:rose_bush", "minecraft:peony", "minecraft:dead_bush",
"minecraft:sweet_berry_bush", "minecraft:brown_mushroom", "minecraft:red_mushroom");
private static final Set<String> PLANT_SUFFIXES = Set.of("_tulip", "_sapling");
private static final Set<String> SOILS = Set.of(
"minecraft:grass_block", "minecraft:dirt", "minecraft:coarse_dirt", "minecraft:podzol",
"minecraft:rooted_dirt", "minecraft:moss_block", "minecraft:mud", "minecraft:mycelium",
"minecraft:sand", "minecraft:red_sand", "minecraft:farmland");
private static final Set<String> VINES = Set.of(
"minecraft:vine", "minecraft:glow_lichen", "minecraft:cave_vines", "minecraft:cave_vines_plant",
"minecraft:weeping_vines", "minecraft:twisting_vines");
private StubPlants() {
}
static boolean isPlant(String blockKey) {
return PLANTS.contains(blockKey) || PLANT_SUFFIXES.stream().anyMatch(blockKey::endsWith);
}
static boolean holdsPlants(String blockKey) {
return SOILS.contains(blockKey);
}
static boolean isVine(String blockKey) {
return VINES.contains(blockKey);
}
}
@@ -18,6 +18,7 @@
package art.arcane.iris.probe;
import art.arcane.iris.engine.decorator.DecoratorPlatformHooks;
import art.arcane.iris.engine.object.material.BlockDataMergeSupport;
import art.arcane.iris.engine.object.prefab.IrisObjectRotation;
import art.arcane.iris.engine.object.prefab.TileData;
@@ -41,6 +42,7 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.TreeMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Consumer;
@@ -61,6 +63,7 @@ public final class StubPlatform implements IrisPlatform {
BlockDataMergeSupport.bindPlatformMerger(StubPlatform::mergeStates);
TileData.bindPlatformReader(StubTileData::read);
TileData.bindPlatformFactory(StubTileData::fromProperties);
DecoratorPlatformHooks.bind((state, hunk, rX, rZ, x, y, z, mantle) -> state, PlatformBlockState::isSolid);
}
static PlatformBlockState rotateForTest(IrisObjectRotation rotation, PlatformBlockState state) {
@@ -97,8 +100,9 @@ public final class StubPlatform implements IrisPlatform {
this.key = key;
}
/** The state {@code key} names, keyed the way a platform keys its states: lower case, with a namespace and the properties sorted. */
static StubBlockState of(String key) {
return CACHE.computeIfAbsent(key, StubBlockState::new);
return CACHE.computeIfAbsent(ParsedState.parse(key).serialize(), StubBlockState::new);
}
@Override
@@ -163,7 +167,7 @@ public final class StubPlatform implements IrisPlatform {
@Override
public boolean isFoliage() {
return false;
return StubPlants.isPlant(blockKey());
}
@Override
@@ -213,7 +217,7 @@ public final class StubPlatform implements IrisPlatform {
@Override
public boolean isDecorant() {
return false;
return StubPlants.isPlant(blockKey());
}
@Override
@@ -238,12 +242,12 @@ public final class StubPlatform implements IrisPlatform {
@Override
public boolean isVineBlock() {
return false;
return StubPlants.isVine(blockKey());
}
@Override
public boolean canPlaceOnto(PlatformBlockState onto) {
return true;
return !isDecorant() || onto instanceof StubBlockState soil && StubPlants.holdsPlants(soil.blockKey());
}
@Override
@@ -444,7 +448,7 @@ public final class StubPlatform implements IrisPlatform {
private record ParsedState(String blockKey, LinkedHashMap<String, String> properties) {
private static ParsedState parse(String key) {
String normalized = key == null ? "minecraft:air" : key.trim().toLowerCase(Locale.ROOT);
String normalized = namespaced(key == null ? "minecraft:air" : key.trim().toLowerCase(Locale.ROOT));
int open = normalized.indexOf('[');
if (open < 0 || !normalized.endsWith("]")) {
return new ParsedState(normalized, new LinkedHashMap<>());
@@ -462,13 +466,20 @@ public final class StubPlatform implements IrisPlatform {
return new ParsedState(normalized.substring(0, open), properties);
}
private static String namespaced(String key) {
int namespaceEnd = key.indexOf(':');
int propertiesStart = key.indexOf('[');
boolean hasNamespace = namespaceEnd >= 0 && (propertiesStart < 0 || namespaceEnd < propertiesStart);
return hasNamespace ? key : "minecraft:" + key;
}
private String serialize() {
if (properties.isEmpty()) {
return blockKey;
}
StringBuilder serialized = new StringBuilder(blockKey).append('[');
boolean first = true;
for (Map.Entry<String, String> entry : properties.entrySet()) {
for (Map.Entry<String, String> entry : new TreeMap<>(properties).entrySet()) {
if (!first) {
serialized.append(',');
}
@@ -29,7 +29,7 @@ public final class StubPlatformStateTest {
StubPlatform.rotateForTest(rotation, state("minecraft:oak_stairs[facing=north,half=bottom]")).key());
assertEquals("minecraft:oak_log[axis=x]",
StubPlatform.rotateForTest(rotation, state("minecraft:oak_log[axis=z]")).key());
assertEquals("minecraft:oak_fence[north=false,east=false,south=false,west=true]",
assertEquals("minecraft:oak_fence[east=false,north=false,south=false,west=true]",
StubPlatform.rotateForTest(rotation,
state("minecraft:oak_fence[north=true,east=false,south=false,west=false]")).key());
}
@@ -90,9 +90,9 @@ public final class StubPlatformStateTest {
assertEquals("minecraft:oak_stairs[facing=west,half=bottom]", state("minecraft:oak_stairs[facing=east,half=bottom]").mirrorX().key());
assertEquals("minecraft:oak_stairs[facing=north,half=bottom]", state("minecraft:oak_stairs[facing=north,half=bottom]").mirrorX().key());
assertEquals("minecraft:oak_stairs[facing=south,half=bottom]", state("minecraft:oak_stairs[facing=north,half=bottom]").mirrorZ().key());
assertEquals("minecraft:oak_fence[north=true,east=false,south=false,west=false]",
assertEquals("minecraft:oak_fence[east=false,north=true,south=false,west=false]",
state("minecraft:oak_fence[north=true,east=false,south=false,west=false]").mirrorX().key());
assertEquals("minecraft:oak_fence[north=false,east=false,south=true,west=false]",
assertEquals("minecraft:oak_fence[east=false,north=false,south=true,west=false]",
state("minecraft:oak_fence[north=true,east=false,south=false,west=false]").mirrorZ().key());
assertEquals("minecraft:oak_sign[rotation=12]", state("minecraft:oak_sign[rotation=4]").mirrorX().key());
assertEquals("minecraft:oak_sign[rotation=4]", state("minecraft:oak_sign[rotation=4]").mirrorZ().key());