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

@@ -6,6 +6,7 @@ import net.minecraft.SharedConstants;
import net.minecraft.server.Bootstrap;
import net.minecraft.util.random.Weighted;
import net.minecraft.util.random.WeightedList;
import net.minecraft.util.valueproviders.UniformInt;
import net.minecraft.world.entity.EntityTypes;
import net.minecraft.world.level.biome.MobSpawnSettings;
import org.junit.Test;
@@ -24,10 +25,10 @@ public class IrisModdedChunkGeneratorSpawnTest {
@Test
public void explicitSpawnsReplaceMatchingVanillaTypesAndPreserveOthers() {
MobSpawnSettings.SpawnerData zombie = new MobSpawnSettings.SpawnerData(EntityTypes.ZOMBIE, 1, 4);
MobSpawnSettings.SpawnerData vanillaSlime = new MobSpawnSettings.SpawnerData(EntityTypes.SLIME, 1, 1);
MobSpawnSettings.SpawnerData explicitSlime = new MobSpawnSettings.SpawnerData(EntityTypes.SLIME, 2, 5);
MobSpawnSettings.SpawnerData explicitCow = new MobSpawnSettings.SpawnerData(EntityTypes.COW, 2, 4);
MobSpawnSettings.SpawnerData zombie = new MobSpawnSettings.SpawnerData(EntityTypes.ZOMBIE, UniformInt.of(1, 4));
MobSpawnSettings.SpawnerData vanillaSlime = new MobSpawnSettings.SpawnerData(EntityTypes.SLIME, UniformInt.of(1, 1));
MobSpawnSettings.SpawnerData explicitSlime = new MobSpawnSettings.SpawnerData(EntityTypes.SLIME, UniformInt.of(2, 5));
MobSpawnSettings.SpawnerData explicitCow = new MobSpawnSettings.SpawnerData(EntityTypes.COW, UniformInt.of(2, 4));
WeightedList<MobSpawnSettings.SpawnerData> vanilla = WeightedList.of(List.of(
new Weighted<>(zombie, 100),
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 custom = dimension("custom_contract", IrisEnvironment.CUSTOM, -128, 384, 384, customOptions);
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");
KList<File> roots = new KList<>();
roots.add(packDirectory.toFile());
@@ -51,15 +51,15 @@ import static org.junit.Assert.assertTrue;
public class ModdedForcedDatapackTest {
@Test
public void metadataRetains262FormatWhenBukkitAlsoSupports263() throws IOException {
public void metadataUses263DataFormat() throws IOException {
Path packDirectory = Files.createTempDirectory("iris-modded-pack-format");
try {
ModdedForcedDatapack.writePackMeta(packDirectory);
JSONObject pack = new JSONObject(Files.readString(packDirectory.resolve("pack.mcmeta")))
.getJSONObject("pack");
assertEquals(107, pack.getInt("pack_format"));
assertEquals(107, pack.getInt("min_format"));
assertEquals(107, pack.getInt("max_format"));
assertEquals(121, pack.getInt("pack_format"));
assertEquals(121, pack.getInt("min_format"));
assertEquals(121, pack.getInt("max_format"));
} finally {
deleteTree(packDirectory);
}
@@ -33,7 +33,7 @@ public class ModdedPlatformPathsTest {
@Override
public String minecraftVersion() {
return "26.2";
return "26.3";
}
@Override
@@ -14,16 +14,18 @@ import net.minecraft.core.registries.Registries;
import net.minecraft.resources.Identifier;
import net.minecraft.resources.ResourceKey;
import net.minecraft.server.Bootstrap;
import net.minecraft.world.level.ChunkPos;
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.Climate;
import net.minecraft.world.level.chunk.ChunkGeneratorStructureState;
import net.minecraft.world.level.levelgen.RandomState;
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.RandomSpreadType;
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.Test;
@@ -166,10 +168,10 @@ public class ModdedStructureSetFrequencyOverridesTest {
) {
return new RandomSpreadStructurePlacement(
Vec3i.ZERO,
StructurePlacement.FrequencyReductionMethod.DEFAULT,
AbstractSpreadingStructurePlacement.FrequencyReductionMethod.DEFAULT,
1F,
salt,
Optional.of(new StructurePlacement.ExclusionZone(exclusionTarget, 1)),
Optional.of(new AbstractSpreadingStructurePlacement.ExclusionZone(exclusionTarget, 1)),
spacing,
separation,
RandomSpreadType.LINEAR);
@@ -183,6 +185,7 @@ public class ModdedStructureSetFrequencyOverridesTest {
RandomState.class,
BiomeSource.class,
long.class,
ChunkPos.class,
long.class,
List.class);
constructor.setAccessible(true);
@@ -190,6 +193,7 @@ public class ModdedStructureSetFrequencyOverridesTest {
null,
new EmptyBiomeSource(),
1L,
ChunkPos.ZERO,
1L,
sets);
}
@@ -211,8 +215,8 @@ public class ModdedStructureSetFrequencyOverridesTest {
private static final class EmptyBiomeSource extends BiomeSource {
@Override
public Holder<Biome> getNoiseBiome(int x, int y, int z, Climate.Sampler sampler) {
return null;
public BiomeResolver createResolver(Climate.Sampler sampler) {
return (x, y, z) -> null;
}
@Override
@@ -226,18 +230,14 @@ public class ModdedStructureSetFrequencyOverridesTest {
}
}
private static final class UnsupportedPlacement extends StructurePlacement {
private UnsupportedPlacement() {
super(Vec3i.ZERO, FrequencyReductionMethod.DEFAULT, 1F, 1, Optional.empty());
}
private static final class UnsupportedPlacement implements StructurePlacement {
@Override
protected boolean isPlacementChunk(ChunkGeneratorStructureState state, int x, int z) {
public boolean isStructureChunk(ChunkGeneratorStructureState state, int x, int z) {
return false;
}
@Override
public StructurePlacementType<?> type() {
public com.mojang.serialization.MapCodec<? extends StructurePlacement> codec() {
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.ChestBlockEntity;
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.storage.TagValueInput;
import org.junit.BeforeClass;
@@ -61,9 +62,9 @@ public class ModdedTileParityTest {
sign.loadWithComponents(TagValueInput.create(ProblemReporter.DISCARDING, registries, tile.nativeData().payload()));
assertEquals("Iris", sign.getFrontText().getMessage(0, false).getString());
assertEquals("parity", sign.getBackText().getMessage(3, false).getString());
assertEquals(DyeColor.BLUE, sign.getFrontText().getColor());
assertEquals("Iris", sign.getText(SignTextSlot.FRONT).getMessages(false).get(0).getString());
assertEquals("parity", sign.getText(SignTextSlot.BACK).getMessages(false).get(3).getString());
assertEquals(DyeColor.BLUE, sign.getText(SignTextSlot.FRONT).getColor());
}
@Test
@@ -12,8 +12,11 @@ import art.arcane.volmlib.util.math.RNG;
import net.minecraft.SharedConstants;
import net.minecraft.core.BlockPos;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.server.Bootstrap;
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.Blocks;
import net.minecraft.world.level.block.state.BlockState;
@@ -22,6 +25,8 @@ import org.junit.BeforeClass;
import org.junit.Test;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import static org.junit.Assert.assertEquals;
@@ -42,6 +47,8 @@ public class ModdedWaterEntitySpawnTest {
state.initCache();
}
}
BuiltInRegistries.BLOCK.prepareTagReload(new TagLoader.LoadResult<>(Registries.BLOCK, Map.of(
BlockTags.BLOCKS_MOTION, List.of(Blocks.OAK_FENCE.builtInRegistryHolder())))).apply();
}
@Test
@@ -6,7 +6,11 @@ import art.arcane.volmlib.nativelib.minecraft26_2.modded.ModdedPlatformWorld;
import net.minecraft.SharedConstants;
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 org.junit.BeforeClass;
import org.junit.Test;
@@ -32,11 +36,11 @@ public class NativeStructureOperationsTest {
@Test
public void objectFeaturesMatchPaperGroups() {
assertEquals("trees", NativeStructureOperations.classifyFeature(Feature.TREE));
assertEquals("fallen_trees", NativeStructureOperations.classifyFeature(Feature.FALLEN_TREE));
assertEquals("mushrooms", NativeStructureOperations.classifyFeature(Feature.HUGE_BROWN_MUSHROOM));
assertEquals("mushrooms", NativeStructureOperations.classifyFeature(Feature.HUGE_RED_MUSHROOM));
assertNull(NativeStructureOperations.classifyFeature(Feature.ORE));
assertEquals("trees", NativeStructureOperations.classifyFeature(mock(TreeFeature.class)));
assertEquals("fallen_trees", NativeStructureOperations.classifyFeature(mock(FallenTreeFeature.class)));
assertEquals("mushrooms", NativeStructureOperations.classifyFeature(mock(HugeBrownMushroomFeature.class)));
assertEquals("mushrooms", NativeStructureOperations.classifyFeature(mock(HugeRedMushroomFeature.class)));
assertNull(NativeStructureOperations.classifyFeature(mock(OreFeature.class)));
}
@Test