Public Access
Add native biome families, desert vegetation, static sky controls and Seamless views
Build and smoke / changes (push) Waiting to run
Build and smoke / changes (push) Waiting to run
This commit is contained in:
1 parent
90e4a98a7a
commit
d199ac253e
92 files changed
+2520
-224
No files matched your search
+70
@@ -0,0 +1,70 @@
|
||||
package net.dnorberg.rivencraft.regression;
|
||||
import java.util.List;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.common.EventBusSubscriber;
|
||||
import net.neoforged.neoforge.event.server.ServerStartedEvent;
|
||||
import net.dnorberg.rivencraft.book.*;
|
||||
import net.dnorberg.rivencraft.writing.*;
|
||||
import net.dnorberg.rivencraft.network.AgeCelestialAnglePayload;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
@EventBusSubscriber(modid="rivencraft")
|
||||
public class StaticSkyProbe {
|
||||
static int checks;
|
||||
static void check(boolean condition,String label) {
|
||||
if(!condition) throw new AssertionError(label);
|
||||
checks++;
|
||||
}
|
||||
@SubscribeEvent public static void start(ServerStartedEvent event) {
|
||||
event.getServer().execute(() -> {
|
||||
try {
|
||||
run(event.getServer());
|
||||
System.out.println("STATIC109_PASS checks="+checks);
|
||||
}catch(Throwable error) {
|
||||
System.out.println("STATIC109_FAIL "+error);
|
||||
error.printStackTrace();
|
||||
}finally { event.getServer().halt(false); }
|
||||
});
|
||||
}
|
||||
static WritingEntry page(String id) {
|
||||
return WritingEntry.symbol(new SymbolReference(ResourceLocation.fromNamespaceAndPath("rivencraft",id)));
|
||||
}
|
||||
static AgeGenerationPlan plan(net.minecraft.server.MinecraftServer server,String... ids) {
|
||||
var entries=new java.util.ArrayList<WritingEntry>();
|
||||
entries.add(WritingEntry.linkPanel());
|
||||
for(var id:ids) entries.add(page(id));
|
||||
return AgeGenerationPlan.compile(new OrderedWriting(entries),109L,
|
||||
AgeGenerationProfiles.STANDARD,AgeTraits.select(109L),server.registryAccess());
|
||||
}
|
||||
static void run(net.minecraft.server.MinecraftServer server) {
|
||||
String[][] pages={{"sky/static"},{"number/0","sky/static"},{"number/8","sky/static"},
|
||||
{"number/1","number/23","sky/static"},{"number/5","number/3","sky/static"},
|
||||
{"number/24","number/24","sky/static"}};
|
||||
int[] expected={48,1,8,48,128,128};
|
||||
for(int i=0;i<pages.length;i++) {
|
||||
var plan=plan(server,pages[i]);
|
||||
check(plan.writingInstability()==0,"No number/order penalty");
|
||||
var sky=AgeSkyProfile.compile(plan,AgeTraits.select(109L));
|
||||
check(sky.staticResolution()==expected[i],"Resolution");
|
||||
var loaded=AgeGenerationPlan.load(plan.save());
|
||||
check(AgeSkyProfile.compile(loaded,AgeTraits.select(109L)).equals(sky),"Frozen plan persistence");
|
||||
var buffer=new RegistryFriendlyByteBuf(Unpooled.buffer(),server.registryAccess());
|
||||
try {
|
||||
var packet=new AgeCelestialAnglePayload(net.minecraft.world.level.Level.OVERWORLD,0F,sky);
|
||||
AgeCelestialAnglePayload.STREAM_CODEC.encode(buffer,packet);
|
||||
check(AgeCelestialAnglePayload.STREAM_CODEC.decode(buffer).equals(packet),"Network round trip");
|
||||
check(buffer.readableBytes()==0,"No unread bytes");
|
||||
}finally { buffer.release(); }
|
||||
}
|
||||
var color=plan(server,"number/10","color/red","number/8","sky/static");
|
||||
var sky=AgeSkyProfile.compile(color,AgeTraits.select(109L));
|
||||
check(sky.color()==0x640000 && sky.staticResolution()==8,"Independent color and resolution");
|
||||
check(AgeSkyProfile.compile(plan(server,"sky/overworld"),AgeTraits.select(109L)).staticResolution()==48,
|
||||
"Non-static default");
|
||||
var misplaced=plan(server,"number/8","color/red","sky/static");
|
||||
check(AgeSkyProfile.compile(misplaced,AgeTraits.select(109L)).staticResolution()==48,"Adjacent only");
|
||||
var flood=plan(server,"number/2","number/24","environment/flooded");
|
||||
check(AgeFlooding.requested(flood)==74 && flood.writingInstability()==0,"Flooded digit grammar unchanged");
|
||||
}
|
||||
}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
package net.dnorberg.rivencraft.regression;
|
||||
import java.util.List;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.common.EventBusSubscriber;
|
||||
import net.neoforged.neoforge.event.server.ServerStartedEvent;
|
||||
import net.dnorberg.rivencraft.age.*;
|
||||
import net.dnorberg.rivencraft.writing.PortWritingRecovery;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import com.mojang.serialization.JsonOps;
|
||||
import com.google.gson.JsonParser;
|
||||
@EventBusSubscriber(modid="rivencraft")
|
||||
public class StaticSkyProbe {
|
||||
static int checks;
|
||||
static void check(boolean condition,String label) {
|
||||
if(!condition) throw new AssertionError(label);
|
||||
checks++;
|
||||
}
|
||||
@SubscribeEvent public static void start(ServerStartedEvent event) {
|
||||
event.getServer().execute(() -> {
|
||||
try {
|
||||
run(event.getServer());
|
||||
System.out.println("STATIC109_PASS checks="+checks);
|
||||
}catch(Throwable error) {
|
||||
System.out.println("STATIC109_FAIL "+error);
|
||||
error.printStackTrace();
|
||||
}finally { event.getServer().halt(false); }
|
||||
});
|
||||
}
|
||||
static List<Identifier> pages(String... paths) {
|
||||
return java.util.Arrays.stream(paths).map(s->Identifier.fromNamespaceAndPath("rivencraft",s)).toList();
|
||||
}
|
||||
static void run(net.minecraft.server.MinecraftServer server) {
|
||||
String[][] cases={{"sky/static"},{"number/0","sky/static"},{"number/8","sky/static"},
|
||||
{"number/1","number/23","sky/static"},{"number/5","number/3","sky/static"},
|
||||
{"number/24","number/24","sky/static"}};
|
||||
int[] expected={48,1,8,48,128,128};
|
||||
for(int i=0;i<cases.length;i++) {
|
||||
var writing=pages(cases[i]);
|
||||
check(PortWritingRecovery.recover(writing).diagnostics().isEmpty(),"No number/order penalty");
|
||||
check(PortAgeColors.validNumbers(writing),"Numeric writing valid");
|
||||
var colors=PortAgeColors.compile(writing,109L);
|
||||
check(colors.staticResolution()==expected[i],"Resolution");
|
||||
var saved=PortAgeColors.CODEC.encodeStart(JsonOps.INSTANCE,colors).getOrThrow();
|
||||
check(PortAgeColors.CODEC.parse(JsonOps.INSTANCE,saved).getOrThrow().equals(colors),"Saved codec");
|
||||
var buffer=new RegistryFriendlyByteBuf(Unpooled.buffer(),server.registryAccess());
|
||||
try {
|
||||
var id=Identifier.parse("rivencraft:age/static_probe");
|
||||
var packet=new AgeCatalogPayload(109,List.of(id),java.util.Map.of(id,colors),
|
||||
java.util.Map.of(),java.util.Map.of());
|
||||
AgeCatalogPayload.STREAM_CODEC.encode(buffer,packet);
|
||||
check(AgeCatalogPayload.STREAM_CODEC.decode(buffer).equals(packet),"Full catalog round trip");
|
||||
check(buffer.readableBytes()==0,"No unread bytes");
|
||||
}finally { buffer.release(); }
|
||||
}
|
||||
var old=PortAgeColors.CODEC.parse(JsonOps.INSTANCE,JsonParser.parseString(
|
||||
"{\"sky\":-1,\"ambient\":-1}")).getOrThrow();
|
||||
check(old.staticResolution()==48 && old.equals(PortAgeColors.NATIVE),"Old save default");
|
||||
var color=PortAgeColors.compile(pages("number/10","color/red","number/8","sky/static"),109L);
|
||||
check(color.sky()==0x640000 && color.staticResolution()==8,"Independent color");
|
||||
check(PortAgeColors.compile(pages("number/8","color/red","sky/static"),109L).staticResolution()==48,
|
||||
"Adjacent only");
|
||||
check(PortAgeColors.compile(pages("sky/overworld"),109L).staticResolution()==48,"Non-static default");
|
||||
var flood=pages("number/2","number/24","environment/flooded");
|
||||
check(PortFlooding.requested(flood)==74 && PortWritingRecovery.recover(flood).diagnostics().isEmpty(),
|
||||
"Flooded grammar unchanged");
|
||||
check(!PortWritingRecovery.recover(pages("number/8","sky/overworld")).diagnostics().isEmpty(),
|
||||
"Other sky does not consume number");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user