Compare commits

...
1 Commits
Author SHA1 Message Date
dnorberg 441f2896d7 Add Flooded pages across Minecraft versions and fix 1.21.1 workstations
Build and smoke / changes (push) Waiting to run
2026-11-15 22:08:56 -05:00
40 changed files with 1018 additions and 64 deletions

No files matched your search

+6
View File
@@ -32,6 +32,12 @@ Minecraft **26.3** is also supported through a separate **Java 25 / NeoForge
separate; 1.21.1 remains supported with its existing dependencies. The guide below separate; 1.21.1 remains supported with its existing dependencies. The guide below
describes 1.21.1 unless stated otherwise. describes 1.21.1 unless stated otherwise.
Current releases: **1.21.1.0.3** and **26.3.0.5**. Both add
[Flooded Pages](docs/FLOODED_PAGES.md). The 1.21.1 update also corrects Ink Mixer
cost and Flat ground height. Reborn's known 26.3 crashes are tracked in
[#118](https://git.paddedcell.org/dnorberg/rivencraft/issues/118); full optional
Seamless support is planned in [#117](https://git.paddedcell.org/dnorberg/rivencraft/issues/117).
## Getting started ## Getting started
1. Make an Ink Vial from two black dyes, a glass bottle, and a water bucket. 1. Make an Ink Vial from two black dyes, a glass bottle, and a water bucket.
+14
View File
@@ -0,0 +1,14 @@
# Rivencraft 1.21.1.0.1
For Minecraft 1.21.1, NeoForge 21.1.264 and Java 21.
Requires Dynamic Dimensions AR Edition and Bad Packets as before.
- Fixed Ink Mixers draining a full vial for one Link Panel. Each panel now costs
one paper and one ink; one full vial produces 16 panels.
- Modifier chances remain in the basin while previewing and reset only when a
panel is taken. Output refreshes immediately; vial exchange still returns a
vanilla glass bottle and respects bottle-slot space.
- Hand-making a panel retains its separate two-ink cost.
- Updated the JEI guide text to state the Mixer cost.
- This is the first 1.21.1 release using Minecraft-prefixed version identity.
The independently maintained 26.3 line already uses the correct mixer cost.
+16
View File
@@ -0,0 +1,16 @@
# Rivencraft 1.21.1.0.2
For Minecraft 1.21.1, NeoForge 21.1.264 and Java 21.
Includes the unpublished 1.21.1.0.1 Ink Mixer fix; requires Dynamic Dimensions AR
Edition and Bad Packets as before.
- Flat Age generation now starts bedrock at Y=0, dirt at Y=1–2 and grass at Y=3,
matching 26.3. The existing footing search uses this surface for arrival.
- Void and non-Flat generation are unchanged. Dimension profiles whose minimum
is already zero do not receive extra padding.
- Existing generated chunks are not rewritten. Newly generated chunks in existing
Flat Ages use the new layout and can meet old chunks at a height discontinuity.
Existing saved arrival positions are retained; create a fresh Age to test.
- Ink Mixers use one paper and one ink per panel (16 panels per full vial).
Modifier chances reset only when a panel is taken; hand-making defaults to two ink.
- JEI mixer text reflects the one-ink cost. Uses Minecraft-prefixed version names.
+40
View File
@@ -0,0 +1,40 @@
# Rivencraft 1.21.1.0.3
For **Minecraft 1.21.1**, **NeoForge 21.1.264** and **Java 21**.
Requires **Dynamic Dimensions AR Edition** and **Bad Packets**.
## Flooded Pages
- Added the Flooded Environment Page for Cave, Standard, Amplified, Island,
Flat and Void terrain. The default highest water block is Y=63.
- Number Pages immediately before Flooded form base-25 digits: Number 24 +
Flooded sets Y=24; Number 2 + Number 24 + Flooded sets Y=74. The visible water
surface is one block above that coordinate. Last Flooded wins.
- Levels are nonnegative and clamp below the dimension ceiling to leave room
for a safe arrival platform and player headroom.
- Flooding fills open space after terrain/carvers/decorations, preserving solid
features and waterloggable blocks. Lower levels drain higher ordinary water.
- Cave default water aquifers are disabled without Flooded. Water policy persists
in saved writing and generator codecs; fallback platforms sit above flood water.
- Included in Creative and optional JEI using existing glyph composition.
## Ink Mixer and Flat Ages
- Each Link Panel from the Ink Mixer consumes one paper and one ink. A full vial
makes 16 panels. Modifier chances reset only when a panel is taken; vial
exchange still returns a vanilla glass bottle. Hand-making defaults to two ink.
- Flat solid layers now start at Y=0: bedrock at 0, dirt at 1–2, grass at 3.
New Flat Ages arrive on their surface rather than far above the ground.
- JEI wording states the mixer cost. This release adopts Minecraft-prefixed
version identity and collects the unpublished 1.21.1.0.1–0.2 fixes.
## Validation and save behavior
The player passed the Mixer, fresh Flat arrival/revisit and Flooded checks.
Focused tests passed: four Mixer checks, three Flat checks and three Flooded
checks, including codecs, two water levels and preserved features. Temporary
test worlds were removed.
Existing generated chunks and saved arrival positions are not rewritten. New
chunks in old Flat Ages may meet previous chunks at a height seam. Use new Ages
for new writing. See [Flooded rules](https://git.paddedcell.org/dnorberg/rivencraft/src/branch/main/docs/FLOODED_PAGES.md).
+3 -1
View File
@@ -17,7 +17,7 @@ tasks.named('wrapper', Wrapper).configure {
version = mod_version version = mod_version
group = mod_group_id group = mod_group_id
List<String> archivedGameTestSuites = ['linking', 'environment', 'writing', 'grammar', 'generation', 'desk', 'binder', 'mixer', 'recipe', 'instability'] List<String> archivedGameTestSuites = ['linking', 'environment', 'writing', 'grammar', 'generation', 'desk', 'binder', 'mixer', 'recipe', 'instability', 'flat', 'flood']
List<String> selectedArchivedGameTestSuites = providers.gradleProperty('withArchivedGameTests') List<String> selectedArchivedGameTestSuites = providers.gradleProperty('withArchivedGameTests')
.map { it.toBoolean() }.orElse(false).get() ? archivedGameTestSuites .map { it.toBoolean() }.orElse(false).get() ? archivedGameTestSuites
: providers.gradleProperty('archivedGameTestSuites').orElse('').get() : providers.gradleProperty('archivedGameTestSuites').orElse('').get()
@@ -29,6 +29,8 @@ String enabledGameTestNamespaces = ([mod_id] + selectedArchivedGameTestSuites.co
"rivencraft_archive_${it}" "rivencraft_archive_${it}"
}).join(',') }).join(',')
sourceSets.main.java.srcDir('shared/src/main/java')
sourceSets.main.resources { sourceSets.main.resources {
// Include resources generated by data generators. // Include resources generated by data generators.
srcDir('src/generated/resources') srcDir('src/generated/resources')
+9
View File
@@ -102,3 +102,12 @@ automated two-client pass. The test server was stopped, logs retained under
build/verification/issue100-manual, and its temporary world removed. build/verification/issue100-manual, and its temporary world removed.
See [the final parity review](MC263_PARITY_REVIEW.md). Renderer bug #116 remains See [the final parity review](MC263_PARITY_REVIEW.md). Renderer bug #116 remains
separately tracked. #103/#104 and parent #96 close after release verification. separately tracked. #103/#104 and parent #96 close after release verification.
## 2026-11-15 release update
The first Minecraft-prefixed 1.21.1 release is 1.21.1.0.3, collecting Mixer #105,
Flat #106 and Flooded #107. The matching 26.3 release is 26.3.0.5 with Flooded and
the Reborn acknowledgement guard. Both player checks passed; publication was
explicitly authorized. Reborn is not crash-free: #118 remains open. #117 owns
full Seamless support. #116 was user-closed as resolved. Prior dated evidence
above remains historical; unchanged earlier artifacts are not relabeled.
+98
View File
@@ -0,0 +1,98 @@
# Flooded Pages (issue #107)
Available in releases 1.21.1.0.3 and 26.3.0.5. The player passed both game
versions, with Reborn crashes separately tracked in
[#118](https://git.paddedcell.org/dnorberg/rivencraft/issues/118).
## Writing
Flooded is an Environment Page in Creative and the page feed used by optional
JEI. It reuses glyph composition, without a new bitmap.
Number Pages immediately before Flooded encode the absolute topmost water block
Y as base-25 digits, most significant first.
| Number Pages before Flooded | Water block Y |
| --- | --- |
| None | 63 |
| 0 | 0 |
| 24 | 24 |
| 2, 13 | 63 |
| 2, 24 | 74 |
| 4, 0 | 100 |
The visible surface is at Y+1. Only an adjacent number run applies; other pages
break it. The last Flooded wins. An unnumbered final Flooded returns to Y=63.
Duplicates follow ordinary singular-controller recovery and instability.
Number chains are special to Flooded; color/celestial number behavior is unchanged.
Existing Number Pages are unsigned. Requested levels clamp between
max(0, dimension minimum Y) and dimension maximum Y minus 5, leaving emergency
platform/headroom space. Overflow saturates safely. There is no signed Number
Page for a negative surface; open spaces below zero still flood.
## Generation and travel
Works with Cave, Standard, Amplified, Flat, Island and Void terrain.
Without Flooded, Cave default fluid is air and water aquifers are disabled;
separate authored fluid/lake features retain their own behavior.
Flooding runs after terrain, carvers and decorations. It fills air, preserves
solid terrain/material features and roofs, and wets waterloggable blocks. A lower
requested line drains ordinary water/aquatic plants above it and dries waterlogged
solids without deleting them. It is generation, not a per-tick refill system.
Neighbor features and normal fluid physics can still change blocks afterward.
The policy is frozen into generator state/ordered writing and survives codec
reload. Worldgen does not consult mutable SavedData. Arrival searches reject
submerged space. Fallback platforms rise above the water; no-platform travel may
fail safely when natural footing is unavailable.
Existing generated chunks are not rewritten or retroactively drained. Existing
saved arrival positions remain. Use new Ages for validation; mixed old/new chunks
can retain different earlier layouts.
## Validation
1.21.1: three focused tests passed for ordered numbers, plan/generator codecs,
two water levels in Cave-like in-memory chunks, dry Cave settings, solid/waterlogged
block preservation and the public page feed.
26.3: 21 isolated dedicated checks passed for equivalent grammar/support/feed,
two levels, block preservation/draining, codec and authored non-Cave biome, dry
Cave defaults and safe-height bounds. The first probe exposed an adjacent-number
grammar penalty; it was corrected before the passing run. No test stalled.
The port probe stays outside shipping sources and uses a disposable world/build:
python3 scripts/regression_flood263.py
Player checks on both versions:
1. A fresh Cave Age without Flooded stays free of default water flooding.
2. Cave Ages using 24 + Flooded and 2 + 24 + Flooded stop at water block Y=24
and Y=74 respectively.
3. A Flat/Plains Age with Flooded uses the selected/default level and safe arrival.
4. Return, save/reload, revisit, and check new chunks retain the same water level.
Books/portals must not spawn the player underwater.
5. Flooded appears in Environment Creative pages and JEI when installed.
Optionally verify a large number chain clamps safely near the ceiling.
Both game versions are tested sequentially. Test logs remain under
build/verification/flood107; temporary worlds and fixture outputs are removed.
## Reborn travel disconnect during player validation
The 26.3.0.4 client disconnected on a block-change acknowledgement after Age
travel. Reborn 7.0.12 called getClientWorlds while its world map was uninitialized
after dimension replacement. The integrated server stopped after the client left;
the report was not a Flooded generator server exception.
26.3.0.5 adds a client-only compatibility guard: on the game thread, while Reborn's
map is uninitialized, use vanilla acknowledgement handling for the packet
listener's world. Initialized Reborn retains its normal multiworld handling.
No networking payload format, 1.21.1 code or saved player data changed for this fix.
Build and target-method signatures verified. The player accepted 26.3 Flooded,
but subsequently encountered a different null-section rebuild crash while exploring.
That renderer failure remains unresolved in #118; 26.3.0.5 is not advertised as
crash-free with Reborn. Full Seamless support is tracked in #117.
+11 -1
View File
@@ -26,7 +26,7 @@ core tests when investigating an issue:
``` ```
Available suite names are `linking`, `environment`, `writing`, `grammar`, Available suite names are `linking`, `environment`, `writing`, `grammar`,
`generation`, `desk`, `binder`, `mixer`, `recipe`, and `instability`. The `generation` archive `generation`, `desk`, `binder`, `mixer`, `recipe`, `instability`, `flat`, and `flood`. The `generation` archive
keeps the detailed feature, structure, ore, crystal, and fissure regressions keeps the detailed feature, structure, ore, crystal, and fissure regressions
out of the default smoke run. The `instability` archive adds multi-player loaded-chunk selection, policy gates, and protected-block checks without rerunning the default scoring and migration tests. Three checks formerly registered twice in the out of the default smoke run. The `instability` archive adds multi-player loaded-chunk selection, policy gates, and protected-block checks without rerunning the default scoring and migration tests. Three checks formerly registered twice in the
core and their archives now run only through the core wrapper. Run all core and their archives now run only through the core wrapper. Run all
@@ -175,3 +175,13 @@ server, so physical placement is handed to the player for in-game verification:
Repeat Repeat
with `gl` or `glo` to confirm names do not change page validity. An explicit with `gl` or `glo` to confirm names do not change page validity. An explicit
Flat or Cave Terrain Page with Rocks should still be rejected. Flat or Cave Terrain Page with Rocks should still be rejected.
The `flat` archive covers issue #106 without loading dynamic Ages: Y=0 layer/height
queries, authored-biome generator codec reload, zero-minimum dimension profiles,
and unchanged empty Void columns. Travel/revisit/full-world restart remains a
player check in a fresh Flat Age.
The flood archive covers #107 grammar/codecs and in-memory water filling.
The 26.3 equivalent is scripts/regression_flood263.py. Run servers sequentially.
See [Flooded Pages](FLOODED_PAGES.md) for the travel/reload player checklist.
+5
View File
@@ -1,5 +1,10 @@
# 26.3 port parity and acceptance review # 26.3 port parity and acceptance review
Update 2026-11-15: Flooded passed on both versions (#107). #116 was later closed
by the user as resolved; current Reborn crashes are separately tracked in #118.
Full Seamless live views remain future work in #117. The dated port review below
does not imply all subsequent third-party renderer bugs are fixed.
Reviewed 2026-11-14 for 26.3.0.3 against the independently maintained 1.21.1 Reviewed 2026-11-14 for 26.3.0.3 against the independently maintained 1.21.1
implementation. This closes the port feature checklist, not every open bug or implementation. This closes the port feature checklist, not every open bug or
future enhancement. The dated development entries in MINECRAFT_26_3_PORT.md future enhancement. The dated development entries in MINECRAFT_26_3_PORT.md
+2 -2
View File
@@ -35,8 +35,8 @@ mod_id=rivencraft
mod_name=Rivencraft mod_name=Rivencraft
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default. # The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=LGPL-3.0-or-later mod_license=LGPL-3.0-or-later
# Existing 1.21.1 release number. Adopt the Minecraft-prefixed policy in README.md on its next code release. # Minecraft.release-slice.iteration; independent of the 26.3 release track.
mod_version=1.0.1.1 mod_version=1.21.1.0.3
immersive_portals_version=6.0.7 immersive_portals_version=6.0.7
terrablender_version=4.1.0.8 terrablender_version=4.1.0.8
serene_seasons_version_id=pHEgQQUE serene_seasons_version_id=pHEgQQUE
+12 -4
View File
@@ -1,6 +1,6 @@
# Minecraft 26.3 # Minecraft 26.3
The current **Minecraft 26.3 release is 26.3.0.3**, for NeoForge 26.3.0.99 and The current **Minecraft 26.3 release is 26.3.0.5**, for NeoForge 26.3.0.99 and
Java 25. It uses Rivencraft's first-party Age backend, with no Dynamic Dimensions Java 25. It uses Rivencraft's first-party Age backend, with no Dynamic Dimensions
or Bad Packets dependency. The writing loop, authored/seeded Ages, generation or Bad Packets dependency. The writing loop, authored/seeded Ages, generation
features, weather/skies/celestials, libraries, crystal portals, live instability, features, weather/skies/celestials, libraries, crystal portals, live instability,
@@ -13,8 +13,12 @@ available without it. Random-page eligibility and glyph descriptions are include
Use one portal fork per instance. The server controls crystal live views through Use one portal fork per instance. The server controls crystal live views through
`book_previews.reborn_crystal_live_views`; clients can disable live book views `book_previews.reborn_crystal_live_views`; clients can disable live book views
with `book_previews.reborn_live_views` in `rivencraft-local.toml`. with `book_previews.reborn_live_views` in `rivencraft-local.toml`.
Reborn's Static Sky rendering issue remains tracked in **Known Reborn crashes:** [#118](https://git.paddedcell.org/dnorberg/rivencraft/issues/118)
[#116](https://git.paddedcell.org/dnorberg/rivencraft/issues/116). tracks the world-reset acknowledgement problem and an unresolved null-section
rebuild crash during exploration. 26.3.0.5 mitigates the acknowledgement gap;
it does not fix the section rebuild crash. The earlier Static Sky issue #116
was closed after the user reported it resolved. Full Seamless live-view support
is tracked in [#117](https://git.paddedcell.org/dnorberg/rivencraft/issues/117).
The port feature and acceptance review is recorded in The port feature and acceptance review is recorded in
[the parity review](../../docs/MC263_PARITY_REVIEW.md). Book exploration matches [the parity review](../../docs/MC263_PARITY_REVIEW.md). Book exploration matches
@@ -22,7 +26,11 @@ The port feature and acceptance review is recorded in
movement is disabled. The final dedicated-server restart/return check passed. movement is disabled. The final dedicated-server restart/return check passed.
Create/Ponder scenes are not ported to this target. Use matching client/server Create/Ponder scenes are not ported to this target. Use matching client/server
builds, keep saves separate from 1.21.1 and back up before updating. builds, keep saves separate from 1.21.1 and back up before updating.
See [release notes](RELEASE_NOTES_26.3.0.3.md). See [release notes](RELEASE_NOTES_26.3.0.5.md).
Flooded Environment Pages now fill Cave and other terrain to Y=63 by default,
or the absolute base-25 Number Pages immediately before Flooded. Both-version
player checks passed. See [Flooded rules](../../docs/FLOODED_PAGES.md).
The entries below record how the port was built, including earlier alpha-only The entries below record how the port was built, including earlier alpha-only
limitations that were addressed by later slices. limitations that were addressed by later slices.
+17
View File
@@ -0,0 +1,17 @@
# Rivencraft 26.3.0.4
Minecraft 26.3 / NeoForge 26.3.0.99 / Java 25. Local test build.
- Added Flooded Environment Pages with the same 1.21.1 rules: default water block
Y=63, or adjacent base-25 Number Pages (2,24 means Y=74). Last Flooded wins.
- Works with Cave and other terrain, preserving solid features. Cave defaults
remain dry without Flooded.
- Lower lines drain higher ordinary water; waterlogged solids are wet/dried.
Policy persists in generator writing/codecs.
- Safe fallback platforms rise above water within build-height limits.
Creative and optional JEI reuse the existing glyph/page pipeline.
- Existing generated chunks are not rewritten. See docs/FLOODED_PAGES.md.
Known Static Sky/Reborn bug #116 remains separate.
Awaiting player acceptance and explicit publication instruction; not committed,
pushed or published.
+46
View File
@@ -0,0 +1,46 @@
# Rivencraft 26.3.0.5
For **Minecraft 26.3**, **NeoForge 26.3.0.99** and **Java 25**.
Dynamic Dimensions and Bad Packets are not required. All integrations remain optional.
## Flooded Pages
- Added Flooded Environment Pages for Cave and other terrain. Default highest
water block Y=63; adjacent Number Pages encode a base-25 absolute height.
Number 24 + Flooded means Y=24; Number 2 + Number 24 + Flooded means Y=74.
- Last Flooded wins. Unsigned heights clamp below the ceiling with safe
platform/headroom space. Cave defaults remain dry without Flooded.
- Flooding preserves solid terrain/features, wets waterloggable blocks and drains
ordinary water above a lower requested line. Policy persists in generator writing.
- Safe fallback platforms sit above water; no-platform travel can fail safely.
- Creative and optional JEI use the existing glyph/page pipeline.
- Existing generated chunks are not rewritten.
## Reborn compatibility and known crashes
- Added a targeted Reborn 7.0.12 acknowledgement guard for the reported protocol
disconnect during Age travel. While Reborn's world map is uninitialized, keep
vanilla acknowledgement handling for the packet listener's world; normal
multiworld handling resumes once ready. Packet scheduling stays on the game thread.
- **Known issue [#118](https://git.paddedcell.org/dnorberg/rivencraft/issues/118):**
Reborn can still crash during exploration when a queued section rebuild resolves
to null. This release does not fix that renderer crash or establish which mod
made the queue stale. The player accepted Flooded with these Reborn issues noted.
- [#117](https://git.paddedcell.org/dnorberg/rivencraft/issues/117) tracks full
Seamless live-view support. Seamless currently has native dimension synchronization
and normal travel, with animated fallback views; live views remain Reborn-only.
- The earlier Static Sky leak #116 was closed after the user reported it had gone
away with recent changes, possibly after interactive view was implemented.
That timing is not a verified root-cause fix. It is not the new section rebuild failure.
- Built-in animated book/portal views and ordinary travel remain available without
a portal renderer. Disabling only Rivencraft live views has not been proven to
prevent all Reborn crashes. No required or bundled portal-mod dependency is added.
## Validation
Both-version Flooded in-game checks passed. Three focused 1.21.1 tests and 21
isolated 26.3 checks covered grammar, two water levels, codecs, preserved solids,
dry Cave defaults and page availability. The 26.3.0.5 build and acknowledgement
target signatures were verified. No claim that Reborn is crash-free is made.
Temporary worlds/fixtures were removed; production JAR contains no test fixtures.
See [Flooded rules](https://git.paddedcell.org/dnorberg/rivencraft/src/branch/main/docs/FLOODED_PAGES.md).
+2
View File
@@ -53,6 +53,8 @@ dependencies {
if (project.hasProperty('withJei')) localRuntime "mezz.jei:jei-${minecraft_version}-neoforge:${jei_version}" if (project.hasProperty('withJei')) localRuntime "mezz.jei:jei-${minecraft_version}-neoforge:${jei_version}"
} }
sourceSets.main.java.srcDir('../../shared/src/main/java')
group = 'net.dnorberg.rivencraft' group = 'net.dnorberg.rivencraft'
version = mod_version version = mod_version
+1 -1
View File
@@ -7,7 +7,7 @@ neo_version=26.3.0.99
mod_id=rivencraft mod_id=rivencraft
mod_name=Rivencraft mod_name=Rivencraft
mod_license=LGPL-3.0-or-later mod_license=LGPL-3.0-or-later
mod_version=26.3.0.3 mod_version=26.3.0.5
jei_version=31.17.0.109 jei_version=31.17.0.109
@@ -1,5 +1,7 @@
package net.dnorberg.rivencraft.age; package net.dnorberg.rivencraft.age;
import net.dnorberg.rivencraft.shared.FloodingRules;
import java.util.Set; import java.util.Set;
import net.dnorberg.rivencraft.Rivencraft; import net.dnorberg.rivencraft.Rivencraft;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
@@ -76,14 +78,18 @@ public final class PortAgeTravel {
} }
} }
} }
return generatePlatform ? makePlatform(target, new BlockPos(0, 64, 0)) : null; return generatePlatform ? makePlatform(target, new BlockPos(0, fallbackFeet(target), 0)) : null;
} }
BlockPos surface = findSurfaceLanding(target, 0, 0); BlockPos surface = findSurfaceLanding(target, 0, 0);
if (surface != null) return surface; if (surface != null) return surface;
// Only build above the actual highest obstruction, never in a pocket // Only build above the actual highest obstruction, never in a pocket
// beneath it. Void Ages retain the usual platform floor at Y=63. // beneath it. Void Ages retain the usual platform floor at Y=63.
BlockPos obstruction = highestObstruction(target, 0, 0); BlockPos obstruction = highestObstruction(target, 0, 0);
int y = obstruction == null ? 64 : Math.max(64, obstruction.getY() + 3); boolean flooded = target.getChunkSource().getGenerator() instanceof PortFeatureChunkGenerator features
&& features.floodSurface() != FloodingRules.NONE;
int clearance = flooded && obstruction != null && !target.getFluidState(obstruction).isEmpty() ? 2 : 3;
int y = obstruction == null ? fallbackFeet(target)
: Math.max(fallbackFeet(target), obstruction.getY() + clearance);
return generatePlatform ? makePlatform(target, new BlockPos(0, y, 0)) : null; return generatePlatform ? makePlatform(target, new BlockPos(0, y, 0)) : null;
} }
@@ -124,6 +130,12 @@ public final class PortAgeTravel {
.value().noiseSettings()); .value().noiseSettings());
} }
private static int fallbackFeet(ServerLevel target) {
int requested = target.getChunkSource().getGenerator() instanceof PortFeatureChunkGenerator features
? features.floodSurface() : FloodingRules.NONE;
return FloodingRules.platformFloor(requested, target.getMinY(), target.getMaxY()) + 1;
}
private static BlockPos makePlatform(ServerLevel target, BlockPos foot) { private static BlockPos makePlatform(ServerLevel target, BlockPos foot) {
if (foot.getY() <= target.getMinY() || foot.getY() + 2 >= target.getMaxY()) return null; if (foot.getY() <= target.getMinY() || foot.getY() + 2 >= target.getMaxY()) return null;
// A carved pocket inside a flooded cave immediately refills. Refuse // A carved pocket inside a flooded cave immediately refills. Refuse
@@ -86,6 +86,7 @@ public final class PortFeatureChunkGenerator extends ChunkGenerator {
private final long ageSeed; private final long ageSeed;
private final boolean libraries; private final boolean libraries;
private final List<Identifier> librarySymbols; private final List<Identifier> librarySymbols;
private final int floodSurface;
public PortFeatureChunkGenerator(ChunkGenerator base, PortRockPlan rocks, public PortFeatureChunkGenerator(ChunkGenerator base, PortRockPlan rocks,
PortVegetationPlan vegetation, int dungeons, PortLakePlan lakes, PortVegetationPlan vegetation, int dungeons, PortLakePlan lakes,
@@ -107,8 +108,10 @@ public final class PortFeatureChunkGenerator extends ChunkGenerator {
this.ageSeed = ageSeed; this.ageSeed = ageSeed;
this.libraries = libraries; this.libraries = libraries;
this.librarySymbols = List.copyOf(librarySymbols); this.librarySymbols = List.copyOf(librarySymbols);
this.floodSurface = PortFlooding.requested(librarySymbols);
} }
public int floodSurface() { return floodSurface; }
public ChunkGenerator base() { return base; } public ChunkGenerator base() { return base; }
public PortRockPlan rocks() { return rocks; } public PortRockPlan rocks() { return rocks; }
public PortVegetationPlan vegetation() { return vegetation; } public PortVegetationPlan vegetation() { return vegetation; }
@@ -300,5 +303,6 @@ public final class PortFeatureChunkGenerator extends ChunkGenerator {
} }
} }
if (libraries) PortLibraryFeature.generate(level, chunk, ageSeed, librarySymbols); if (libraries) PortLibraryFeature.generate(level, chunk, ageSeed, librarySymbols);
PortFlooding.apply(chunk, floodSurface);
} }
} }
@@ -0,0 +1,45 @@
package net.dnorberg.rivencraft.age;
import java.util.List;
import net.dnorberg.rivencraft.shared.FloodingRules;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.Identifier;
import net.minecraft.tags.FluidTags;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.chunk.ChunkAccess;
public final class PortFlooding {
public static final Identifier PAGE = Identifier.fromNamespaceAndPath("rivencraft", "environment/flooded");
private PortFlooding() {}
public static int requested(List<Identifier> pages) {
return FloodingRules.requested(pages.stream().map(page -> {
if (page.equals(PAGE)) return FloodingRules.FLOODED;
if (page.getNamespace().equals("rivencraft") && page.getPath().startsWith("number/")) {
try {
int digit = Integer.parseInt(page.getPath().substring(7));
if (digit >= 0 && digit <= 24) return digit;
} catch (NumberFormatException ignored) { }
}
return FloodingRules.OTHER;
}).toList());
}
public static void apply(ChunkAccess chunk, int requested) {
int surface = FloodingRules.surface(requested, chunk.getMinY(), chunk.getMaxY());
if (surface == FloodingRules.NONE) return;
BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos();
int startX = chunk.getPos().getMinBlockX(), startZ = chunk.getPos().getMinBlockZ();
for (int x = 0; x < 16; x++) for (int z = 0; z < 16; z++) {
for (int y = chunk.getMinY(); y < chunk.getMaxY(); y++) {
pos.set(startX + x, y, startZ + z);
var state = chunk.getBlockState(pos);
if (y <= surface && state.isAir())
chunk.setBlockState(pos, Blocks.WATER.defaultBlockState());
else if (state.hasProperty(BlockStateProperties.WATERLOGGED))
chunk.setBlockState(pos, state.setValue(BlockStateProperties.WATERLOGGED, y <= surface));
else if (y > surface && state.getFluidState().is(FluidTags.WATER))
chunk.setBlockState(pos, Blocks.AIR.defaultBlockState());
}
}
}
}
@@ -0,0 +1,17 @@
package net.dnorberg.rivencraft.client;
import net.minecraft.client.multiplayer.ClientLevel;
import qouteall.imm_ptl.core.ClientWorldLoader;
/** Reborn's world map is briefly unavailable during vanilla dimension replacement. */
public final class RebornPredictionAcks {
private RebornPredictionAcks() {}
public static boolean handleDuringWorldReset(ClientLevel packetLevel, int sequence) {
if (ClientWorldLoader.getIsInitialized()) return false;
// The old remote worlds have been discarded. Preserve the vanilla ack for
// the packet listener's live world until Reborn rebuilds its multiworld map.
if (packetLevel != null) packetLevel.handleBlockChangedAck(sequence);
return true;
}
}
@@ -0,0 +1,26 @@
package net.dnorberg.rivencraft.mixin;
import net.dnorberg.rivencraft.client.RebornPredictionAcks;
import net.dnorberg.rivencraft.compat.RebornBookPreviews;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.multiplayer.ClientPacketListener;
import net.minecraft.network.protocol.game.ClientboundBlockChangedAckPacket;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
/** Keep transitional acks out of Reborn's initialized-world assertion. */
@Mixin(value = ClientPacketListener.class, priority = 2000)
public abstract class RebornBlockAckMixin {
@Shadow private ClientLevel level;
@Inject(method = "handleBlockChangedAck", at = @At("HEAD"), cancellable = true)
private void rivencraft$ackDuringWorldReset(ClientboundBlockChangedAckPacket packet, CallbackInfo callback) {
// Off-thread packets must reach vanilla's normal scheduling path first.
if (Minecraft.getInstance().isSameThread() && RebornBookPreviews.available()
&& RebornPredictionAcks.handleDuringWorldReset(level, packet.sequence())) callback.cancel();
}
}
@@ -60,7 +60,8 @@ public final class PortAuthoredWriting {
|| net.dnorberg.rivencraft.compat.SereneSeasonsCompatibility.available(); || net.dnorberg.rivencraft.compat.SereneSeasonsCompatibility.available();
if (net.dnorberg.rivencraft.age.PortAgeColors.isModifier(page) if (net.dnorberg.rivencraft.age.PortAgeColors.isModifier(page)
|| net.dnorberg.rivencraft.age.PortDayCycle.supports(page)) return true; || net.dnorberg.rivencraft.age.PortDayCycle.supports(page)) return true;
if (page.equals(net.dnorberg.rivencraft.age.PortAcceleratedTicks.PAGE) if (page.equals(net.dnorberg.rivencraft.age.PortFlooding.PAGE)
|| page.equals(net.dnorberg.rivencraft.age.PortAcceleratedTicks.PAGE)
|| net.dnorberg.rivencraft.age.PortInstabilityData.isCorrupted(page)) return true; || net.dnorberg.rivencraft.age.PortInstabilityData.isCorrupted(page)) return true;
if (isTerrain(page) || controller(page) != null || PortWeatherMode.forPage(page) != null if (isTerrain(page) || controller(page) != null || PortWeatherMode.forPage(page) != null
|| PortLighting.forPage(page) != null || PortSkyStyle.forPage(page) != null) return true; || PortLighting.forPage(page) != null || PortSkyStyle.forPage(page) != null) return true;
@@ -135,7 +136,8 @@ public final class PortAuthoredWriting {
if (pendingMaterial != null && !(pendingMaterial.equals("rivencraft:block") if (pendingMaterial != null && !(pendingMaterial.equals("rivencraft:block")
&& (page.equals(ROCKS) || PortTerrainFeaturePlan.acceptsMaterial(page)) && (page.equals(ROCKS) || PortTerrainFeaturePlan.acceptsMaterial(page))
|| pendingMaterial.equals("rivencraft:fluid") && PortLakePlan.isLake(page))) return false; || pendingMaterial.equals("rivencraft:fluid") && PortLakePlan.isLake(page))) return false;
if (net.dnorberg.rivencraft.age.PortAgeColors.isModifier(page) if (page.equals(net.dnorberg.rivencraft.age.PortFlooding.PAGE)
|| net.dnorberg.rivencraft.age.PortAgeColors.isModifier(page)
|| net.dnorberg.rivencraft.age.PortDayCycle.supports(page)) { || net.dnorberg.rivencraft.age.PortDayCycle.supports(page)) {
// Shared colors target Sky, Ambient Light Color or Normal Time; trailing colors tint the sky. // Shared colors target Sky, Ambient Light Color or Normal Time; trailing colors tint the sky.
} else if (net.dnorberg.rivencraft.age.PortInstabilityData.isCorrupted(page)) { } else if (net.dnorberg.rivencraft.age.PortInstabilityData.isCorrupted(page)) {
@@ -9,7 +9,7 @@ import net.minecraft.resources.Identifier;
/** 1.21.1 grammar diagnostics and singular-controller recovery; preserve ordered modifier chains. */ /** 1.21.1 grammar diagnostics and singular-controller recovery; preserve ordered modifier chains. */
public final class PortWritingRecovery { public final class PortWritingRecovery {
private static final Set<String> SINGULAR = Set.of("terrain", "biome_controller", "weather", "season", "lighting", "sky"); private static final Set<String> SINGULAR = Set.of("terrain", "biome_controller", "weather", "season", "lighting", "sky", "flooding");
private static final Set<String> MODIFIERS = Set.of("period_modifier", "angle_modifier", "phase_modifier", "size_modifier", private static final Set<String> MODIFIERS = Set.of("period_modifier", "angle_modifier", "phase_modifier", "size_modifier",
"celestial_color", "direction_modifier"); "celestial_color", "direction_modifier");
public record Diagnostic(String code, int index, int points) {} public record Diagnostic(String code, int index, int points) {}
@@ -29,7 +29,8 @@ public final class PortWritingRecovery {
var entry = PortSymbolPages.find(page); var entry = PortSymbolPages.find(page);
if (entry == null || !PortAuthoredWriting.isPageImplemented(page)) { implemented = false; continue; } if (entry == null || !PortAuthoredWriting.isPageImplemented(page)) { implemented = false; continue; }
String role = entry.role(); String role = entry.role();
if (pendingNumber != null && !numberTarget(role)) { if (pendingNumber != null && !numberTarget(role)
&& !(role.equals("color_number") && numberRunTargetsFlooded(pages, index))) {
diagnostics.add(new Diagnostic("misplaced_modifier", pendingNumber, 100)); diagnostics.add(new Diagnostic("misplaced_modifier", pendingNumber, 100));
pendingNumber = null; pendingNumber = null;
} }
@@ -78,9 +79,18 @@ public final class PortWritingRecovery {
// The port's category compilers select by role, so no physical resort is necessary. // The port's category compilers select by role, so no physical resort is necessary.
return new Result(active, diagnostics, implemented); return new Result(active, diagnostics, implemented);
} }
private static boolean numberRunTargetsFlooded(List<Identifier> pages, int index) {
for (int next = index + 1; next < pages.size(); next++) {
var entry = PortSymbolPages.find(pages.get(next));
if (entry == null) return false;
if (!entry.role().equals("color_number")) return entry.role().equals("flooding");
}
return false;
}
private static boolean numberTarget(String role) { private static boolean numberTarget(String role) {
return role.equals("color") || role.equals("period_modifier") || role.equals("angle_modifier") return role.equals("color") || role.equals("period_modifier") || role.equals("angle_modifier")
|| role.equals("phase_modifier") || role.equals("size_modifier"); || role.equals("phase_modifier") || role.equals("size_modifier") || role.equals("flooding");
} }
private static int stage(String role) { private static int stage(String role) {
return switch (role) { return switch (role) {
@@ -18,7 +18,8 @@
"StaticSkyStateMixin", "StaticSkyStateMixin",
"StaticSkyRendererMixin", "StaticSkyRendererMixin",
"RebornGuiRenderingMixin", "RebornGuiRenderingMixin",
"ClientLevelSoundMixin" "ClientLevelSoundMixin",
"RebornBlockAckMixin"
], ],
"injectors": { "injectors": {
"defaultRequire": 1 "defaultRequire": 1
+1 -1
View File
@@ -12,7 +12,7 @@ def affected(paths):
targets.add("mc1211") targets.add("mc1211")
if path.startswith("ports/mc263/") and not path.endswith(".md"): if path.startswith("ports/mc263/") and not path.endswith(".md"):
targets.add("mc263") 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")) targets.update(("mc1211", "mc263"))
return sorted(targets) 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(["src/main/java/net/dnorberg/rivencraft/Rivencraft.java"]), ["mc1211"])
self.assertEqual(affected(["ports/mc263/src/main/java/Example.java"]), ["mc263"]) 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(["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"]), []) self.assertEqual(affected(["README.md", "scripts/publish_mod_sites.py"]), [])
def test_release_identity_rejects_mislabeled_channels(self): def test_release_identity_rejects_mislabeled_channels(self):
@@ -0,0 +1,40 @@
package net.dnorberg.rivencraft.shared;
import java.util.List;
/** Game-version independent ordered Flooded instructions and safe height bounds. */
public final class FloodingRules {
public static final int NONE = Integer.MIN_VALUE;
public static final int FLOODED = -1;
public static final int OTHER = -2;
public static final int DEFAULT_SURFACE = 63;
private FloodingRules() {}
/** Tokens 0..24 are base-25 digits; only the contiguous run before Flooded applies. */
public static int requested(List<Integer> tokens) {
int result = NONE;
long digits = 0;
boolean numbered = false;
for (int token : tokens) {
if (token >= 0 && token <= 24) {
digits = Math.min(Integer.MAX_VALUE, digits * 25 + token);
numbered = true;
} else {
if (token == FLOODED) result = numbered ? (int) digits : DEFAULT_SURFACE;
digits = 0;
numbered = false;
}
}
return result;
}
/** Retain four blocks above the water for an emergency floor and player headroom. */
public static int surface(int requested, int minY, int maxY) {
return requested == NONE ? NONE : Math.clamp(requested, Math.max(0, minY), maxY - 5);
}
public static int platformFloor(int requested, int minY, int maxY) {
int water = surface(requested, minY, maxY);
return water == NONE ? 63 : water + 1;
}
}
@@ -28,6 +28,7 @@ public final class InkMixerBlockEntity extends BlockEntity implements Container
public static final int PAPER = 1; public static final int PAPER = 1;
public static final int BOTTLES = 2; public static final int BOTTLES = 2;
public static final int SIZE = 3; public static final int SIZE = 3;
private static final int LINK_PANEL_INK_COST = 1;
private NonNullList<ItemStack> items = NonNullList.withSize(SIZE, ItemStack.EMPTY); private NonNullList<ItemStack> items = NonNullList.withSize(SIZE, ItemStack.EMPTY);
private int inkRemaining; private int inkRemaining;
@@ -126,13 +127,13 @@ public final class InkMixerBlockEntity extends BlockEntity implements Container
public boolean canCreateLinkPanel() { public boolean canCreateLinkPanel() {
if (!items.get(PAPER).is(Items.PAPER)) return false; if (!items.get(PAPER).is(Items.PAPER)) return false;
return InkVialExchange.canPay(items, INK, BOTTLES, inkRemaining, InkVialItem.CAPACITY); return InkVialExchange.canPay(items, INK, BOTTLES, inkRemaining, LINK_PANEL_INK_COST);
} }
/** Commit inputs only when a virtual output is actually taken. */ /** Commit inputs only when a virtual output is actually taken. */
public boolean consumeLinkPanelMaterials() { public boolean consumeLinkPanelMaterials() {
if (!canCreateLinkPanel()) return false; if (!canCreateLinkPanel()) return false;
int cost = InkVialItem.CAPACITY; int cost = LINK_PANEL_INK_COST;
if (inkRemaining < cost) { if (inkRemaining < cost) {
inkRemaining += InkVialExchange.exchange(items, INK, BOTTLES); inkRemaining += InkVialExchange.exchange(items, INK, BOTTLES);
} }
@@ -56,6 +56,8 @@ import net.minecraft.world.level.levelgen.FlatLevelSource;
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings; import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
import net.minecraft.world.level.levelgen.SurfaceRules; import net.minecraft.world.level.levelgen.SurfaceRules;
import net.minecraft.world.level.levelgen.flat.FlatLevelGeneratorSettings; import net.minecraft.world.level.levelgen.flat.FlatLevelGeneratorSettings;
import net.minecraft.world.level.levelgen.flat.FlatLayerInfo;
import net.dnorberg.rivencraft.shared.FloodingRules;
import net.neoforged.fml.ModList; import net.neoforged.fml.ModList;
/** Creates, reloads, and resolves Rivencraft's runtime Age dimensions. */ /** Creates, reloads, and resolves Rivencraft's runtime Age dimensions. */
@@ -244,14 +246,18 @@ public final class AgeDimensionService {
if (age.caveTerrain()) { if (age.caveTerrain()) {
// Cave Ages are enclosed. Searching from the world ceiling would // Cave Ages are enclosed. Searching from the world ceiling would
// select or expose their roof, so begin with the floor beneath a // select or expose their roof, so begin with the floor beneath a
// player standing at Y=64 and search downward from there. // player standing at Y=64, or above an explicitly higher flood line.
floorCenter = highestFootedSurface(level, CAVE_SPAWN_SEARCH_Y - 1) int water = FloodingRules.surface(AgeFlooding.requested(age.plan()),
.orElseGet(() -> generatePlatform ? fallbackSpawnFloor(level) : null); level.getMinBuildHeight(), level.getMaxBuildHeight());
} else if (isNetherStyle(level)) { int searchTop = water == FloodingRules.NONE ? CAVE_SPAWN_SEARCH_Y - 1
: Math.max(CAVE_SPAWN_SEARCH_Y - 1, water + 1);
floorCenter = highestFootedSurface(level, searchTop)
.orElseGet(() -> generatePlatform ? fallbackSpawnFloor(level, age) : null);
} else if (isNetherStyle(level) && AgeFlooding.requested(age.plan()) == FloodingRules.NONE) {
floorCenter = generatePlatform ? netherSpawnFloor(level) floorCenter = generatePlatform ? netherSpawnFloor(level)
: highestFootedSurface(level, CAVE_SPAWN_SEARCH_Y - 1).orElse(null); : highestFootedSurface(level, CAVE_SPAWN_SEARCH_Y - 1).orElse(null);
} else { } else {
floorCenter = highestFootedSurface(level).orElseGet(() -> generatePlatform ? fallbackSpawnFloor(level) : null); floorCenter = highestFootedSurface(level).orElseGet(() -> generatePlatform ? fallbackSpawnFloor(level, age) : null);
} }
if (floorCenter == null) return null; if (floorCenter == null) return null;
@@ -260,7 +266,7 @@ public final class AgeDimensionService {
for (int z = -PLATFORM_RADIUS; z <= PLATFORM_RADIUS; z++) { for (int z = -PLATFORM_RADIUS; z <= PLATFORM_RADIUS; z++) {
BlockPos floor = floorCenter.offset(x, 0, z); BlockPos floor = floorCenter.offset(x, 0, z);
level.setBlock(floor, ModBlocks.CLOUD_PLATFORM.get().defaultBlockState(), 2); level.setBlock(floor, ModBlocks.CLOUD_PLATFORM.get().defaultBlockState(), 2);
for (int y = 1; y <= 4; y++) { for (int y = 1; y <= 4 && floor.getY() + y < level.getMaxBuildHeight(); y++) {
level.setBlock(floor.above(y), Blocks.AIR.defaultBlockState(), 2); level.setBlock(floor.above(y), Blocks.AIR.defaultBlockState(), 2);
} }
} }
@@ -338,12 +344,27 @@ public final class AgeDimensionService {
return Optional.empty(); return Optional.empty();
} }
private static BlockPos fallbackSpawnFloor(ServerLevel level) { private static BlockPos fallbackSpawnFloor(ServerLevel level, AgeDefinition age) {
int floorY = Math.clamp(FALLBACK_PLATFORM_Y, int floorY = Math.clamp(FloodingRules.platformFloor(AgeFlooding.requested(age.plan()),
level.getMinBuildHeight(), level.getMaxBuildHeight() - 5); level.getMinBuildHeight(), level.getMaxBuildHeight()),
level.getMinBuildHeight(), level.getMaxBuildHeight() - 4);
return new BlockPos(0, floorY, 0); return new BlockPos(0, floorY, 0);
} }
/** Keep the flat surface at Y=3 even when its dimension extends below zero. */
static FlatLevelGeneratorSettings flatSettings(MinecraftServer server, AgeRuntimeProfile profile) {
var settings = FlatLevelGeneratorSettings.getDefault(
server.registryAccess().lookupOrThrow(Registries.BIOME),
server.registryAccess().lookupOrThrow(Registries.STRUCTURE_SET),
server.registryAccess().lookupOrThrow(Registries.PLACED_FEATURE));
int minY = server.registryAccess().lookupOrThrow(Registries.DIMENSION_TYPE)
.getOrThrow(ResourceKey.create(Registries.DIMENSION_TYPE, profile.dimensionType()))
.value().minY();
if (minY < 0) settings.getLayersInfo().addFirst(new FlatLayerInfo(-minY, Blocks.AIR));
settings.updateLayers();
return settings;
}
private static ChunkGenerator createGenerator(MinecraftServer server, AgeDefinition age) { private static ChunkGenerator createGenerator(MinecraftServer server, AgeDefinition age) {
AgeRuntimeProfile profile = runtimeProfile(age); AgeRuntimeProfile profile = runtimeProfile(age);
BiomeSource biomeSource = createBiomeSource(server, age, profile); BiomeSource biomeSource = createBiomeSource(server, age, profile);
@@ -351,13 +372,9 @@ public final class AgeDimensionService {
List<AgeFeatureSelection.Choice> features = age.plan() == null List<AgeFeatureSelection.Choice> features = age.plan() == null
? age.randomFeatures() : AgeFeatureSelection.resolved(age.plan()); ? age.randomFeatures() : AgeFeatureSelection.resolved(age.plan());
if (profile.terrain() == AgeRuntimeProfile.Terrain.FLAT) { if (profile.terrain() == AgeRuntimeProfile.Terrain.FLAT) {
var settings = FlatLevelGeneratorSettings.getDefault( var settings = flatSettings(server, profile);
server.registryAccess().lookupOrThrow(Registries.BIOME),
server.registryAccess().lookupOrThrow(Registries.STRUCTURE_SET),
server.registryAccess().lookupOrThrow(Registries.PLACED_FEATURE)
);
return age.generationVersion() < AgeDefinition.LEGACY_GENERATOR_CUTOFF return age.generationVersion() < AgeDefinition.LEGACY_GENERATOR_CUTOFF
? new FlatLevelSource(settings) : new AgeFlatChunkGenerator(biomeSource, settings, features, age.seed(), libraryAgeSymbols); ? new FlatLevelSource(settings) : new AgeFlatChunkGenerator(biomeSource, settings, features, age.seed(), libraryAgeSymbols, AgeFlooding.requested(age.plan()));
} }
if (profile.terrain() == AgeRuntimeProfile.Terrain.VOID) { if (profile.terrain() == AgeRuntimeProfile.Terrain.VOID) {
FlatLevelGeneratorSettings settings = new FlatLevelGeneratorSettings( FlatLevelGeneratorSettings settings = new FlatLevelGeneratorSettings(
@@ -367,7 +384,7 @@ public final class AgeDimensionService {
); );
settings.updateLayers(); settings.updateLayers();
return age.generationVersion() < AgeDefinition.LEGACY_GENERATOR_CUTOFF return age.generationVersion() < AgeDefinition.LEGACY_GENERATOR_CUTOFF
? new FlatLevelSource(settings) : new AgeFlatChunkGenerator(biomeSource, settings, features, age.seed(), libraryAgeSymbols); ? new FlatLevelSource(settings) : new AgeFlatChunkGenerator(biomeSource, settings, features, age.seed(), libraryAgeSymbols, AgeFlooding.requested(age.plan()));
} }
var noiseSettings = server.registryAccess().lookupOrThrow(Registries.NOISE_SETTINGS); var noiseSettings = server.registryAccess().lookupOrThrow(Registries.NOISE_SETTINGS);
@@ -376,11 +393,12 @@ public final class AgeDimensionService {
NoiseGeneratorSettings baseSettings = noiseSettings.getOrThrow(settingsKey).value(); NoiseGeneratorSettings baseSettings = noiseSettings.getOrThrow(settingsKey).value();
Holder<NoiseGeneratorSettings> settings = Holder.direct(withBiomeMaterialRules(baseSettings)); Holder<NoiseGeneratorSettings> settings = Holder.direct(withBiomeMaterialRules(baseSettings));
boolean caveTerrain = AgeBiomeSelection.isCave(profile); boolean caveTerrain = AgeBiomeSelection.isCave(profile);
if (caveTerrain) settings = Holder.direct(dryCaveSettings(settings.value()));
return age.generationVersion() < AgeDefinition.LEGACY_GENERATOR_CUTOFF return age.generationVersion() < AgeDefinition.LEGACY_GENERATOR_CUTOFF
? new NoiseBasedChunkGenerator(biomeSource, settings) ? new NoiseBasedChunkGenerator(biomeSource, settings)
: new AgeFeatureChunkGenerator(biomeSource, settings, features, age.seed(), : new AgeFeatureChunkGenerator(biomeSource, settings, features, age.seed(),
caveTerrain, caveTerrain ? TerraBlenderBiomes.nether(server.registryAccess()) : List.of(), caveTerrain, caveTerrain ? TerraBlenderBiomes.nether(server.registryAccess()) : List.of(),
libraryAgeSymbols); libraryAgeSymbols, AgeFlooding.requested(age.plan()));
} }
/** Freeze the Age's authoring/result pages into the generator; worldgen never reads SavedData. */ /** Freeze the Age's authoring/result pages into the generator; worldgen never reads SavedData. */
@@ -415,6 +433,13 @@ public final class AgeDimensionService {
return ids.stream().filter(id -> SymbolCatalog.isKnown(new SymbolReference(id))).toList(); return ids.stream().filter(id -> SymbolCatalog.isKnown(new SymbolReference(id))).toList();
} }
static NoiseGeneratorSettings dryCaveSettings(NoiseGeneratorSettings base) {
return new NoiseGeneratorSettings(base.noiseSettings(), base.defaultBlock(),
Blocks.AIR.defaultBlockState(), base.noiseRouter(), base.surfaceRule(), base.spawnTarget(),
base.noiseSettings().minY() - 1, base.disableMobGeneration(), false,
base.oreVeinsEnabled(), base.useLegacyRandomSource());
}
private static NoiseGeneratorSettings withBiomeMaterialRules(NoiseGeneratorSettings base) { private static NoiseGeneratorSettings withBiomeMaterialRules(NoiseGeneratorSettings base) {
SurfaceRules.RuleSource biomeMaterials = SurfaceRules.sequence( SurfaceRules.RuleSource biomeMaterials = SurfaceRules.sequence(
SurfaceRules.ifTrue( SurfaceRules.ifTrue(
@@ -0,0 +1,43 @@
package net.dnorberg.rivencraft.book;
import net.dnorberg.rivencraft.shared.FloodingRules;
import net.dnorberg.rivencraft.writing.SymbolSemantics;
import net.minecraft.core.BlockPos;
import net.minecraft.tags.FluidTags;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.chunk.ChunkAccess;
/** Frozen authored water surface applied after terrain, carvers and decorations. */
public final class AgeFlooding {
private AgeFlooding() {}
public static int requested(AgeGenerationPlan plan) {
if (plan == null) return FloodingRules.NONE;
return FloodingRules.requested(plan.symbols().stream()
.sorted(java.util.Comparator.comparingInt(AgeGenerationPlan.ResolvedSymbol::index))
.map(symbol -> symbol.semantics().role() == SymbolSemantics.Role.COLOR_NUMBER
? (int) ((SymbolSemantics.NumberValue) symbol.semantics().value()).amount()
: symbol.semantics().role() == SymbolSemantics.Role.FLOODING
? FloodingRules.FLOODED : FloodingRules.OTHER).toList());
}
public static void apply(ChunkAccess chunk, int requested) {
int surface = FloodingRules.surface(requested, chunk.getMinBuildHeight(), chunk.getMaxBuildHeight());
if (surface == FloodingRules.NONE) return;
BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos();
int startX = chunk.getPos().getMinBlockX(), startZ = chunk.getPos().getMinBlockZ();
for (int x = 0; x < 16; x++) for (int z = 0; z < 16; z++) {
for (int y = chunk.getMinBuildHeight(); y < chunk.getMaxBuildHeight(); y++) {
pos.set(startX + x, y, startZ + z);
var state = chunk.getBlockState(pos);
if (y <= surface && state.isAir())
chunk.setBlockState(pos, Blocks.WATER.defaultBlockState(), false);
else if (state.hasProperty(BlockStateProperties.WATERLOGGED))
chunk.setBlockState(pos, state.setValue(BlockStateProperties.WATERLOGGED, y <= surface), false);
else if (y > surface && state.getFluidState().is(FluidTags.WATER))
chunk.setBlockState(pos, Blocks.AIR.defaultBlockState(), false);
}
}
}
}
@@ -0,0 +1,85 @@
package net.dnorberg.rivencraft.book;
import com.google.gson.JsonElement;
import com.mojang.serialization.JsonOps;
import java.util.List;
import java.util.Optional;
import net.dnorberg.rivencraft.world.AgeFlatChunkGenerator;
import net.minecraft.core.registries.Registries;
import net.minecraft.gametest.framework.GameTest;
import net.minecraft.gametest.framework.GameTestHelper;
import net.minecraft.resources.ResourceLocation;
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.levelgen.Heightmap;
import net.minecraft.world.level.levelgen.flat.FlatLevelGeneratorSettings;
import net.neoforged.neoforge.gametest.GameTestHolder;
import net.neoforged.neoforge.gametest.PrefixGameTestTemplate;
/** Focused, storage-free checks; real Flat Age travel/reload remains player validation. */
@GameTestHolder("rivencraft_archive_flat")
@PrefixGameTestTemplate(false)
public final class FlatOriginGameTests {
private FlatOriginGameTests() {}
@GameTest(template = "empty")
public static void flatLayersAndAuthoredBiomeSurviveCodecReload(GameTestHelper helper) {
var profile = AgeRuntimeProfiles.resolve(AgeGenerationProfiles.FLAT);
var settings = AgeDimensionService.flatSettings(helper.getLevel().getServer(), profile);
var desert = helper.getLevel().registryAccess().lookupOrThrow(Registries.BIOME)
.getOrThrow(Biomes.DESERT);
var generator = new AgeFlatChunkGenerator(new FixedBiomeSource(desert), settings);
var ops = helper.getLevel().registryAccess().createSerializationContext(JsonOps.INSTANCE);
JsonElement saved = AgeFlatChunkGenerator.CODEC.codec().encodeStart(ops, generator).getOrThrow();
var restored = AgeFlatChunkGenerator.CODEC.codec().parse(ops, saved).getOrThrow();
var height = LevelHeightAccessor.create(-64, 384);
assertSurface(helper, generator, height);
assertSurface(helper, restored, height);
helper.assertTrue(restored.getBiomeSource().possibleBiomes().stream().allMatch(b -> b.is(Biomes.DESERT)),
"Reload must retain the authored Desert biome");
helper.succeed();
}
@GameTest(template = "empty")
public static void zeroMinimumDoesNotReceiveAirPadding(GameTestHelper helper) {
var flat = AgeRuntimeProfiles.resolve(AgeGenerationProfiles.FLAT);
var profile = new AgeRuntimeProfile(flat.schemaVersion(), flat.terrain(), flat.noiseSettings(),
flat.biomePreset(), ResourceLocation.withDefaultNamespace("the_nether"));
var settings = AgeDimensionService.flatSettings(helper.getLevel().getServer(), profile);
var biome = helper.getLevel().registryAccess().lookupOrThrow(Registries.BIOME).getOrThrow(Biomes.PLAINS);
assertSurface(helper, new AgeFlatChunkGenerator(new FixedBiomeSource(biome), settings),
LevelHeightAccessor.create(0, 256));
helper.succeed();
}
@GameTest(template = "empty")
public static void voidColumnAndSpawnHeightRemainEmpty(GameTestHelper helper) {
var biome = helper.getLevel().registryAccess().lookupOrThrow(Registries.BIOME).getOrThrow(Biomes.THE_VOID);
var settings = new FlatLevelGeneratorSettings(Optional.empty(), biome, List.of());
settings.updateLayers();
var generator = new AgeFlatChunkGenerator(new FixedBiomeSource(biome), settings);
var height = LevelHeightAccessor.create(-64, 384);
helper.assertValueEqual(generator.getSpawnHeight(height), -64, "Void keeps its empty-column spawn metadata");
helper.assertValueEqual(generator.getBaseHeight(0, 0, Heightmap.Types.WORLD_SURFACE_WG, height, null),
-64, "Void must not acquire flat ground");
helper.assertTrue(generator.getBaseColumn(0, 0, height, null).getBlock(0).isAir(),
"Void must remain empty at Y=0");
helper.succeed();
}
private static void assertSurface(GameTestHelper helper, AgeFlatChunkGenerator generator,
LevelHeightAccessor height) {
var column = generator.getBaseColumn(0, 0, height, null);
helper.assertTrue(column.getBlock(-1).isAir(), "Flat ground must have air below Y=0");
helper.assertTrue(column.getBlock(0).is(Blocks.BEDROCK), "Bedrock must be at Y=0");
helper.assertTrue(column.getBlock(1).is(Blocks.DIRT) && column.getBlock(2).is(Blocks.DIRT),
"Dirt must occupy Y=1 and Y=2");
helper.assertTrue(column.getBlock(3).is(Blocks.GRASS_BLOCK), "Grass must be at Y=3");
helper.assertTrue(column.getBlock(4).isAir(), "Arrival at Y=4 must have headroom");
helper.assertValueEqual(generator.getSpawnHeight(height), 4, "Flat spawn metadata must be above the surface");
helper.assertValueEqual(generator.getBaseHeight(0, 0, Heightmap.Types.WORLD_SURFACE_WG, height, null),
4, "Surface height queries must agree with spawn metadata");
}
}
@@ -0,0 +1,132 @@
package net.dnorberg.rivencraft.book;
import java.util.List;
import java.util.ArrayList;
import net.dnorberg.rivencraft.shared.FloodingRules;
import net.dnorberg.rivencraft.item.PageItem;
import net.dnorberg.rivencraft.writing.*;
import net.dnorberg.rivencraft.world.AgeFlatChunkGenerator;
import net.minecraft.core.BlockPos;
import net.minecraft.core.registries.Registries;
import net.minecraft.gametest.framework.GameTest;
import net.minecraft.gametest.framework.GameTestHelper;
import net.minecraft.resources.ResourceLocation;
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.ProtoChunk;
import net.minecraft.world.level.chunk.UpgradeData;
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
import com.mojang.serialization.JsonOps;
import net.neoforged.neoforge.gametest.GameTestHolder;
import net.neoforged.neoforge.gametest.PrefixGameTestTemplate;
@GameTestHolder("rivencraft_archive_flood")
@PrefixGameTestTemplate(false)
public final class FloodedGameTests {
private FloodedGameTests() {}
private static WritingEntry page(String id) {
return WritingEntry.symbol(new SymbolReference(ResourceLocation.fromNamespaceAndPath("rivencraft", id)));
}
private static AgeGenerationPlan plan(GameTestHelper helper, String... pages) {
var entries = new ArrayList<WritingEntry>();
entries.add(WritingEntry.linkPanel());
entries.add(page("terrain/cave"));
entries.add(page("biome/lush_caves"));
entries.add(page("biome/single"));
for (String id : pages) entries.add(page(id));
var writing = new OrderedWriting(entries);
var parsed = WritingGrammar.parse(writing);
helper.assertTrue(parsed.diagnostics().stream().noneMatch(d ->
d.code() == WritingGrammar.Code.MISPLACED_MODIFIER
|| d.code() == WritingGrammar.Code.DANGLING_MODIFIER),
"A Flooded digit chain must be consumed without dangling-number penalties");
return AgeGenerationPlan.compile(writing, 107L, AgeGenerationProfiles.CAVE,
AgeTraits.LEGACY_DEFAULTS, helper.getLevel().registryAccess());
}
@GameTest(template = "empty")
public static void orderedDigitsAndPlanGeneratorPersistence(GameTestHelper helper) {
var authored = plan(helper, "number/2", "number/13", "environment/flooded");
helper.assertValueEqual(AgeFlooding.requested(authored), 63, "Base-25 digits 2,13 must mean absolute Y=63");
helper.assertValueEqual(AgeFlooding.requested(AgeGenerationPlan.load(authored.save())), 63,
"Saved writing must retain the water level");
helper.assertValueEqual(AgeFlooding.requested(plan(helper, "environment/flooded")), 63, "Default must be Y=63");
helper.assertValueEqual(AgeFlooding.requested(plan(helper, "number/2", "number/13",
"environment/flooded", "number/4", "environment/flooded")), 4,
"Last Flooded must use its own adjacent number");
helper.assertValueEqual(AgeFlooding.requested(plan(helper, "number/4", "environment/flooded",
"environment/flooded")), 63, "An unnumbered final Flooded must reset to the default");
helper.assertValueEqual(AgeFlooding.requested(plan(helper)), FloodingRules.NONE, "Flooding must be opt-in");
helper.assertValueEqual(FloodingRules.surface(Integer.MAX_VALUE, -64, 320), 315,
"Huge numbers must leave safe platform/headroom space");
helper.assertValueEqual(FloodingRules.platformFloor(24, -64, 320), 25,
"Low flooded fallback must sit just above the selected water level");
helper.assertValueEqual(FloodingRules.platformFloor(Integer.MAX_VALUE, -64, 320), 316,
"Fallback floor must be above the water and inside build height");
var registries = helper.getLevel().registryAccess();
var biome = registries.lookupOrThrow(Registries.BIOME).getOrThrow(Biomes.DESERT);
var generator = new AgeFlatChunkGenerator(new FixedBiomeSource(biome),
AgeDimensionService.flatSettings(helper.getLevel().getServer(),
AgeRuntimeProfiles.resolve(AgeGenerationProfiles.FLAT)), List.of(), 107L, List.of(), 74);
var ops = registries.createSerializationContext(JsonOps.INSTANCE);
var encoded = AgeFlatChunkGenerator.CODEC.codec().encodeStart(ops, generator).getOrThrow();
var restored = AgeFlatChunkGenerator.CODEC.codec().parse(ops, encoded).getOrThrow();
helper.assertValueEqual(restored.floodSurface(), 74, "Generator codec must freeze the authored water level");
var caveSettings = registries.lookupOrThrow(Registries.NOISE_SETTINGS)
.getOrThrow(NoiseGeneratorSettings.CAVES).value();
var caveGenerator = new net.dnorberg.rivencraft.world.AgeFeatureChunkGenerator(
new FixedBiomeSource(registries.lookupOrThrow(Registries.BIOME).getOrThrow(Biomes.LUSH_CAVES)),
net.minecraft.core.Holder.direct(AgeDimensionService.dryCaveSettings(caveSettings)),
List.of(), 107L, true, List.of(), List.of(), 74);
var caveEncoded = net.dnorberg.rivencraft.world.AgeFeatureChunkGenerator.CODEC.codec()
.encodeStart(ops, caveGenerator).getOrThrow();
var caveRestored = net.dnorberg.rivencraft.world.AgeFeatureChunkGenerator.CODEC.codec()
.parse(ops, caveEncoded).getOrThrow();
helper.assertValueEqual(caveRestored.floodSurface(), 74, "Cave generator codec must retain its water level");
helper.succeed();
}
@GameTest(template = "empty")
public static void caveOpeningsFillAtTwoHeightsWithoutReplacingSolidFeatures(GameTestHelper helper) {
var chunk = new ProtoChunk(new ChunkPos(0, 0), UpgradeData.EMPTY,
LevelHeightAccessor.create(-64, 256),
helper.getLevel().registryAccess().registryOrThrow(Registries.BIOME), null);
chunk.setBlockState(new BlockPos(2, 10, 2), Blocks.DIAMOND_BLOCK.defaultBlockState(), false);
chunk.setBlockState(new BlockPos(2, 90, 2), Blocks.STONE.defaultBlockState(), false);
chunk.setBlockState(new BlockPos(3, 60, 3), Blocks.WATER.defaultBlockState(), false);
chunk.setBlockState(new BlockPos(4, 60, 4), Blocks.OAK_FENCE.defaultBlockState()
.setValue(BlockStateProperties.WATERLOGGED, true), false);
AgeFlooding.apply(chunk, FloodingRules.NONE);
helper.assertTrue(chunk.getBlockState(new BlockPos(1, 24, 1)).isAir(), "Dry Age must remain unchanged");
AgeFlooding.apply(chunk, 24);
helper.assertTrue(chunk.getBlockState(new BlockPos(1, 24, 1)).is(Blocks.WATER), "Low surface must be Y=24");
helper.assertTrue(chunk.getBlockState(new BlockPos(1, 25, 1)).isAir(), "Low surface must stop above Y=24");
helper.assertTrue(chunk.getBlockState(new BlockPos(3, 60, 3)).isAir(), "Water above requested level must drain");
helper.assertFalse(chunk.getBlockState(new BlockPos(4, 60, 4)).getValue(BlockStateProperties.WATERLOGGED),
"Draining must preserve and dry waterlogged solid blocks");
AgeFlooding.apply(chunk, 74);
helper.assertTrue(chunk.getBlockState(new BlockPos(1, 74, 1)).is(Blocks.WATER), "High surface must be Y=74");
helper.assertTrue(chunk.getBlockState(new BlockPos(1, 75, 1)).isAir(), "High surface must stop above Y=74");
helper.assertTrue(chunk.getBlockState(new BlockPos(2, 10, 2)).is(Blocks.DIAMOND_BLOCK)
&& chunk.getBlockState(new BlockPos(2, 90, 2)).is(Blocks.STONE),
"Flooding must preserve authored material features and cave roof");
helper.succeed();
}
@GameTest(template = "empty")
public static void dryCaveDefaultsAndPublicPageFeed(GameTestHelper helper) {
var base = helper.getLevel().registryAccess().lookupOrThrow(Registries.NOISE_SETTINGS)
.getOrThrow(NoiseGeneratorSettings.CAVES).value();
var dry = AgeDimensionService.dryCaveSettings(base);
helper.assertTrue(dry.defaultFluid().isAir(), "Cave default fluid must be air");
helper.assertTrue(dry.seaLevel() < dry.noiseSettings().minY() && !dry.isAquifersEnabled(),
"Unwritten Cave terrain must not create water aquifers");
helper.assertTrue(PageItem.bundledCreativeSymbols().contains("environment/flooded"),
"Flooded must be in the generated public Creative/JEI feed");
helper.succeed();
}
}
@@ -110,9 +110,9 @@ public final class InkMixerGameTests {
helper.assertTrue(menu.getCarried().is(ModItems.PAGE.get()), "Taking result must give a Link Panel"); helper.assertTrue(menu.getCarried().is(ModItems.PAGE.get()), "Taking result must give a Link Panel");
helper.assertValueEqual(mixer.getItem(InkMixerBlockEntity.PAPER).getCount(), 1, helper.assertValueEqual(mixer.getItem(InkMixerBlockEntity.PAPER).getCount(), 1,
"Taking result must use exactly one paper"); "Taking result must use exactly one paper");
helper.assertValueEqual(mixer.inkRemaining(), 0, helper.assertValueEqual(mixer.inkRemaining(), 15,
"Taking one panel must spend the entire Ink Vial"); "Taking one panel must spend exactly one ink");
helper.assertFalse(mixer.canCreateLinkPanel(), "A second panel needs another Ink Vial"); helper.assertTrue(mixer.canCreateLinkPanel(), "Remaining ink must enable another panel");
var saved = mixer.saveWithoutMetadata(helper.getLevel().registryAccess()); var saved = mixer.saveWithoutMetadata(helper.getLevel().registryAccess());
var restored = new InkMixerBlockEntity(mixer.getBlockPos(), ModBlocks.INK_MIXER.get().defaultBlockState()); var restored = new InkMixerBlockEntity(mixer.getBlockPos(), ModBlocks.INK_MIXER.get().defaultBlockState());
restored.loadWithComponents(saved, helper.getLevel().registryAccess()); restored.loadWithComponents(saved, helper.getLevel().registryAccess());
@@ -123,20 +123,41 @@ public final class InkMixerGameTests {
} }
@GameTest(template = "empty") @GameTest(template = "empty")
public static void eachLinkPanelConsumesOneInkVial(GameTestHelper helper) { public static void oneVialProducesSixteenPanelsAndResetsEachMixture(GameTestHelper helper) {
InkMixerBlockEntity mixer = place(helper); InkMixerBlockEntity mixer = place(helper);
mixer.setItem(InkMixerBlockEntity.PAPER, new ItemStack(Items.PAPER, 3)); mixer.setItem(InkMixerBlockEntity.PAPER, new ItemStack(Items.PAPER, 16));
mixer.setItem(InkMixerBlockEntity.INK, new ItemStack(ModItems.INK_VIAL.get(), 2)); mixer.setItem(InkMixerBlockEntity.INK, new ItemStack(ModItems.INK_VIAL.get()));
helper.assertTrue(mixer.canCreateLinkPanel(), "First vial must enable the first panel"); var player = helper.makeMockServerPlayerInLevel();
helper.assertTrue(mixer.consumeLinkPanelMaterials(), "First panel must be produced"); player.moveTo(mixer.getBlockPos().getX() + 0.5, mixer.getBlockPos().getY() + 0.5,
helper.assertValueEqual(mixer.inkRemaining(), 16, "Second vial must refill after first panel"); mixer.getBlockPos().getZ() + 0.5);
helper.assertValueEqual(mixer.getItem(InkMixerBlockEntity.BOTTLES).getCount(), 2, InkMixerMenu menu = new InkMixerMenu(1, player.getInventory(), mixer);
"Both spent vials must return bottles"); for (int taken = 1; taken <= 16; taken++) {
helper.assertTrue(mixer.consumeLinkPanelMaterials(), "Second panel must be produced"); helper.assertTrue(mixer.addModifier(new ItemStack(Items.GUNPOWDER), 1),
helper.assertValueEqual(mixer.inkRemaining(), 0, "Second panel must use the whole second vial"); "Each remaining ink unit must accept a fresh additive");
helper.assertFalse(mixer.canCreateLinkPanel(), "Two vials must not make a third panel"); menu.broadcastChanges();
helper.assertValueEqual(mixer.getItem(InkMixerBlockEntity.PAPER).getCount(), 1, helper.assertValueEqual(mixer.modifierChancePermille(0), 200,
"Each panel must also use one paper"); "Previewing the panel must preserve the mixture");
menu.setCarried(ItemStack.EMPTY);
menu.clicked(InkMixerMenu.RESULT, 0, ClickType.PICKUP, player);
helper.assertTrue(menu.getCarried().is(ModItems.PAGE.get()),
"Every pickup must produce a panel");
helper.assertValueEqual(menu.getCarried().getCount(), 1,
"Each pickup must produce exactly one panel");
helper.assertValueEqual(mixer.inkRemaining(), 16 - taken,
"Every pickup must consume exactly one ink");
helper.assertValueEqual(mixer.getItem(InkMixerBlockEntity.PAPER).getCount(), 16 - taken,
"Every pickup must consume exactly one paper");
for (int index = 0; index < 3; index++)
helper.assertValueEqual(mixer.modifierChancePermille(index), 0,
"Taking each panel must reset every modifier chance");
helper.assertTrue(menu.getSlot(InkMixerMenu.RESULT).hasItem() == (taken < 16),
"Output must refresh immediately and disappear when inputs run out");
}
helper.assertValueEqual(mixer.getItem(InkMixerBlockEntity.BOTTLES).getCount(), 1,
"One vial must return exactly one glass bottle");
helper.assertTrue(mixer.getItem(InkMixerBlockEntity.BOTTLES).is(Items.GLASS_BOTTLE),
"The vial exchange must use vanilla glass bottles");
helper.assertFalse(mixer.consumeLinkPanelMaterials(), "A seventeenth panel must fail");
helper.succeed(); helper.succeed();
} }
@@ -2,6 +2,8 @@ package net.dnorberg.rivencraft.world;
import com.mojang.serialization.Codec; import com.mojang.serialization.Codec;
import com.mojang.serialization.MapCodec; import com.mojang.serialization.MapCodec;
import net.dnorberg.rivencraft.book.AgeFlooding;
import net.dnorberg.rivencraft.shared.FloodingRules;
import com.mojang.serialization.codecs.RecordCodecBuilder; import com.mojang.serialization.codecs.RecordCodecBuilder;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@@ -62,7 +64,9 @@ public final class AgeFeatureChunkGenerator extends NoiseBasedChunkGenerator {
ResourceLocation.CODEC.listOf().optionalFieldOf("nether_biomes", List.of()) ResourceLocation.CODEC.listOf().optionalFieldOf("nether_biomes", List.of())
.forGetter(generator -> generator.netherBiomeIds), .forGetter(generator -> generator.netherBiomeIds),
ResourceLocation.CODEC.listOf().optionalFieldOf("library_age_symbols", List.of()) ResourceLocation.CODEC.listOf().optionalFieldOf("library_age_symbols", List.of())
.forGetter(generator -> generator.libraryAgeSymbols)) .forGetter(generator -> generator.libraryAgeSymbols),
Codec.INT.optionalFieldOf("flood_surface", FloodingRules.NONE)
.forGetter(generator -> generator.floodSurface))
.apply(instance, AgeFeatureChunkGenerator::new)); .apply(instance, AgeFeatureChunkGenerator::new));
private final Holder<NoiseGeneratorSettings> settings; private final Holder<NoiseGeneratorSettings> settings;
@@ -71,6 +75,7 @@ public final class AgeFeatureChunkGenerator extends NoiseBasedChunkGenerator {
private final boolean netherCaveMaterials; private final boolean netherCaveMaterials;
private final List<ResourceLocation> netherBiomeIds; private final List<ResourceLocation> netherBiomeIds;
private final List<ResourceLocation> libraryAgeSymbols; private final List<ResourceLocation> libraryAgeSymbols;
private final int floodSurface;
public AgeFeatureChunkGenerator(BiomeSource biomes, Holder<NoiseGeneratorSettings> settings, public AgeFeatureChunkGenerator(BiomeSource biomes, Holder<NoiseGeneratorSettings> settings,
List<AgeFeatureSelection.Choice> features, long ageSeed, List<AgeFeatureSelection.Choice> features, long ageSeed,
@@ -82,6 +87,14 @@ public final class AgeFeatureChunkGenerator extends NoiseBasedChunkGenerator {
List<AgeFeatureSelection.Choice> features, long ageSeed, List<AgeFeatureSelection.Choice> features, long ageSeed,
boolean netherCaveMaterials, List<ResourceLocation> netherBiomeIds, boolean netherCaveMaterials, List<ResourceLocation> netherBiomeIds,
List<ResourceLocation> libraryAgeSymbols) { List<ResourceLocation> libraryAgeSymbols) {
this(biomes, settings, features, ageSeed, netherCaveMaterials, netherBiomeIds,
libraryAgeSymbols, FloodingRules.NONE);
}
public AgeFeatureChunkGenerator(BiomeSource biomes, Holder<NoiseGeneratorSettings> settings,
List<AgeFeatureSelection.Choice> features, long ageSeed,
boolean netherCaveMaterials, List<ResourceLocation> netherBiomeIds,
List<ResourceLocation> libraryAgeSymbols, int floodSurface) {
super(biomes, settings); super(biomes, settings);
this.settings = settings; this.settings = settings;
this.features = List.copyOf(features); this.features = List.copyOf(features);
@@ -89,8 +102,10 @@ public final class AgeFeatureChunkGenerator extends NoiseBasedChunkGenerator {
this.netherCaveMaterials = netherCaveMaterials; this.netherCaveMaterials = netherCaveMaterials;
this.netherBiomeIds = List.copyOf(netherBiomeIds); this.netherBiomeIds = List.copyOf(netherBiomeIds);
this.libraryAgeSymbols = List.copyOf(libraryAgeSymbols); this.libraryAgeSymbols = List.copyOf(libraryAgeSymbols);
this.floodSurface = floodSurface;
} }
public int floodSurface() { return floodSurface; }
public List<AgeFeatureSelection.Choice> ageFeatures() { return features; } public List<AgeFeatureSelection.Choice> ageFeatures() { return features; }
@Override @Override
@@ -267,5 +282,6 @@ public final class AgeFeatureChunkGenerator extends NoiseBasedChunkGenerator {
// Place after vanilla and authored decoration so later features cannot grow through // Place after vanilla and authored decoration so later features cannot grow through
// the building; the library check preserves existing solid structures. // the building; the library check preserves existing solid structures.
if (!netherCaveMaterials) MystcraftLibraryFeature.generate(level, chunk, ageSeed, libraryAgeSymbols); if (!netherCaveMaterials) MystcraftLibraryFeature.generate(level, chunk, ageSeed, libraryAgeSymbols);
AgeFlooding.apply(chunk, floodSurface);
} }
} }
@@ -2,6 +2,8 @@ package net.dnorberg.rivencraft.world;
import com.mojang.serialization.Codec; import com.mojang.serialization.Codec;
import com.mojang.serialization.MapCodec; import com.mojang.serialization.MapCodec;
import net.dnorberg.rivencraft.book.AgeFlooding;
import net.dnorberg.rivencraft.shared.FloodingRules;
import com.mojang.serialization.codecs.RecordCodecBuilder; import com.mojang.serialization.codecs.RecordCodecBuilder;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@@ -44,13 +46,16 @@ public final class AgeFlatChunkGenerator extends ChunkGenerator {
.forGetter(generator -> generator.features), .forGetter(generator -> generator.features),
Codec.LONG.optionalFieldOf("age_seed", 0L).forGetter(generator -> generator.ageSeed), Codec.LONG.optionalFieldOf("age_seed", 0L).forGetter(generator -> generator.ageSeed),
ResourceLocation.CODEC.listOf().optionalFieldOf("library_age_symbols", List.of()) ResourceLocation.CODEC.listOf().optionalFieldOf("library_age_symbols", List.of())
.forGetter(generator -> generator.libraryAgeSymbols)) .forGetter(generator -> generator.libraryAgeSymbols),
Codec.INT.optionalFieldOf("flood_surface", FloodingRules.NONE)
.forGetter(generator -> generator.floodSurface))
.apply(instance, AgeFlatChunkGenerator::new)); .apply(instance, AgeFlatChunkGenerator::new));
private final FlatLevelGeneratorSettings settings; private final FlatLevelGeneratorSettings settings;
private final List<AgeFeatureSelection.Choice> features; private final List<AgeFeatureSelection.Choice> features;
private final long ageSeed; private final long ageSeed;
private final List<ResourceLocation> libraryAgeSymbols; private final List<ResourceLocation> libraryAgeSymbols;
private final int floodSurface;
public AgeFlatChunkGenerator(BiomeSource biomeSource, FlatLevelGeneratorSettings settings) { public AgeFlatChunkGenerator(BiomeSource biomeSource, FlatLevelGeneratorSettings settings) {
this(biomeSource, settings, List.of(), 0L); this(biomeSource, settings, List.of(), 0L);
@@ -64,14 +69,22 @@ public final class AgeFlatChunkGenerator extends ChunkGenerator {
public AgeFlatChunkGenerator(BiomeSource biomeSource, FlatLevelGeneratorSettings settings, public AgeFlatChunkGenerator(BiomeSource biomeSource, FlatLevelGeneratorSettings settings,
List<AgeFeatureSelection.Choice> features, long ageSeed, List<AgeFeatureSelection.Choice> features, long ageSeed,
List<ResourceLocation> libraryAgeSymbols) { List<ResourceLocation> libraryAgeSymbols) {
this(biomeSource, settings, features, ageSeed, libraryAgeSymbols, FloodingRules.NONE);
}
public AgeFlatChunkGenerator(BiomeSource biomeSource, FlatLevelGeneratorSettings settings,
List<AgeFeatureSelection.Choice> features, long ageSeed,
List<ResourceLocation> libraryAgeSymbols, int floodSurface) {
super(biomeSource, Util.memoize(settings::adjustGenerationSettings)); super(biomeSource, Util.memoize(settings::adjustGenerationSettings));
this.settings = settings; this.settings = settings;
this.features = List.copyOf(features); this.features = List.copyOf(features);
this.ageSeed = ageSeed; this.ageSeed = ageSeed;
this.libraryAgeSymbols = List.copyOf(libraryAgeSymbols); this.libraryAgeSymbols = List.copyOf(libraryAgeSymbols);
this.floodSurface = floodSurface;
} }
public FlatLevelGeneratorSettings settings() { return settings; } public FlatLevelGeneratorSettings settings() { return settings; }
public int floodSurface() { return floodSurface; }
public List<AgeFeatureSelection.Choice> ageFeatures() { return features; } public List<AgeFeatureSelection.Choice> ageFeatures() { return features; }
@Override @Override
@@ -144,6 +157,7 @@ public final class AgeFlatChunkGenerator extends ChunkGenerator {
ObelisksFeature.generate(level, chunk, ageSeed, choice, obeliskOccurrence++); ObelisksFeature.generate(level, chunk, ageSeed, choice, obeliskOccurrence++);
} }
MystcraftLibraryFeature.generate(level, chunk, ageSeed, libraryAgeSymbols); MystcraftLibraryFeature.generate(level, chunk, ageSeed, libraryAgeSymbols);
AgeFlooding.apply(chunk, floodSurface);
} }
@Override @Override
@@ -97,6 +97,7 @@ public record SymbolSemantics(Role role, Value value) {
BLOCK("block", Kind.RESOURCE), BLOCK("block", Kind.RESOURCE),
FEATURE("feature", Kind.RESOURCE), FEATURE("feature", Kind.RESOURCE),
ENVIRONMENT("environment", Kind.CHOICE, "accelerated"), ENVIRONMENT("environment", Kind.CHOICE, "accelerated"),
FLOODING("flooding", Kind.CHOICE, "flooded"),
CORRUPTED("corrupted", Kind.CHOICE, "large", "medium", "small"); CORRUPTED("corrupted", Kind.CHOICE, "large", "medium", "small");
private final String id; private final String id;
@@ -76,12 +76,12 @@ public final class WritingGrammar {
symbols.add(parsed); symbols.add(parsed);
if (pendingNumber != null && !numberTarget(role) && role != Role.COLOR_NUMBER) { if (pendingNumber != null && !numberTarget(role) && role != Role.COLOR_NUMBER) {
diagnostics.add(new Diagnostic(Code.MISPLACED_MODIFIER, pendingNumber.index(), diagnostics.add(new Diagnostic(Code.MISPLACED_MODIFIER, pendingNumber.index(),
"A number page must be immediately followed by a color or celestial modifier page")); "A number page must be immediately followed by a color, celestial modifier or Flooded page"));
pendingNumber = null; pendingNumber = null;
} }
if (role == Role.COLOR_NUMBER) { if (role == Role.COLOR_NUMBER) {
if (pendingNumber != null) diagnostics.add(new Diagnostic(Code.MISPLACED_MODIFIER, if (pendingNumber != null && !numberRunTargetsFlooded(writing, index, resolver)) diagnostics.add(new Diagnostic(Code.MISPLACED_MODIFIER,
pendingNumber.index(), "A number page must be immediately followed by a color or celestial modifier page")); pendingNumber.index(), "A number page must be immediately followed by a color, celestial modifier or Flooded page"));
pendingNumber = parsed; pendingNumber = parsed;
} else if (numberTarget(role)) { } else if (numberTarget(role)) {
pendingNumber = null; pendingNumber = null;
@@ -136,7 +136,7 @@ public final class WritingGrammar {
} }
} }
if (pendingNumber != null) diagnostics.add(new Diagnostic(Code.DANGLING_MODIFIER, if (pendingNumber != null) diagnostics.add(new Diagnostic(Code.DANGLING_MODIFIER,
pendingNumber.index(), "A number page must be followed by a color or celestial modifier page")); pendingNumber.index(), "A number page must be followed by a color, celestial modifier or Flooded page"));
if (panels == 0) diagnostics.add(new Diagnostic(Code.MISSING_PANEL, -1, if (panels == 0) diagnostics.add(new Diagnostic(Code.MISSING_PANEL, -1,
"Add a Link Panel as the first page")); "Add a Link Panel as the first page"));
for (ParsedSymbol dangling : pendingModifiers.values()) { for (ParsedSymbol dangling : pendingModifiers.values()) {
@@ -178,7 +178,7 @@ public final class WritingGrammar {
private static boolean singular(Role role) { private static boolean singular(Role role) {
return switch (role) { return switch (role) {
case TERRAIN, BIOME_CONTROLLER, WEATHER, SEASON, LIGHTING, SKY -> true; case TERRAIN, BIOME_CONTROLLER, WEATHER, SEASON, LIGHTING, SKY, FLOODING -> true;
default -> false; default -> false;
}; };
} }
@@ -189,10 +189,23 @@ public final class WritingGrammar {
|| role == Role.CELESTIAL_COLOR || role == Role.DIRECTION_MODIFIER; || role == Role.CELESTIAL_COLOR || role == Role.DIRECTION_MODIFIER;
} }
private static boolean numberRunTargetsFlooded(OrderedWriting writing, int index,
Function<SymbolReference, Optional<SymbolDefinition>> resolver) {
for (int next = index + 1; next < writing.entries().size(); next++) {
var reference = writing.entries().get(next).symbol();
if (reference.isEmpty()) return false;
var semantics = resolver.apply(reference.get()).flatMap(SymbolDefinition::semantics);
if (semantics.isEmpty()) return false;
Role role = semantics.get().role();
if (role != Role.COLOR_NUMBER) return role == Role.FLOODING;
}
return false;
}
private static boolean numberTarget(Role role) { private static boolean numberTarget(Role role) {
return role == Role.COLOR || role == Role.PERIOD_MODIFIER return role == Role.COLOR || role == Role.PERIOD_MODIFIER
|| role == Role.ANGLE_MODIFIER || role == Role.PHASE_MODIFIER || role == Role.ANGLE_MODIFIER || role == Role.PHASE_MODIFIER
|| role == Role.SIZE_MODIFIER; || role == Role.SIZE_MODIFIER || role == Role.FLOODING;
} }
private static int stage(Role role) { private static int stage(Role role) {
@@ -208,7 +221,7 @@ public final class WritingGrammar {
case PERIOD_MODIFIER, ANGLE_MODIFIER, PHASE_MODIFIER, SIZE_MODIFIER, case PERIOD_MODIFIER, ANGLE_MODIFIER, PHASE_MODIFIER, SIZE_MODIFIER,
CELESTIAL_COLOR, DIRECTION_MODIFIER -> 7; CELESTIAL_COLOR, DIRECTION_MODIFIER -> 7;
case CELESTIAL -> 8; case CELESTIAL -> 8;
case BLOCK, FEATURE, ENVIRONMENT, CORRUPTED -> 9; case BLOCK, FEATURE, ENVIRONMENT, CORRUPTED, FLOODING -> 9;
}; };
} }
@@ -419,7 +419,7 @@
"jei.rivencraft.writing": "Rivencraft Writing", "jei.rivencraft.writing": "Rivencraft Writing",
"jei.rivencraft.writing.link_panel_hand": "Hold paper and an Ink Vial in opposite hands; use the vial to make a Link Panel.", "jei.rivencraft.writing.link_panel_hand": "Hold paper and an Ink Vial in opposite hands; use the vial to make a Link Panel.",
"jei.rivencraft.ink_mixer": "Ink Mixer", "jei.rivencraft.ink_mixer": "Ink Mixer",
"jei.rivencraft.ink_mixer.usage": "Paper + ink makes a Link Panel. One vial fills 16 ink; each panel uses the configured ink cost. The empty vial returns as a glass bottle.", "jei.rivencraft.ink_mixer.usage": "One paper + one ink makes a Link Panel. One vial fills 16 ink and makes 16 panels. The empty vial returns as a glass bottle.",
"jei.rivencraft.ink_mixer.additive": "Click this additive into the ink basin: %s. Effects roll when the panel is taken.", "jei.rivencraft.ink_mixer.additive": "Click this additive into the ink basin: %s. Effects roll when the panel is taken.",
"jei.rivencraft.ink_mixer.effect": "%s %s%%", "jei.rivencraft.ink_mixer.effect": "%s %s%%",
"jei.rivencraft.writing.copy": "At a Writing Desk, select a stored Page, add paper and ink, then take the copy. The source Page stays.", "jei.rivencraft.writing.copy": "At a Writing Desk, select a stored Page, add paper and ink, then take the copy. The source Page stays.",
@@ -473,5 +473,7 @@
"advancement.rivencraft.enter_age.title": "The Journey Begins", "advancement.rivencraft.enter_age.title": "The Journey Begins",
"advancement.rivencraft.enter_age.description": "Safely link into an Age you have written.", "advancement.rivencraft.enter_age.description": "Safely link into an Age you have written.",
"advancement.rivencraft.open_portal.title": "A Window Between Ages", "advancement.rivencraft.open_portal.title": "A Window Between Ages",
"advancement.rivencraft.open_portal.description": "Activate a Crystal Portal with a bound book." "advancement.rivencraft.open_portal.description": "Activate a Crystal Portal with a bound book.",
"symbol.rivencraft.environment.flooded": "Flooded",
"symbol.rivencraft.environment.flooded.description": "Fill open space with water up to Y=63, or the base-25 Number Pages immediately before this page. Works in Cave terrain. Last Flooded wins; heights are bounded for safe arrival."
} }
@@ -0,0 +1,11 @@
{
"schema_version": 2,
"name": "symbol.rivencraft.environment.flooded",
"description": "symbol.rivencraft.environment.flooded.description",
"category": "rivencraft:environment",
"semantics": {
"role": "flooding",
"value": "flooded"
},
"poem": "Environment Flow Static Elevate"
}