Public Access
Add Flooded pages across Minecraft versions and fix 1.21.1 workstations
Build and smoke / changes (push) Waiting to run
Build and smoke / changes (push) Waiting to run
This commit is contained in:
1 parent
4a59fb5d02
commit
441f2896d7
40 files changed
+1018
-64
No files matched your search
@@ -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");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user