Modded 26.3 datapacks

- The forced datapack, datapack commands, and world check render biomes and dimension types with the 26.3 data fixer and pack format 121
- Modded tests use the 26.3 feature, placement, spawner, sign, and biome resolver APIs
- The water spawn test binds a blocks_motion fixture so solid waterlogged blocks still obstruct spawns
This commit is contained in:
Brian Neumann-Fopiano committed 2026-09-29 02:48:58 -04:00
1 parent 94c7181aec
commit 92e5daa13e
12 files changed
+52 -39

No files matched your search

@@ -315,11 +315,11 @@ public final class ModdedForcedDatapack {
throw new IllegalStateException("SHA-256 is unavailable", missing); throw new IllegalStateException("SHA-256 is unavailable", missing);
} }
digest.update((HASH_SALT + '|' + ModdedEngineBootstrap.loader().platformName() digest.update((HASH_SALT + '|' + ModdedEngineBootstrap.loader().platformName()
+ '|' + DataVersion.V26_2.getPackFormat() + '\n').getBytes(StandardCharsets.UTF_8)); + '|' + DataVersion.V26_3.getPackFormat() + '\n').getBytes(StandardCharsets.UTF_8));
String inputFingerprint = IrisDatapackCompiler.computeInputFingerprint( String inputFingerprint = IrisDatapackCompiler.computeInputFingerprint(
compilationPackRoots(), compilationPackRoots(),
List.of(), List.of(),
DataVersion.V26_2.get(), DataVersion.V26_3.get(),
false false
); );
digest.update(inputFingerprint.getBytes(StandardCharsets.UTF_8)); digest.update(inputFingerprint.getBytes(StandardCharsets.UTF_8));
@@ -328,7 +328,7 @@ public final class ModdedForcedDatapack {
private static void writeStagedPack(Path stagingDirectory) throws IOException { private static void writeStagedPack(Path stagingDirectory) throws IOException {
Map<String, KSet<String>> seenBiomes = new LinkedHashMap<>(); Map<String, KSet<String>> seenBiomes = new LinkedHashMap<>();
IDataFixer fixer = DataVersion.V26_2.get(); IDataFixer fixer = DataVersion.V26_3.get();
int packCount = 0; int packCount = 0;
KList<String> presetIds = new KList<>(); KList<String> presetIds = new KList<>();
@@ -679,7 +679,7 @@ public final class ModdedForcedDatapack {
} }
static void writePackMeta(Path packDirectory) throws IOException { static void writePackMeta(Path packDirectory) throws IOException {
int packFormat = DataVersion.V26_2.getPackFormat(); int packFormat = DataVersion.V26_3.getPackFormat();
String json = "{\n" String json = "{\n"
+ " \"pack\": {\n" + " \"pack\": {\n"
+ " \"description\": \"Iris world generation biomes and dimension types for installed packs.\",\n" + " \"description\": \"Iris world generation biomes and dimension types for installed packs.\",\n"
@@ -55,7 +55,7 @@ final class WorldCheckDimensionContract {
} }
static Dimension expectedDimensionContract(IrisDimension dimension) { static Dimension expectedDimensionContract(IrisDimension dimension) {
JSONObject json = new JSONObject(dimension.getDimensionType().toJson(DataVersion.V26_2.get())); JSONObject json = new JSONObject(dimension.getDimensionType().toJson(DataVersion.V26_3.get()));
return new Dimension( return new Dimension(
json.getInt("min_y"), json.getInt("min_y"),
json.getInt("height"), json.getInt("height"),
@@ -165,7 +165,7 @@ public final class ModdedDatapackCommands {
IrisDimension dimension = engine.getDimension(); IrisDimension dimension = engine.getDimension();
String json; String json;
try { try {
json = dimension.getDimensionType().toJson(DataVersion.V26_2.get()); json = dimension.getDimensionType().toJson(DataVersion.V26_3.get());
} catch (Throwable e) { } catch (Throwable e) {
ModdedIrisLog.error("Iris dimension type generation failed for {}", dimension.getLoadKey(), e); ModdedIrisLog.error("Iris dimension type generation failed for {}", dimension.getLoadKey(), e);
IrisModdedCommands.fail(source, IrisLanguage.plain(ModdedCommandMessages.MODDED_DATAPACK_COMMANDS_DIMENSION_TYPE_GENERATION_FAILED, MessageArgument.untrusted("value", level.name()), MessageArgument.untrusted("value2", String.valueOf(e.getMessage())))); IrisModdedCommands.fail(source, IrisLanguage.plain(ModdedCommandMessages.MODDED_DATAPACK_COMMANDS_DIMENSION_TYPE_GENERATION_FAILED, MessageArgument.untrusted("value", level.name()), MessageArgument.untrusted("value2", String.valueOf(e.getMessage()))));
@@ -187,7 +187,7 @@ public final class ModdedDatapackCommands {
} }
File mcmeta = new File(worldDatapacksFolder(server), WORLD_PACK_NAME + "/pack.mcmeta"); File mcmeta = new File(worldDatapacksFolder(server), WORLD_PACK_NAME + "/pack.mcmeta");
int packFormat = DataVersion.V26_2.getPackFormat(); int packFormat = DataVersion.V26_3.getPackFormat();
String meta = "{\n" String meta = "{\n"
+ " \"pack\": {\n" + " \"pack\": {\n"
+ " \"description\": \"Iris dimension types derived from the installed Iris packs.\",\n" + " \"description\": \"Iris dimension types derived from the installed Iris packs.\",\n"
@@ -503,7 +503,7 @@ public final class ModdedPregenMethod implements PregeneratorMethod {
/** /**
* A dedicated server with {@code pause-when-empty-seconds > 0} returns from * A dedicated server with {@code pause-when-empty-seconds > 0} returns from
* {@code MinecraftServer#tickServer} before {@code tickChildren} once it has been empty for that * {@code MinecraftServer#tickServer} before {@code tickChildren} once it has been empty for that
* long (26.2 only keeps {@code tickConnection} plus the task/chunk-poll window alive). That * long (26.3 only keeps {@code tickConnection} plus the task/chunk-poll window alive). That
* freezes every per-tick Iris service - world manager, scheduler, protocol sync, pregen HUD - and * freezes every per-tick Iris service - world manager, scheduler, protocol sync, pregen HUD - and
* the loader's own generation hooks for the whole job, and console pregen on a default * the loader's own generation hooks for the whole job, and console pregen on a default
* server.properties is always empty. The guard zeroes the setting for the duration of the job * server.properties is always empty. The guard zeroes the setting for the duration of the job
@@ -6,6 +6,7 @@ import net.minecraft.SharedConstants;
import net.minecraft.server.Bootstrap; import net.minecraft.server.Bootstrap;
import net.minecraft.util.random.Weighted; import net.minecraft.util.random.Weighted;
import net.minecraft.util.random.WeightedList; import net.minecraft.util.random.WeightedList;
import net.minecraft.util.valueproviders.UniformInt;
import net.minecraft.world.entity.EntityTypes; import net.minecraft.world.entity.EntityTypes;
import net.minecraft.world.level.biome.MobSpawnSettings; import net.minecraft.world.level.biome.MobSpawnSettings;
import org.junit.Test; import org.junit.Test;
@@ -24,10 +25,10 @@ public class IrisModdedChunkGeneratorSpawnTest {
@Test @Test
public void explicitSpawnsReplaceMatchingVanillaTypesAndPreserveOthers() { public void explicitSpawnsReplaceMatchingVanillaTypesAndPreserveOthers() {
MobSpawnSettings.SpawnerData zombie = new MobSpawnSettings.SpawnerData(EntityTypes.ZOMBIE, 1, 4); MobSpawnSettings.SpawnerData zombie = new MobSpawnSettings.SpawnerData(EntityTypes.ZOMBIE, UniformInt.of(1, 4));
MobSpawnSettings.SpawnerData vanillaSlime = new MobSpawnSettings.SpawnerData(EntityTypes.SLIME, 1, 1); MobSpawnSettings.SpawnerData vanillaSlime = new MobSpawnSettings.SpawnerData(EntityTypes.SLIME, UniformInt.of(1, 1));
MobSpawnSettings.SpawnerData explicitSlime = new MobSpawnSettings.SpawnerData(EntityTypes.SLIME, 2, 5); MobSpawnSettings.SpawnerData explicitSlime = new MobSpawnSettings.SpawnerData(EntityTypes.SLIME, UniformInt.of(2, 5));
MobSpawnSettings.SpawnerData explicitCow = new MobSpawnSettings.SpawnerData(EntityTypes.COW, 2, 4); MobSpawnSettings.SpawnerData explicitCow = new MobSpawnSettings.SpawnerData(EntityTypes.COW, UniformInt.of(2, 4));
WeightedList<MobSpawnSettings.SpawnerData> vanilla = WeightedList.of(List.of( WeightedList<MobSpawnSettings.SpawnerData> vanilla = WeightedList.of(List.of(
new Weighted<>(zombie, 100), new Weighted<>(zombie, 100),
new Weighted<>(vanillaSlime, 1))); new Weighted<>(vanillaSlime, 1)));
@@ -79,7 +79,7 @@ public class ModdedDimensionTypeParityTest {
IrisDimension end = dimension("the_end", IrisEnvironment.THE_END, 0, 256, 256, new IrisDimensionTypeOptions()); IrisDimension end = dimension("the_end", IrisEnvironment.THE_END, 0, 256, 256, new IrisDimensionTypeOptions());
IrisDimension custom = dimension("custom_contract", IrisEnvironment.CUSTOM, -128, 384, 384, customOptions); IrisDimension custom = dimension("custom_contract", IrisEnvironment.CUSTOM, -128, 384, 384, customOptions);
List<IrisDimension> dimensions = List.of(overworld, nether, end, custom); List<IrisDimension> dimensions = List.of(overworld, nether, end, custom);
IDataFixer fixer = DataVersion.V26_2.get(); IDataFixer fixer = DataVersion.V26_3.get();
Path packDirectory = Files.createTempDirectory("iris-dimension-contracts"); Path packDirectory = Files.createTempDirectory("iris-dimension-contracts");
KList<File> roots = new KList<>(); KList<File> roots = new KList<>();
roots.add(packDirectory.toFile()); roots.add(packDirectory.toFile());
@@ -51,15 +51,15 @@ import static org.junit.Assert.assertTrue;
public class ModdedForcedDatapackTest { public class ModdedForcedDatapackTest {
@Test @Test
public void metadataRetains262FormatWhenBukkitAlsoSupports263() throws IOException { public void metadataUses263DataFormat() throws IOException {
Path packDirectory = Files.createTempDirectory("iris-modded-pack-format"); Path packDirectory = Files.createTempDirectory("iris-modded-pack-format");
try { try {
ModdedForcedDatapack.writePackMeta(packDirectory); ModdedForcedDatapack.writePackMeta(packDirectory);
JSONObject pack = new JSONObject(Files.readString(packDirectory.resolve("pack.mcmeta"))) JSONObject pack = new JSONObject(Files.readString(packDirectory.resolve("pack.mcmeta")))
.getJSONObject("pack"); .getJSONObject("pack");
assertEquals(107, pack.getInt("pack_format")); assertEquals(121, pack.getInt("pack_format"));
assertEquals(107, pack.getInt("min_format")); assertEquals(121, pack.getInt("min_format"));
assertEquals(107, pack.getInt("max_format")); assertEquals(121, pack.getInt("max_format"));
} finally { } finally {
deleteTree(packDirectory); deleteTree(packDirectory);
} }
@@ -33,7 +33,7 @@ public class ModdedPlatformPathsTest {
@Override @Override
public String minecraftVersion() { public String minecraftVersion() {
return "26.2"; return "26.3";
} }
@Override @Override
@@ -14,16 +14,18 @@ import net.minecraft.core.registries.Registries;
import net.minecraft.resources.Identifier; import net.minecraft.resources.Identifier;
import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceKey;
import net.minecraft.server.Bootstrap; import net.minecraft.server.Bootstrap;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.biome.BiomeResolver;
import net.minecraft.world.level.biome.BiomeSource; import net.minecraft.world.level.biome.BiomeSource;
import net.minecraft.world.level.biome.Climate; import net.minecraft.world.level.biome.Climate;
import net.minecraft.world.level.chunk.ChunkGeneratorStructureState; import net.minecraft.world.level.chunk.ChunkGeneratorStructureState;
import net.minecraft.world.level.levelgen.RandomState; import net.minecraft.world.level.levelgen.RandomState;
import net.minecraft.world.level.levelgen.structure.StructureSet; import net.minecraft.world.level.levelgen.structure.StructureSet;
import net.minecraft.world.level.levelgen.structure.placement.AbstractSpreadingStructurePlacement;
import net.minecraft.world.level.levelgen.structure.placement.RandomSpreadStructurePlacement; import net.minecraft.world.level.levelgen.structure.placement.RandomSpreadStructurePlacement;
import net.minecraft.world.level.levelgen.structure.placement.RandomSpreadType; import net.minecraft.world.level.levelgen.structure.placement.RandomSpreadType;
import net.minecraft.world.level.levelgen.structure.placement.StructurePlacement; import net.minecraft.world.level.levelgen.structure.placement.StructurePlacement;
import net.minecraft.world.level.levelgen.structure.placement.StructurePlacementType;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
@@ -166,10 +168,10 @@ public class ModdedStructureSetFrequencyOverridesTest {
) { ) {
return new RandomSpreadStructurePlacement( return new RandomSpreadStructurePlacement(
Vec3i.ZERO, Vec3i.ZERO,
StructurePlacement.FrequencyReductionMethod.DEFAULT, AbstractSpreadingStructurePlacement.FrequencyReductionMethod.DEFAULT,
1F, 1F,
salt, salt,
Optional.of(new StructurePlacement.ExclusionZone(exclusionTarget, 1)), Optional.of(new AbstractSpreadingStructurePlacement.ExclusionZone(exclusionTarget, 1)),
spacing, spacing,
separation, separation,
RandomSpreadType.LINEAR); RandomSpreadType.LINEAR);
@@ -183,6 +185,7 @@ public class ModdedStructureSetFrequencyOverridesTest {
RandomState.class, RandomState.class,
BiomeSource.class, BiomeSource.class,
long.class, long.class,
ChunkPos.class,
long.class, long.class,
List.class); List.class);
constructor.setAccessible(true); constructor.setAccessible(true);
@@ -190,6 +193,7 @@ public class ModdedStructureSetFrequencyOverridesTest {
null, null,
new EmptyBiomeSource(), new EmptyBiomeSource(),
1L, 1L,
ChunkPos.ZERO,
1L, 1L,
sets); sets);
} }
@@ -211,8 +215,8 @@ public class ModdedStructureSetFrequencyOverridesTest {
private static final class EmptyBiomeSource extends BiomeSource { private static final class EmptyBiomeSource extends BiomeSource {
@Override @Override
public Holder<Biome> getNoiseBiome(int x, int y, int z, Climate.Sampler sampler) { public BiomeResolver createResolver(Climate.Sampler sampler) {
return null; return (x, y, z) -> null;
} }
@Override @Override
@@ -226,18 +230,14 @@ public class ModdedStructureSetFrequencyOverridesTest {
} }
} }
private static final class UnsupportedPlacement extends StructurePlacement { private static final class UnsupportedPlacement implements StructurePlacement {
private UnsupportedPlacement() {
super(Vec3i.ZERO, FrequencyReductionMethod.DEFAULT, 1F, 1, Optional.empty());
}
@Override @Override
protected boolean isPlacementChunk(ChunkGeneratorStructureState state, int x, int z) { public boolean isStructureChunk(ChunkGeneratorStructureState state, int x, int z) {
return false; return false;
} }
@Override @Override
public StructurePlacementType<?> type() { public com.mojang.serialization.MapCodec<? extends StructurePlacement> codec() {
return null; return null;
} }
} }
@@ -19,6 +19,7 @@ import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.BarrelBlockEntity; import net.minecraft.world.level.block.entity.BarrelBlockEntity;
import net.minecraft.world.level.block.entity.ChestBlockEntity; import net.minecraft.world.level.block.entity.ChestBlockEntity;
import net.minecraft.world.level.block.entity.SignBlockEntity; import net.minecraft.world.level.block.entity.SignBlockEntity;
import net.minecraft.world.level.block.entity.SignTextSlot;
import net.minecraft.world.level.block.entity.SpawnerBlockEntity; import net.minecraft.world.level.block.entity.SpawnerBlockEntity;
import net.minecraft.world.level.storage.TagValueInput; import net.minecraft.world.level.storage.TagValueInput;
import org.junit.BeforeClass; import org.junit.BeforeClass;
@@ -61,9 +62,9 @@ public class ModdedTileParityTest {
sign.loadWithComponents(TagValueInput.create(ProblemReporter.DISCARDING, registries, tile.nativeData().payload())); sign.loadWithComponents(TagValueInput.create(ProblemReporter.DISCARDING, registries, tile.nativeData().payload()));
assertEquals("Iris", sign.getFrontText().getMessage(0, false).getString()); assertEquals("Iris", sign.getText(SignTextSlot.FRONT).getMessages(false).get(0).getString());
assertEquals("parity", sign.getBackText().getMessage(3, false).getString()); assertEquals("parity", sign.getText(SignTextSlot.BACK).getMessages(false).get(3).getString());
assertEquals(DyeColor.BLUE, sign.getFrontText().getColor()); assertEquals(DyeColor.BLUE, sign.getText(SignTextSlot.FRONT).getColor());
} }
@Test @Test
@@ -12,8 +12,11 @@ import art.arcane.volmlib.util.math.RNG;
import net.minecraft.SharedConstants; import net.minecraft.SharedConstants;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.server.Bootstrap; import net.minecraft.server.Bootstrap;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.TagLoader;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
@@ -22,6 +25,8 @@ import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set; import java.util.Set;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
@@ -42,6 +47,8 @@ public class ModdedWaterEntitySpawnTest {
state.initCache(); state.initCache();
} }
} }
BuiltInRegistries.BLOCK.prepareTagReload(new TagLoader.LoadResult<>(Registries.BLOCK, Map.of(
BlockTags.BLOCKS_MOTION, List.of(Blocks.OAK_FENCE.builtInRegistryHolder())))).apply();
} }
@Test @Test
@@ -6,7 +6,11 @@ import art.arcane.volmlib.nativelib.minecraft26_2.modded.ModdedPlatformWorld;
import net.minecraft.SharedConstants; import net.minecraft.SharedConstants;
import net.minecraft.server.Bootstrap; import net.minecraft.server.Bootstrap;
import net.minecraft.world.level.levelgen.feature.Feature; import net.minecraft.world.level.levelgen.feature.FallenTreeFeature;
import net.minecraft.world.level.levelgen.feature.HugeBrownMushroomFeature;
import net.minecraft.world.level.levelgen.feature.HugeRedMushroomFeature;
import net.minecraft.world.level.levelgen.feature.OreFeature;
import net.minecraft.world.level.levelgen.feature.TreeFeature;
import net.minecraft.world.level.levelgen.structure.BoundingBox; import net.minecraft.world.level.levelgen.structure.BoundingBox;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
@@ -32,11 +36,11 @@ public class NativeStructureOperationsTest {
@Test @Test
public void objectFeaturesMatchPaperGroups() { public void objectFeaturesMatchPaperGroups() {
assertEquals("trees", NativeStructureOperations.classifyFeature(Feature.TREE)); assertEquals("trees", NativeStructureOperations.classifyFeature(mock(TreeFeature.class)));
assertEquals("fallen_trees", NativeStructureOperations.classifyFeature(Feature.FALLEN_TREE)); assertEquals("fallen_trees", NativeStructureOperations.classifyFeature(mock(FallenTreeFeature.class)));
assertEquals("mushrooms", NativeStructureOperations.classifyFeature(Feature.HUGE_BROWN_MUSHROOM)); assertEquals("mushrooms", NativeStructureOperations.classifyFeature(mock(HugeBrownMushroomFeature.class)));
assertEquals("mushrooms", NativeStructureOperations.classifyFeature(Feature.HUGE_RED_MUSHROOM)); assertEquals("mushrooms", NativeStructureOperations.classifyFeature(mock(HugeRedMushroomFeature.class)));
assertNull(NativeStructureOperations.classifyFeature(Feature.ORE)); assertNull(NativeStructureOperations.classifyFeature(mock(OreFeature.class)));
} }
@Test @Test