Public Access
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
78a0f7ee51 | ||
|
|
dd219bb58a | ||
|
|
b48cc8a6ce |
No files matched your search
@@ -8,9 +8,13 @@ The bootstrap, books/linking, Ages, writing-system, and Age-grammar milestones a
|
|||||||
The writing system uses a data-pack symbol catalog and persistent
|
The writing system uses a data-pack symbol catalog and persistent
|
||||||
ordered-writing model. Linking Books and Descriptive Books create persistent
|
ordered-writing model. Linking Books and Descriptive Books create persistent
|
||||||
Ages from either authored supported symbols or seeded random completion.
|
Ages from either authored supported symbols or seeded random completion.
|
||||||
Instability and the remaining unsupported Legacy symbol effects have not been
|
Milestone 6 instability work is in progress: Ages persist frozen instability
|
||||||
ported yet. The [Milestone 5 acceptance record](docs/MILESTONE_5_ACCEPTANCE.md)
|
scores and provider plans, and the bounded runtime implements status effects,
|
||||||
lists the supported grammar, optional integrations, and limits.
|
colored decay, lightning, explosions, meteors, burning, and erosion. The
|
||||||
|
[Milestone 5 acceptance record](docs/MILESTONE_5_ACCEPTANCE.md) lists the
|
||||||
|
supported grammar, optional integrations, and limits; the
|
||||||
|
[instability runtime policy](docs/INSTABILITY_RUNTIME.md) records the current
|
||||||
|
effects and modern safety boundaries.
|
||||||
|
|
||||||
Milestone 4 now includes stackable blank Pages plus server-created symbol,
|
Milestone 4 now includes stackable blank Pages plus server-created symbol,
|
||||||
unresolved-symbol, and baseline link-panel states. Page visuals follow the
|
unresolved-symbol, and baseline link-panel states. Page visuals follow the
|
||||||
|
|||||||
@@ -2,8 +2,10 @@
|
|||||||
|
|
||||||
Every newly created Age now gets a version-1 `Instability` compound inside its server-owned `rivencraft_ages` saved definition. It contains the total `Score` and an ordered `Breakdown` of reason, original page index (zero-based, or -1 for an Age-wide cause), points, and explanation. `AgeRegistrySavedData.instability(UUID)` is the read-only server query. No client tooltip or live data-pack lookup is needed to read a saved score.
|
Every newly created Age now gets a version-1 `Instability` compound inside its server-owned `rivencraft_ages` saved definition. It contains the total `Score` and an ordered `Breakdown` of reason, original page index (zero-based, or -1 for an Age-wide cause), points, and explanation. `AgeRegistrySavedData.instability(UUID)` is the read-only server query. No client tooltip or live data-pack lookup is needed to read a saved score.
|
||||||
|
|
||||||
The baseline is explicitly zero for page-free and Link-Panel-only random Ages, and for authored Ages. Incomplete writing receives seed-based completion and a zero-point explanatory entry. Supported writing defects use the provisional Milestone 6 grammar costs: duplicate/conflicting single-choice pages +500, out-of-order or misplaced pages +100. Legacy's audited bright-lighting symbol adds +500 whether authored or seed-selected. Other balance costs are not guessed for symbols that Rivencraft has not implemented. The score is not yet an active hazard or effect selection.
|
The baseline is explicitly zero for page-free and Link-Panel-only random Ages, and for authored Ages. Incomplete writing receives seed-based completion and a zero-point explanatory entry. Supported writing defects use the provisional Milestone 6 grammar costs: duplicate/conflicting single-choice pages +500, out-of-order or misplaced pages +100. Legacy's audited Bright Lighting symbol adds +500 for every occurrence, including a seed-generated controller. Mineshafts, Nether Fortresses, Strongholds, and Villages add +100 for the fourth and every later occurrence. By project balance decision, Bastions, Trial Chambers, Ancient Cities, Shipwrecks, Ocean Ruins, Pillager Outposts, Ruined Portals, Nether Fossils, Buried Treasure, and Trail Ruins follow that same rule. The first three occurrences and all other audited Legacy feature symbols have no direct page cost. An authored structure may override its vanilla biome eligibility; every structure-page occurrence adds +100 if **any** selected biome is unsupported, even when another selected biome is compatible. Seed completion still prefers compatible biomes and therefore avoids that cost when it can. Other modern-only features remain neutral. The frozen score selects a deterministic, persisted provider plan through the Milestone 6 runtime. Registered handlers apply that plan only inside loaded Rivencraft Ages and remain subject to the documented scheduler and effect-specific safety bounds.
|
||||||
|
|
||||||
The score is calculated after the Age plan and effective traits are chosen, then saved with the Age identity before its dimension is generated. The same UUID returns the existing definition, including the same score, on repeated use. Spawn updates preserve it. Reload only deserializes the frozen breakdown; it never reruns the current grammar or catalog. An older Age definition without `Instability` is migrated to a persisted version-1 neutral score of zero, rather than retroactively scoring its writing. A future scoring-rule change must introduce an explicit new schema/migration policy, not silently reinterpret existing Ages. Issue #66 additionally freezes a provider selection from this score; see [runtime policy](INSTABILITY_RUNTIME.md).
|
The score is calculated after the Age plan and effective traits are chosen, then saved with the Age identity before its dimension is generated. The same UUID returns the existing definition, including the same score, on repeated use. Spawn updates preserve it. Reload only deserializes the frozen breakdown; it never reruns the current grammar or catalog. An older Age definition without `Instability` is migrated to a persisted version-1 neutral score of zero, rather than retroactively scoring its writing. A future scoring-rule change must introduce an explicit new schema/migration policy, not silently reinterpret existing Ages. Issue #66 added the frozen provider selection; issues #67–#70 added the current handlers. See the [runtime policy](INSTABILITY_RUNTIME.md).
|
||||||
|
|
||||||
Unknown or unsupported pages remain invalid for *new* Ages. Their absence from a later registry does not change an already saved score. Focused GameTests cover stable/defective writing, random baseline and bright lighting, repeated identity, save round-trip, and missing-symbol/old-save behavior.
|
Unknown or unsupported pages remain invalid for *new* Ages. Their absence from a later registry does not change an already saved score. Focused GameTests cover stable/defective writing, random baseline and bright lighting, repeated identity, save round-trip, and missing-symbol/old-save behavior.
|
||||||
|
|
||||||
|
`/rivencraft age instability` inspects the Age containing the command source; an optional dimension ID inspects an unloaded or different registered Age. It reports immutable base score, stability bonus, runtime penalty, and effective score. The pinned Legacy tree defines player-death and player-presence bonus classes but does not register them as default providers, so Rivencraft leaves player-driven modifiers disabled: bonus and penalty are zero and effective equals base. There is therefore no mutable bonus save to migrate in this release. No death, PvP event, player identity, or dimension transition can transfer stability between Ages. Any future opt-in mechanic must persist separately from `Instability`, define caps and reset behavior, and must not rewrite the generation plan or frozen provider plan.
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
# Mystcraft Legacy instability audit (Milestone 6, issue #63)
|
# Mystcraft Legacy instability audit (Milestone 6, issue #63)
|
||||||
|
|
||||||
This is a behavior contract for Milestone 6, **not a completed runtime instability system**. It compares the user-provided 0.13.7.06 class files at `/home/dnorberg/Documents/mystcraft-src/mystcraft-1.12.2-0.13.7.06/` with [Mystcraft Legacy source at commit `9bc8ddc`](https://github.com/Mystcraft/Mystcraft-Legacy/tree/9bc8ddc061845df0cd5ea47f4fdef773cff786ae). Values below are source defaults, not a claim that every historical config or server used them. Rivencraft 0.5.1.0 saves a provisional writing-instability score and repaired active-page order, but has no hazard loop yet.
|
This is the behavior contract used to implement Milestone 6. It is pinned to [Mystcraft Legacy source at commit `9bc8ddc`](https://github.com/Mystcraft/Mystcraft-Legacy/tree/9bc8ddc061845df0cd5ea47f4fdef773cff786ae). Values below are source defaults, not a claim that every historical config or server used them. Rivencraft now persists frozen writing-instability scores and provider plans and runs the implemented providers through a bounded, Age-scoped scheduler. The audit remains authoritative for Legacy behavior; the linked runtime documents identify modern adaptations and remaining gaps.
|
||||||
|
|
||||||
## Score, grammar, and selection in Legacy
|
## Score, grammar, and selection in Legacy
|
||||||
|
|
||||||
@@ -15,6 +15,10 @@ Legacy's [`AgeController`](https://github.com/Mystcraft/Mystcraft-Legacy/blob/9b
|
|||||||
| Unsupported/unmatched page | Legacy logs unmatched symbols during reconstruction and skips their logic; its `AgeData.getBaseInstability()` still has a TODO for calculating instability from pages. This is not a sound compatibility contract. | Remains fatal for *new* books until semantic and runtime support exists; never silently erase the page or pretend its effect applied. Existing saved books retain their IDs. |
|
| Unsupported/unmatched page | Legacy logs unmatched symbols during reconstruction and skips their logic; its `AgeData.getBaseInstability()` still has a TODO for calculating instability from pages. This is not a sound compatibility contract. | Remains fatal for *new* books until semantic and runtime support exists; never silently erase the page or pretend its effect applied. Existing saved books retain their IDs. |
|
||||||
| Other penalties/bonuses | `AgeController.addInstability(int)` is available to symbol logic. The base/book score is persisted as a `short`; Legacy's [`InstabilityBonusManager`](https://github.com/Mystcraft/Mystcraft-Legacy/blob/9bc8ddc061845df0cd5ea47f4fdef773cff786ae/src/main/java/com/xcompwiz/mystcraft/instability/bonus/InstabilityBonusManager.java) also has dynamic player death/behavior components. | Persist a versioned score breakdown for Age writing and environmental contributions. Do not infer death/troll mechanics from the mere existence of Legacy classes. |
|
| Other penalties/bonuses | `AgeController.addInstability(int)` is available to symbol logic. The base/book score is persisted as a `short`; Legacy's [`InstabilityBonusManager`](https://github.com/Mystcraft/Mystcraft-Legacy/blob/9bc8ddc061845df0cd5ea47f4fdef773cff786ae/src/main/java/com/xcompwiz/mystcraft/instability/bonus/InstabilityBonusManager.java) also has dynamic player death/behavior components. | Persist a versioned score breakdown for Age writing and environmental contributions. Do not infer death/troll mechanics from the mere existence of Legacy classes. |
|
||||||
|
|
||||||
|
The complete Legacy `instabilityModifier` audit found direct feature-page costs only for Mineshafts, Nether Fortresses, Strongholds, and Villages. Their first three occurrences cost zero; the fourth and every later occurrence adds 100. Every other Legacy feature class inherited `SymbolBase`'s zero modifier. Rivencraft applies that exact rule to the four matching pages. By project balance decision, Bastions, Trial Chambers, Ancient Cities, Shipwrecks, Ocean Ruins, Pillager Outposts, Ruined Portals, Nether Fossils, Buried Treasure, and Trail Ruins use the same repeat rule. Matching Legacy features such as Caves, Crystal Formations, Dense Ores, Dungeons, Floating Islands, Huge Trees, Deep/Surface Lakes, Obelisks, Ravines, Skylands, Spheres, Spikes, Star Fissures, and Tendrils have no direct page cost. Legacy could still derive instability later from excess profiled blocks, especially ores, but that separate 400-chunk profiling system is intentionally not ported. Other modern-only Rivencraft features remain neutral.
|
||||||
|
|
||||||
|
Bright Lighting adds 500 for every authored occurrence. A generated Bright Lighting controller also adds 500. This is independent of the 500-point extra-controller cost, so two authored Bright Lighting pages produce 1,500 total: 500 for each symbol and 500 for the repeated controller.
|
||||||
|
|
||||||
Source for controller and modifier defaults: [`InstabilityData`](https://github.com/Mystcraft/Mystcraft-Legacy/blob/9bc8ddc061845df0cd5ea47f4fdef773cff786ae/src/main/java/com/xcompwiz/mystcraft/instability/InstabilityData.java), [`AgeController`](https://github.com/Mystcraft/Mystcraft-Legacy/blob/9bc8ddc061845df0cd5ea47f4fdef773cff786ae/src/main/java/com/xcompwiz/mystcraft/world/AgeController.java). The local 0.13.7.06 `Modifier.class` confirms `dangling_default=100`. Legacy grammar **ranks** weight which missing symbols are selected; they are not a direct instability score or deck tier. See [grammar audit](LEGACY_AGE_GRAMMAR_AUDIT.md) and [random weights](RANDOM_AGE_WEIGHTS.md).
|
Source for controller and modifier defaults: [`InstabilityData`](https://github.com/Mystcraft/Mystcraft-Legacy/blob/9bc8ddc061845df0cd5ea47f4fdef773cff786ae/src/main/java/com/xcompwiz/mystcraft/instability/InstabilityData.java), [`AgeController`](https://github.com/Mystcraft/Mystcraft-Legacy/blob/9bc8ddc061845df0cd5ea47f4fdef773cff786ae/src/main/java/com/xcompwiz/mystcraft/world/AgeController.java). The local 0.13.7.06 `Modifier.class` confirms `dangling_default=100`. Legacy grammar **ranks** weight which missing symbols are selected; they are not a direct instability score or deck tier. See [grammar audit](LEGACY_AGE_GRAMMAR_AUDIT.md) and [random weights](RANDOM_AGE_WEIGHTS.md).
|
||||||
|
|
||||||
[`InstabilityController`](https://github.com/Mystcraft/Mystcraft-Legacy/blob/9bc8ddc061845df0cd5ea47f4fdef773cff786ae/src/main/java/com/xcompwiz/mystcraft/instability/InstabilityController.java) rounds its working score toward zero to the current smallest registered positive provider cost (500 by default), then rebuilds active effects when that rounded score changes. Each seeded deck preserves its saved card order; new cards are shuffled with the Age seed. For each deck it subtracts the deck entry cost, then walks cards in order, paying each provider activation cost until the next card cannot be afforded. A provider's occurrences become its level. **Deck costs are gates, not mutually exclusive severity bands**: at high score multiple decks can contribute effects. Provider `.enabled` config can remove cards. The actual effect set cannot be inferred from a score alone without the saved deck orders and enabled providers ([`Deck`](https://github.com/Mystcraft/Mystcraft-Legacy/blob/9bc8ddc061845df0cd5ea47f4fdef773cff786ae/src/main/java/com/xcompwiz/mystcraft/instability/Deck.java), [`InstabilityManager`](https://github.com/Mystcraft/Mystcraft-Legacy/blob/9bc8ddc061845df0cd5ea47f4fdef773cff786ae/src/main/java/com/xcompwiz/mystcraft/instability/InstabilityManager.java)).
|
[`InstabilityController`](https://github.com/Mystcraft/Mystcraft-Legacy/blob/9bc8ddc061845df0cd5ea47f4fdef773cff786ae/src/main/java/com/xcompwiz/mystcraft/instability/InstabilityController.java) rounds its working score toward zero to the current smallest registered positive provider cost (500 by default), then rebuilds active effects when that rounded score changes. Each seeded deck preserves its saved card order; new cards are shuffled with the Age seed. For each deck it subtracts the deck entry cost, then walks cards in order, paying each provider activation cost until the next card cannot be afforded. A provider's occurrences become its level. **Deck costs are gates, not mutually exclusive severity bands**: at high score multiple decks can contribute effects. Provider `.enabled` config can remove cards. The actual effect set cannot be inferred from a score alone without the saved deck orders and enabled providers ([`Deck`](https://github.com/Mystcraft/Mystcraft-Legacy/blob/9bc8ddc061845df0cd5ea47f4fdef773cff786ae/src/main/java/com/xcompwiz/mystcraft/instability/Deck.java), [`InstabilityManager`](https://github.com/Mystcraft/Mystcraft-Legacy/blob/9bc8ddc061845df0cd5ea47f4fdef773cff786ae/src/main/java/com/xcompwiz/mystcraft/instability/InstabilityManager.java)).
|
||||||
@@ -35,8 +39,8 @@ These entry costs are from [`InstabilityData.initialize()`](https://github.com/M
|
|||||||
|
|
||||||
| Family | Legacy behavior | M6 disposition |
|
| Family | Legacy behavior | M6 disposition |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| Player and hostile-mob potions | Local/global blindness, fatigue, hunger, nausea, poison, slowness, weakness, wither; hostile regeneration/resistance ([`EffectPotion`](https://github.com/Mystcraft/Mystcraft-Legacy/blob/9bc8ddc061845df0cd5ea47f4fdef773cff786ae/src/main/java/com/xcompwiz/mystcraft/effects/EffectPotion.java)). | Implement in #67 with server-only, Age-scoped entity targeting and rate limits. No effects in preview/snapshot worlds. |
|
| Player and hostile-mob potions | Local/global blindness, fatigue, hunger, nausea, poison, slowness, weakness, wither; hostile regeneration/resistance ([`EffectPotion`](https://github.com/Mystcraft/Mystcraft-Legacy/blob/9bc8ddc061845df0cd5ea47f4fdef773cff786ae/src/main/java/com/xcompwiz/mystcraft/effects/EffectPotion.java)). | Implemented in #67 with server-only, Age-scoped entity targeting and rate limits. No effects run in preview/snapshot worlds. |
|
||||||
| Colored decay | Blue, purple, red, white providers place advancing decay and extra-tick it; black provider is commented out. Decay handlers differ in spread/consumption ([providers](https://github.com/Mystcraft/Mystcraft-Legacy/tree/9bc8ddc061845df0cd5ea47f4fdef773cff786ae/src/main/java/com/xcompwiz/mystcraft/instability/providers), [handlers](https://github.com/Mystcraft/Mystcraft-Legacy/tree/9bc8ddc061845df0cd5ea47f4fdef773cff786ae/src/main/java/com/xcompwiz/mystcraft/instability/decay)). | Implement bounded, reversible-by-admin world mutation in #68; exact 1.12 spread/update rates require adaptation and tests. Exclude protected spawn/portal areas. Black/green/yellow are **not** proven active Legacy providers. |
|
| Colored decay | Blue, purple, red, white providers place advancing decay and extra-tick it; black provider is commented out. Decay handlers differ in spread/consumption ([providers](https://github.com/Mystcraft/Mystcraft-Legacy/tree/9bc8ddc061845df0cd5ea47f4fdef773cff786ae/src/main/java/com/xcompwiz/mystcraft/instability/providers), [handlers](https://github.com/Mystcraft/Mystcraft-Legacy/tree/9bc8ddc061845df0cd5ea47f4fdef773cff786ae/src/main/java/com/xcompwiz/mystcraft/instability/decay)). | Implemented in #68 as bounded world mutation with protected spawn/portal areas and configurable shutdown. Black/green/yellow remain excluded because they are **not** proven active Legacy providers. |
|
||||||
| Lightning and explosions | Random per-chunk strike/explosion attempts ([`EffectLightning`](https://github.com/Mystcraft/Mystcraft-Legacy/blob/9bc8ddc061845df0cd5ea47f4fdef773cff786ae/src/main/java/com/xcompwiz/mystcraft/effects/EffectLightning.java), [`EffectExplosions`](https://github.com/Mystcraft/Mystcraft-Legacy/blob/9bc8ddc061845df0cd5ea47f4fdef773cff786ae/src/main/java/com/xcompwiz/mystcraft/effects/EffectExplosions.java)). | Implemented in #69 with separate damage/fire/griefing policies and loaded-Age bounds; see `INSTABILITY_RUNTIME.md`. |
|
| Lightning and explosions | Random per-chunk strike/explosion attempts ([`EffectLightning`](https://github.com/Mystcraft/Mystcraft-Legacy/blob/9bc8ddc061845df0cd5ea47f4fdef773cff786ae/src/main/java/com/xcompwiz/mystcraft/effects/EffectLightning.java), [`EffectExplosions`](https://github.com/Mystcraft/Mystcraft-Legacy/blob/9bc8ddc061845df0cd5ea47f4fdef773cff786ae/src/main/java/com/xcompwiz/mystcraft/effects/EffectExplosions.java)). | Implemented in #69 with separate damage/fire/griefing policies and loaded-Age bounds; see `INSTABILITY_RUNTIME.md`. |
|
||||||
| Meteor, scorching | Meteor entity spawn and sky-exposed entity ignition ([`EffectMeteor`](https://github.com/Mystcraft/Mystcraft-Legacy/blob/9bc8ddc061845df0cd5ea47f4fdef773cff786ae/src/main/java/com/xcompwiz/mystcraft/effects/EffectMeteor.java), [`EffectScorched`](https://github.com/Mystcraft/Mystcraft-Legacy/blob/9bc8ddc061845df0cd5ea47f4fdef773cff786ae/src/main/java/com/xcompwiz/mystcraft/effects/EffectScorched.java)). | #70 implements a bounded meteor descent/impact and the active `burning` card; see `INSTABILITY_ENVIRONMENTAL.md`. Legacy `meteor/roar.ogg` is reused. |
|
| Meteor, scorching | Meteor entity spawn and sky-exposed entity ignition ([`EffectMeteor`](https://github.com/Mystcraft/Mystcraft-Legacy/blob/9bc8ddc061845df0cd5ea47f4fdef773cff786ae/src/main/java/com/xcompwiz/mystcraft/effects/EffectMeteor.java), [`EffectScorched`](https://github.com/Mystcraft/Mystcraft-Legacy/blob/9bc8ddc061845df0cd5ea47f4fdef773cff786ae/src/main/java/com/xcompwiz/mystcraft/effects/EffectScorched.java)). | #70 implements a bounded meteor descent/impact and the active `burning` card; see `INSTABILITY_ENVIRONMENTAL.md`. Legacy `meteor/roar.ogg` is reused. |
|
||||||
| Crumble and erosion | Crumble maps blocks to weaker states; erosion spreads adjacent fluids and has extra lake-generation methods ([`EffectCrumble`](https://github.com/Mystcraft/Mystcraft-Legacy/blob/9bc8ddc061845df0cd5ea47f4fdef773cff786ae/src/main/java/com/xcompwiz/mystcraft/effects/EffectCrumble.java), [`EffectErosion`](https://github.com/Mystcraft/Mystcraft-Legacy/blob/9bc8ddc061845df0cd5ea47f4fdef773cff786ae/src/main/java/com/xcompwiz/mystcraft/effects/EffectErosion.java)). | #70 implements guarded fluid spread. Erosion's provider is absent from the active Legacy deck; it is deliberately enabled by default in this test slice without adding a saved deck card, per user request. |
|
| Crumble and erosion | Crumble maps blocks to weaker states; erosion spreads adjacent fluids and has extra lake-generation methods ([`EffectCrumble`](https://github.com/Mystcraft/Mystcraft-Legacy/blob/9bc8ddc061845df0cd5ea47f4fdef773cff786ae/src/main/java/com/xcompwiz/mystcraft/effects/EffectCrumble.java), [`EffectErosion`](https://github.com/Mystcraft/Mystcraft-Legacy/blob/9bc8ddc061845df0cd5ea47f4fdef773cff786ae/src/main/java/com/xcompwiz/mystcraft/effects/EffectErosion.java)). | #70 implements guarded fluid spread. Erosion's provider is absent from the active Legacy deck; it is deliberately enabled by default in this test slice without adding a saved deck card, per user request. |
|
||||||
@@ -45,15 +49,17 @@ These entry costs are from [`InstabilityData.initialize()`](https://github.com/M
|
|||||||
|
|
||||||
Assets in the supplied local tree: `assets/mystcraft/textures/blocks/decay_{black,blue,green,purple,red,white,yellow}.png`, corresponding decay block/item model JSON, and `assets/mystcraft/sounds/entity/meteor/roar.ogg`. Before importing, review attribution/license and fit modern 16×16 assets. Texture availability does not make an effect active. Use current Minecraft effects/sounds where adaptation is cleaner; no new artwork is needed for this audit.
|
Assets in the supplied local tree: `assets/mystcraft/textures/blocks/decay_{black,blue,green,purple,red,white,yellow}.png`, corresponding decay block/item model JSON, and `assets/mystcraft/sounds/entity/meteor/roar.ogg`. Before importing, review attribution/license and fit modern 16×16 assets. Texture availability does not make an effect active. Use current Minecraft effects/sounds where adaptation is cleaner; no new artwork is needed for this audit.
|
||||||
|
|
||||||
## Rivencraft boundary and proposed safety contract
|
## Rivencraft boundary and current safety contract
|
||||||
|
|
||||||
[`WritingGrammar`](../src/main/java/net/dnorberg/rivencraft/writing/WritingGrammar.java) classifies `INCOMPLETE` as seeded completion and supported writing defects as accepted instability. `AgeGenerationPlan.compile()` freezes the original writing, repaired active-page indexes, and a provisional writing-instability score before world generation. #64 now persists a versioned score breakdown; saved provider/deck choice remains future work. The plan must not mutate an already-created Age when a data pack changes. Server-side settings may disable execution, but should not rewrite the saved authored score.
|
[`WritingGrammar`](../src/main/java/net/dnorberg/rivencraft/writing/WritingGrammar.java) classifies `INCOMPLETE` as seeded completion and supported writing defects as accepted instability. `AgeGenerationPlan.compile()` freezes the original writing, repaired active-page indexes, and a provisional writing-instability score before world generation. #64 persists the versioned score breakdown, and #66 derives and persists the provider/deck choice from that frozen score. The plan must not mutate an already-created Age when a data pack changes. Server-side settings may disable execution, but do not rewrite the saved authored score or provider plan.
|
||||||
|
|
||||||
For #65, **eligible-to-become-unstable** means a known, supported page whose semantics and resulting world are still deterministic: repeated/conflicting single-choice pages and otherwise valid out-of-order or misplaced pages. The implementation retains every original page, uses the last single-choice page, sorts active categories, and saves 500 per extra/conflicting choice or 100 per misplaced page. These are provisional Rivencraft values, not a full port of every `IAgeSymbol.instabilityModifier`. Missing branches are explicitly classified as zero-cost seeded completion; legal repeated feature/material pages are not automatically errors. **Remain fatal**: missing/duplicate/misordered Link Panel, over-capacity book, unresolved or schema-v1 display-only symbol, unsupported weather/angle/runtime profile/biome/feature, unavailable required optional mod, and any combination the compiler cannot represent safely. Binder and unbound-book previews distinguish blocked writing, seeded completion, and accepted instability before binding; the server revalidates on output. This intentionally differs from Legacy's silent unmatched-symbol skip, universal controller cost assumptions, and modifier-specific dangling costs. A full symbol-specific Legacy penalty port remains a separate balance task, not a claim of parity in this slice.
|
For #65, **eligible-to-become-unstable** means a known, supported page whose semantics and resulting world are still deterministic: repeated/conflicting single-choice pages and otherwise valid out-of-order or misplaced pages. The implementation retains every original page, uses the last single-choice page, sorts active categories, and saves 500 per extra/conflicting choice or 100 per misplaced page. Issue #71 adds the audited Bright Lighting and repeat-structure modifiers described above. Missing branches are explicitly classified as zero-cost seeded completion; legal repeated feature/material pages are not automatically errors, though a fourth matching Legacy structure now receives its source-defined cost. **Remain fatal**: missing/duplicate/misordered Link Panel, over-capacity book, unresolved or schema-v1 display-only symbol, unsupported weather/angle/runtime profile/biome/feature, unavailable required optional mod, and any combination the compiler cannot represent safely. Binder and unbound-book previews distinguish blocked writing, seeded completion, and accepted instability before binding; the server revalidates on output. This intentionally differs from Legacy's silent unmatched-symbol skip, universal controller cost assumptions, and modifier-specific dangling costs.
|
||||||
|
|
||||||
|
Legacy includes `PlayerKilledBonus` and `PlayerTrollPenalty` classes, but the pinned source contains no default provider registration for either. Rivencraft does not activate death, PvP, player-presence, or cross-dimension credit from dormant classes. Consequently #71 has no mutable per-Age bonus state to migrate, cap, reset, or persist: the stability bonus and runtime penalty are both zero, and the effective score equals the frozen base score. `/rivencraft age instability [dimension]` reports those four values and the disabled policy explicitly. This prevents unrelated players, deaths in other dimensions, and repeated deaths from changing an Age. A future opt-in policy must use separate versioned saved data and define its cap/reset rules before it can alter runtime selection.
|
||||||
|
|
||||||
Automated #65 checks cover classification, preserved input slots on rejection, and an accepted unstable preview. The live output/one-time Age creation check is assigned to in-game testing because the GameTest storage phase stalled when that transaction ran; the test world is not retained.
|
Automated #65 checks cover classification, preserved input slots on rejection, and an accepted unstable preview. The live output/one-time Age creation check is assigned to in-game testing because the GameTest storage phase stalled when that transaction ran; the test world is not retained.
|
||||||
|
|
||||||
Issue #66 establishes a server-only scheduler with bounded per-Age actions, provider calls, levels, cooldowns, loaded-chunk candidates, and rotating active-Age admission. World-mutating handlers are **off by default**. No provider effects are registered yet; #67–#70 must enforce protected spawn/link platforms, portals, and provider-specific damage/spread limits before activation. These are **Rivencraft safety adaptations**, not Legacy defaults. Expose score breakdown, selected effects, enablement, and budget suppression in server diagnostics (#72). See [runtime policy](INSTABILITY_RUNTIME.md).
|
Issue #66 established a server-only scheduler with bounded per-Age actions, provider calls, levels, cooldowns, loaded-chunk candidates, and rotating active-Age admission. Issues #67–#70 registered the current status, decay, lightning, explosion, meteor, burning, and erosion handlers with protected spawn/link platforms, portal exclusions, and provider-specific damage or spread limits. Instability and world-mutating handlers are enabled by default for newly generated configs to match Legacy's active default; operators can disable them without changing a saved Age. The bounds and protection hooks are **Rivencraft safety adaptations**, not Legacy defaults. Score breakdown, selected effects, enablement, and budget suppression remain part of diagnostics issue #72. See the [runtime policy](INSTABILITY_RUNTIME.md).
|
||||||
|
|
||||||
M6 owns scoring, selection, effects, controls, and regression. M7 still owns portal/transport and broader polish; M6 must not depend on new M7 structures. An illegal biome/terrain combination that is presently unrepresentable remains a generation failure until a separate, safe compiler path exists; instability must not be used to disguise absent worldgen support. Existing pre-release saves need explicit migration behavior in #73 rather than a silent rescore.
|
M6 owns scoring, selection, effects, controls, and regression. M7 still owns portal/transport and broader polish; M6 must not depend on new M7 structures. An illegal biome/terrain combination that is presently unrepresentable remains a generation failure until a separate, safe compiler path exists; instability must not be used to disguise absent worldgen support. Existing pre-release saves need explicit migration behavior in #73 rather than a silent rescore.
|
||||||
|
|
||||||
|
|||||||
+18
-1
@@ -5,6 +5,22 @@ The world-generation, dimension, registry, networking, and rendering APIs have
|
|||||||
changed substantially, so the work is divided into independently testable
|
changed substantially, so the work is divided into independently testable
|
||||||
milestones.
|
milestones.
|
||||||
|
|
||||||
|
## Porting principles
|
||||||
|
|
||||||
|
The primary goal is to reproduce verified Mystcraft Legacy behavior as closely
|
||||||
|
as practical. Legacy source and the supplied 0.13.7.06 build are the behavioral
|
||||||
|
reference for grammar, probabilities, ordering, defaults, visuals, and gameplay
|
||||||
|
effects. A difference should be deliberate and documented rather than inferred
|
||||||
|
from modern implementation convenience.
|
||||||
|
|
||||||
|
Minecraft 1.21.1 has different world heights, registries, threading, networking,
|
||||||
|
data-pack APIs, and server protection expectations. Where an exact port would be
|
||||||
|
unsafe, technically impossible, or incompatible with current Minecraft,
|
||||||
|
Rivencraft preserves the player-visible intent while using bounded modern
|
||||||
|
mechanics. New features may extend Legacy when they fit Age writing and linking,
|
||||||
|
but extensions must be identified separately from compatibility behavior and
|
||||||
|
must not silently change existing saved Ages.
|
||||||
|
|
||||||
## Project tracking
|
## Project tracking
|
||||||
|
|
||||||
Gitea is the source of truth for project status:
|
Gitea is the source of truth for project status:
|
||||||
@@ -42,7 +58,8 @@ acceptance issue and all required implementation issues are complete.
|
|||||||
TerraBlender and Serene Seasons integration. **Complete for the supported
|
TerraBlender and Serene Seasons integration. **Complete for the supported
|
||||||
subset.** See the [acceptance record](MILESTONE_5_ACCEPTANCE.md) and
|
subset.** See the [acceptance record](MILESTONE_5_ACCEPTANCE.md) and
|
||||||
[Legacy grammar audit](LEGACY_AGE_GRAMMAR_AUDIT.md).
|
[Legacy grammar audit](LEGACY_AGE_GRAMMAR_AUDIT.md).
|
||||||
6. **Instability** — deterministic validation and server-safe effects. Start with the
|
6. **Instability** — deterministic validation and server-safe effects. **In
|
||||||
|
progress.** Start with the
|
||||||
[Legacy instability audit](LEGACY_INSTABILITY_AUDIT.md), which separates
|
[Legacy instability audit](LEGACY_INSTABILITY_AUDIT.md), which separates
|
||||||
source behavior from proposed 1.21.1 safety limits.
|
source behavior from proposed 1.21.1 safety limits.
|
||||||
7. **Structures and polish** — libraries, crystals, portals, recipes, models,
|
7. **Structures and polish** — libraries, crystals, portals, recipes, models,
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ New Binder writing has at most one Link Panel plus 252 symbol pages (the current
|
|||||||
|
|
||||||
The supported order follows the representable subset of the [Legacy grammar audit](LEGACY_AGE_GRAMMAR_AUDIT.md): terrain; zero or more biome pages; biome controller; weather; season; lighting; sky effects; zero or more period or phase modifiers; one celestial page; then zero or more features, each optionally preceded by a compatible material page. Biome pages precede the controller that consumes them, and celestial modifiers precede the celestial page. Terrain, controller, weather, season, lighting, sky, and celestial are single-choice categories; identical repeats are duplicates and differing values conflict. Repeated modifiers, biome pages, feature pages, and material pages are intentional and retain their order. An unpaired material page receives a seeded compatible feature during compilation. Angle modifiers remain recognized in the schema but are rejected at binding until a sky renderer can apply sun tilt.
|
The supported order follows the representable subset of the [Legacy grammar audit](LEGACY_AGE_GRAMMAR_AUDIT.md): terrain; zero or more biome pages; biome controller; weather; season; lighting; sky effects; zero or more period or phase modifiers; one celestial page; then zero or more features, each optionally preceded by a compatible material page. Biome pages precede the controller that consumes them, and celestial modifiers precede the celestial page. Terrain, controller, weather, season, lighting, sky, and celestial are single-choice categories; identical repeats are duplicates and differing values conflict. Repeated modifiers, biome pages, feature pages, and material pages are intentional and retain their order. An unpaired material page receives a seeded compatible feature during compilation. Angle modifiers remain recognized in the schema but are rejected at binding until a sky renderer can apply sun tilt.
|
||||||
|
|
||||||
Missing terrain, controller, weather, lighting, celestial, or the controller's minimum biome count is an **incomplete** warning, not an error: the compiler retains seed-selected traits for missing branches. An omitted terrain page uses a seed-selected profile compatible with authored feature pages, so changing the Age name cannot accidentally select Flat, Void, or Cave terrain for Rocks or Lakes. If no profile can support the writing, binding still rejects it. Native consumes no authored biome pages; Single consumes one; Tiled/Grid and Tiny–Huge require two, with seeded filler when pages are missing. From 0.5.1.0, known misplaced or repeated pages no longer block creation: the book keeps its original order, while the server repairs category order, uses the last single-choice controller, and stores a writing-instability score in the Age plan. A conflicting/repeated choice adds 500; an out-of-order page or misplaced modifier adds 100. Native ignores surplus authored biome pages and Single uses the first, with the conflict recorded as instability. These are Rivencraft's provisional penalties, not a claim of exact Legacy values for every symbol. Incorrectly placed pages are **not** red-highlighted; their warning remains available as a tooltip. Unknown IDs, schema-v1 display-only symbols, unavailable dependencies/profiles, unsupported semantic effects or feature/material pairs, missing/extra Link Panels, and oversized writing still reject a new Age. The Binder disables output for those fatal errors and shows a red page indication where applicable. Rejected inputs remain removable.
|
Missing terrain, controller, weather, lighting, celestial, or the controller's minimum biome count is an **incomplete** warning, not an error: the compiler retains seed-selected traits for missing branches. An omitted terrain page uses a seed-selected profile compatible with authored feature pages, so changing the Age name cannot accidentally select Flat, Void, or Cave terrain for Rocks or Lakes. If no profile can support the writing, binding still rejects it. Native consumes no authored biome pages; Single consumes one; Tiled/Grid and Tiny–Huge require two, with seeded filler when pages are missing. From 0.5.1.0, known misplaced or repeated pages no longer block creation: the book keeps its original order, while the server repairs category order, uses the last single-choice controller, and stores a writing-instability score in the Age plan. A conflicting/repeated choice adds 500; an out-of-order page or misplaced modifier adds 100. Native ignores surplus authored biome pages and Single uses the first, with the conflict recorded as instability. Audited Legacy symbol modifiers also add 500 for each Bright Lighting page and 100 for each Mineshafts, Nether Fortresses, Strongholds, or Villages occurrence after the third. Modern structures configured with the same rule are Bastions, Trial Chambers, Ancient Cities, Shipwrecks, Ocean Ruins, Pillager Outposts, Ruined Portals, Nether Fossils, Buried Treasure, and Trail Ruins. Every repeated structure page increases that structure's placement rate: probability-based structures multiply their chance, grid-based structures use a denser grid, and Strongholds add more positions to each ring and more positions overall. One page retains the vanilla placement rate. Authored structures can generate outside their vanilla biome set; each structure-page occurrence that requires this override adds 100 instability. Seed completion selects compatible biomes where possible. Other feature pages have no direct symbol cost. Incorrectly placed pages are **not** red-highlighted; their warning remains available as a tooltip. Unknown IDs, schema-v1 display-only symbols, unavailable dependencies/profiles, unsupported semantic effects or feature/material pairs, missing/extra Link Panels, and oversized writing still reject a new Age. The Binder disables output for those fatal errors and shows a red page indication where applicable. Rejected inputs remain removable.
|
||||||
|
|
||||||
The plan stores the original writing order, the authoritative semantic value of each resolved symbol, the active repaired-page indexes, the writing-instability score, the Age seed, and a copy of the selected runtime profile. An explicit terrain page overrides random terrain selection; an omitted terrain uses a seed-selected compatible profile. The built-in Standard, Amplified, Cave, Island, Flat, and Void terrain pages select their matching generation resources. Age loading uses the frozen runtime profile and does not need the original symbol definition or runtime-profile JSON, though its referenced noise, biome-preset, and dimension-type registry entries must remain available. Existing bound books without plans are not reinterpreted. Page-free and Link-Panel-only books keep the pre-existing random path. Biome and environment pages affect new Ages, and the supported feature subset below is compiled into the same frozen plan. Runtime effects for a nonzero writing-instability score are not implemented yet.
|
The plan stores the original writing order, the authoritative semantic value of each resolved symbol, the active repaired-page indexes, the writing-instability score, the Age seed, and a copy of the selected runtime profile. An explicit terrain page overrides random terrain selection; an omitted terrain uses a seed-selected compatible profile. The built-in Standard, Amplified, Cave, Island, Flat, and Void terrain pages select their matching generation resources. Age loading uses the frozen runtime profile and does not need the original symbol definition or runtime-profile JSON, though its referenced noise, biome-preset, and dimension-type registry entries must remain available. Existing bound books without plans are not reinterpreted. Page-free and Link-Panel-only books keep the pre-existing random path. Biome and environment pages affect new Ages, and the supported feature subset below is compiled into the same frozen plan. Nonzero instability can select a persisted provider plan; status effects, decay, lightning, explosions, meteors, burning, and test-enabled erosion run through the bounded Age-scoped scheduler described in [the runtime policy](INSTABILITY_RUNTIME.md).
|
||||||
|
|
||||||
## Supported feature pages (issue #35)
|
## Supported feature pages (issue #35)
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -36,7 +36,7 @@ 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
|
||||||
# The mod version. Rivencraft uses the x.y.z.b policy documented in README.md.
|
# The mod version. Rivencraft uses the x.y.z.b policy documented in README.md.
|
||||||
mod_version=0.5.8.2
|
mod_version=0.5.8.7
|
||||||
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=B6nTjh4b
|
serene_seasons_version_id=B6nTjh4b
|
||||||
|
|||||||
@@ -88,6 +88,9 @@ public record AgeBiomeSelection(AgeTraits.BiomeDistribution distribution, List<R
|
|||||||
Random countRandom = new Random(seed ^ 0x42494F4D45434F55L);
|
Random countRandom = new Random(seed ^ 0x42494F4D45434F55L);
|
||||||
while (target < maximum && countRandom.nextInt(3) != 0) target++;
|
while (target < maximum && countRandom.nextInt(3) != 0) target++;
|
||||||
}
|
}
|
||||||
|
completeStructureBiomes(writing, registries, availableBiomes, authored, distribution,
|
||||||
|
selected, distinct, seed);
|
||||||
|
target = Math.max(target, distinct.size());
|
||||||
// An authored Void Age must not acquire The Void as an unrequested second biome.
|
// An authored Void Age must not acquire The Void as an unrequested second biome.
|
||||||
List<ResourceLocation> filler = profile.terrain() == AgeRuntimeProfile.Terrain.VOID && !authored.isEmpty()
|
List<ResourceLocation> filler = profile.terrain() == AgeRuntimeProfile.Terrain.VOID && !authored.isEmpty()
|
||||||
? new ArrayList<>() : new ArrayList<>(availableBiomes);
|
? new ArrayList<>() : new ArrayList<>(availableBiomes);
|
||||||
@@ -103,6 +106,59 @@ public record AgeBiomeSelection(AgeTraits.BiomeDistribution distribution, List<R
|
|||||||
return new AgeBiomeSelection(distribution, selected);
|
return new AgeBiomeSelection(distribution, selected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Seed-completed biome branches must be able to host every authored structure page. */
|
||||||
|
private static void completeStructureBiomes(WritingGrammar.Result writing, RegistryAccess registries,
|
||||||
|
List<ResourceLocation> available,
|
||||||
|
List<ResourceLocation> authored,
|
||||||
|
AgeTraits.BiomeDistribution distribution,
|
||||||
|
List<ResourceLocation> selected,
|
||||||
|
Set<ResourceLocation> distinct,
|
||||||
|
long seed) {
|
||||||
|
List<Set<ResourceLocation>> requirements = writing.symbols().stream()
|
||||||
|
.filter(symbol -> symbol.semantics().role() == SymbolSemantics.Role.FEATURE)
|
||||||
|
.map(symbol -> ((SymbolSemantics.ResourceValue) symbol.semantics().value()).id())
|
||||||
|
.filter(AgeStructureSelection::feature)
|
||||||
|
.filter(feature -> !AgeStructureSelection.dungeons(feature))
|
||||||
|
.distinct()
|
||||||
|
.map(feature -> AgeStructureSelection.compatibleBiomes(feature, registries))
|
||||||
|
.filter(requirement -> !requirement.isEmpty())
|
||||||
|
.toList();
|
||||||
|
if (requirements.isEmpty()) return;
|
||||||
|
|
||||||
|
if (distribution == AgeTraits.BiomeDistribution.SINGLE) {
|
||||||
|
if (!authored.isEmpty()) return;
|
||||||
|
List<ResourceLocation> candidates = available.stream()
|
||||||
|
.filter(candidate -> requirements.stream().allMatch(requirement -> requirement.contains(candidate)))
|
||||||
|
.toList();
|
||||||
|
if (candidates.isEmpty()) return;
|
||||||
|
ResourceLocation selectedBiome = deterministicChoice(candidates, seed, 0x5354525543544249L);
|
||||||
|
selected.clear();
|
||||||
|
distinct.clear();
|
||||||
|
selected.add(selectedBiome);
|
||||||
|
distinct.add(selectedBiome);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int index = 0; index < requirements.size(); index++) {
|
||||||
|
Set<ResourceLocation> requirement = requirements.get(index);
|
||||||
|
if (selected.stream().anyMatch(requirement::contains)) continue;
|
||||||
|
List<ResourceLocation> candidates = available.stream()
|
||||||
|
.filter(requirement::contains)
|
||||||
|
.filter(candidate -> !distinct.contains(candidate))
|
||||||
|
.toList();
|
||||||
|
if (candidates.isEmpty()) continue;
|
||||||
|
ResourceLocation selectedBiome = deterministicChoice(candidates, seed, 0x5354525543544249L + index);
|
||||||
|
selected.add(selectedBiome);
|
||||||
|
distinct.add(selectedBiome);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ResourceLocation deterministicChoice(List<ResourceLocation> choices, long seed, long salt) {
|
||||||
|
List<ResourceLocation> shuffled = new ArrayList<>(choices);
|
||||||
|
java.util.Collections.shuffle(shuffled, new Random(seed ^ salt));
|
||||||
|
return shuffled.getFirst();
|
||||||
|
}
|
||||||
|
|
||||||
public static List<ResourceLocation> eligible(RegistryAccess registries, AgeRuntimeProfile profile) {
|
public static List<ResourceLocation> eligible(RegistryAccess registries, AgeRuntimeProfile profile) {
|
||||||
var registry = registries.lookupOrThrow(Registries.BIOME);
|
var registry = registries.lookupOrThrow(Registries.BIOME);
|
||||||
if (isCave(profile)) {
|
if (isCave(profile)) {
|
||||||
|
|||||||
@@ -1,15 +1,38 @@
|
|||||||
package net.dnorberg.rivencraft.book;
|
package net.dnorberg.rivencraft.book;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import net.dnorberg.rivencraft.writing.WritingGrammar;
|
import net.dnorberg.rivencraft.writing.WritingGrammar;
|
||||||
|
import net.minecraft.core.RegistryAccess;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.nbt.ListTag;
|
import net.minecraft.nbt.ListTag;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
/** Frozen, server-owned score. Only new Age creation consults the current symbol catalog. */
|
/** Frozen, server-owned score. Only new Age creation consults the current symbol catalog. */
|
||||||
public record AgeInstability(int version, int score, List<Contribution> breakdown) {
|
public record AgeInstability(int version, int score, List<Contribution> breakdown) {
|
||||||
public static final int CURRENT_VERSION = 1;
|
public static final int CURRENT_VERSION = 1;
|
||||||
|
private static final int BRIGHT_LIGHTING_COST = 500;
|
||||||
|
private static final int EXCESS_LEGACY_STRUCTURE_COST = 100;
|
||||||
|
private static final int FORCED_STRUCTURE_BIOME_COST = 100;
|
||||||
|
private static final Map<ResourceLocation, String> COUNTED_STRUCTURES = Map.ofEntries(
|
||||||
|
Map.entry(id("mineshafts"), "Mineshafts"),
|
||||||
|
Map.entry(id("nether_fortresses"), "Nether Fortresses"),
|
||||||
|
Map.entry(id("strongholds"), "Strongholds"),
|
||||||
|
Map.entry(id("villages"), "Villages"),
|
||||||
|
Map.entry(id("bastions"), "Bastions"),
|
||||||
|
Map.entry(id("trial_chambers"), "Trial Chambers"),
|
||||||
|
Map.entry(id("ancient_cities"), "Ancient Cities"),
|
||||||
|
Map.entry(id("shipwrecks"), "Shipwrecks"),
|
||||||
|
Map.entry(id("ocean_ruins"), "Ocean Ruins"),
|
||||||
|
Map.entry(id("pillager_outposts"), "Pillager Outposts"),
|
||||||
|
Map.entry(id("ruined_portals"), "Ruined Portals"),
|
||||||
|
Map.entry(id("nether_fossils"), "Nether Fossils"),
|
||||||
|
Map.entry(id("buried_treasure"), "Buried Treasure"),
|
||||||
|
Map.entry(id("trail_ruins"), "Trail Ruins")
|
||||||
|
);
|
||||||
|
|
||||||
public AgeInstability {
|
public AgeInstability {
|
||||||
if (version != CURRENT_VERSION) throw new IllegalArgumentException("Unsupported instability version " + version);
|
if (version != CURRENT_VERSION) throw new IllegalArgumentException("Unsupported instability version " + version);
|
||||||
@@ -25,7 +48,7 @@ public record AgeInstability(int version, int score, List<Contribution> breakdow
|
|||||||
List.of(new Contribution("legacy_neutral", -1, 0, "Age predates frozen instability scoring")));
|
List.of(new Contribution("legacy_neutral", -1, 0, "Age predates frozen instability scoring")));
|
||||||
}
|
}
|
||||||
|
|
||||||
static AgeInstability compute(AgeGenerationPlan plan, AgeTraits traits) {
|
static AgeInstability compute(AgeGenerationPlan plan, AgeTraits traits, RegistryAccess registries) {
|
||||||
Objects.requireNonNull(traits, "traits");
|
Objects.requireNonNull(traits, "traits");
|
||||||
List<Contribution> contributions = new ArrayList<>();
|
List<Contribution> contributions = new ArrayList<>();
|
||||||
if (plan == null) {
|
if (plan == null) {
|
||||||
@@ -40,21 +63,69 @@ public record AgeInstability(int version, int score, List<Contribution> breakdow
|
|||||||
contributions.add(new Contribution(diagnostic.code().name().toLowerCase(java.util.Locale.ROOT),
|
contributions.add(new Contribution(diagnostic.code().name().toLowerCase(java.util.Locale.ROOT),
|
||||||
diagnostic.index(), diagnostic.instability(), diagnostic.message()));
|
diagnostic.index(), diagnostic.instability(), diagnostic.message()));
|
||||||
}
|
}
|
||||||
|
addAuditedSymbolCosts(plan, registries, contributions);
|
||||||
}
|
}
|
||||||
// Legacy's bright-lighting symbol adds +500. Other balance costs are deferred
|
// A missing lighting controller is seed-completed. Legacy runs the generated
|
||||||
// until their corresponding authored symbols and audited values exist.
|
// symbol's own modifier, so a generated Bright Lighting choice still costs 500.
|
||||||
if (traits.lighting() == AgeTraits.Lighting.BRIGHT) {
|
if (traits.lighting() == AgeTraits.Lighting.BRIGHT && (plan == null || plan.symbols().stream()
|
||||||
int pageIndex = plan == null ? -1 : plan.activeSymbols().stream()
|
.noneMatch(symbol -> symbol.semantics().role()
|
||||||
.filter(symbol -> symbol.semantics().role()
|
== net.dnorberg.rivencraft.writing.SymbolSemantics.Role.LIGHTING))) {
|
||||||
== net.dnorberg.rivencraft.writing.SymbolSemantics.Role.LIGHTING)
|
contributions.add(new Contribution("bright_lighting", -1, BRIGHT_LIGHTING_COST,
|
||||||
.mapToInt(AgeGenerationPlan.ResolvedSymbol::index).findFirst().orElse(-1);
|
"Seeded bright lighting"));
|
||||||
contributions.add(new Contribution("bright_lighting", pageIndex, 500,
|
|
||||||
pageIndex < 0 ? "Seeded bright lighting" : "Authored bright lighting"));
|
|
||||||
}
|
}
|
||||||
return new AgeInstability(CURRENT_VERSION,
|
return new AgeInstability(CURRENT_VERSION,
|
||||||
contributions.stream().mapToInt(Contribution::points).sum(), contributions);
|
contributions.stream().mapToInt(Contribution::points).sum(), contributions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void addAuditedSymbolCosts(AgeGenerationPlan plan, RegistryAccess registries,
|
||||||
|
List<Contribution> contributions) {
|
||||||
|
Map<ResourceLocation, Integer> structureCounts = new HashMap<>();
|
||||||
|
for (AgeGenerationPlan.ResolvedSymbol symbol : plan.symbols()) {
|
||||||
|
if (symbol.semantics().role()
|
||||||
|
== net.dnorberg.rivencraft.writing.SymbolSemantics.Role.LIGHTING
|
||||||
|
&& symbol.semantics().value()
|
||||||
|
instanceof net.dnorberg.rivencraft.writing.SymbolSemantics.ChoiceValue choice
|
||||||
|
&& choice.id().equals("bright")) {
|
||||||
|
contributions.add(new Contribution("bright_lighting", symbol.index(), BRIGHT_LIGHTING_COST,
|
||||||
|
"Authored bright lighting"));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (symbol.semantics().role()
|
||||||
|
!= net.dnorberg.rivencraft.writing.SymbolSemantics.Role.FEATURE
|
||||||
|
|| !(symbol.semantics().value()
|
||||||
|
instanceof net.dnorberg.rivencraft.writing.SymbolSemantics.ResourceValue resource)) continue;
|
||||||
|
String name = COUNTED_STRUCTURES.get(resource.id());
|
||||||
|
if (name == null) continue;
|
||||||
|
int count = structureCounts.merge(resource.id(), 1, Integer::sum);
|
||||||
|
if (AgeStructureSelection.requiresBiomeOverride(resource.id(), plan.biomeSelection(), registries)) {
|
||||||
|
contributions.add(new Contribution("forced_biome_" + resource.id().getPath(), symbol.index(),
|
||||||
|
FORCED_STRUCTURE_BIOME_COST,
|
||||||
|
name + " occurrence " + count + " is forced into an unsupported biome"));
|
||||||
|
}
|
||||||
|
int cost = featureCost(resource.id(), count);
|
||||||
|
if (cost > 0) {
|
||||||
|
contributions.add(new Contribution("excess_" + resource.id().getPath(), symbol.index(),
|
||||||
|
cost,
|
||||||
|
name + " occurrence " + count + " exceeds Legacy's first three free occurrences"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int featureCost(ResourceLocation feature, int occurrence) {
|
||||||
|
if (occurrence < 1) throw new IllegalArgumentException("Feature occurrence must be positive");
|
||||||
|
return COUNTED_STRUCTURES.containsKey(feature) && occurrence > 3
|
||||||
|
? EXCESS_LEGACY_STRUCTURE_COST : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Current totals exposed to diagnostics. Player-driven mutable bonuses are deliberately disabled. */
|
||||||
|
public Totals totals() {
|
||||||
|
return new Totals(score, 0, 0, score);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ResourceLocation id(String path) {
|
||||||
|
return ResourceLocation.fromNamespaceAndPath("rivencraft", path);
|
||||||
|
}
|
||||||
|
|
||||||
public CompoundTag save() {
|
public CompoundTag save() {
|
||||||
CompoundTag tag = new CompoundTag();
|
CompoundTag tag = new CompoundTag();
|
||||||
tag.putInt("Version", version);
|
tag.putInt("Version", version);
|
||||||
@@ -92,4 +163,13 @@ public record AgeInstability(int version, int score, List<Contribution> breakdow
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public record Totals(int baseScore, int stabilityBonus, int instabilityPenalty, int effectiveScore) {
|
||||||
|
public Totals {
|
||||||
|
if (baseScore < 0 || stabilityBonus < 0 || instabilityPenalty < 0
|
||||||
|
|| effectiveScore != Math.max(0, baseScore + instabilityPenalty - stabilityBonus)) {
|
||||||
|
throw new IllegalArgumentException("Invalid instability totals");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -125,13 +125,91 @@ public final class AgePersistenceGameTests {
|
|||||||
AgeInstability bright = AgeInstability.compute(null, new AgeTraits(
|
AgeInstability bright = AgeInstability.compute(null, new AgeTraits(
|
||||||
AgeTraits.LEGACY_DEFAULTS.biomeDistribution(), AgeTraits.Lighting.BRIGHT,
|
AgeTraits.LEGACY_DEFAULTS.biomeDistribution(), AgeTraits.Lighting.BRIGHT,
|
||||||
AgeTraits.LEGACY_DEFAULTS.weather(), AgeTraits.LEGACY_DEFAULTS.celestialPeriod(),
|
AgeTraits.LEGACY_DEFAULTS.weather(), AgeTraits.LEGACY_DEFAULTS.celestialPeriod(),
|
||||||
AgeTraits.LEGACY_DEFAULTS.celestialAngle(), AgeTraits.LEGACY_DEFAULTS.celestialPhase()));
|
AgeTraits.LEGACY_DEFAULTS.celestialAngle(), AgeTraits.LEGACY_DEFAULTS.celestialPhase()),
|
||||||
|
helper.getLevel().registryAccess());
|
||||||
helper.assertValueEqual(bright.score(), 500, "Bright lighting has the audited Legacy cost");
|
helper.assertValueEqual(bright.score(), 500, "Bright lighting has the audited Legacy cost");
|
||||||
helper.assertValueEqual(AgeInstability.load(bright.save()), bright,
|
helper.assertValueEqual(AgeInstability.load(bright.save()), bright,
|
||||||
"A score must survive its own versioned round trip");
|
"A score must survive its own versioned round trip");
|
||||||
helper.succeed();
|
helper.succeed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GameTest(template = "empty")
|
||||||
|
public static void auditedSymbolCostsAreCountedAndAgeScoped(GameTestHelper helper) {
|
||||||
|
List<String> legacyStructures = List.of("mineshafts", "nether_fortresses", "strongholds", "villages");
|
||||||
|
for (String structure : legacyStructures) {
|
||||||
|
AgeDefinition three = AgeRegistrySavedData.resolveOrCreate(helper.getLevel(),
|
||||||
|
new AgeReference(UUID.randomUUID(), "Three " + structure), structureWriting(structure, 3));
|
||||||
|
AgeDefinition four = AgeRegistrySavedData.resolveOrCreate(helper.getLevel(),
|
||||||
|
new AgeReference(UUID.randomUUID(), "Four " + structure), structureWriting(structure, 4));
|
||||||
|
helper.assertValueEqual(three.instability().score(), 0,
|
||||||
|
"The first three " + structure + " pages retain Legacy's zero cost");
|
||||||
|
helper.assertValueEqual(four.instability().score(), 100,
|
||||||
|
"The fourth " + structure + " page must add Legacy's 100-point cost");
|
||||||
|
helper.assertTrue(four.instability().breakdown().stream().anyMatch(part ->
|
||||||
|
part.reason().equals("excess_" + structure) && part.pageIndex() == 8),
|
||||||
|
"The excess structure cost must identify its authored page");
|
||||||
|
}
|
||||||
|
for (String structure : List.of("bastions", "trial_chambers", "ancient_cities", "shipwrecks",
|
||||||
|
"ocean_ruins", "pillager_outposts", "ruined_portals", "nether_fossils", "buried_treasure",
|
||||||
|
"trail_ruins")) {
|
||||||
|
ResourceLocation id = ResourceLocation.fromNamespaceAndPath("rivencraft", structure);
|
||||||
|
helper.assertTrue(AgeInstability.featureCost(id, 1) == 0
|
||||||
|
&& AgeInstability.featureCost(id, 3) == 0
|
||||||
|
&& AgeInstability.featureCost(id, 4) == 100
|
||||||
|
&& AgeInstability.featureCost(id, 5) == 100,
|
||||||
|
structure + " must follow the selected Legacy Mineshaft repeat rule");
|
||||||
|
}
|
||||||
|
helper.assertValueEqual(AgeInstability.featureCost(
|
||||||
|
ResourceLocation.parse("rivencraft:trial_chambers"), 4), 100,
|
||||||
|
"Modern repeated structures must use the same deterministic scoring path");
|
||||||
|
helper.assertValueEqual(AgeInstability.featureCost(ResourceLocation.parse("rivencraft:dungeons"), 4), 0,
|
||||||
|
"A Legacy-neutral feature must remain neutral when repeated");
|
||||||
|
|
||||||
|
OrderedWriting duplicateBright = new OrderedWriting(List.of(
|
||||||
|
WritingEntry.linkPanel(),
|
||||||
|
WritingEntry.symbol(new SymbolReference(ResourceLocation.parse("rivencraft:terrain/standard"))),
|
||||||
|
WritingEntry.symbol(new SymbolReference(ResourceLocation.parse("rivencraft:lighting/bright"))),
|
||||||
|
WritingEntry.symbol(new SymbolReference(ResourceLocation.parse("rivencraft:lighting/bright")))
|
||||||
|
));
|
||||||
|
AgeDefinition bright = AgeRegistrySavedData.resolveOrCreate(helper.getLevel(),
|
||||||
|
new AgeReference(UUID.randomUUID(), "Double Bright"), duplicateBright);
|
||||||
|
helper.assertValueEqual(bright.instability().score(), 1500,
|
||||||
|
"Each Bright Lighting page costs 500 and the extra controller costs another 500");
|
||||||
|
helper.assertValueEqual(bright.instability().breakdown().stream()
|
||||||
|
.filter(part -> part.reason().equals("bright_lighting")).count(), 2L,
|
||||||
|
"Every authored Bright Lighting occurrence must retain its own cost");
|
||||||
|
|
||||||
|
AgeInstability.Totals totals = bright.instability().totals();
|
||||||
|
helper.assertValueEqual(totals.baseScore(), 1500, "Diagnostics must expose the immutable base score");
|
||||||
|
helper.assertTrue(totals.stabilityBonus() == 0 && totals.instabilityPenalty() == 0
|
||||||
|
&& totals.effectiveScore() == totals.baseScore(),
|
||||||
|
"Dormant player bonus classes must not create mutable, cross-Age credit");
|
||||||
|
AgeDefinition restored = AgeRegistrySavedData.load(
|
||||||
|
AgeRegistrySavedData.get(helper.getLevel()).save(new CompoundTag(), helper.getLevel().registryAccess()),
|
||||||
|
helper.getLevel().registryAccess()).find(bright.id()).orElseThrow();
|
||||||
|
helper.assertValueEqual(restored.instability().totals(), totals,
|
||||||
|
"The base/adjustment diagnostic must remain identical after reload");
|
||||||
|
helper.succeed();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static OrderedWriting structureWriting(String structure, int count) {
|
||||||
|
boolean nether = structure.equals("nether_fortresses");
|
||||||
|
List<WritingEntry> entries = new java.util.ArrayList<>(List.of(
|
||||||
|
WritingEntry.linkPanel(),
|
||||||
|
WritingEntry.symbol(new SymbolReference(ResourceLocation.parse(
|
||||||
|
nether ? "rivencraft:terrain/cave" : "rivencraft:terrain/standard"))),
|
||||||
|
WritingEntry.symbol(new SymbolReference(ResourceLocation.parse(
|
||||||
|
nether ? "rivencraft:biome/nether_wastes" : "rivencraft:biome/plains"))),
|
||||||
|
WritingEntry.symbol(new SymbolReference(ResourceLocation.parse("rivencraft:biome/single"))),
|
||||||
|
WritingEntry.symbol(new SymbolReference(ResourceLocation.parse("rivencraft:lighting/normal")))
|
||||||
|
));
|
||||||
|
for (int index = 0; index < count; index++) {
|
||||||
|
entries.add(WritingEntry.symbol(new SymbolReference(
|
||||||
|
ResourceLocation.parse("rivencraft:feature/" + structure))));
|
||||||
|
}
|
||||||
|
return new OrderedWriting(entries);
|
||||||
|
}
|
||||||
|
|
||||||
@GameTest(template = "empty")
|
@GameTest(template = "empty")
|
||||||
public static void missingRegistryEntryDoesNotReinterpretAnOldAge(GameTestHelper helper) {
|
public static void missingRegistryEntryDoesNotReinterpretAnOldAge(GameTestHelper helper) {
|
||||||
UUID id = UUID.randomUUID();
|
UUID id = UUID.randomUUID();
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ public final class AgeRegistrySavedData extends SavedData {
|
|||||||
AgeTraits traits = AgeTraits.select(seed);
|
AgeTraits traits = AgeTraits.select(seed);
|
||||||
AgeGenerationPlan plan = AgeGenerationPlan.compile(writing, seed, seedProfile, traits, registries);
|
AgeGenerationPlan plan = AgeGenerationPlan.compile(writing, seed, seedProfile, traits, registries);
|
||||||
AgeTraits effectiveTraits = AgeEnvironmentCompiler.apply(plan, traits);
|
AgeTraits effectiveTraits = AgeEnvironmentCompiler.apply(plan, traits);
|
||||||
AgeInstability instability = AgeInstability.compute(plan, effectiveTraits);
|
AgeInstability instability = AgeInstability.compute(plan, effectiveTraits, registries);
|
||||||
AgeInstabilityPlan instabilityPlan = AgeInstabilityPlan.select(instability, seed);
|
AgeInstabilityPlan instabilityPlan = AgeInstabilityPlan.select(instability, seed);
|
||||||
AgeDefinition created = new AgeDefinition(
|
AgeDefinition created = new AgeDefinition(
|
||||||
reference.id(),
|
reference.id(),
|
||||||
|
|||||||
@@ -4,16 +4,22 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import net.dnorberg.rivencraft.Rivencraft;
|
import net.dnorberg.rivencraft.Rivencraft;
|
||||||
|
import net.dnorberg.rivencraft.mixin.StructurePlacementAccessor;
|
||||||
import net.dnorberg.rivencraft.writing.OrderedWriting;
|
import net.dnorberg.rivencraft.writing.OrderedWriting;
|
||||||
import net.dnorberg.rivencraft.writing.SymbolReference;
|
import net.dnorberg.rivencraft.writing.SymbolReference;
|
||||||
import net.dnorberg.rivencraft.writing.WritingEntry;
|
import net.dnorberg.rivencraft.writing.WritingEntry;
|
||||||
import net.minecraft.core.registries.Registries;
|
import net.minecraft.core.registries.Registries;
|
||||||
|
import net.minecraft.world.level.biome.Biomes;
|
||||||
|
import net.minecraft.world.level.biome.FixedBiomeSource;
|
||||||
|
import net.minecraft.world.level.chunk.ChunkGeneratorStructureState;
|
||||||
import net.minecraft.gametest.framework.GameTest;
|
import net.minecraft.gametest.framework.GameTest;
|
||||||
import net.minecraft.gametest.framework.GameTestHelper;
|
import net.minecraft.gametest.framework.GameTestHelper;
|
||||||
import net.minecraft.resources.ResourceKey;
|
import net.minecraft.resources.ResourceKey;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.level.levelgen.structure.BuiltinStructureSets;
|
import net.minecraft.world.level.levelgen.structure.BuiltinStructureSets;
|
||||||
import net.minecraft.world.level.levelgen.structure.StructureSet;
|
import net.minecraft.world.level.levelgen.structure.StructureSet;
|
||||||
|
import net.minecraft.world.level.levelgen.structure.placement.ConcentricRingsStructurePlacement;
|
||||||
|
import net.minecraft.world.level.levelgen.structure.placement.RandomSpreadStructurePlacement;
|
||||||
import net.neoforged.neoforge.gametest.GameTestHolder;
|
import net.neoforged.neoforge.gametest.GameTestHolder;
|
||||||
import net.neoforged.neoforge.gametest.PrefixGameTestTemplate;
|
import net.neoforged.neoforge.gametest.PrefixGameTestTemplate;
|
||||||
|
|
||||||
@@ -90,6 +96,166 @@ public final class AgeStructureGameTests {
|
|||||||
helper.succeed();
|
helper.succeed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GameTest(template = "empty")
|
||||||
|
public static void repeatedStructurePagesIncreasePlacementFrequency(GameTestHelper helper) {
|
||||||
|
var lookup = helper.getLevel().registryAccess().lookupOrThrow(Registries.STRUCTURE_SET);
|
||||||
|
|
||||||
|
RandomSpreadStructurePlacement oneVillage = (RandomSpreadStructurePlacement) lookup
|
||||||
|
.getOrThrow(BuiltinStructureSets.VILLAGES).value().placement();
|
||||||
|
RandomSpreadStructurePlacement twoVillages = (RandomSpreadStructurePlacement) AgeStructureSelection
|
||||||
|
.filteredLookup(lookup, repeated("villages", 2)).getOrThrow(BuiltinStructureSets.VILLAGES)
|
||||||
|
.value().placement();
|
||||||
|
helper.assertTrue(oneVillage.spacing() == 34 && twoVillages.spacing() == 24,
|
||||||
|
"A second Village page must approximately double density by reducing grid spacing");
|
||||||
|
|
||||||
|
RandomSpreadStructurePlacement oneMineshaft = (RandomSpreadStructurePlacement) lookup
|
||||||
|
.getOrThrow(BuiltinStructureSets.MINESHAFTS).value().placement();
|
||||||
|
RandomSpreadStructurePlacement twoMineshafts = (RandomSpreadStructurePlacement) AgeStructureSelection
|
||||||
|
.filteredLookup(lookup, repeated("mineshafts", 2)).getOrThrow(BuiltinStructureSets.MINESHAFTS)
|
||||||
|
.value().placement();
|
||||||
|
float oneFrequency = ((StructurePlacementAccessor) oneMineshaft).rivencraft$frequency();
|
||||||
|
float twoFrequency = ((StructurePlacementAccessor) twoMineshafts).rivencraft$frequency();
|
||||||
|
helper.assertTrue(oneMineshaft.spacing() == 1 && twoMineshafts.spacing() == 1
|
||||||
|
&& Math.abs(twoFrequency - oneFrequency * 2.0F) < 0.000001F,
|
||||||
|
"A second Mineshaft page must double its per-chunk probability");
|
||||||
|
|
||||||
|
ConcentricRingsStructurePlacement oneStronghold = (ConcentricRingsStructurePlacement) lookup
|
||||||
|
.getOrThrow(BuiltinStructureSets.STRONGHOLDS).value().placement();
|
||||||
|
ConcentricRingsStructurePlacement twoStrongholds = (ConcentricRingsStructurePlacement) AgeStructureSelection
|
||||||
|
.filteredLookup(lookup, repeated("strongholds", 2)).getOrThrow(BuiltinStructureSets.STRONGHOLDS)
|
||||||
|
.value().placement();
|
||||||
|
helper.assertTrue(twoStrongholds.distance() == oneStronghold.distance()
|
||||||
|
&& twoStrongholds.spread() == oneStronghold.spread() * 2
|
||||||
|
&& twoStrongholds.count() == oneStronghold.count() * 2,
|
||||||
|
"A second Stronghold page must double positions per ring and total positions");
|
||||||
|
helper.succeed();
|
||||||
|
}
|
||||||
|
|
||||||
|
@GameTest(template = "empty")
|
||||||
|
public static void repeatedStructuresConstrainSeedCompletedBiomes(GameTestHelper helper) {
|
||||||
|
OrderedWriting fourVillages = new OrderedWriting(new java.util.ArrayList<>(java.util.stream.Stream.concat(
|
||||||
|
java.util.stream.Stream.of(WritingEntry.linkPanel()),
|
||||||
|
java.util.stream.IntStream.range(0, 4).mapToObj(ignored -> page("feature/villages")))
|
||||||
|
.toList()));
|
||||||
|
try {
|
||||||
|
AgeRegistrySavedData.validateNewWriting(helper.getLevel(), "four", fourVillages);
|
||||||
|
} catch (IllegalArgumentException exception) {
|
||||||
|
helper.fail("Four Village pages without explicit biome pages must use compatible seeded completion: "
|
||||||
|
+ exception.getMessage());
|
||||||
|
}
|
||||||
|
helper.succeed();
|
||||||
|
}
|
||||||
|
|
||||||
|
@GameTest(template = "empty")
|
||||||
|
public static void authoredVillagesOverrideBiomeWithInstability(GameTestHelper helper) {
|
||||||
|
OrderedWriting writing = new OrderedWriting(List.of(WritingEntry.linkPanel(),
|
||||||
|
page("terrain/standard"), page("biome/the_end"), page("biome/single"),
|
||||||
|
page("feature/villages"), page("feature/villages")));
|
||||||
|
AgeDefinition age;
|
||||||
|
try {
|
||||||
|
age = AgeRegistrySavedData.resolveOrCreate(helper.getLevel(),
|
||||||
|
new AgeReference(java.util.UUID.randomUUID(), "Forced End Villages"), writing);
|
||||||
|
} catch (IllegalArgumentException exception) {
|
||||||
|
helper.fail("Authored Villages must be allowed outside vanilla Village biomes: "
|
||||||
|
+ exception.getMessage());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
helper.assertValueEqual(age.instability().score(), 200,
|
||||||
|
"Each of two Villages forced into The End biome must add 100 instability");
|
||||||
|
helper.assertValueEqual(age.instability().breakdown().stream()
|
||||||
|
.filter(part -> part.reason().equals("forced_biome_villages")).count(), 2L,
|
||||||
|
"Every forced Village occurrence must retain its own instability contribution");
|
||||||
|
helper.succeed();
|
||||||
|
}
|
||||||
|
|
||||||
|
@GameTest(template = "empty")
|
||||||
|
public static void mixedEndAndTaigaVillagesChargeForEndPortion(GameTestHelper helper) {
|
||||||
|
for (String firstBiome : List.of("the_end", "plains")) {
|
||||||
|
var writing = new OrderedWriting(List.of(WritingEntry.linkPanel(),
|
||||||
|
page("terrain/standard"), page("biome/" + firstBiome), page("biome/taiga"),
|
||||||
|
page("biome/tiled"), page("lighting/normal"),
|
||||||
|
page("feature/villages"), page("feature/villages")));
|
||||||
|
var age = AgeRegistrySavedData.resolveOrCreate(helper.getLevel(),
|
||||||
|
new AgeReference(java.util.UUID.randomUUID(), "Mixed " + firstBiome), writing);
|
||||||
|
int expected = firstBiome.equals("the_end") ? 200 : 0;
|
||||||
|
helper.assertValueEqual(age.instability().score(), expected,
|
||||||
|
"Each Village page must charge 100 if any selected biome needs the override");
|
||||||
|
helper.assertValueEqual(age.instability().breakdown().stream()
|
||||||
|
.filter(part -> part.reason().equals("forced_biome_villages")).count(),
|
||||||
|
firstBiome.equals("the_end") ? 2L : 0L,
|
||||||
|
"Compatible Taiga must not erase the End portion's forced-biome charges");
|
||||||
|
}
|
||||||
|
helper.succeed();
|
||||||
|
}
|
||||||
|
|
||||||
|
@GameTest(template = "empty")
|
||||||
|
public static void forcedVillageSurvivesStructureStateBiomeGate(GameTestHelper helper) {
|
||||||
|
var registries = helper.getLevel().registryAccess();
|
||||||
|
var sets = registries.lookupOrThrow(Registries.STRUCTURE_SET);
|
||||||
|
var end = new FixedBiomeSource(registries.lookupOrThrow(Registries.BIOME).getOrThrow(Biomes.THE_END));
|
||||||
|
var villages = repeated("villages", 1);
|
||||||
|
var random = helper.getLevel().getChunkSource().randomState();
|
||||||
|
var baseline = ChunkGeneratorStructureState.createForNormal(random, 42L, end,
|
||||||
|
AgeStructureSelection.filteredLookup(sets, villages, end));
|
||||||
|
helper.assertTrue(baseline.possibleStructureSets().stream()
|
||||||
|
.noneMatch(holder -> holder.unwrapKey().filter(BuiltinStructureSets.VILLAGES::equals).isPresent()),
|
||||||
|
"Vanilla rejects a Village structure set in a single End biome before the biome mixin runs");
|
||||||
|
|
||||||
|
var planned = ChunkGeneratorStructureState.createForNormal(random, 42L,
|
||||||
|
AgeStructureSelection.planningBiomes(end, sets, villages),
|
||||||
|
AgeStructureSelection.filteredLookup(sets, villages, end));
|
||||||
|
helper.assertTrue(planned.possibleStructureSets().stream()
|
||||||
|
.anyMatch(holder -> holder.unwrapKey().filter(BuiltinStructureSets.VILLAGES::equals).isPresent()),
|
||||||
|
"The authored Village must survive the structure-state biome gate");
|
||||||
|
var village = sets.getOrThrow(BuiltinStructureSets.VILLAGES).value().structures().getFirst().structure();
|
||||||
|
helper.assertTrue(!planned.getPlacementsForStructure(village).isEmpty(),
|
||||||
|
"The forced Village must have an actual placement in the Age structure state");
|
||||||
|
helper.assertTrue(planned.possibleStructureSets().stream().noneMatch(holder -> holder.unwrapKey()
|
||||||
|
.filter(BuiltinStructureSets.DESERT_PYRAMIDS::equals).isPresent()),
|
||||||
|
"Planning biomes must not enable unrelated desert structures in the End Age");
|
||||||
|
helper.assertTrue(end.possibleBiomes().size() == 1 && end.possibleBiomes().contains(
|
||||||
|
registries.lookupOrThrow(Registries.BIOME).getOrThrow(Biomes.THE_END)),
|
||||||
|
"The actual Age biome source must remain End-only");
|
||||||
|
helper.succeed();
|
||||||
|
}
|
||||||
|
|
||||||
|
@GameTest(template = "empty")
|
||||||
|
public static void otherAuthoredStructuresOverrideBiomeWithInstability(GameTestHelper helper) {
|
||||||
|
var registries = helper.getLevel().registryAccess();
|
||||||
|
var sets = registries.lookupOrThrow(Registries.STRUCTURE_SET);
|
||||||
|
var end = new FixedBiomeSource(registries.lookupOrThrow(Registries.BIOME).getOrThrow(Biomes.THE_END));
|
||||||
|
var random = helper.getLevel().getChunkSource().randomState();
|
||||||
|
for (var entry : Map.of("shipwrecks", BuiltinStructureSets.SHIPWRECKS,
|
||||||
|
"trial_chambers", BuiltinStructureSets.TRIAL_CHAMBERS).entrySet()) {
|
||||||
|
String feature = entry.getKey();
|
||||||
|
var choices = repeated(feature, 1);
|
||||||
|
var planned = ChunkGeneratorStructureState.createForNormal(random, 42L,
|
||||||
|
AgeStructureSelection.planningBiomes(end, sets, choices),
|
||||||
|
AgeStructureSelection.filteredLookup(sets, choices, end));
|
||||||
|
helper.assertTrue(planned.possibleStructureSets().stream()
|
||||||
|
.anyMatch(holder -> holder.unwrapKey().filter(entry.getValue()::equals).isPresent()),
|
||||||
|
"Authored " + feature + " must survive the structure-state biome gate");
|
||||||
|
var structure = sets.getOrThrow(entry.getValue()).value().structures().getFirst().structure();
|
||||||
|
helper.assertTrue(!planned.getPlacementsForStructure(structure).isEmpty(),
|
||||||
|
"Authored " + feature + " must have a placement in the End Age");
|
||||||
|
|
||||||
|
var writing = new OrderedWriting(List.of(WritingEntry.linkPanel(),
|
||||||
|
page("terrain/standard"), page("biome/the_end"), page("biome/single"),
|
||||||
|
page("feature/" + feature)));
|
||||||
|
var age = AgeRegistrySavedData.resolveOrCreate(helper.getLevel(),
|
||||||
|
new AgeReference(java.util.UUID.randomUUID(), "Forced " + feature), writing);
|
||||||
|
helper.assertValueEqual(age.instability().score(), 100,
|
||||||
|
"An authored " + feature + " outside its normal biomes must add 100 instability");
|
||||||
|
}
|
||||||
|
helper.succeed();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<AgeFeatureSelection.Choice> repeated(String feature, int count) {
|
||||||
|
return java.util.stream.IntStream.range(0, count)
|
||||||
|
.mapToObj(ignored -> new AgeFeatureSelection.Choice(id(feature), Optional.<ResourceLocation>empty()))
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
|
||||||
private static ResourceLocation id(String path) {
|
private static ResourceLocation id(String path) {
|
||||||
return ResourceLocation.fromNamespaceAndPath(Rivencraft.MOD_ID, path);
|
return ResourceLocation.fromNamespaceAndPath(Rivencraft.MOD_ID, path);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,33 @@
|
|||||||
package net.dnorberg.rivencraft.book;
|
package net.dnorberg.rivencraft.book;
|
||||||
|
|
||||||
|
import com.mojang.serialization.MapCodec;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
import net.dnorberg.rivencraft.mixin.StructurePlacementAccessor;
|
||||||
import net.minecraft.core.Holder;
|
import net.minecraft.core.Holder;
|
||||||
import net.minecraft.core.HolderLookup;
|
import net.minecraft.core.HolderLookup;
|
||||||
|
import net.minecraft.core.HolderOwner;
|
||||||
import net.minecraft.core.HolderSet;
|
import net.minecraft.core.HolderSet;
|
||||||
import net.minecraft.core.RegistryAccess;
|
import net.minecraft.core.RegistryAccess;
|
||||||
import net.minecraft.core.registries.Registries;
|
import net.minecraft.core.registries.Registries;
|
||||||
import net.minecraft.resources.ResourceKey;
|
import net.minecraft.resources.ResourceKey;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.tags.TagKey;
|
import net.minecraft.tags.TagKey;
|
||||||
|
import net.minecraft.world.level.biome.Biome;
|
||||||
|
import net.minecraft.world.level.biome.BiomeSource;
|
||||||
|
import net.minecraft.world.level.biome.Climate;
|
||||||
import net.minecraft.world.level.levelgen.structure.BuiltinStructureSets;
|
import net.minecraft.world.level.levelgen.structure.BuiltinStructureSets;
|
||||||
|
import net.minecraft.world.level.levelgen.structure.Structure;
|
||||||
import net.minecraft.world.level.levelgen.structure.StructureSet;
|
import net.minecraft.world.level.levelgen.structure.StructureSet;
|
||||||
|
import net.minecraft.world.level.levelgen.structure.placement.ConcentricRingsStructurePlacement;
|
||||||
|
import net.minecraft.world.level.levelgen.structure.placement.RandomSpreadStructurePlacement;
|
||||||
|
import net.minecraft.world.level.levelgen.structure.placement.StructurePlacement;
|
||||||
|
|
||||||
/** Frozen Age structure-page choices and their vanilla structure-set gate. */
|
/** Frozen Age structure-page choices and their vanilla structure-set gate. */
|
||||||
public final class AgeStructureSelection {
|
public final class AgeStructureSelection {
|
||||||
@@ -98,14 +109,9 @@ public final class AgeStructureSelection {
|
|||||||
var set = registries.lookupOrThrow(Registries.STRUCTURE_SET)
|
var set = registries.lookupOrThrow(Registries.STRUCTURE_SET)
|
||||||
.get(ResourceKey.create(Registries.STRUCTURE_SET, setId));
|
.get(ResourceKey.create(Registries.STRUCTURE_SET, setId));
|
||||||
if (set.isEmpty()) return "Feature " + feature + " requires missing structure set " + setId;
|
if (set.isEmpty()) return "Feature " + feature + " requires missing structure set " + setId;
|
||||||
if (biomes == null) return null;
|
// Authored structures intentionally override vanilla biome eligibility. An
|
||||||
Set<ResourceLocation> selected = Set.copyOf(biomes.biomes());
|
// incompatible selection is legal writing and receives instability instead.
|
||||||
boolean compatible = set.orElseThrow().value().structures().stream()
|
return null;
|
||||||
.flatMap(entry -> entry.structure().value().biomes().stream())
|
|
||||||
.map(holder -> holder.unwrapKey().map(ResourceKey::location).orElse(null))
|
|
||||||
.anyMatch(selected::contains);
|
|
||||||
return compatible ? null : "Feature " + feature
|
|
||||||
+ " needs at least one biome allowed by structure set " + setId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean placedExists(RegistryAccess registries, ResourceLocation id) {
|
private static boolean placedExists(RegistryAccess registries, ResourceLocation id) {
|
||||||
@@ -113,10 +119,47 @@ public final class AgeStructureSelection {
|
|||||||
.get(ResourceKey.create(Registries.PLACED_FEATURE, id)).isPresent();
|
.get(ResourceKey.create(Registries.PLACED_FEATURE, id)).isPresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Set<ResourceLocation> compatibleBiomes(ResourceLocation feature, RegistryAccess registries) {
|
||||||
|
ResourceLocation structureSet = setId(feature);
|
||||||
|
if (structureSet == null) return Set.of();
|
||||||
|
return registries.lookupOrThrow(Registries.STRUCTURE_SET)
|
||||||
|
.get(ResourceKey.create(Registries.STRUCTURE_SET, structureSet)).stream()
|
||||||
|
.flatMap(holder -> holder.value().structures().stream())
|
||||||
|
.flatMap(entry -> entry.structure().value().biomes().stream())
|
||||||
|
.flatMap(holder -> holder.unwrapKey().stream())
|
||||||
|
.map(ResourceKey::location)
|
||||||
|
.collect(java.util.stream.Collectors.toUnmodifiableSet());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean biomeCompatible(ResourceLocation feature, AgeBiomeSelection biomes,
|
||||||
|
RegistryAccess registries) {
|
||||||
|
Set<ResourceLocation> compatible = compatibleBiomes(feature, registries);
|
||||||
|
return compatible.isEmpty() || biomes.biomes().stream().anyMatch(compatible::contains);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A mixed pool still needs the authored override wherever its structure is not normally allowed. */
|
||||||
|
public static boolean requiresBiomeOverride(ResourceLocation feature, AgeBiomeSelection biomes,
|
||||||
|
RegistryAccess registries) {
|
||||||
|
Set<ResourceLocation> compatible = compatibleBiomes(feature, registries);
|
||||||
|
return !compatible.isEmpty() && biomes.biomes().stream().anyMatch(biome -> !compatible.contains(biome));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** True when this exact registered structure belongs to an authored structure page. */
|
||||||
|
public static boolean authoredStructure(Structure structure, RegistryAccess registries,
|
||||||
|
List<AgeFeatureSelection.Choice> choices) {
|
||||||
|
Set<ResourceLocation> enabled = enabledSets(choices).keySet();
|
||||||
|
var sets = registries.lookupOrThrow(Registries.STRUCTURE_SET);
|
||||||
|
return enabled.stream().map(id -> ResourceKey.create(Registries.STRUCTURE_SET, id))
|
||||||
|
.flatMap(key -> sets.get(key).stream())
|
||||||
|
.flatMap(holder -> holder.value().structures().stream())
|
||||||
|
.anyMatch(entry -> entry.structure().value() == structure);
|
||||||
|
}
|
||||||
|
|
||||||
public static List<AgeFeatureSelection.Choice> randomChoices(long ageSeed, AgeRuntimeProfile profile,
|
public static List<AgeFeatureSelection.Choice> randomChoices(long ageSeed, AgeRuntimeProfile profile,
|
||||||
AgeBiomeSelection biomes, RegistryAccess registries) {
|
AgeBiomeSelection biomes, RegistryAccess registries) {
|
||||||
List<LegacyRankChoice.Option<ResourceLocation>> eligible = new ArrayList<>(FEATURES.stream()
|
List<LegacyRankChoice.Option<ResourceLocation>> eligible = new ArrayList<>(FEATURES.stream()
|
||||||
.filter(id -> error(id, profile, biomes, registries) == null)
|
.filter(id -> error(id, profile, biomes, registries) == null)
|
||||||
|
.filter(id -> dungeons(id) || biomeCompatible(id, biomes, registries))
|
||||||
.map(id -> new LegacyRankChoice.Option<>(id, randomRank(id))).toList());
|
.map(id -> new LegacyRankChoice.Option<>(id, randomRank(id))).toList());
|
||||||
Random random = new Random(ageSeed ^ 0x5354525543545552L);
|
Random random = new Random(ageSeed ^ 0x5354525543545552L);
|
||||||
int count = random.nextInt(3);
|
int count = random.nextInt(3);
|
||||||
@@ -136,25 +179,47 @@ public final class AgeStructureSelection {
|
|||||||
return 3; // Structures added after Legacy are uncommon, but still discoverable.
|
return 3; // Structures added after Legacy are uncommon, but still discoverable.
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Set<ResourceLocation> enabledSets(List<AgeFeatureSelection.Choice> choices) {
|
private static Map<ResourceLocation, Integer> enabledSets(List<AgeFeatureSelection.Choice> choices) {
|
||||||
return choices.stream().filter(choice -> feature(choice.id()) && !dungeons(choice.id()))
|
Map<ResourceLocation, Integer> counts = new HashMap<>();
|
||||||
.map(choice -> setId(choice.id())).collect(java.util.stream.Collectors.toUnmodifiableSet());
|
choices.stream().filter(choice -> feature(choice.id()) && !dungeons(choice.id()))
|
||||||
|
.forEach(choice -> counts.merge(setId(choice.id()), 1, Integer::sum));
|
||||||
|
return Map.copyOf(counts);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Stream<Holder<StructureSet>> allowedSets(Stream<Holder<StructureSet>> sets,
|
public static Stream<Holder<StructureSet>> allowedSets(Stream<Holder<StructureSet>> sets,
|
||||||
List<AgeFeatureSelection.Choice> choices) {
|
List<AgeFeatureSelection.Choice> choices) {
|
||||||
Set<ResourceLocation> enabled = enabledSets(choices);
|
return allowedSets(sets, choices, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Stream<Holder<StructureSet>> allowedSets(Stream<Holder<StructureSet>> sets,
|
||||||
|
List<AgeFeatureSelection.Choice> choices,
|
||||||
|
BiomeSource actualBiomes) {
|
||||||
|
Map<ResourceLocation, Integer> enabled = enabledSets(choices);
|
||||||
return sets.filter(holder -> holder.unwrapKey()
|
return sets.filter(holder -> holder.unwrapKey()
|
||||||
.map(key -> allowed(key.location(), enabled)).orElse(false));
|
.map(key -> allowed(key.location(), enabled.keySet())
|
||||||
|
&& (actualBiomes == null || enabled.containsKey(key.location())
|
||||||
|
|| hasActualBiome(holder.value(), actualBiomes))).orElse(false))
|
||||||
|
.map(holder -> scaledHolder(holder, enabled));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HolderLookup<StructureSet> filteredLookup(HolderLookup<StructureSet> lookup,
|
public static HolderLookup<StructureSet> filteredLookup(HolderLookup<StructureSet> lookup,
|
||||||
List<AgeFeatureSelection.Choice> choices) {
|
List<AgeFeatureSelection.Choice> choices) {
|
||||||
Set<ResourceLocation> enabled = enabledSets(choices);
|
return filteredLookup(lookup, choices, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HolderLookup<StructureSet> filteredLookup(HolderLookup<StructureSet> lookup,
|
||||||
|
List<AgeFeatureSelection.Choice> choices,
|
||||||
|
BiomeSource actualBiomes) {
|
||||||
|
Map<ResourceLocation, Integer> enabled = enabledSets(choices);
|
||||||
|
Map<ResourceKey<StructureSet>, Holder.Reference<StructureSet>> scaled = new HashMap<>();
|
||||||
return new HolderLookup<>() {
|
return new HolderLookup<>() {
|
||||||
@Override
|
@Override
|
||||||
public Optional<Holder.Reference<StructureSet>> get(ResourceKey<StructureSet> key) {
|
public Optional<Holder.Reference<StructureSet>> get(ResourceKey<StructureSet> key) {
|
||||||
return allowed(key.location(), enabled) ? lookup.get(key) : Optional.empty();
|
if (!allowed(key.location(), enabled.keySet())) return Optional.empty();
|
||||||
|
return lookup.get(key).filter(holder -> actualBiomes == null || enabled.containsKey(key.location())
|
||||||
|
|| hasActualBiome(holder.value(), actualBiomes))
|
||||||
|
.map(holder -> scaled.computeIfAbsent(key,
|
||||||
|
ignored -> scaledReference(holder, enabled.getOrDefault(key.location(), 1))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -164,7 +229,13 @@ public final class AgeStructureSelection {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Stream<Holder.Reference<StructureSet>> listElements() {
|
public Stream<Holder.Reference<StructureSet>> listElements() {
|
||||||
return lookup.listElements().filter(holder -> allowed(holder.key().location(), enabled));
|
return lookup.listElements()
|
||||||
|
.filter(holder -> allowed(holder.key().location(), enabled.keySet()))
|
||||||
|
.filter(holder -> actualBiomes == null || enabled.containsKey(holder.key().location())
|
||||||
|
|| hasActualBiome(holder.value(), actualBiomes))
|
||||||
|
.map(holder -> scaled.computeIfAbsent(holder.key(),
|
||||||
|
ignored -> scaledReference(holder,
|
||||||
|
enabled.getOrDefault(holder.key().location(), 1))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -177,4 +248,101 @@ public final class AgeStructureSelection {
|
|||||||
private static boolean allowed(ResourceLocation set, Set<ResourceLocation> enabled) {
|
private static boolean allowed(ResourceLocation set, Set<ResourceLocation> enabled) {
|
||||||
return !CONTROLLED_SETS.contains(set) || enabled.contains(set);
|
return !CONTROLLED_SETS.contains(set) || enabled.contains(set);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean hasActualBiome(StructureSet set, BiomeSource actualBiomes) {
|
||||||
|
Set<Holder<Biome>> present = actualBiomes.possibleBiomes();
|
||||||
|
return set.structures().stream().flatMap(entry -> entry.structure().value().biomes().stream())
|
||||||
|
.anyMatch(present::contains);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Only the structure planner sees these extra biomes; terrain and weather keep the real source. */
|
||||||
|
public static BiomeSource planningBiomes(BiomeSource actual, HolderLookup<StructureSet> sets,
|
||||||
|
List<AgeFeatureSelection.Choice> choices) {
|
||||||
|
Set<ResourceLocation> enabled = enabledSets(choices).keySet();
|
||||||
|
List<Holder<Biome>> structureBiomes = enabled.stream()
|
||||||
|
.map(id -> sets.get(ResourceKey.create(Registries.STRUCTURE_SET, id)))
|
||||||
|
.flatMap(Optional::stream)
|
||||||
|
.flatMap(holder -> holder.value().structures().stream())
|
||||||
|
.flatMap(entry -> entry.structure().value().biomes().stream())
|
||||||
|
.distinct().toList();
|
||||||
|
return structureBiomes.isEmpty() ? actual : new PlanningBiomeSource(actual, structureBiomes);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final class PlanningBiomeSource extends BiomeSource {
|
||||||
|
private final BiomeSource actual;
|
||||||
|
private final List<Holder<Biome>> structureBiomes;
|
||||||
|
|
||||||
|
private PlanningBiomeSource(BiomeSource actual, List<Holder<Biome>> structureBiomes) {
|
||||||
|
this.actual = actual;
|
||||||
|
this.structureBiomes = structureBiomes;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected MapCodec<? extends BiomeSource> codec() {
|
||||||
|
throw new UnsupportedOperationException("Structure-planning biome sources are never serialized");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Stream<Holder<Biome>> collectPossibleBiomes() {
|
||||||
|
return Stream.concat(actual.possibleBiomes().stream(), structureBiomes.stream());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Holder<Biome> getNoiseBiome(int x, int y, int z, Climate.Sampler sampler) {
|
||||||
|
return actual.getNoiseBiome(x, y, z, sampler);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Holder<StructureSet> scaledHolder(Holder<StructureSet> holder,
|
||||||
|
Map<ResourceLocation, Integer> enabled) {
|
||||||
|
int occurrences = holder.unwrapKey().map(key -> enabled.getOrDefault(key.location(), 1)).orElse(1);
|
||||||
|
return occurrences == 1 ? holder : Holder.direct(scaled(holder.value(), occurrences));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Holder.Reference<StructureSet> scaledReference(Holder.Reference<StructureSet> holder,
|
||||||
|
int occurrences) {
|
||||||
|
if (occurrences == 1) return holder;
|
||||||
|
return new ScaledReference(holder.key(), scaled(holder.value(), occurrences));
|
||||||
|
}
|
||||||
|
|
||||||
|
static StructureSet scaled(StructureSet set, int occurrences) {
|
||||||
|
if (occurrences < 1) throw new IllegalArgumentException("Structure occurrence count must be positive");
|
||||||
|
if (occurrences == 1) return set;
|
||||||
|
StructurePlacement placement = set.placement();
|
||||||
|
StructurePlacementAccessor base = (StructurePlacementAccessor) placement;
|
||||||
|
if (placement instanceof RandomSpreadStructurePlacement random) {
|
||||||
|
float originalFrequency = base.rivencraft$frequency();
|
||||||
|
float frequency = Math.min(1.0F, originalFrequency * occurrences);
|
||||||
|
double frequencyFactor = originalFrequency > 0.0F ? frequency / originalFrequency : 1.0;
|
||||||
|
double spacingFactor = occurrences / frequencyFactor;
|
||||||
|
int spacing = Math.max(1, (int) Math.round(random.spacing() / Math.sqrt(spacingFactor)));
|
||||||
|
int separation = spacing == 1 ? 0 : Math.min(spacing - 1,
|
||||||
|
(int) Math.round((double) random.separation() * spacing / random.spacing()));
|
||||||
|
return new StructureSet(set.structures(), new RandomSpreadStructurePlacement(
|
||||||
|
base.rivencraft$locateOffset(), base.rivencraft$frequencyReductionMethod(), frequency,
|
||||||
|
base.rivencraft$salt(), base.rivencraft$exclusionZone(), spacing, separation,
|
||||||
|
random.spreadType()));
|
||||||
|
}
|
||||||
|
if (placement instanceof ConcentricRingsStructurePlacement rings) {
|
||||||
|
int count = saturatedMultiply(rings.count(), occurrences, 4095);
|
||||||
|
int spread = Math.min(count, saturatedMultiply(rings.spread(), occurrences, 1023));
|
||||||
|
return new StructureSet(set.structures(), new ConcentricRingsStructurePlacement(
|
||||||
|
base.rivencraft$locateOffset(), base.rivencraft$frequencyReductionMethod(),
|
||||||
|
base.rivencraft$frequency(), base.rivencraft$salt(), base.rivencraft$exclusionZone(),
|
||||||
|
rings.distance(), spread, count, rings.preferredBiomes()));
|
||||||
|
}
|
||||||
|
return set;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int saturatedMultiply(int value, int multiplier, int maximum) {
|
||||||
|
return (int) Math.min(maximum, (long) value * multiplier);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final class ScaledReference extends Holder.Reference<StructureSet> {
|
||||||
|
private static final HolderOwner<StructureSet> OWNER = new HolderOwner<>() {};
|
||||||
|
|
||||||
|
private ScaledReference(ResourceKey<StructureSet> key, StructureSet value) {
|
||||||
|
super(Type.STAND_ALONE, OWNER, key, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -27,6 +27,17 @@ public final class RivencraftCommands {
|
|||||||
.then(Commands.literal("age")
|
.then(Commands.literal("age")
|
||||||
.then(Commands.literal("list")
|
.then(Commands.literal("list")
|
||||||
.executes(context -> listAges(context.getSource())))
|
.executes(context -> listAges(context.getSource())))
|
||||||
|
.then(Commands.literal("instability")
|
||||||
|
.executes(context -> inspectInstability(context.getSource(),
|
||||||
|
context.getSource().getLevel().dimension().location().toString()))
|
||||||
|
.then(Commands.argument("dimension", StringArgumentType.string())
|
||||||
|
.suggests((context, builder) -> {
|
||||||
|
AgeRegistrySavedData.get(context.getSource().getLevel()).definitions()
|
||||||
|
.forEach(age -> builder.suggest(age.dimensionId().toString()));
|
||||||
|
return builder.buildFuture();
|
||||||
|
})
|
||||||
|
.executes(context -> inspectInstability(context.getSource(),
|
||||||
|
StringArgumentType.getString(context, "dimension")))))
|
||||||
.then(Commands.literal("unload")
|
.then(Commands.literal("unload")
|
||||||
.then(Commands.argument("dimension", StringArgumentType.string())
|
.then(Commands.argument("dimension", StringArgumentType.string())
|
||||||
.suggests((context, builder) -> {
|
.suggests((context, builder) -> {
|
||||||
@@ -119,6 +130,28 @@ public final class RivencraftCommands {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static int inspectInstability(CommandSourceStack source, String requestedDimension) {
|
||||||
|
ResourceLocation dimension = ResourceLocation.tryParse(requestedDimension);
|
||||||
|
if (dimension == null) {
|
||||||
|
source.sendFailure(Component.literal("Invalid dimension id: " + requestedDimension));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
AgeDefinition age = AgeRegistrySavedData.get(source.getLevel()).findByDimension(dimension).orElse(null);
|
||||||
|
if (age == null) {
|
||||||
|
source.sendFailure(Component.literal("Unknown Rivencraft Age: " + dimension));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
var totals = age.instability().totals();
|
||||||
|
source.sendSuccess(() -> Component.literal(age.name() + " — " + age.dimensionId()), false);
|
||||||
|
source.sendSuccess(() -> Component.literal("Instability: base " + totals.baseScore()
|
||||||
|
+ ", stability bonus " + totals.stabilityBonus()
|
||||||
|
+ ", penalty " + totals.instabilityPenalty()
|
||||||
|
+ ", effective " + totals.effectiveScore()), false);
|
||||||
|
source.sendSuccess(() -> Component.literal("Mutable player bonuses: disabled (no active Legacy registration)"),
|
||||||
|
false);
|
||||||
|
return totals.effectiveScore();
|
||||||
|
}
|
||||||
|
|
||||||
private static int pulseDecay(net.minecraft.commands.CommandSourceStack source, String colorName, int attempts) {
|
private static int pulseDecay(net.minecraft.commands.CommandSourceStack source, String colorName, int attempts) {
|
||||||
DecayBlock.Color color;
|
DecayBlock.Color color;
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package net.dnorberg.rivencraft.mixin;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import net.dnorberg.rivencraft.book.AgeFeatureSelection;
|
||||||
|
import net.dnorberg.rivencraft.book.AgeStructureSelection;
|
||||||
|
import net.dnorberg.rivencraft.world.AgeFeatureChunkGenerator;
|
||||||
|
import net.dnorberg.rivencraft.world.AgeFlatChunkGenerator;
|
||||||
|
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||||
|
import net.minecraft.world.level.levelgen.structure.Structure;
|
||||||
|
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.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
/** Lets explicitly authored structures generate outside their vanilla biome sets. */
|
||||||
|
@Mixin(Structure.class)
|
||||||
|
public abstract class AgeStructureBiomeMixin {
|
||||||
|
@Shadow
|
||||||
|
protected abstract Optional<Structure.GenerationStub> findGenerationPoint(
|
||||||
|
Structure.GenerationContext context);
|
||||||
|
|
||||||
|
@Inject(method = "findValidGenerationPoint", at = @At("HEAD"), cancellable = true)
|
||||||
|
private void rivencraft$allowAuthoredStructureBiome(Structure.GenerationContext context,
|
||||||
|
CallbackInfoReturnable<Optional<Structure.GenerationStub>> cir) {
|
||||||
|
ChunkGenerator generator = context.chunkGenerator();
|
||||||
|
List<AgeFeatureSelection.Choice> features;
|
||||||
|
if (generator instanceof AgeFeatureChunkGenerator age) features = age.ageFeatures();
|
||||||
|
else if (generator instanceof AgeFlatChunkGenerator age) features = age.ageFeatures();
|
||||||
|
else return;
|
||||||
|
if (AgeStructureSelection.authoredStructure((Structure) (Object) this,
|
||||||
|
context.registryAccess(), features)) {
|
||||||
|
cir.setReturnValue(findGenerationPoint(context));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package net.dnorberg.rivencraft.mixin;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
import net.minecraft.core.Vec3i;
|
||||||
|
import net.minecraft.world.level.levelgen.structure.placement.StructurePlacement;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||||
|
|
||||||
|
/** Exposes immutable placement settings so per-Age structure density can preserve vanilla behavior. */
|
||||||
|
@Mixin(StructurePlacement.class)
|
||||||
|
public interface StructurePlacementAccessor {
|
||||||
|
@Accessor("locateOffset")
|
||||||
|
Vec3i rivencraft$locateOffset();
|
||||||
|
|
||||||
|
@Accessor("frequencyReductionMethod")
|
||||||
|
StructurePlacement.FrequencyReductionMethod rivencraft$frequencyReductionMethod();
|
||||||
|
|
||||||
|
@Accessor("frequency")
|
||||||
|
float rivencraft$frequency();
|
||||||
|
|
||||||
|
@Accessor("salt")
|
||||||
|
int rivencraft$salt();
|
||||||
|
|
||||||
|
@Accessor("exclusionZone")
|
||||||
|
Optional<StructurePlacement.ExclusionZone> rivencraft$exclusionZone();
|
||||||
|
}
|
||||||
@@ -110,8 +110,10 @@ public final class AgeFeatureChunkGenerator extends NoiseBasedChunkGenerator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChunkGeneratorStructureState createState(HolderLookup<StructureSet> sets, RandomState random, long seed) {
|
public ChunkGeneratorStructureState createState(HolderLookup<StructureSet> sets, RandomState random, long seed) {
|
||||||
return ChunkGeneratorStructureState.createForNormal(random, seed, getBiomeSource(),
|
BiomeSource actual = getBiomeSource();
|
||||||
AgeStructureSelection.filteredLookup(sets, features));
|
return ChunkGeneratorStructureState.createForNormal(random, seed,
|
||||||
|
AgeStructureSelection.planningBiomes(actual, sets, features),
|
||||||
|
AgeStructureSelection.filteredLookup(sets, features, actual));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -72,8 +72,9 @@ public final class AgeFlatChunkGenerator extends ChunkGenerator {
|
|||||||
Stream<Holder<StructureSet>> entries = settings.structureOverrides()
|
Stream<Holder<StructureSet>> entries = settings.structureOverrides()
|
||||||
.map(HolderSet::stream)
|
.map(HolderSet::stream)
|
||||||
.orElseGet(() -> structures.listElements().map(holder -> (Holder<StructureSet>) holder));
|
.orElseGet(() -> structures.listElements().map(holder -> (Holder<StructureSet>) holder));
|
||||||
return ChunkGeneratorStructureState.createForFlat(random, seed, biomeSource,
|
return ChunkGeneratorStructureState.createForFlat(random, seed,
|
||||||
AgeStructureSelection.allowedSets(entries, features));
|
AgeStructureSelection.planningBiomes(biomeSource, structures, features),
|
||||||
|
AgeStructureSelection.allowedSets(entries, features, biomeSource));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -4,7 +4,9 @@
|
|||||||
"package": "net.dnorberg.rivencraft.mixin",
|
"package": "net.dnorberg.rivencraft.mixin",
|
||||||
"compatibilityLevel": "JAVA_21",
|
"compatibilityLevel": "JAVA_21",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"AgeDungeonPlacementMixin"
|
"AgeDungeonPlacementMixin",
|
||||||
|
"AgeStructureBiomeMixin",
|
||||||
|
"StructurePlacementAccessor"
|
||||||
],
|
],
|
||||||
"client": [
|
"client": [
|
||||||
"client.ClientLevelSoundMixin",
|
"client.ClientLevelSoundMixin",
|
||||||
|
|||||||
Reference in new issue
Block a user