diff --git a/README.md b/README.md index a85cc8d..8de1352 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,15 @@ Terrain-aware procedural castles and independent culture regions for Minecraft. Original idea: Emre's brother. Concept and project direction: Emre (`badmon61`). -## Status: 0.2.0-alpha.1 — opt-in terraced architecture +## Status: 0.2.1-alpha.1 — identity and architectural diagnostics + +**New in 0.2.1:** Seed-stable, culture-dependent castle names and regional dynasties, symbolic heraldry, age, chronological construction milestones, and a condition-derived *planned* occupancy category. These are narrative metadata only: **no NPCs, loot, actual banners or timeline simulation are spawned**. The two existing castle shapes and culture map remain unchanged. Different regions may coincidentally share generated names; uniqueness is not promised. + +The terraced preview now includes a quick dimensional/material/access summary. Use `/castleforge inspect` after `/castleforge preview terraced` (or classic preview) to read the current design report. Preview and inspect are read-only. Reports expire with the preview (120 seconds), and are cleared by build confirmation. + +Small visible facade improvement: culture-sensitive accent blocks for trim and timber. This changes palette appearance, **not** the geometry generator, region borders or world settings. Refer to [identity and diagnostic contract](docs/IDENTITY_AND_DIAGNOSTICS.md). + +## Previously: 0.2.0-alpha.1 — opt-in terraced architecture **Disposable test worlds only. No automatic world generation and no completed in-game acceptance test.** @@ -32,13 +40,14 @@ Automatic exploration-time generation; automatically measured biome scaling; arb Target remains **Minecraft Java 26.1.2**, **Java 25**, **Fabric Loader 0.19.5+**, **Fabric API 0.155.3+26.1.2**. 1. Use a separate Prism/Fabric instance and a new disposable Creative world with commands enabled. -2. Install `castleforge-fabric-0.2.0-alpha.1.jar` from a successful branch Actions build plus the matching Fabric API. Replace the old CastleForge JAR; do not install two versions or a `-sources.jar`. +2. Install `castleforge-fabric-0.2.1-alpha.1.jar` from a successful branch Actions build plus the matching Fabric API. Replace the old CastleForge JAR; do not install two versions or a `-sources.jar`. 3. Start on superflat to verify the build workflow, then test a second disposable world with open, gradual slopes. The new survey is 105 × 105 blocks; the whole site must already be loaded. 4. Execute separately: ```mcfunction /castleforge region /castleforge preview terraced +/castleforge inspect /castleforge build confirm /castleforge status ``` @@ -75,7 +84,7 @@ The CI uses pinned Gradle; a Gradle wrapper is not yet checked in. Pure generato bash scripts/verify-core.sh ``` -The classic suite checks 50 seeds. The new suite checks **32 seeds × 5 synthetic terrains = 160 combinations**, all eight culture profiles, all four rotations, roofs and condition states, determinism, navigation, bounded supports, rejection cases, negative/world-edge coordinates and concurrent planning. A golden geometry digest detects unintended generator drift. Repeated per-voxel assertions are not millions of different test scenarios. +The classic suite checks 50 seeds. A third suite checks narrative identities across 100 seeds and eight cultures, coherent chronology, region-level dynasties, diagnostic counts and reporting. The new suite checks **32 seeds × 5 synthetic terrains = 160 combinations**, all eight culture profiles, all four rotations, roofs and condition states, determinism, navigation, bounded supports, rejection cases, negative/world-edge coordinates and concurrent planning. A golden geometry digest detects unintended generator drift. Repeated per-voxel assertions are not millions of different test scenarios. Passing these checks is **not a Minecraft launch, entity-pathfinding, block-physics or visual test**. See [terraced architecture and acceptance checklist](docs/TERRACED_ARCHITECTURE.md), [original architecture](docs/ARCHITECTURE.md), [classic test checklist](docs/TESTING.md), [initial alpha validation](docs/VALIDATION.md), and [long-term roadmap](docs/ROADMAP.md). diff --git a/build.gradle b/build.gradle index a96dda7..76d59af 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ plugins { } allprojects { group = 'dev.castleforge' - version = '0.2.0-alpha.1' + version = '0.2.1-alpha.1' repositories { mavenCentral() } } tasks.named('build') { dependsOn ':core:build', ':fabric:build' } diff --git a/core/build.gradle b/core/build.gradle index 9689425..057dcca 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -16,4 +16,11 @@ tasks.register('verifyTerraces', JavaExec) { maxHeapSize = '512m' mustRunAfter verifyCore } -tasks.named('check') { dependsOn verifyCore, verifyTerraces } +tasks.register('verifyIdentity', JavaExec) { + dependsOn testClasses + classpath = sourceSets.test.runtimeClasspath + mainClass = 'dev.castleforge.core.IdentityVerification' + maxHeapSize = '512m' + mustRunAfter verifyTerraces +} +tasks.named('check') { dependsOn verifyCore, verifyTerraces, verifyIdentity } diff --git a/core/src/main/java/dev/castleforge/core/CastleIdentity.java b/core/src/main/java/dev/castleforge/core/CastleIdentity.java new file mode 100644 index 0000000..5e4ae0f --- /dev/null +++ b/core/src/main/java/dev/castleforge/core/CastleIdentity.java @@ -0,0 +1,79 @@ +package dev.castleforge.core; + +import java.util.*; +import static dev.castleforge.core.CastlePlanner.Condition; + +/** + * Versioned narrative identity for a hypothetical castle site. + * Pure data: it neither spawns inhabitants nor edits, loads or samples terrain. + * Names are project-authored syllable combinations, not imported schematics. + */ +public final class CastleIdentity { + public static final int VERSION = 1; + public enum Occupancy { INHABITED, SPARSE, ABANDONED } + public record Event(int yearsAgo, String key, String description) {} + public record Identity(String name, String dynasty, String heraldry, String culture, + String cultureRegionId, int ageYears, Condition condition, + Occupancy expectedOccupancy, List events) { + public Identity { events = List.copyOf(events); } + public String oneLine() { + return name + " / " + dynasty + " / " + ageYears + " years / " + condition + + " / planned population: " + expectedOccupancy; + } + } + private record Names(String title, String housePrefix, String[] roots, String[] suffixes) {} + private static Names names(String style) { + return switch (style) { + case "nordic" -> new Names("Hold", "Clan", new String[]{"Frost","Storm","Raven","Skald","Winter","Iron"}, new String[]{"holm","gard","fjell","vik","heim","havn"}); + case "mediterranean" -> new Names("Castello", "House", new String[]{"Monte","Vela","Rosa","Luna","Bel","Porto"}, new String[]{"vento","mar","fiore","castro","verde","alto"}); + case "desert_citadel" -> new Names("Citadel", "House", new String[]{"Qasr","Sahar","Nur","Rimal","Zafir","Miraj"}, new String[]{"ara","edin","amir","sahir","nura","zan"}); + case "east_asian" -> new Names("Fortress", "House", new String[]{"Kiri","Hoshi","Mizu","Kaze","Taka","Yama"}, new String[]{"yama","kawa","mori","shima","sora","tani"}); + case "gothic" -> new Names("Bastion", "House", new String[]{"Schatten","Nebel","Raben","Nacht","Dorn","Aschen"}, new String[]{"fels","wacht","turm","krone","stein","hain"}); + case "high_fantasy" -> new Names("Spire", "House", new String[]{"Aether","Elden","Lumi","Valen","Caeli","Solis"}, new String[]{"dorn","spire","myr","thal","ria","wyn"}); + case "maritime" -> new Names("Fort", "House", new String[]{"Sturm","Wellen","Tiden","Wind","Salz","Falken"}, new String[]{"klippe","hafen","wacht","fels","werft","holm"}); + default -> new Names("Castle", "House", new String[]{"Falken","Hohen","Eichen","Greifen","Rosen","Silber"}, new String[]{"fels","wacht","burg","stein","hain","krone"}); + }; + } + private static final String[] HERALDRY = { + "silver falcon on blue", "golden sun on black", "white stag on green", "red tower on ivory", + "black raven on silver", "golden lion on crimson", "three stars on purple", "silver wave on teal" + }; + private static int pick(long value, int size) { return Math.floorMod(value, size); } + + public static Identity generate(long worldSeed, int x, int z, CultureMap.Region region, Condition condition) { + Objects.requireNonNull(region, "region"); + Objects.requireNonNull(condition, "condition"); + Names n = names(region.style()); + long site = CultureMap.hash(worldSeed ^ 0x434153544c454944L, x, z); + long kingdom = CultureMap.mix(worldSeed ^ 0x4b494e47444f4d31L ^ CultureMap.mix(region.id().hashCode())); + String name = n.title + " " + n.roots[pick(site,n.roots.length)] + + n.suffixes[pick(CultureMap.mix(site^17L),n.suffixes.length)]; + String dynasty = n.housePrefix + " " + n.roots[pick(kingdom,n.roots.length)] + + n.suffixes[pick(CultureMap.mix(kingdom^19L),n.suffixes.length)]; + String heraldry = HERALDRY[pick(CultureMap.mix(kingdom^23L),HERALDRY.length)]; + int age = 120 + pick(CultureMap.mix(site^29L),681); + Occupancy occupancy = switch(condition) { + case RESTORED -> Occupancy.INHABITED; + case WEATHERED -> Occupancy.SPARSE; + case RUINED -> Occupancy.ABANDONED; + }; + List events = new ArrayList<>(); + events.add(new Event(age, "founded", "A fortified watchpost was established.")); + int extension = age * (47 + pick(CultureMap.mix(site^31L),16)) / 100; + events.add(new Event(extension, "expanded", "The garrison was enlarged with halls and additional defenses.")); + if (condition == Condition.RESTORED) { + events.add(new Event(Math.max(5, age/9), "restored", "Recent repairs renewed the roofs, gate and inhabited quarters.")); + } else if (condition == Condition.WEATHERED) { + events.add(new Event(Math.max(10, age/7), "decline", "The household dwindled and maintenance gradually ceased.")); + } else { + int siege = Math.max(25, age/4); + events.add(new Event(siege, "siege", "An old siege damaged the defenses and several residential wings.")); + events.add(new Event(Math.max(2, siege/4), "abandoned", "The remaining residents finally left the fortress.")); + } + for (int i=1;i= events.get(i-1).yearsAgo()) + throw new IllegalStateException("History chronology invalid"); + return new Identity(name, dynasty, heraldry, region.style(), region.id(), age, condition, occupancy, events); + } + private CastleIdentity() {} +} diff --git a/core/src/main/java/dev/castleforge/core/PlanDiagnostics.java b/core/src/main/java/dev/castleforge/core/PlanDiagnostics.java new file mode 100644 index 0000000..23b8557 --- /dev/null +++ b/core/src/main/java/dev/castleforge/core/PlanDiagnostics.java @@ -0,0 +1,49 @@ +package dev.castleforge.core; + +import java.util.*; +import static dev.castleforge.core.TerracedCastlePlanner.*; + +/** Bounded, immutable summary for operator previews and architecture regression checks. */ +public final class PlanDiagnostics { + public record Report(int width, int length, int height, int surveyedCells, + int plannedCells, int solids, int emptyCells, int foundationCells, + int weatheredCells, int stairs, int bridges, int modules, + int storeys, int navigationTargets, int terraceRelief) { + public String compact() { + return width + "x" + length + "x" + height + " blocks; " + + modules + " buildings / " + storeys + " floors; " + + bridges + " bridge links; " + stairs + " stairs; " + + navigationTargets + " walkable targets; " + + foundationCells + " foundation blocks"; + } + } + public static Report analyze(Plan plan) { + Objects.requireNonNull(plan); + int minX=Integer.MAX_VALUE,minY=Integer.MAX_VALUE,minZ=Integer.MAX_VALUE; + int maxX=Integer.MIN_VALUE,maxY=Integer.MIN_VALUE,maxZ=Integer.MIN_VALUE; + int air=0, foundations=0, weathered=0, stairs=0; + Set coordinates = new HashSet<>(); + for (Block b : plan.blocks()) { + var p=b.pos(); + if(!coordinates.add(p)) throw new IllegalArgumentException("Duplicate architecture position"); + minX=Math.min(minX,p.x()); maxX=Math.max(maxX,p.x()); + minY=Math.min(minY,p.y()); maxY=Math.max(maxY,p.y()); + minZ=Math.min(minZ,p.z()); maxZ=Math.max(maxZ,p.z()); + switch (b.kind()) { + case AIR -> air++; + case FOUNDATION -> foundations++; + case WEATHERED -> weathered++; + case STAIR, ROOF_STAIR -> stairs++; + default -> {} + } + } + if (coordinates.isEmpty()) throw new IllegalArgumentException("No building geometry"); + int storeys=plan.rooms().stream().mapToInt(Room::storeys).sum(); + int bridges=(int)plan.links().stream().filter(Link::bridge).count(); + return new Report(maxX-minX+1,maxZ-minZ+1,maxY-minY+1, + (2*TerracedCastlePlanner.RADIUS+1)*(2*TerracedCastlePlanner.RADIUS+1), + plan.blocks().size(),plan.blocks().size()-air,air,foundations,weathered, + stairs,bridges,plan.rooms().size(),storeys,plan.targets().size(),plan.relief()); + } + private PlanDiagnostics() {} +} diff --git a/core/src/test/java/dev/castleforge/core/IdentityVerification.java b/core/src/test/java/dev/castleforge/core/IdentityVerification.java new file mode 100644 index 0000000..f88b085 --- /dev/null +++ b/core/src/test/java/dev/castleforge/core/IdentityVerification.java @@ -0,0 +1,59 @@ +package dev.castleforge.core; + +import java.util.*; +import static dev.castleforge.core.CastlePlanner.Condition; + +/** Independent identity/telemetry checks; pure Java 21, no Minecraft runtime. */ +public final class IdentityVerification { + private static int assertions; + private static void check(boolean pass, String text) { + assertions++; + if(!pass) throw new AssertionError(text); + } + public static void main(String[] args) { + String[] styles={"central_european","nordic","mediterranean","desert_citadel","east_asian", + "gothic","high_fantasy","maritime"}; + Set names=new HashSet<>(), emblems=new HashSet<>(), dynasties=new HashSet<>(); + for(int seed=0;seed<100;seed++) for(String style:styles) { + var region=new CultureMap.Region("kingdom-"+seed+"-"+style,style,style,0,0,0,7168); + for(Condition condition:Condition.values()) { + var a=CastleIdentity.generate(seed,seed*100,-seed*37,region,condition); + var b=CastleIdentity.generate(seed,seed*100,-seed*37,region,condition); + check(a.equals(b),"stable site identity"); + check(a.ageYears()>=120 && a.ageYears()<=800,"plausible age range"); + check(a.events().size()>=3,"historical milestones"); + check(a.events().getFirst().yearsAgo()==a.ageYears(),"foundation starts chronology"); + for(int i=1;i7,"name produced"); + check(a.culture().equals(style),"original culture retained"); + check(a.expectedOccupancy()==switch(condition) { + case RESTORED -> CastleIdentity.Occupancy.INHABITED; + case WEATHERED -> CastleIdentity.Occupancy.SPARSE; + case RUINED -> CastleIdentity.Occupancy.ABANDONED; + }, "intended population follows maintenance"); + names.add(a.name()); dynasties.add(a.dynasty()); emblems.add(a.heraldry()); + } + var a=CastleIdentity.generate(seed,0,0,region,Condition.RESTORED); + var b=CastleIdentity.generate(seed,10000,5000,region,Condition.RUINED); + check(a.dynasty().equals(b.dynasty()) && a.heraldry().equals(b.heraldry()), + "same region shares lineage across castle sites"); + } + check(names.size()>120,"names differ across culture and seed"); + check(dynasties.size()>40,"kingdoms get distinct dynasties"); + check(emblems.size()==8,"all heraldic combinations represented"); + var region=new CultureMap.Region("special","gothic","nordic",0,0,0,7168); + check(!CastleIdentity.generate(1,0,0,region,Condition.RUINED) + .equals(CastleIdentity.generate(2,0,0,region,Condition.RUINED)),"seed changes identity"); + var plan=TerracedCastlePlanner.plan(42,0,0,(x,z)->64,region); + var report=PlanDiagnostics.analyze(plan); + check(report.width()>=35 && report.width()<=105 && report.length()>=70 && report.height()>=18, "bounded elongated multi-court layout"); + check(report.modules()==8 && report.navigationTargets()==plan.targets().size(),"module/target counts"); + check(report.plannedCells()==report.solids()+report.emptyCells(),"every voxel classified"); + check(report.storeys()>=13 && report.foundationCells()>=0,"room floors tracked"); + check(report.terraceRelief()==plan.relief(),"terrace relief unchanged"); + check(report.compact().contains("bridge links"),"plain text debug report"); + System.out.println("PASS identity/diagnostics: "+assertions+" assertions across 100 seeds and 8 cultures."); + } + private IdentityVerification() {} +} diff --git a/docs/IDENTITY_AND_DIAGNOSTICS.md b/docs/IDENTITY_AND_DIAGNOSTICS.md new file mode 100644 index 0000000..0b6b6ab --- /dev/null +++ b/docs/IDENTITY_AND_DIAGNOSTICS.md @@ -0,0 +1,28 @@ +# Castle identities and architectural reports (0.2.1 alpha) + +## What is implemented + +`CastleIdentity.generate(seed, x, z, region, condition)` is a stateless, independent core function: +- Site name and regional dynasty are derived from seed and culture and can be recreated without a save-file database. +- Regional heraldry is a **textual motif**; Minecraft banner/block entities have not been generated. +- Ages range from 120 to 800 fictional years. Construction events are sorted from oldest to newest and depend on restoration status. +- Intended population level is `INHABITED`, `SPARSE`, or `ABANDONED`, but **does not spawn entities**. +- All returned collections are immutable. `CastleIdentity.VERSION = 1` is the metadata algorithm version. It is independent from world geography and geometry versions. + +`PlanDiagnostics.analyze(plan)` counts planned cells, foundation/weathered/stair blocks, module storeys, bridge links and navigation target declarations, plus a 3D bounding box. It reports the *plan* rather than measured FPS, actual height-map validation or proven Minecraft pathfinding. + +The Fabric bridge exposes metadata in the existing preview summary and an additional read-only `/castleforge inspect` command. This command reads the most recent, still-valid preview **for the current operator**. It performs no extra chunk generation or block placement. It cannot inspect already-placed castles or discover existing structures. + +Facades use a culturally more suitable decorative trim and timber block where possible. Existing geometry is unchanged. Material changes only affect future manually placed castles, not existing world blocks. + +## Test and acceptance + +- `gradle --no-daemon build` must run all three core suites and compile the Fabric adapter. +- `bash scripts/verify-core.sh` can verify the pure Java core with JDK 21+. +- Verify the metadata suite covers all eight culture IDs, 100 seeds, three preservation states, chronology, reproducibility, population intentions and dynasty consistency. +- In Minecraft test `/castleforge preview terraced`, then `/castleforge inspect`; confirm no world blocks changed. +- Inspect both classic and terraced plans; compare the preview report to the actual built result. +- Test aged/ruined castles' trim/wood combinations under all cultural palettes and watch for unsupported block states. +- Keep `main` and the previously compiled terraced alpha intact until in-game feedback validates the new build. + +This metadata release intentionally does **not** alter `CultureMap`, `CastlePlanner`, `TerracedCastlePlanner` or `PlanNavigation`. It does not solve large monuments, natural generation, automatic biome measurement or Bedrock. diff --git a/fabric/src/main/java/dev/castleforge/fabric/CastleForge.java b/fabric/src/main/java/dev/castleforge/fabric/CastleForge.java index 38006a6..4f40008 100644 --- a/fabric/src/main/java/dev/castleforge/fabric/CastleForge.java +++ b/fabric/src/main/java/dev/castleforge/fabric/CastleForge.java @@ -3,6 +3,8 @@ import dev.castleforge.core.CastlePlanner; import dev.castleforge.core.CultureMap; import dev.castleforge.core.TerracedCastlePlanner; +import dev.castleforge.core.CastleIdentity; +import dev.castleforge.core.PlanDiagnostics; import com.mojang.brigadier.arguments.IntegerArgumentType; import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; @@ -39,7 +41,7 @@ public final class CastleForge implements ModInitializer { CommandRegistrationCallback.EVENT.register((dispatcher, registry, environment) -> dispatcher.register( Commands.literal("castleforge") .requires(s -> s.permissions().hasPermission(Permissions.COMMANDS_MODERATOR)) - .executes(c -> say(c.getSource(), "CastleForge alpha: /castleforge region | preview [terraced] [x z] | build confirm | status | cancel | undo. TEST WORLDS ONLY.")) + .executes(c -> say(c.getSource(), "CastleForge alpha: /castleforge region | preview [terraced] [x z] | build confirm | inspect | status | cancel | undo. TEST WORLDS ONLY.")) .then(Commands.literal("region").executes(c -> safely(c.getSource(), () -> region(c.getSource())))) .then(Commands.literal("preview") .executes(c -> safely(c.getSource(), () -> preview(c.getSource(), null, null, false))) @@ -55,6 +57,7 @@ public final class CastleForge implements ModInitializer { IntegerArgumentType.getInteger(c,"x"), IntegerArgumentType.getInteger(c,"z"), true))))))) .then(Commands.literal("build").then(Commands.literal("confirm") .executes(c -> safely(c.getSource(), () -> build(c.getSource()))))) + .then(Commands.literal("inspect").executes(c -> safely(c.getSource(), () -> inspect(c.getSource())))) .then(Commands.literal("status").executes(c -> safely(c.getSource(), () -> status(c.getSource())))) .then(Commands.literal("cancel").executes(c -> safely(c.getSource(), () -> cancel(c.getSource())))) .then(Commands.literal("undo").executes(c -> safely(c.getSource(), () -> undo(c.getSource())))) @@ -125,12 +128,18 @@ private int preview(CommandSourceStack source, Integer x, Integer z, boolean ter }; List desired = new ArrayList<>(); String summary; + String details; if (terraced) { var plan = TerracedCastlePlanner.plan(level.getSeed(),ox,oz,ground,region); for (var block : plan.blocks()) { var v = block.pos(); desired.add(new Desired(new BlockPos(v.x(),v.y(),v.z()),palette.resolve(block))); } - summary = "TERRACED v1 / " + plan.condition() + "; " + plan.terraces().size() + " courts, " + var report = PlanDiagnostics.analyze(plan); + var identity = CastleIdentity.generate(level.getSeed(),ox,oz,region,plan.condition()); + details = identity.oneLine() + "; heraldry: " + identity.heraldry() + + "; " + report.compact() + "; oldest milestone: " + + identity.events().getFirst().description(); + summary = identity.name() + " / TERRACED v1 / " + plan.condition() + "; " + plan.terraces().size() + " courts, " + plan.rooms().size() + " modules, " + plan.targets().size() + " verified access targets; terrace relief " + plan.relief() + "; rotation " + (plan.quarterTurns()*90) + " degrees"; } else { @@ -138,7 +147,10 @@ private int preview(CommandSourceStack source, Integer x, Integer z, boolean ter for (var voxel : plan.voxels()) { var v = voxel.pos(); desired.add(new Desired(new BlockPos(v.x(),v.y(),v.z()),palette.resolve(voxel.material()))); } - summary = "CLASSIC / " + plan.condition() + "; relief " + plan.relief(); + var identity = CastleIdentity.generate(level.getSeed(),ox,oz,region,plan.condition()); + details = identity.oneLine() + "; heraldry: " + identity.heraldry() + + "; classic reference plan (no terraced report)."; + summary = identity.name() + " / CLASSIC / " + plan.condition() + "; relief " + plan.relief(); } List edits = new ArrayList<>(); for (Desired cell : desired) { @@ -152,11 +164,19 @@ private int preview(CommandSourceStack source, Integer x, Integer z, boolean ter checks.add(new Check(pos,before)); if (!before.equals(after)) edits.add(new Edit(pos,before,after)); } - s.previews.put(user,new Preview(level,List.copyOf(edits),List.copyOf(checks),System.nanoTime())); + s.previews.put(user,new Preview(level,List.copyOf(edits),List.copyOf(checks),System.nanoTime(),details)); LOGGER.info("CastleForge preview {} at {},{}: {} edits; {}",user,ox,oz,edits.size(),summary); return say(source,"PREVIEW only: " + region.style() + " at " + ox + "," + oz + "; " + summary + "; " + edits.size() + " edits. /castleforge build confirm within 120s. Disposable test world only; back up first."); } + private int inspect(CommandSourceStack source) throws IOException { + Preview p = session(source).previews.get(owner(source)); + if (p == null || System.nanoTime() - p.created > PREVIEW_LIFETIME_NS + || p.level != source.getLevel()) { + throw new IllegalArgumentException("No fresh preview to inspect. Run /castleforge preview first."); + } + return say(source,"CastleForge design report: " + p.details); + } private int build(CommandSourceStack source) throws IOException { Session s = session(source); if (s.job != null && !s.job.finished) throw new IllegalArgumentException("Another job is running."); @@ -215,7 +235,7 @@ private static int safely(CommandSourceStack source, Action action) { private record Desired(BlockPos pos, BlockState state) {} private record Check(BlockPos pos, BlockState expected) {} private record Edit(BlockPos pos, BlockState before, BlockState after) {} - private record Preview(ServerLevel level, List edits, List checks, long created) {} + private record Preview(ServerLevel level, List edits, List checks, long created, String details) {} private static boolean matchesUndo(BlockState actual, BlockState expected) { // Neighbor updates recompute stair shape; never ignore facing, half, material or waterlogging changes. if (expected.getBlock() instanceof StairBlock && actual.is(expected.getBlock())) diff --git a/fabric/src/main/java/dev/castleforge/fabric/Palette.java b/fabric/src/main/java/dev/castleforge/fabric/Palette.java index 224af8e..8d42681 100644 --- a/fabric/src/main/java/dev/castleforge/fabric/Palette.java +++ b/fabric/src/main/java/dev/castleforge/fabric/Palette.java @@ -40,11 +40,12 @@ BlockState resolve(TerracedCastlePlanner.Block block) { Direction facing = Direction.valueOf(block.facing().name()); return switch (block.kind()) { case AIR -> Blocks.AIR.defaultBlockState(); - case FOUNDATION, WALL, TRIM -> masonry.defaultBlockState(); + case FOUNDATION, WALL -> masonry.defaultBlockState(); + case TRIM -> decorativeTrim(masonry).defaultBlockState(); case WEATHERED -> weathered.defaultBlockState(); case FLOOR -> floor.defaultBlockState(); case ROOF -> roof.defaultBlockState(); - case TIMBER -> Blocks.STRIPPED_SPRUCE_LOG.defaultBlockState(); + case TIMBER -> decorativeTimber(floor).defaultBlockState(); case GLASS -> Blocks.GLASS.defaultBlockState(); case LIGHT -> Blocks.GLOWSTONE.defaultBlockState(); case STAIR -> stairs(masonry).defaultBlockState().setValue(StairBlock.FACING, facing); @@ -52,6 +53,20 @@ BlockState resolve(TerracedCastlePlanner.Block block) { case LADDER -> Blocks.LADDER.defaultBlockState().setValue(LadderBlock.FACING, facing); }; } + private static Block decorativeTrim(Block wall) { + if (wall == Blocks.SANDSTONE || wall == Blocks.CUT_SANDSTONE) return Blocks.CHISELED_SANDSTONE; + if (wall == Blocks.COBBLESTONE) return Blocks.POLISHED_ANDESITE; + if (wall == Blocks.DEEPSLATE_BRICKS) return Blocks.POLISHED_DEEPSLATE; + if (wall == Blocks.QUARTZ_BRICKS) return Blocks.QUARTZ_PILLAR; + return Blocks.CHISELED_STONE_BRICKS; + } + private static Block decorativeTimber(Block flooring) { + if (flooring == Blocks.SPRUCE_PLANKS) return Blocks.STRIPPED_SPRUCE_LOG; + if (flooring == Blocks.DARK_OAK_PLANKS) return Blocks.STRIPPED_DARK_OAK_LOG; + if (flooring == Blocks.OAK_PLANKS) return Blocks.STRIPPED_OAK_LOG; + if (flooring == Blocks.SMOOTH_SANDSTONE) return Blocks.STRIPPED_ACACIA_LOG; + return Blocks.STRIPPED_SPRUCE_LOG; + } private static Block stairs(Block block) { if (block == Blocks.SANDSTONE || block == Blocks.TERRACOTTA) return Blocks.SANDSTONE_STAIRS; if (block == Blocks.COBBLESTONE) return Blocks.COBBLESTONE_STAIRS; diff --git a/scripts/verify-core.sh b/scripts/verify-core.sh index 98372e5..e2bf004 100755 --- a/scripts/verify-core.sh +++ b/scripts/verify-core.sh @@ -7,3 +7,4 @@ find core/src/main/java core/src/test/java -name '*.java' -print > "$output/sour javac --release 21 -d "$output" @"$output/sources.txt" java -Xmx512m -cp "$output" dev.castleforge.core.CoreVerification java -Xmx512m -cp "$output" dev.castleforge.core.TerracedVerification +java -Xmx512m -cp "$output" dev.castleforge.core.IdentityVerification