Add Flooded pages across Minecraft versions and fix 1.21.1 workstations
Build and smoke / changes (push) Waiting to run

This commit is contained in:
dnorberg committed 2026-11-15 22:08:56 -05:00
1 parent 4a59fb5d02
commit 441f2896d7
40 files changed
+1018 -64

No files matched your search

+1 -1
View File
@@ -12,7 +12,7 @@ def affected(paths):
targets.add("mc1211")
if path.startswith("ports/mc263/") and not path.endswith(".md"):
targets.add("mc263")
if path.startswith(("src/main/resources/", "src/generated/", "buildSrc/", "gradle/")) or path in {"gradlew", "gradlew.bat"}:
if path.startswith(("src/main/resources/", "src/generated/", "buildSrc/", "gradle/", "shared/src/main/java/")) or path in {"gradlew", "gradlew.bat"}:
targets.update(("mc1211", "mc263"))
return sorted(targets)
@@ -0,0 +1,101 @@
package net.dnorberg.rivencraft.regression;
import java.util.List;
import com.mojang.serialization.JsonOps;
import net.dnorberg.rivencraft.age.*;
import net.dnorberg.rivencraft.writing.*;
import net.dnorberg.rivencraft.item.PageItem;
import net.dnorberg.rivencraft.shared.FloodingRules;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Holder;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.Identifier;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.LevelHeightAccessor;
import net.minecraft.world.level.biome.Biomes;
import net.minecraft.world.level.biome.FixedBiomeSource;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.chunk.*;
import net.minecraft.world.level.levelgen.flat.FlatLevelGeneratorSettings;
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.neoforge.event.server.ServerStartedEvent;
/** Isolated fixture: never part of the production source set or JAR. */
@EventBusSubscriber(modid = "rivencraft")
public final class FloodedProbe {
private static int checks;
private static Identifier id(String path) { return Identifier.fromNamespaceAndPath("rivencraft", path); }
private static void check(boolean pass, String label) {
if (!pass) throw new AssertionError(label);
checks++;
}
@SubscribeEvent public static void start(ServerStartedEvent event) {
event.getServer().execute(() -> {
try {
run(event.getServer());
System.out.println("FLOODED263_PASS checks=" + checks);
} catch (Throwable error) {
System.out.println("FLOODED263_FAIL " + error);
error.printStackTrace();
} finally { event.getServer().halt(false); }
});
}
private static void run(MinecraftServer server) throws Exception {
var pages = List.of(id("terrain/cave"), id("biome/lush_caves"), id("biome/single"),
id("number/2"), id("number/24"), PortFlooding.PAGE);
check(PortAuthoredWriting.supports(pages), "Cave + Flooded writing supported");
check(PortFlooding.requested(pages) == 74, "2,24 means Y=74");
check(PortFlooding.requested(List.of(PortFlooding.PAGE)) == 63, "default");
check(PortFlooding.requested(List.of(id("number/4"), PortFlooding.PAGE, PortFlooding.PAGE)) == 63,
"last unnumbered instruction resets");
check(PortFlooding.requested(List.of()) == FloodingRules.NONE, "opt-in");
check(PortWritingRecovery.recover(pages).diagnostics().stream().noneMatch(d ->
d.code().equals("dangling_modifier") || d.code().equals("misplaced_modifier")), "digit grammar");
check(PortAuthoredWriting.isPageImplemented(PortFlooding.PAGE), "page supported");
check(PortSymbolPages.pages("rivencraft:environment", server.registryAccess()).stream().anyMatch(stack ->
PageItem.content(stack).symbol().map(ref -> ref.id().equals(PortFlooding.PAGE)).orElse(false)),
"Creative/JEI feed");
var chunk = new ProtoChunk(new ChunkPos(0, 0), UpgradeData.EMPTY,
LevelHeightAccessor.create(-64, 256), PalettedContainerFactory.create(server.registryAccess()), null);
chunk.setBlockState(new BlockPos(2, 10, 2), Blocks.DIAMOND_BLOCK.defaultBlockState());
chunk.setBlockState(new BlockPos(2, 90, 2), Blocks.STONE.defaultBlockState());
chunk.setBlockState(new BlockPos(3, 60, 3), Blocks.WATER.defaultBlockState());
chunk.setBlockState(new BlockPos(4, 60, 4), Blocks.OAK_FENCE.defaultBlockState()
.setValue(BlockStateProperties.WATERLOGGED, true));
PortFlooding.apply(chunk, FloodingRules.NONE);
check(chunk.getBlockState(new BlockPos(1, 24, 1)).isAir(), "dry unchanged");
PortFlooding.apply(chunk, 24);
check(chunk.getBlockState(new BlockPos(1, 24, 1)).is(Blocks.WATER), "low water");
check(chunk.getBlockState(new BlockPos(1, 25, 1)).isAir(), "low upper bound");
check(chunk.getBlockState(new BlockPos(3, 60, 3)).isAir(), "drain higher water");
check(!chunk.getBlockState(new BlockPos(4, 60, 4)).getValue(BlockStateProperties.WATERLOGGED), "dry fence");
PortFlooding.apply(chunk, 74);
check(chunk.getBlockState(new BlockPos(1, 74, 1)).is(Blocks.WATER), "high water");
check(chunk.getBlockState(new BlockPos(1, 75, 1)).isAir(), "high upper bound");
check(chunk.getBlockState(new BlockPos(2, 10, 2)).is(Blocks.DIAMOND_BLOCK)
&& chunk.getBlockState(new BlockPos(2, 90, 2)).is(Blocks.STONE), "features/roof preserved");
var biomes = server.registryAccess().lookupOrThrow(Registries.BIOME);
var settings = FlatLevelGeneratorSettings.getDefault(biomes,
server.registryAccess().lookupOrThrow(Registries.STRUCTURE_SET),
server.registryAccess().lookupOrThrow(Registries.PLACED_FEATURE));
var base = new PortFlatChunkGenerator(new FixedBiomeSource(biomes.getOrThrow(Biomes.DESERT)), settings);
var generator = new PortFeatureChunkGenerator(base, null, null, 0, null, null, 107L, false, pages);
var ops = server.registryAccess().createSerializationContext(JsonOps.INSTANCE);
var encoded = PortFeatureChunkGenerator.CODEC.codec().encodeStart(ops, generator).getOrThrow();
var restored = PortFeatureChunkGenerator.CODEC.codec().parse(ops, encoded).getOrThrow();
check(restored.floodSurface() == 74, "codec water level");
check(restored.getBiomeSource().possibleBiomes().stream().allMatch(b -> b.is(Biomes.DESERT)),
"non-cave authored biome");
var method = RuntimeAgeBackend.class.getDeclaredMethod("dryCaveSettings", MinecraftServer.class);
method.setAccessible(true);
var dry = (NoiseGeneratorSettings) ((Holder<?>) method.invoke(null, server)).value();
check(dry.defaultFluid().isAir() && dry.aquifers().isEmpty() && dry.seaLevel() < dry.noiseSettings().minY(),
"dry Cave default");
check(FloodingRules.surface(Integer.MAX_VALUE, -64, 320) == 315, "water clamp");
check(FloodingRules.platformFloor(Integer.MAX_VALUE, -64, 320) + 1 == 317, "safe fallback height");
}
}
+58
View File
@@ -0,0 +1,58 @@
#!/usr/bin/env python3
"""Focused Flooded checks in one disposable 26.3 server; fixtures never ship."""
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():
logs = ROOT / "build/verification/flood107"
logs.mkdir(parents=True, exist_ok=True)
log = logs / "mc263.log"
with server_test_lock(), tempfile.TemporaryDirectory(prefix="rivencraft-flood263-") 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/flood263") + """'))
}
}
""")
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=107\nview-distance=2\nsimulation-distance=2\n"
'generator-settings={"layers":[{"height":1,"block":"minecraft:bedrock"}],"biome":"minecraft:plains"}\n')
process = None
try:
with log.open("w") as output:
process = subprocess.Popen([str(ROOT / "gradlew"), "-p", str(ROOT / "ports/mc263"),
"--no-daemon", "-I", str(init), "runServer", f"-PserverRunDir={server}", "--console=plain"],
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: Flooded probe stalled; stopping without retry. Use docs/FLOODED_PAGES.md.")
return 2
text = log.read_text()
if process.returncode or "FLOODED263_PASS" not in text or "FLOODED263_FAIL" in text:
print(text[-10000:])
return 1
print(next(line for line in text.splitlines() if "FLOODED263_PASS" in line))
return 0
finally:
stop(process)
print("Removing temporary server world, fixture configuration and isolated outputs. Log:", log)
if __name__ == "__main__":
raise SystemExit(run())
+1
View File
@@ -16,6 +16,7 @@ class WorkflowChecks(unittest.TestCase):
self.assertEqual(affected(["src/main/java/net/dnorberg/rivencraft/Rivencraft.java"]), ["mc1211"])
self.assertEqual(affected(["ports/mc263/src/main/java/Example.java"]), ["mc263"])
self.assertEqual(affected(["src/main/resources/assets/rivencraft/sounds.json"]), ["mc1211", "mc263"])
self.assertEqual(affected(["shared/src/main/java/Rules.java"]), ["mc1211", "mc263"])
self.assertEqual(affected(["README.md", "scripts/publish_mod_sites.py"]), [])
def test_release_identity_rejects_mislabeled_channels(self):