Complete X.1.0 milestone for Minecraft 1.21.1 and 26.3
Build and smoke / changes (push) Waiting to run

This commit is contained in:
dnorberg committed 2026-11-18 22:55:03 -05:00
1 parent 6630ed7ab1
commit 10a70e3b6a
39 files changed
+1308 -65

No files matched your search

@@ -0,0 +1,191 @@
package net.dnorberg.rivencraft.book;
import java.util.*;
import com.mojang.serialization.JsonOps;
import net.dnorberg.rivencraft.shared.NativeBiomeKind;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator;
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
import net.minecraft.world.level.levelgen.Aquifer;
import net.minecraft.world.level.block.Blocks;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.neoforge.event.server.ServerStartedEvent;
/** Disposable fixture: exercises real generator settings, fluid picker and codecs. */
@EventBusSubscriber(modid="rivencraft")
public final class NativeFluidProbe {
private static int checks;
private static void check(boolean value, String label) {
if (!value) throw new AssertionError(label);
checks++;
}
static ResourceLocation id(String path) { return ResourceLocation.fromNamespaceAndPath("rivencraft", path); }
@SubscribeEvent public static void start(ServerStartedEvent event) {
event.getServer().execute(() -> {
try { run(event.getServer()); System.out.println("NATIVE119_PASS checks=" + checks); }
catch (Throwable error) { System.out.println("NATIVE119_FAIL " + error); error.printStackTrace(); }
finally { event.getServer().halt(false); }
});
}
static void run(MinecraftServer server) throws Exception {
testFlatGround(server);
int index = 0;
for (var family : List.of(NativeBiomeKind.NETHER, NativeBiomeKind.END, NativeBiomeKind.CAVES)) {
for (String terrain : List.of("standard", "amplified", "island", "cave", "flat", "void")) {
var entries = new net.dnorberg.rivencraft.writing.OrderedWriting(List.of(
net.dnorberg.rivencraft.writing.WritingEntry.linkPanel(),
net.dnorberg.rivencraft.writing.WritingEntry.symbol(new net.dnorberg.rivencraft.writing.SymbolReference(id("terrain/" + terrain))),
net.dnorberg.rivencraft.writing.WritingEntry.symbol(new net.dnorberg.rivencraft.writing.SymbolReference(id("biome/native_" + family.name().toLowerCase(Locale.ROOT))))));
var traits = AgeTraits.select(119L).withBiomeDistribution(AgeTraits.BiomeDistribution.NATIVE);
var plan = AgeGenerationPlan.compile(entries,119L,AgeGenerationProfiles.STANDARD,traits,server.registryAccess());
check(plan.biomeSelection().nativeKind() == family, "Frozen family");
var expectedSky = family == NativeBiomeKind.NETHER ? AgeSkyProfile.Style.NETHER
: family == NativeBiomeKind.END ? AgeSkyProfile.Style.END : AgeSkyProfile.Style.INHERITED;
check(AgeSkyProfile.compile(plan,traits).style() == expectedSky, "Native sky default " + family + terrain);
check(AgeSkyProfile.compile(AgeGenerationPlan.load(plan.save()),traits).style() == expectedSky, "Sky plan reload");
if (family != NativeBiomeKind.CAVES) {
var expectedEffect = family == NativeBiomeKind.NETHER
? net.minecraft.world.level.dimension.BuiltinDimensionTypes.NETHER_EFFECTS
: net.minecraft.world.level.dimension.BuiltinDimensionTypes.END_EFFECTS;
check(AgeEnvironmentCompiler.skyEffects(plan,
net.minecraft.world.level.dimension.BuiltinDimensionTypes.OVERWORLD_EFFECTS).equals(expectedEffect),
"Native dimension sky effect");
if (terrain.equals("standard")) {
for (String sky : List.of("overworld", "nether", "end", "static")) {
var written = new ArrayList<>(entries.entries());
written.add(net.dnorberg.rivencraft.writing.WritingEntry.symbol(
new net.dnorberg.rivencraft.writing.SymbolReference(id("sky/" + sky))));
written.add(net.dnorberg.rivencraft.writing.WritingEntry.symbol(
new net.dnorberg.rivencraft.writing.SymbolReference(id("celestial/sun"))));
var override = AgeGenerationPlan.compile(new net.dnorberg.rivencraft.writing.OrderedWriting(written),
119L,AgeGenerationProfiles.STANDARD,traits,server.registryAccess());
check(AgeSkyProfile.compile(override,traits).style() == AgeSkyProfile.Style.valueOf(sky.toUpperCase(Locale.ROOT)),
"Explicit sky wins with celestial");
}
var written = new ArrayList<>(entries.entries());
written.add(net.dnorberg.rivencraft.writing.WritingEntry.symbol(
new net.dnorberg.rivencraft.writing.SymbolReference(id("celestial/sun"))));
var celestial = AgeGenerationPlan.compile(new net.dnorberg.rivencraft.writing.OrderedWriting(written),
119L,AgeGenerationProfiles.STANDARD,traits,server.registryAccess());
check(AgeSkyProfile.compile(celestial,traits).style() == expectedSky, "Celestial does not override Native default");
}
}
var age = new AgeDefinition(UUID.randomUUID(),"probe",119L,AgeGenerationProfiles.STANDARD,
AgeDefinition.CURRENT_GENERATION_VERSION,0L,id("age/fluid119_" + index++),null,traits,plan);
var factory = AgeDimensionService.class.getDeclaredMethod("createGenerator",MinecraftServer.class,AgeDefinition.class);
factory.setAccessible(true);
var generator = (ChunkGenerator) factory.invoke(null,server,age);
var ops = server.registryAccess().createSerializationContext(JsonOps.INSTANCE);
var encoded = ChunkGenerator.CODEC.encodeStart(ops, generator).getOrThrow();
var restored = ChunkGenerator.CODEC.parse(ops, encoded).getOrThrow();
NoiseBasedChunkGenerator noise = generator instanceof NoiseBasedChunkGenerator n ? n : null;
NoiseBasedChunkGenerator restoredNoise = restored instanceof NoiseBasedChunkGenerator n ? n : null;
if (noise == null) {
check(restoredNoise == null, "Flat/Void remains flat: " + terrain);
continue;
}
var settings = noise.generatorSettings().value();
var reloaded = restoredNoise.generatorSettings().value();
check(reloaded.defaultFluid().equals(settings.defaultFluid())
&& reloaded.seaLevel() == settings.seaLevel(), "Fluid codec " + family + terrain);
if (family == NativeBiomeKind.NETHER) {
check(settings.defaultFluid().is(Blocks.LAVA), "Nether natural lava " + terrain);
check(!settings.isAquifersEnabled(), "Nether disables water aquifers " + terrain);
} else if (family == NativeBiomeKind.END) {
check(settings.defaultFluid().isAir(), "End dry " + terrain);
check(settings.seaLevel() < settings.noiseSettings().minY(), "End fluid below dimension " + terrain);
check(!settings.isAquifersEnabled(), "End disables aquifers " + terrain);
} else {
check(terrain.equals("cave") ? settings.defaultFluid().isAir()
: settings.defaultFluid().is(Blocks.WATER), "Other Native family unchanged " + terrain);
continue;
}
var method = NoiseBasedChunkGenerator.class.getDeclaredMethod("createFluidPicker", NoiseGeneratorSettings.class);
method.setAccessible(true);
var picker = (Aquifer.FluidPicker) method.invoke(null, settings);
boolean water = false, lava = false, anyFluid = false;
for (int y = settings.noiseSettings().minY(); y < settings.noiseSettings().minY() + settings.noiseSettings().height(); y++) {
var block = picker.computeFluid(0, y, 0).at(y);
water |= block.is(Blocks.WATER); lava |= block.is(Blocks.LAVA);
anyFluid |= !block.getFluidState().isEmpty();
}
check(!water, "No natural water anywhere in column " + family + terrain);
check(family == NativeBiomeKind.NETHER ? lava == (settings.seaLevel() > settings.noiseSettings().minY()) : !anyFluid, "Nether lava / End dry picker " + terrain);
}
}
}
static void testFlatGround(MinecraftServer server) throws Exception {
var registry = server.registryAccess().lookupOrThrow(Registries.BIOME);
var random = server.overworld().getChunkSource().randomState();
var settings = AgeDimensionService.flatSettings(server,AgeRuntimeProfiles.resolve(AgeGenerationProfiles.FLAT));
var keys = List.of(net.minecraft.world.level.biome.Biomes.THE_END, net.minecraft.world.level.biome.Biomes.CRIMSON_FOREST,
net.minecraft.world.level.biome.Biomes.WARPED_FOREST, net.minecraft.world.level.biome.Biomes.SOUL_SAND_VALLEY,
net.minecraft.world.level.biome.Biomes.BASALT_DELTAS, net.minecraft.world.level.biome.Biomes.NETHER_WASTES,
net.minecraft.world.level.biome.Biomes.PLAINS);
var tops = List.of(Blocks.END_STONE,Blocks.CRIMSON_NYLIUM,Blocks.WARPED_NYLIUM,Blocks.SOUL_SAND,Blocks.BASALT,Blocks.NETHERRACK,Blocks.GRASS_BLOCK);
var soils = List.of(Blocks.END_STONE,Blocks.NETHERRACK,Blocks.NETHERRACK,Blocks.SOUL_SOIL,Blocks.BLACKSTONE,Blocks.NETHERRACK,Blocks.DIRT);
for (int i=0;i<keys.size();i++) {
ChunkGenerator original = new net.dnorberg.rivencraft.world.AgeFlatChunkGenerator(
new net.minecraft.world.level.biome.FixedBiomeSource(registry.getOrThrow(keys.get(i))),settings);
var ops = server.registryAccess().createSerializationContext(JsonOps.INSTANCE);
var saved = ChunkGenerator.CODEC.encodeStart(ops,original).getOrThrow();
for (var generator : List.of(original,ChunkGenerator.CODEC.parse(ops,saved).getOrThrow())) {
var height = net.minecraft.world.level.LevelHeightAccessor.create(-64,384);
var chunk = new net.minecraft.world.level.chunk.ProtoChunk(new net.minecraft.world.level.ChunkPos(-1,2),
net.minecraft.world.level.chunk.UpgradeData.EMPTY,height,
server.registryAccess().registryOrThrow(Registries.BIOME),null);
generator.fillFromNoise(null,random,null,chunk).join();
check(chunk.getBlockState(new net.minecraft.core.BlockPos(-15,3,33)).is(tops.get(i)), "Actual flat top " + keys.get(i));
check(chunk.getBlockState(new net.minecraft.core.BlockPos(-15,1,33)).is(soils.get(i)), "Actual flat soil");
check(chunk.getBlockState(new net.minecraft.core.BlockPos(-15,0,33)).is(Blocks.BEDROCK), "Bedrock retained");
check(chunk.getBlockState(new net.minecraft.core.BlockPos(-15,-1,33)).isAir()
&& chunk.getBlockState(new net.minecraft.core.BlockPos(-15,4,33)).isAir(), "Flat bounds unchanged");
check(generator.getBaseColumn(-15,33,height,random).getBlock(3).is(tops.get(i)), "Column agrees with placed blocks");
}
}
var plains = registry.getOrThrow(net.minecraft.world.level.biome.Biomes.PLAINS);
var region = new net.dnorberg.rivencraft.world.AgeFlatChunkGenerator(
new net.minecraft.world.level.biome.FixedBiomeSource(plains),settings,List.of(),119L,List.of(),
net.dnorberg.rivencraft.shared.FloodingRules.NONE,List.of(plains.key().location()));
var ops = server.registryAccess().createSerializationContext(JsonOps.INSTANCE);
var loaded = ChunkGenerator.CODEC.parse(ops,ChunkGenerator.CODEC.encodeStart(ops,region).getOrThrow()).getOrThrow();
check(loaded.getBaseColumn(0,0,net.minecraft.world.level.LevelHeightAccessor.create(-64,384),random)
.getBlock(3).is(Blocks.NETHERRACK), "Region-only Nether classification persists without a tag");
var end = registry.getOrThrow(net.minecraft.world.level.biome.Biomes.THE_END);
check(net.dnorberg.rivencraft.shared.FlatBiomeMaterials.layer(Blocks.DIAMOND_BLOCK.defaultBlockState(),end,false)
.is(Blocks.DIAMOND_BLOCK), "Explicit non-soil material retained");
check(net.dnorberg.rivencraft.shared.FlatBiomeMaterials.layer(Blocks.WATER.defaultBlockState(),end,false)
.is(Blocks.WATER), "Authored fluid retained");
var bind = net.minecraft.core.Holder.Reference.class.getDeclaredMethod("bindTags",Collection.class);
bind.setAccessible(true);var old = plains.tags().toList();
try {
var tags = new ArrayList<>(old);tags.add(net.minecraft.tags.BiomeTags.IS_END);bind.invoke(plains,tags);
var tagged = new net.dnorberg.rivencraft.world.AgeFlatChunkGenerator(
new net.minecraft.world.level.biome.FixedBiomeSource(plains),settings);
check(tagged.getBaseColumn(0,0,net.minecraft.world.level.LevelHeightAccessor.create(-64,384),random)
.getBlock(3).is(Blocks.END_STONE), "Tag-classified modded-style End biome");
} finally { bind.invoke(plains,old); }
var mixedSource = new net.minecraft.world.level.biome.CheckerboardColumnBiomeSource(
net.minecraft.core.HolderSet.direct(List.<net.minecraft.core.Holder<net.minecraft.world.level.biome.Biome>>of(
end,plains,registry.getOrThrow(net.minecraft.world.level.biome.Biomes.CRIMSON_FOREST))),0);
var mixed = new net.dnorberg.rivencraft.world.AgeFlatChunkGenerator(mixedSource,settings);
var seen = new HashSet<net.minecraft.world.level.block.Block>();
for (int cx=-2;cx<=2;cx++) {
int x=cx*16+1;
var biome = mixedSource.getNoiseBiome(net.minecraft.core.QuartPos.fromBlock(x),0,0,random.sampler());
var expected = biome.is(net.minecraft.world.level.biome.Biomes.THE_END) ? Blocks.END_STONE
: biome.is(net.minecraft.world.level.biome.Biomes.CRIMSON_FOREST) ? Blocks.CRIMSON_NYLIUM : Blocks.GRASS_BLOCK;
seen.add(expected);
var height = net.minecraft.world.level.LevelHeightAccessor.create(-64,384);
var chunk = new net.minecraft.world.level.chunk.ProtoChunk(new net.minecraft.world.level.ChunkPos(cx,0),net.minecraft.world.level.chunk.UpgradeData.EMPTY,height,server.registryAccess().registryOrThrow(Registries.BIOME),null);
mixed.fillFromNoise(null,random,null,chunk).join();
check(chunk.getBlockState(new net.minecraft.core.BlockPos(x,3,1)).is(expected), "Mixed biome actual surface");
check(mixed.getBaseColumn(x,1,height,random).getBlock(3).is(expected), "Mixed biome spawn column");
}
check(seen.size()==3, "Mixed test visits End, Nether and Overworld");
}
}
@@ -0,0 +1,174 @@
package net.dnorberg.rivencraft.age;
import java.util.*;
import com.mojang.serialization.JsonOps;
import net.dnorberg.rivencraft.shared.NativeBiomeKind;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.Identifier;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator;
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
import net.minecraft.world.level.levelgen.Aquifer;
import net.minecraft.world.level.block.Blocks;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.neoforge.event.server.ServerStartedEvent;
/** Disposable fixture: exercises real generator settings, fluid picker and codecs. */
@EventBusSubscriber(modid="rivencraft")
public final class NativeFluidProbe {
private static int checks;
private static void check(boolean value, String label) {
if (!value) throw new AssertionError(label);
checks++;
}
static Identifier id(String path) { return Identifier.fromNamespaceAndPath("rivencraft", path); }
@SubscribeEvent public static void start(ServerStartedEvent event) {
event.getServer().execute(() -> {
try { run(event.getServer()); System.out.println("NATIVE119_PASS checks=" + checks); }
catch (Throwable error) { System.out.println("NATIVE119_FAIL " + error); error.printStackTrace(); }
finally { event.getServer().halt(false); }
});
}
static void run(MinecraftServer server) throws Exception {
testFlatGround(server);
int index = 0;
for (var family : List.of(NativeBiomeKind.NETHER, NativeBiomeKind.END, NativeBiomeKind.CAVES)) {
for (String terrain : List.of("standard", "amplified", "island", "cave", "flat", "void")) {
var selection = net.dnorberg.rivencraft.writing.PortAuthoredTerrainSelection.select(server,
List.of(id("terrain/" + terrain), id("biome/native_" + family.name().toLowerCase(Locale.ROOT))),119L);
check(selection.biomes().nativeKind() == family, "Frozen family");
var pages = List.of(id("terrain/" + terrain), id("biome/native_" + family.name().toLowerCase(Locale.ROOT)));
var sky = PortEnvironmentSelection.resolve(pages,119L,selection.terrain()).sky();
if (family != NativeBiomeKind.CAVES) {
var expectedSky = family == NativeBiomeKind.NETHER ? PortSkyStyle.NETHER : PortSkyStyle.END;
check(sky == expectedSky, "Native sky default " + family + terrain);
check(PortSkyStyle.CODEC.parse(JsonOps.INSTANCE,PortSkyStyle.CODEC.encodeStart(JsonOps.INSTANCE,sky)
.getOrThrow()).getOrThrow() == expectedSky, "Sky codec reload");
if (terrain.equals("standard")) {
for (String choice : List.of("overworld", "nether", "end", "static")) {
var authored = new ArrayList<>(pages);
authored.add(id("sky/" + choice)); authored.add(id("celestial/sun"));
check(PortEnvironmentSelection.resolve(authored,119L,selection.terrain()).sky()
== PortSkyStyle.valueOf(choice.toUpperCase(Locale.ROOT)), "Explicit sky wins with celestial");
}
var celestial = new ArrayList<>(pages); celestial.add(id("celestial/sun"));
check(PortSkyStyle.resolve(celestial,119L) == expectedSky, "Celestial does not override Native default");
}
}
var level = RuntimeAgeBackend.create(server,id("age/fluid119_" + index++),119L,selection.biomes(),selection.terrain());
var generator = level.getChunkSource().getGenerator();
if (family != NativeBiomeKind.CAVES) check(level.dimensionTypeRegistration().unwrapKey().orElseThrow()
.identifier().getPath().endsWith("_sky_" + family.name().toLowerCase(Locale.ROOT)), "Runtime dimension sky");
var ops = server.registryAccess().createSerializationContext(JsonOps.INSTANCE);
var encoded = ChunkGenerator.CODEC.encodeStart(ops, generator).getOrThrow();
var restored = ChunkGenerator.CODEC.parse(ops, encoded).getOrThrow();
NoiseBasedChunkGenerator noise = ((PortFeatureChunkGenerator) generator).base() instanceof NoiseBasedChunkGenerator n ? n : null;
NoiseBasedChunkGenerator restoredNoise = ((PortFeatureChunkGenerator) restored).base() instanceof NoiseBasedChunkGenerator n ? n : null;
if (noise == null) {
check(restoredNoise == null, "Flat/Void remains flat: " + terrain);
continue;
}
var settings = noise.generatorSettings().value();
var reloaded = restoredNoise.generatorSettings().value();
check(reloaded.defaultFluid().equals(settings.defaultFluid())
&& reloaded.seaLevel() == settings.seaLevel(), "Fluid codec " + family + terrain);
if (family == NativeBiomeKind.NETHER) {
check(settings.defaultFluid().is(Blocks.LAVA), "Nether natural lava " + terrain);
check(!settings.aquifers().isPresent(), "Nether disables water aquifers " + terrain);
} else if (family == NativeBiomeKind.END) {
check(settings.defaultFluid().isAir(), "End dry " + terrain);
check(settings.seaLevel() < settings.noiseSettings().minY(), "End fluid below dimension " + terrain);
check(!settings.aquifers().isPresent(), "End disables aquifers " + terrain);
} else {
check(terrain.equals("cave") ? settings.defaultFluid().isAir()
: settings.defaultFluid().is(Blocks.WATER), "Other Native family unchanged " + terrain);
continue;
}
var method = NoiseBasedChunkGenerator.class.getDeclaredMethod("createFluidPicker", NoiseGeneratorSettings.class);
method.setAccessible(true);
var picker = (Aquifer.FluidPicker) method.invoke(null, settings);
boolean water = false, lava = false, anyFluid = false;
for (int y = settings.noiseSettings().minY(); y < settings.noiseSettings().minY() + settings.noiseSettings().height(); y++) {
var block = picker.computeFluid(0, y, 0).at(y);
water |= block.is(Blocks.WATER); lava |= block.is(Blocks.LAVA);
anyFluid |= !block.getFluidState().isEmpty();
}
check(!water, "No natural water anywhere in column " + family + terrain);
check(family == NativeBiomeKind.NETHER ? lava == (settings.seaLevel() > settings.noiseSettings().minY()) : !anyFluid, "Nether lava / End dry picker " + terrain);
}
}
}
static void testFlatGround(MinecraftServer server) throws Exception {
var registry = server.registryAccess().lookupOrThrow(Registries.BIOME);
var random = server.overworld().getChunkSource().randomState();
var keys = List.of(net.minecraft.world.level.biome.Biomes.THE_END, net.minecraft.world.level.biome.Biomes.CRIMSON_FOREST,
net.minecraft.world.level.biome.Biomes.WARPED_FOREST, net.minecraft.world.level.biome.Biomes.SOUL_SAND_VALLEY,
net.minecraft.world.level.biome.Biomes.BASALT_DELTAS, net.minecraft.world.level.biome.Biomes.NETHER_WASTES,
net.minecraft.world.level.biome.Biomes.PLAINS);
var tops = List.of(Blocks.END_STONE,Blocks.CRIMSON_NYLIUM,Blocks.WARPED_NYLIUM,Blocks.SOUL_SAND,Blocks.BASALT,Blocks.NETHERRACK,Blocks.GRASS_BLOCK);
var soils = List.of(Blocks.END_STONE,Blocks.NETHERRACK,Blocks.NETHERRACK,Blocks.SOUL_SOIL,Blocks.BLACKSTONE,Blocks.NETHERRACK,Blocks.DIRT);
net.minecraft.world.level.levelgen.flat.FlatLevelGeneratorSettings settings = null;
for (int i=0;i<keys.size();i++) {
var plan = new PortBiomePlan(PortBiomePlan.Distribution.SINGLE,List.of(keys.get(i).identifier()));
var level = RuntimeAgeBackend.create(server,id("age/flat_ground_" + i),119L,plan,PortAgeTerrain.FLAT);
ChunkGenerator original = ((PortFeatureChunkGenerator)level.getChunkSource().getGenerator()).base();
if (i<6) check(original instanceof PortFlatChunkGenerator, "Single End/Nether bypass fixed");
if (original instanceof PortFlatChunkGenerator flat) settings = flat.settings();
var ops = server.registryAccess().createSerializationContext(JsonOps.INSTANCE);
var saved = ChunkGenerator.CODEC.encodeStart(ops,original).getOrThrow();
for (var generator : List.of(original,ChunkGenerator.CODEC.parse(ops,saved).getOrThrow())) {
var height = net.minecraft.world.level.LevelHeightAccessor.create(-64,384);
var chunk = new net.minecraft.world.level.chunk.ProtoChunk(new net.minecraft.world.level.ChunkPos(-1,2),
net.minecraft.world.level.chunk.UpgradeData.EMPTY,height,
net.minecraft.world.level.chunk.PalettedContainerFactory.create(server.registryAccess()),null);
generator.buildTerrain(chunk,null,random,null,server.overworld().getBiomeManager(),null,generator.getBiomeSource().possibleBiomes()).join();
check(chunk.getBlockState(new net.minecraft.core.BlockPos(-15,3,33)).is(tops.get(i)), "Actual flat top " + keys.get(i));
check(chunk.getBlockState(new net.minecraft.core.BlockPos(-15,1,33)).is(soils.get(i)), "Actual flat soil");
check(chunk.getBlockState(new net.minecraft.core.BlockPos(-15,0,33)).is(Blocks.BEDROCK), "Bedrock retained");
check(chunk.getBlockState(new net.minecraft.core.BlockPos(-15,-1,33)).isAir()
&& chunk.getBlockState(new net.minecraft.core.BlockPos(-15,4,33)).isAir(), "Flat bounds unchanged");
check(generator.getBaseColumn(-15,33,height,random).getBlock(3).is(tops.get(i)), "Column agrees with placed blocks");
}
}
var plains = registry.getOrThrow(net.minecraft.world.level.biome.Biomes.PLAINS);
var region = new PortFlatChunkGenerator(new net.minecraft.world.level.biome.FixedBiomeSource(plains),settings,
List.of(plains.key().identifier()));
var ops = server.registryAccess().createSerializationContext(JsonOps.INSTANCE);
var loaded = ChunkGenerator.CODEC.parse(ops,ChunkGenerator.CODEC.encodeStart(ops,region).getOrThrow()).getOrThrow();
check(loaded.getBaseColumn(0,0,net.minecraft.world.level.LevelHeightAccessor.create(-64,384),random)
.getBlock(3).is(Blocks.NETHERRACK), "Region-only Nether classification persists without a tag");
var end = registry.getOrThrow(net.minecraft.world.level.biome.Biomes.THE_END);
check(net.dnorberg.rivencraft.shared.FlatBiomeMaterials.layer(Blocks.DIAMOND_BLOCK.defaultBlockState(),end,false)
.is(Blocks.DIAMOND_BLOCK), "Explicit non-soil material retained");
check(net.dnorberg.rivencraft.shared.FlatBiomeMaterials.layer(Blocks.WATER.defaultBlockState(),end,false)
.is(Blocks.WATER), "Authored fluid retained");
var bind = net.minecraft.core.Holder.Reference.class.getDeclaredMethod("bindTags",Collection.class);
bind.setAccessible(true);var old = plains.tags().toList();
try {
var tags = new ArrayList<>(old);tags.add(net.minecraft.tags.BiomeTags.IS_END);bind.invoke(plains,tags);
var tagged = new PortFlatChunkGenerator(new net.minecraft.world.level.biome.FixedBiomeSource(plains),settings);
check(tagged.getBaseColumn(0,0,net.minecraft.world.level.LevelHeightAccessor.create(-64,384),random)
.getBlock(3).is(Blocks.END_STONE), "Tag-classified modded-style End biome");
} finally { bind.invoke(plains,old); }
var mixedSource = new net.minecraft.world.level.biome.CheckerboardColumnBiomeSource(
net.minecraft.core.HolderSet.direct(List.<net.minecraft.core.Holder<net.minecraft.world.level.biome.Biome>>of(
end,plains,registry.getOrThrow(net.minecraft.world.level.biome.Biomes.CRIMSON_FOREST))),0);
var mixed = new PortFlatChunkGenerator(mixedSource,settings);
var seen = new HashSet<net.minecraft.world.level.block.Block>();
for (int cx=-2;cx<=2;cx++) {
int x=cx*16+1;
var biome = mixedSource.getNoiseBiome(net.minecraft.core.QuartPos.fromBlock(x),0,0);
var expected = biome.is(net.minecraft.world.level.biome.Biomes.THE_END) ? Blocks.END_STONE
: biome.is(net.minecraft.world.level.biome.Biomes.CRIMSON_FOREST) ? Blocks.CRIMSON_NYLIUM : Blocks.GRASS_BLOCK;
seen.add(expected);
var height = net.minecraft.world.level.LevelHeightAccessor.create(-64,384);
var chunk = new net.minecraft.world.level.chunk.ProtoChunk(new net.minecraft.world.level.ChunkPos(cx,0),net.minecraft.world.level.chunk.UpgradeData.EMPTY,height,net.minecraft.world.level.chunk.PalettedContainerFactory.create(server.registryAccess()),null);
mixed.buildTerrain(chunk,null,random,null,server.overworld().getBiomeManager(),null,mixed.getBiomeSource().possibleBiomes()).join();
check(chunk.getBlockState(new net.minecraft.core.BlockPos(x,3,1)).is(expected), "Mixed biome actual surface");
check(mixed.getBaseColumn(x,1,height,random).getBlock(3).is(expected), "Mixed biome spawn column");
}
check(seen.size()==3, "Mixed test visits End, Nether and Overworld");
}
}
+195
View File
@@ -0,0 +1,195 @@
#!/usr/bin/env python3
"""Isolated 26.3 client-guard checks; no Minecraft client, GPU, server or world starts."""
from pathlib import Path
import shutil
import subprocess
import tempfile
ROOT = Path(__file__).resolve().parents[1]
STUBS = {
"net.minecraft.client.Minecraft": "public class Minecraft { public static boolean sameThread=true; private static final Minecraft INSTANCE=new Minecraft(); public static Minecraft getInstance(){return INSTANCE;} public boolean isSameThread(){return sameThread;} }",
"net.minecraft.client.multiplayer.ClientLevel": "public class ClientLevel { public final java.util.List<Integer> acks=new java.util.ArrayList<>(); public void handleBlockChangedAck(int n){acks.add(n);} }",
"net.minecraft.client.multiplayer.ClientPacketListener": "public class ClientPacketListener {}",
"net.minecraft.network.protocol.game.ClientboundBlockChangedAckPacket": "public record ClientboundBlockChangedAckPacket(int sequence) {}",
"net.dnorberg.rivencraft.compat.ImmersiveBookPreviews": "public class ImmersiveBookPreviews { public static boolean reborn,seamless; public static boolean available(){return reborn||seamless;} }",
"qouteall.imm_ptl.core.ClientWorldLoader": "public class ClientWorldLoader { public static boolean initialized; public static int reads; public static final java.util.List<net.minecraft.client.multiplayer.ClientLevel> worlds=new java.util.ArrayList<>(); public static boolean getIsInitialized(){reads++;return initialized;} public static java.util.Collection<net.minecraft.client.multiplayer.ClientLevel> getClientWorlds(){if(!initialized)throw new IllegalArgumentException();return worlds;} }",
"net.minecraft.client.renderer.chunk.SectionRenderDispatcher": "public class SectionRenderDispatcher { public class RenderSection { public boolean dirty=true; } }",
"net.minecraft.client.renderer.ViewArea": "public class ViewArea implements net.dnorberg.rivencraft.mixin.ViewAreaSectionAccessor { public final java.util.Map<Long,net.minecraft.client.renderer.chunk.SectionRenderDispatcher.RenderSection> sections=new java.util.HashMap<>(); public boolean fail; public int reads; public net.minecraft.client.renderer.chunk.SectionRenderDispatcher.RenderSection rivencraft$getRenderSection(long n){reads++;if(fail)throw new IllegalStateException();return sections.get(n);} }",
"net.minecraft.client.renderer.LevelRenderer": "public class LevelRenderer {}",
"net.minecraft.client.renderer.state.level.CameraRenderState": "public class CameraRenderState {}",
"net.minecraft.client.renderer.state.level.SectionUpdateRenderState": "public record SectionUpdateRenderState(long sectionNode,boolean playerChanged,Object region,java.util.List<Object> additionalRenderers) {}",
"net.minecraft.client.renderer.state.level.LevelRenderState": "public class LevelRenderState { public final java.util.List<SectionUpdateRenderState> sectionUpdateRenderStates=new java.util.ArrayList<>(); }",
}
EXTRACT = r"""
import java.nio.file.*; import java.util.zip.*; import org.objectweb.asm.*;
public class ExtractForkAck {
public static void main(String[] args)throws Exception {
var writer=new ClassWriter(ClassWriter.COMPUTE_FRAMES|ClassWriter.COMPUTE_MAXS);
writer.visit(Opcodes.V25,Opcodes.ACC_PUBLIC,args[1],null,"java/lang/Object",null);
var init=writer.visitMethod(Opcodes.ACC_PUBLIC,"<init>","()V",null,null);
init.visitCode();init.visitVarInsn(Opcodes.ALOAD,0);init.visitMethodInsn(Opcodes.INVOKESPECIAL,"java/lang/Object","<init>","()V",false);init.visitInsn(Opcodes.RETURN);init.visitMaxs(0,0);init.visitEnd();
int[] copied={0};
try(var zip=new ZipFile(args[0])) {
var bytes=zip.getInputStream(zip.getEntry("qouteall/imm_ptl/core/mixin/client/sync/MixinClientPacketListener.class")).readAllBytes();
new ClassReader(bytes).accept(new ClassVisitor(Opcodes.ASM9) {
@Override public MethodVisitor visitMethod(int access,String name,String desc,String sig,String[] exceptions) {
if(!name.equals("redirectHandleBlockChangedAck"))return null;
copied[0]++;
return new MethodVisitor(Opcodes.ASM9,writer.visitMethod(Opcodes.ACC_PUBLIC,"handle",desc,null,null)) {
@Override public AnnotationVisitor visitAnnotation(String desc,boolean visible){return null;}
};
}
},ClassReader.SKIP_FRAMES|ClassReader.SKIP_DEBUG);
}
if(copied[0]!=1)throw new AssertionError("Expected exactly one fork redirect");
writer.visitEnd();Files.write(Path.of(args[2]),writer.toByteArray());
}
}
"""
CHECKS = r"""
import java.util.*;
import java.lang.reflect.*;
import net.minecraft.client.*;
import net.minecraft.client.multiplayer.*;
import net.minecraft.network.protocol.game.*;
import net.minecraft.client.renderer.*;
import net.minecraft.client.renderer.chunk.SectionRenderDispatcher.RenderSection;
import net.minecraft.client.renderer.state.level.*;
import net.dnorberg.rivencraft.mixin.*;
import net.dnorberg.rivencraft.compat.ImmersiveBookPreviews;
import qouteall.imm_ptl.core.ClientWorldLoader;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
public class Client118Checks {
static int checks;
public static class Ack extends ImmersiveBlockAckMixin {}
public static class Rebuild extends ImmersiveSectionRebuildMixin {}
static void check(boolean pass,String message){if(!pass)throw new AssertionError(message);checks++;}
static void field(Object object,Class<?> owner,String name,Object value)throws Exception{
var field=owner.getDeclaredField(name);field.setAccessible(true);field.set(object,value);
}
static void invoke(Object object,Class<?> owner,String name,Class<?>[] types,Object...args)throws Exception{
var method=owner.getDeclaredMethod(name,types);method.setAccessible(true);method.invoke(object,args);
}
static void ack(Ack hook,CallbackInfo callback)throws Exception{
invoke(hook,ImmersiveBlockAckMixin.class,"rivencraft$ackDuringWorldReset",
new Class<?>[]{ClientboundBlockChangedAckPacket.class,CallbackInfo.class},new ClientboundBlockChangedAckPacket(37),callback);
}
static void render(Rebuild hook,CallbackInfo callback)throws Exception{
invoke(hook,ImmersiveSectionRebuildMixin.class,"rivencraft$discardUnavailableSections",
new Class<?>[]{CameraRenderState.class,CallbackInfo.class},new CameraRenderState(),callback);
}
public static void main(String[] args)throws Exception{
for(String engine:List.of("none","reborn","seamless")){
ImmersiveBookPreviews.reborn=engine.equals("reborn");ImmersiveBookPreviews.seamless=engine.equals("seamless");
Object fork=null;Method redirect=null;
if(!engine.equals("none")){
var type=Class.forName(engine.equals("reborn")?"ForkAckReborn":"ForkAckSeamless");
fork=type.getConstructor().newInstance();redirect=type.getMethod("handle",ClientLevel.class,int.class);
ClientWorldLoader.initialized=false;
try{redirect.invoke(fork,new ClientLevel(),37);throw new AssertionError("Original redirect unexpectedly safe");}
catch(InvocationTargetException error){check(error.getCause() instanceof IllegalArgumentException,"Original "+engine+" precondition reproduced");}
}
for(boolean initialized:List.of(false,true)){
ClientWorldLoader.initialized=initialized;ClientWorldLoader.worlds.clear();ClientWorldLoader.reads=0;Minecraft.sameThread=true;
var local=new ClientLevel();var remote=new ClientLevel();ClientWorldLoader.worlds.addAll(List.of(local,remote));
var hook=new Ack();field(hook,ImmersiveBlockAckMixin.class,"level",local);
var callback=new CallbackInfo("ack",true);ack(hook,callback);
boolean fallback=!engine.equals("none")&&!initialized;
check(callback.isCancelled()==fallback,"Cancellation scope "+engine+initialized);
if(!callback.isCancelled()){
if(engine.equals("none"))local.handleBlockChangedAck(37);else redirect.invoke(fork,local,37);
}
check(local.acks.equals(List.of(37)),"Exactly one local ack "+engine+initialized);
check(remote.acks.equals(!engine.equals("none")&&initialized?List.of(37):List.of()),"Warm-map multiworld delivery retained");
local.acks.clear();remote.acks.clear();ClientWorldLoader.reads=0;Minecraft.sameThread=false;
callback=new CallbackInfo("ack",true);ack(hook,callback);
check(!callback.isCancelled()&&local.acks.isEmpty()&&remote.acks.isEmpty()&&ClientWorldLoader.reads==0,"Network-thread scheduling untouched");
}
Minecraft.sameThread=true;ClientWorldLoader.initialized=false;
var hook=new Ack();field(hook,ImmersiveBlockAckMixin.class,"level",null);
var callback=new CallbackInfo("ack",true);ack(hook,callback);
check(callback.isCancelled()!=engine.equals("none"),"Missing packet world handled only for installed fork");
var area=new ViewArea();var first=new net.minecraft.client.renderer.chunk.SectionRenderDispatcher().new RenderSection();var second=new net.minecraft.client.renderer.chunk.SectionRenderDispatcher().new RenderSection();
area.sections.put(1L,first);area.sections.put(2L,second);
var state=new LevelRenderState();Object region=new Object();List<Object> extras=List.of(new Object());
var a=new SectionUpdateRenderState(1,true,region,extras);
var stale=new SectionUpdateRenderState(9,false,new Object(),List.of());
var b=new SectionUpdateRenderState(2,false,new Object(),List.of());
state.sectionUpdateRenderStates.addAll(List.of(a,stale,b,a));
var rebuild=new Rebuild();field(rebuild,ImmersiveSectionRebuildMixin.class,"viewArea",area);
field(rebuild,ImmersiveSectionRebuildMixin.class,"levelRenderState",state);
callback=new CallbackInfo("compile",true);render(rebuild,callback);
boolean active=!engine.equals("none");
check(state.sectionUpdateRenderStates.equals(active?List.of(a,b,a):List.of(a,stale,b,a)),"Only absent sections removed "+engine);
check(state.sectionUpdateRenderStates.getFirst()==a&&a.region()==region&&a.additionalRenderers()==extras,"Valid identity/order/additional geometry preserved");
check(first.dirty&&second.dirty&&!callback.isCancelled(),"Dirty state and render pipeline untouched");
if(!active)check(area.reads==0,"No renderer workaround without optional engine");
state.sectionUpdateRenderStates.clear();state.sectionUpdateRenderStates.add(stale);area.sections.put(9L,new net.minecraft.client.renderer.chunk.SectionRenderDispatcher().new RenderSection());
render(rebuild,new CallbackInfo("compile",true));
check(state.sectionUpdateRenderStates.equals(List.of(stale)),"Newly available section is not blacklisted");
field(rebuild,ImmersiveSectionRebuildMixin.class,"viewArea",null);
render(rebuild,new CallbackInfo("compile",true));
check(state.sectionUpdateRenderStates.equals(List.of(stale)),"Missing view area not mistaken for stale batch");
field(rebuild,ImmersiveSectionRebuildMixin.class,"viewArea",area);
area.fail=true;
if(active){
try{render(rebuild,new CallbackInfo("compile",true));throw new AssertionError("Unrelated exception swallowed");}
catch(InvocationTargetException error){check(error.getCause() instanceof IllegalStateException,"Unrelated renderer exception propagates");}
}
}
System.out.println("CLIENT118_GUARDS_PASS checks="+checks);
}
}
"""
def main():
homes = list((Path.home() / ".gradle/jdks").glob("*25*/bin/javac"))
if not homes:
homes = list((Path.home() / ".gradle/jdks").glob("*25*/*/bin/javac"))
if not homes:
raise SystemExit("JDK 25 not found in Gradle toolchains")
javac = homes[0]
java = javac.with_name("java")
cache = Path.home() / ".gradle/caches/modules-2/files-2.1"
asm = next((cache / "org.ow2.asm/asm/9.11").rglob("asm-*.jar"))
mixin = next((cache / "net.fabricmc/sponge-mixin").rglob("sponge-mixin-*.jar"))
production = ROOT / "ports/mc263/build/classes/java/main"
mods = Path.home() / ".local/share/PrismLauncher/instances/Dev 26.3/minecraft/mods"
forks = {"Reborn": next(mods.glob("immersive-portals-reborn*.jar*")),
"Seamless": next(mods.glob("seamlessportals*.jar"))}
with tempfile.TemporaryDirectory(prefix="rivencraft-client118-") as temporary:
work = Path(temporary)
classes = work / "classes"
classes.mkdir()
for name in ["client/ImmersivePredictionAcks", "client/ImmersiveSectionRebuilds",
"mixin/ImmersiveBlockAckMixin", "mixin/ImmersiveSectionRebuildMixin", "mixin/ViewAreaSectionAccessor"]:
relative = Path("net/dnorberg/rivencraft") / (name + ".class")
dest = classes / relative
dest.parent.mkdir(parents=True, exist_ok=True)
shutil.copy2(production / relative, dest)
sources = []
for name, body in STUBS.items():
package, _, simple = name.rpartition(".")
source = work / Path(name.replace(".", "/") + ".java")
source.parent.mkdir(parents=True, exist_ok=True)
source.write_text("package " + package + ";\n" + body + "\n")
sources.append(source)
for name, body in [("ExtractForkAck", EXTRACT), ("Client118Checks", CHECKS)]:
source = work / (name + ".java")
source.write_text(body)
sources.append(source)
classpath = ":".join(map(str, [classes, asm, mixin]))
subprocess.run([str(javac), "-proc:none", "-cp", classpath, "-d", str(classes), *map(str, sources)], check=True)
for name, jar in forks.items():
subprocess.run([str(java), "-cp", classpath, "ExtractForkAck", str(jar),
"ForkAck" + name, str(classes / ("ForkAck" + name + ".class"))], check=True)
result = subprocess.run([str(java), "-cp", classpath, "Client118Checks"], check=True, capture_output=True, text=True)
output = ROOT / "build/verification/issue118/guards.txt"
output.write_text(result.stdout)
print(result.stdout.strip())
print("No client/server/GPU/world started. Minecraft runtime types were isolated stubs; production guard bytecode and fork redirect bytecode were exercised.")
if __name__ == "__main__":
main()
+67
View File
@@ -0,0 +1,67 @@
#!/usr/bin/env python3
"""Check Native fluid settings/codecs and the real vanilla fluid picker; no chunk generation."""
import argparse
import subprocess
import tempfile
from pathlib import Path
from server_test_lock import server_test_lock
from smoke_server import stop
ROOT = Path(__file__).resolve().parents[1]
def run(target, biome_mods=False):
log = ROOT / f"build/verification/native119/{target}-{'bop' if biome_mods else 'vanilla'}.log"
log.parent.mkdir(parents=True, exist_ok=True)
with server_test_lock(), tempfile.TemporaryDirectory(prefix=f"rivencraft-native119-{target}-") as directory:
work = Path(directory)
init = work / "fixture.gradle"
init.write_text("""
gradle.beforeProject { p ->
p.layout.buildDirectory.set(p.file('""" + str(work / "build") + """'))
p.afterEvaluate {
p.sourceSets.main.java.srcDir(p.file('""" + str(ROOT / "scripts/fixtures/native119" / target) + """'))
}
}
""")
if biome_mods:
game = "1.21.1" if target == "mc1211" else "26.3"
mods = Path.home() / ".local/share/PrismLauncher/instances" / ("Dev " + game) / "minecraft/mods"
jars = [next(mods.glob(pattern)) for pattern in ("BiomesOPlenty*.jar", "TerraBlender*.jar", "GlitchCore*.jar")]
init.write_text(init.read_text() + "\ngradle.projectsEvaluated { gradle.rootProject.dependencies.add('localRuntime', gradle.rootProject.files("
+ ",".join("'" + str(jar) + "'" for jar in jars) + ")) }\n")
server = work / "server"
server.mkdir()
(server / "eula.txt").write_text("eula=true\n")
(server / "server.properties").write_text(
"server-ip=127.0.0.1\nserver-port=0\nonline-mode=false\nwhite-list=false\n"
"level-type=minecraft:flat\nlevel-seed=109\nview-distance=2\nsimulation-distance=2\n"
'generator-settings={"layers":[{"height":1,"block":"minecraft:bedrock"}],"biome":"minecraft:plains"}\n')
process = None
try:
args = [str(ROOT / "gradlew")]
if target == "mc263": args += ["-p", str(ROOT / "ports/mc263")]
args += ["--no-daemon", "-I", str(init), "runServer", f"-PserverRunDir={server}", "--console=plain"]
with log.open("w") as output:
process = subprocess.Popen(args, cwd=ROOT, stdin=subprocess.PIPE, stdout=output,
stderr=subprocess.STDOUT, text=True, start_new_session=True)
try:
process.wait(timeout=60)
except subprocess.TimeoutExpired:
print("HANDOFF: Native fluid probe stalled; stopping without retry. Use docs/NATIVE_FLUIDS.md.")
return 2
text = log.read_text()
if process.returncode or "NATIVE119_PASS" not in text or "NATIVE119_FAIL" in text:
print(text[-8000:])
return 1
print(next(line for line in text.splitlines() if "NATIVE119_PASS" in line))
return 0
finally:
stop(process)
print("Removed temporary test world and isolated fixture outputs. Log:", log)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("target", choices=("mc1211", "mc263"))
parser.add_argument("--biome-mods", action="store_true")
args=parser.parse_args()
raise SystemExit(run(args.target,args.biome_mods))