Public Access
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6452d2c324 | ||
|
|
4541cbbba5 | ||
|
|
68db795216 | ||
|
|
b86e855907 |
No files matched your search
@@ -21,9 +21,23 @@ The spent vial returns a glass bottle. Server owners can adjust the symbol-copy
|
|||||||
and link-panel costs in the `writing` section of `rivencraft-server.toml`.
|
and link-panel costs in the `writing` section of `rivencraft-server.toml`.
|
||||||
The Ink Mixer now offers a Legacy-style station for producing Link Panels:
|
The Ink Mixer now offers a Legacy-style station for producing Link Panels:
|
||||||
insert paper and Ink Vials, then take a Link Panel from the result slot. Each
|
insert paper and Ink Vials, then take a Link Panel from the result slot. Each
|
||||||
vial fills its 16-unit basin and returns a glass bottle; no server tick is
|
vial fills its 16-unit basin and returns a glass bottle; taking one Link Panel
|
||||||
needed. The earlier paper-in-one-hand method remains available. Ink modifier
|
uses the full vial. No server tick is needed. The earlier paper-in-one-hand
|
||||||
ingredients and link properties are planned for Milestone 5.
|
method still uses the configurable link-panel ink cost. Ink Mixer
|
||||||
|
additives can roll Disarm, Maintain Momentum, and Intra Linking onto a Link
|
||||||
|
Panel. Descriptive Books retain Disarm and Momentum; Intra Linking is only
|
||||||
|
meaningful for same-dimension travel with a Linking Book.
|
||||||
|
TerraBlender 1.21.1 integration is optional: registered modded biomes receive
|
||||||
|
Biome pages, with cave and Nether biomes in a separate Cave Biome creative tab.
|
||||||
|
TerraBlender Overworld/Nether regions extend compatible Age
|
||||||
|
biome pools. See [the compatibility matrix](docs/TERRABLENDER_COMPATIBILITY.md)
|
||||||
|
for supported versions and in-game verification.
|
||||||
|
Serene Seasons 1.21.1 can maintain separate season progress in an Age dimension.
|
||||||
|
Rivencraft automatically whitelists loaded Ages without a restart when Serene is installed;
|
||||||
|
season pages can instead opt an Age out or hold it in one season.
|
||||||
|
See [the optional compatibility guide](docs/SERENE_SEASONS_COMPATIBILITY.md)
|
||||||
|
for the supported manual configuration and current limits; Rivencraft does not
|
||||||
|
require Serene Seasons or GlitchCore.
|
||||||
The Writing Desk can copy a selected written page from its collection tabs.
|
The Writing Desk can copy a selected written page from its collection tabs.
|
||||||
The Writing Desk is now craftable from planks, a glass bottle, and a feather.
|
The Writing Desk is now craftable from planks, a glass bottle, and a feather.
|
||||||
It occupies two adjacent blocks, with one shared inventory; loaded paper and
|
It occupies two adjacent blocks, with one shared inventory; loaded paper and
|
||||||
|
|||||||
@@ -91,6 +91,11 @@ repositories {
|
|||||||
content { includeGroup 'curse.maven' }
|
content { includeGroup 'curse.maven' }
|
||||||
}
|
}
|
||||||
maven { url = 'https://maven.bai.lol' }
|
maven { url = 'https://maven.bai.lol' }
|
||||||
|
maven {
|
||||||
|
name = 'TerraBlenderMaven'
|
||||||
|
url = 'https://maven.minecraftforge.net/releases/'
|
||||||
|
content { includeGroup 'com.github.glitchfiend' }
|
||||||
|
}
|
||||||
maven {
|
maven {
|
||||||
url = 'https://api.modrinth.com/maven'
|
url = 'https://api.modrinth.com/maven'
|
||||||
content { includeGroup 'maven.modrinth' }
|
content { includeGroup 'maven.modrinth' }
|
||||||
@@ -238,6 +243,19 @@ dependencies {
|
|||||||
// Keep them on the compile classpath without forcing either mod at runtime.
|
// Keep them on the compile classpath without forcing either mod at runtime.
|
||||||
compileOnly "net.createmod.ponder:ponder-neoforge:${ponder_version}+mc${minecraft_version}"
|
compileOnly "net.createmod.ponder:ponder-neoforge:${ponder_version}+mc${minecraft_version}"
|
||||||
compileOnly "maven.modrinth:immersive-portals-neoforge:${immersive_portals_version}"
|
compileOnly "maven.modrinth:immersive-portals-neoforge:${immersive_portals_version}"
|
||||||
|
// TerraBlender's region API is only used by the guarded compat adapter.
|
||||||
|
compileOnly "com.github.glitchfiend:TerraBlender-neoforge:${minecraft_version}-${terrablender_version}"
|
||||||
|
if (providers.gradleProperty('withTerraBlender').map { it.toBoolean() }.orElse(false).get()) {
|
||||||
|
localRuntime "com.github.glitchfiend:TerraBlender-neoforge:${minecraft_version}-${terrablender_version}"
|
||||||
|
}
|
||||||
|
// The optional compatibility adapter uses Serene's dimension config API.
|
||||||
|
// Neither mod is a required dependency of the published Rivencraft jar.
|
||||||
|
compileOnly "maven.modrinth:e0bNACJD:${serene_seasons_version_id}"
|
||||||
|
compileOnly "maven.modrinth:s3dmwKy5:${glitchcore_version_id}"
|
||||||
|
if (providers.gradleProperty('withSereneSeasons').map { it.toBoolean() }.orElse(false).get()) {
|
||||||
|
localRuntime "maven.modrinth:e0bNACJD:${serene_seasons_version_id}"
|
||||||
|
localRuntime "maven.modrinth:s3dmwKy5:${glitchcore_version_id}"
|
||||||
|
}
|
||||||
implementation "curse.maven:dynamicdimension-ar-edition-1469680:${dynamic_dimensions_file_id}"
|
implementation "curse.maven:dynamicdimension-ar-edition-1469680:${dynamic_dimensions_file_id}"
|
||||||
implementation "lol.bai:badpackets:neo-${badpackets_version}"
|
implementation "lol.bai:badpackets:neo-${badpackets_version}"
|
||||||
// JEI integration is isolated in its plugin and absent from the published runtime dependencies.
|
// JEI integration is isolated in its plugin and absent from the published runtime dependencies.
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 43 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 67 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 79 KiB |
@@ -47,6 +47,52 @@ automated check, and hand its exact scenario to the player for in-game
|
|||||||
verification. Do not keep retrying a stalled test or leave its process running.
|
verification. Do not keep retrying a stalled test or leave its process running.
|
||||||
Keep the narrower non-stalling plan, persistence, and runtime checks automated.
|
Keep the narrower non-stalling plan, persistence, and runtime checks automated.
|
||||||
|
|
||||||
|
The optional `-PwithSereneSeasons=true` runtime is for a real dev client, not
|
||||||
|
the GameTest server: Serene Seasons sends a season payload to GameTest mock
|
||||||
|
players, which cannot negotiate its channel. Follow the real-client Serene test in
|
||||||
|
`docs/SERENE_SEASONS_COMPATIBILITY.md` instead.
|
||||||
|
|
||||||
|
## Manual Ink Mixer modifier check (Milestone 5, issue #36)
|
||||||
|
|
||||||
|
With optional JEI installed, search for the Ink Mixer category. It should show
|
||||||
|
the base paper/ink/vial operation and separate entries for Gunpowder, Mushroom
|
||||||
|
Stew, Experience Bottle, Ender Pearl, Feather, and Fire Charge,
|
||||||
|
with their property chances. Black Dye and Clay Ball should not appear: the
|
||||||
|
former had no working Legacy effect, while Generate Platform is redundant
|
||||||
|
with default Age arrival. Without JEI, Rivencraft should still
|
||||||
|
start and the mixer should work normally.
|
||||||
|
|
||||||
|
Put paper and an Ink Vial in the mixer. Hold Gunpowder on the cursor and
|
||||||
|
right-click the ink basin once; one Gunpowder should be consumed, and hovering
|
||||||
|
the basin should show a 20% Disarm chance. Black Dye, Clay Balls, and an
|
||||||
|
unrelated item such as Stone should remain untouched.
|
||||||
|
Closing and reopening the mixer should retain the chance. Taking a Link Panel
|
||||||
|
should consume one paper and one full Ink Vial, clear the current
|
||||||
|
mixture, and possibly give a panel with Disarm on its tooltip. Repeat until
|
||||||
|
a property-bearing panel appears, craft it with leather, and confirm the
|
||||||
|
unwritten Linking Book preserves the property tooltip. After binding it,
|
||||||
|
link to another dimension; inventory items should drop at the departure point.
|
||||||
|
With twenty Ender Pearls added to a fresh mixture, both Disarm and Intra
|
||||||
|
Linking should show about 96.1%, and the basin should animate both property
|
||||||
|
colors. Taking a panel should reset all three percentages and clear the color
|
||||||
|
effect; a near-certain modifier should show the brighter outer animation.
|
||||||
|
Also bind a Descriptive Book with a Disarm panel and check the same drop behavior.
|
||||||
|
Bind a Descriptive Book with both Intra Linking and Maintain Momentum on its
|
||||||
|
panel: the assembled book should retain Maintain Momentum but omit Intra
|
||||||
|
Linking. For Linking Books, try an unmodified book whose destination is the
|
||||||
|
current dimension: it should refuse travel. A Linking Book with Intra Linking
|
||||||
|
should work in the same dimension. A Descriptive Book does not require or use
|
||||||
|
Intra Linking, even if an older book retained that flag.
|
||||||
|
Automatic Return Links should still appear according to the existing setting
|
||||||
|
and work from an Age back to the Overworld. A full player inventory or blocked glass-bottle slot
|
||||||
|
must not duplicate or consume materials for an output that cannot be taken.
|
||||||
|
|
||||||
|
Link Panels should not enter Notebooks (folders) or Writing Desk tabs, whether
|
||||||
|
clicked, shift-clicked, or dragged onto the page surface. An old Notebook or
|
||||||
|
Desk already holding a Link Panel should still let the player take it out,
|
||||||
|
but the Desk must not offer a copy of it. The Desk should continue to copy
|
||||||
|
ordinary symbol Pages; JEI should show that example instead of Link Panel copying.
|
||||||
|
|
||||||
## Manual Age unload/reload check
|
## Manual Age unload/reload check
|
||||||
|
|
||||||
The automated suite does not unload a freshly generated Age. Minecraft can
|
The automated suite does not unload a freshly generated Age. Minecraft can
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
# Ink Mixer and Link Panel modifiers (Milestone 5, issue #36)
|
||||||
|
|
||||||
|
Legacy source: [`InkEffects`](https://github.com/Mystcraft/Mystcraft-Legacy/blob/9bc8ddc061845df0cd5ea47f4fdef773cff786ae/src/main/java/com/xcompwiz/mystcraft/data/InkEffects.java), [`TileEntityInkMixer`](https://github.com/Mystcraft/Mystcraft-Legacy/blob/9bc8ddc061845df0cd5ea47f4fdef773cff786ae/src/main/java/com/xcompwiz/mystcraft/tileentity/TileEntityInkMixer.java), and [`LinkPropertyAPI`](https://github.com/Mystcraft/Mystcraft-Legacy/blob/9bc8ddc061845df0cd5ea47f4fdef773cff786ae/src/api/java/com/xcompwiz/mystcraft/api/hook/LinkPropertyAPI.java).
|
||||||
|
|
||||||
|
Legacy does **not** use a conventional ingredient slot: the player clicks the ink basin with a carried item. Each accepted item is consumed immediately, changing the basin's property probabilities. A Link Panel is a virtual result; taking it consumes paper and ink, rolls each property independently using a saved next-seed, writes the selected flags to the Page, then resets that basin's mixture. The Link Panel passes those flags to a Linking Book made with leather. The preview must not roll or consume anything.
|
||||||
|
|
||||||
|
| Ingredient | Property | Chance per item |
|
||||||
|
| --- | --- | ---: |
|
||||||
|
| Gunpowder | Disarm | 20% |
|
||||||
|
| Mushroom Stew | Disarm | 5% |
|
||||||
|
| Clay Ball | Generate Platform | 25% |
|
||||||
|
| Experience Bottle | Intra Linking | 15% |
|
||||||
|
| Ender Pearl | Intra Linking + Disarm | 15% each |
|
||||||
|
| Feather | Maintain Momentum | 15% |
|
||||||
|
| Fire Charge | Disarm | 25% |
|
||||||
|
| Black dye | Empty effect key; ignored by Legacy's mixer | None in practice |
|
||||||
|
|
||||||
|
Legacy also has optional ore-dictionary dusts: brass, bronze, tin, iron, lead, silver, diamond, and gold. Their effect combinations are in `InkEffects.init()`. Forge's ore dictionary does not exist in NeoForge 1.21.1, so these should be mapped through item tags only when a suitable tag and item exist; none should become a hard dependency. The `Relative` and `Intra Linking Only` properties are registered but have no built-in ingredient. `Natural`, `External`, `Offensive`, `Op-TP`, and `Following` are internal link flags, not mixer ingredients.
|
||||||
|
|
||||||
|
For each additive, Legacy scales each existing probability by `1 - sum(additive chances)` and then adds the additive's probabilities. Properties are rolled independently on the final Page. The Legacy link effects are: Disarm drops carried inventory before travel; Generate Platform places a single arrival block if a drop exists; Maintain Momentum retains velocity; Intra Linking permits a same-dimension link.
|
||||||
|
|
||||||
|
Rivencraft deliberately diverges from Legacy's shared-probability dilution here: each supported modifier accumulates independently as `new = 1 - (1 - old) × (1 - item chance)^item count`. Twenty Ender Pearls therefore produce about 96.1% each for Disarm and Intra Linking, and a panel can receive both. Taking the panel resets every probability to zero. The GUI uses Legacy's empty-basin atlas sprite, fills the basin dark when ink is present, and projects its colored rotating D'ni effect over the ink (red Disarm, blue Momentum, green Intra); the effect intensifies as a modifier approaches certainty and disappears after output is taken.
|
||||||
|
|
||||||
|
Implementation requirements: keep the mixer server-authoritative; persist mixture probabilities and next-seed; show a deterministic virtual result; consume exact inputs once; prevent duplicate output on shift-click; preserve inputs when output cannot be taken; copy the Page's link properties into a Linking Book; apply supported properties only after destination validation; retain unmodified books' current safe-link behavior; and expose both base and modifier sequences to optional JEI. Tests should cover persistence, multiple additives, invalid items, full inventory/bottle output, and panel-to-book transfer.
|
||||||
|
|
||||||
|
## Rivencraft 0.4.7.x implementation scope
|
||||||
|
|
||||||
|
The built-in vanilla-item rows above are supported except black dye and clay balls. Legacy ignores black dye's empty effect key, so Rivencraft does not consume or advertise it in JEI. Clay Balls are omitted because Age arrival already builds a safe platform by default and a separate Generate Platform link modifier would be redundant. Right-clicking the Ink Mixer basin with a carried item adds one; left-clicking adds the carried stack. The mixture is persistent and its next panel is deterministic. The visual basin tooltip shows current probabilities. Only taking the virtual Link Panel consumes paper/ink and clears the mixture. The Link Panel's property component is copied to a Linking Book by the leather recipe or a Descriptive Book by the Binder. JEI's optional Ink Mixer category lists the base panel and each supported additive interaction with its per-property chance; Rivencraft does not require JEI to run.
|
||||||
|
|
||||||
|
Disarm and Maintain Momentum are applied by the server after confirming a safe destination. Disarm spawns each inventory stack as an item entity at the departure point, including for Descriptive Books. Intra Linking is required only for a Linking Book whose destination is in the player's current dimension; ordinary cross-dimensional Linking Books still work. The Binder treats an Intra Linking panel as an ordinary Link Panel and omits that flag from the resulting Descriptive Book, while retaining Disarm and Maintain Momentum. Automatic Return Links remain enabled under the existing configuration, as requested. The old Generate Platform bit remains readable on pre-0.4.7.1 test items but is neither rolled nor applied. Optional dust-tag mappings remain outside this built-in subset until their cross-mod tags and gameplay meaning are agreed.
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
# Serene Seasons 1.21.1: automatic Age whitelist (issue #38)
|
||||||
|
|
||||||
|
Serene Seasons has a [NeoForge 1.21.1 release, 10.1.0.8](https://modrinth.com/mod/serene-seasons/version/B6nTjh4b), with GlitchCore required ([2.1.0.2 for NeoForge 1.21.1](https://modrinth.com/mod/glitchcore/version/S2TfWrZR)). Its [1.21.1 source](https://github.com/Glitchfiend/SereneSeasons/tree/1.21.1) shows that each `ServerLevel` gets its own `SeasonSavedData` in that dimension's data storage. Season progress is keyed to the level's day time and saved separately, so an enabled Rivencraft Age can have a season independent of the Overworld and other Ages. The public [`SeasonHelper`](https://github.com/Glitchfiend/SereneSeasons/blob/1.21.1/common/src/main/java/sereneseasons/api/season/SeasonHelper.java) can read a level's current season; it does not provide a method to register a dimension or set its season.
|
||||||
|
|
||||||
|
The activation point is Serene Seasons' [`dimension_settings.whitelisted_dimensions`](https://github.com/Glitchfiend/SereneSeasons/blob/1.21.1/common/src/main/java/sereneseasons/config/SeasonsConfig.java). Its default contains only `minecraft:overworld`. On the server, GlitchCore [reloads and synchronizes](https://github.com/Glitchfiend/GlitchCore/blob/1.21.1/common/src/main/java/glitchcore/config/ConfigSync.java) this config when a player connects. Rivencraft adds successfully loaded Age IDs to Serene's in-memory list **and** its saved config so later logins retain them. Rivencraft also sends each newly added ID to players already connected. No restart is needed for a newly generated Age.
|
||||||
|
|
||||||
|
Serene Seasons 10.1.0.8 has no public dynamic-dimension registration hook, so the adapter uses its config object and GlitchCore's config writer directly. This is version-sensitive: verify this path when upgrading either mod. Rivencraft checks that Serene is installed before loading the adapter; neither dependency is required to run Rivencraft.
|
||||||
|
|
||||||
|
## Real-client test path
|
||||||
|
|
||||||
|
1. Install matching NeoForge 1.21.1 builds of Serene Seasons and GlitchCore on the server and client. Keep Rivencraft's `Weather: Normal` for this first test, so its own fixed/accelerated weather controller does not compete with seasonal weather timing.
|
||||||
|
2. While the client stays connected, create an Age. Run `/rivencraft age list` as an operator and note its ID (for example `rivencraft:age/winter_garden`). Confirm this ID appeared in `config/sereneseasons/seasons.toml` under `dimension_settings.whitelisted_dimensions`, with existing entries intact.
|
||||||
|
3. Without restarting or reconnecting, travel into the Age and check `/season get`; change its season with `/season set mid_winter` and check the Overworld and another Age separately.
|
||||||
|
4. Reconnect another client and confirm it receives the same whitelist. Restart the server and confirm both the whitelist entry and the Age's season persisted.
|
||||||
|
5. Build separate Ages with No Seasons, Seasons, and each Eternal page. Confirm No Seasons stays absent from Serene's whitelist, Seasons advances, and each Eternal Age remains in its named mid-season across several in-game days, a reconnect, and a server restart. Verify the Overworld still advances normally. The Eternal page should not stop the Age's sun or moon. With Serene removed, No Seasons should still bind, but the other five pages should refuse to bind with a clear message.
|
||||||
|
|
||||||
|
For a local development run, `./gradlew runClient -PwithSereneSeasons=true` adds these two mods only to that run. The published Rivencraft jar does not include or require them.
|
||||||
|
|
||||||
|
The server config `rivencraft-server.toml` has `serene_seasons.auto_whitelist_ages=true` by default. Set it to `false` to manage Serene's whitelist manually. Disabling it does not delete Age IDs previously added to Serene's config. On startup, Rivencraft also enrolls existing Ages that successfully load, so installing Serene after creating Ages does not require editing IDs one by one.
|
||||||
|
|
||||||
|
## Seasonal pages
|
||||||
|
|
||||||
|
An Age may specify one of six mutually exclusive seasonal modes:
|
||||||
|
|
||||||
|
| Page | Intended Age behavior |
|
||||||
|
| --- | --- |
|
||||||
|
| No Seasons | Opt this Age out of seasonal effects and progression. |
|
||||||
|
| Seasons | Run the optional season mod's normal cycle, independently of the Overworld. |
|
||||||
|
| Eternal Winter | Hold this Age in winter. |
|
||||||
|
| Eternal Summer | Hold this Age in summer. |
|
||||||
|
| Eternal Fall | Hold this Age in fall/autumn. |
|
||||||
|
| Eternal Spring | Hold this Age in spring. |
|
||||||
|
|
||||||
|
The six pages are available in the Season creative tab and the same page feed used by JEI. The writing grammar accepts at most one seasonal page, and its choice is saved in the Age plan. No Seasons removes that Age's ID from Serene's whitelist, even if it was previously enrolled; the other explicit pages enroll it regardless of the automatic-enrollment setting. An Age without a seasonal page follows the server's `auto_whitelist_ages` setting. If Serene Seasons is absent, No Seasons remains valid, but the other five pages reject **new** Age creation with a missing-dependency message rather than silently doing nothing. Existing Ages remain loadable with their saved pages, though their season effects are inactive until a supported season mod returns. The Ecliptic Seasons adapter is separate future work, and only one season mod is expected to be installed at a time.
|
||||||
|
|
||||||
|
For an eternal mode, Rivencraft sets Serene's per-Age saved clock to the midpoint of the chosen season and resets it before it leaves that mid-season. Clients receive Serene's normal season sync. This does not freeze the Age's day/night cycle or change the Overworld's season. Eternal Winter does not guarantee snow in every biome.
|
||||||
|
|
||||||
|
## Current limits
|
||||||
|
|
||||||
|
- The Serene adapter uses Serene's internal saved season state because there is no public per-dimension season-freeze API. The real-client behavior above, including each eternal mode and No Seasons, still needs player verification. Serene's [temperature and precipitation hooks](https://github.com/Glitchfiend/SereneSeasons/blob/1.21.1/common/src/main/java/sereneseasons/season/SeasonHooks.java) only cool eligible biomes.
|
||||||
|
- Serene Seasons' [season tick](https://github.com/Glitchfiend/SereneSeasons/blob/1.21.1/common/src/main/java/sereneseasons/season/SeasonHandler.java) advances from a dimension's day-time changes. A Rivencraft Age with a stopped celestial cycle may also have a stopped season; this needs an in-game check.
|
||||||
|
- Rivencraft's non-Normal weather modes currently control weather in each Age independently. Their timing can conflict with Serene Seasons' weather-frequency changes. Ecliptic Seasons integration remains issue #39; simultaneous installation is not a supported target.
|
||||||
|
|
||||||
|
## Verification so far
|
||||||
|
|
||||||
|
`./gradlew build` passed for candidate 0.4.9.2, and the baseline plus archived environment GameTests passed (35 required tests). The archive now covers seasonal page visibility, exclusivity, and saved-plan persistence without Serene installed. With Serene Seasons 10.1.0.8 and GlitchCore 2.1.0.2 in the optional local runtime, the GameTest server previously crashed when Serene Seasons sent `sereneseasons:sync_season_cycle` to a GameTest mock player that had not negotiated its client payload channel. The stack trace originates in Serene Seasons' `SeasonHandler.sendSeasonUpdate`, through GlitchCore's packet handler and NeoForge's packet check. This is a GameTest mock-network limitation, not a completed absent/present compatibility check. Do not keep rerunning that suite with Serene Seasons; use the real-client test path above instead.
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
# Optional TerraBlender biome compatibility (Milestone 5, issue #37)
|
||||||
|
|
||||||
|
Rivencraft targets TerraBlender NeoForge **1.21.1-4.1.0.8**. The official
|
||||||
|
[1.21.1 release](https://modrinth.com/mod/terrablender/version/4.1.0.8) and
|
||||||
|
[region API](https://github.com/Glitchfiend/TerraBlender/blob/1.21.1/Common/src/main/java/terrablender/api/Regions.java)
|
||||||
|
are available for this Minecraft version. TerraBlender is `compileOnly` and
|
||||||
|
is **not** required by the published Rivencraft jar. For a local development
|
||||||
|
run with TerraBlender, use `-PwithTerraBlender=true`.
|
||||||
|
|
||||||
|
TerraBlender's API registers Overworld and Nether biome *regions*; it does not
|
||||||
|
register arbitrary Rivencraft Age dimensions. Rivencraft therefore keeps its
|
||||||
|
own deterministic Age biome sources and uses a guarded adapter to read the
|
||||||
|
registered region biome IDs. Only biomes still present in Minecraft's biome
|
||||||
|
registry are accepted. TerraBlender Overworld region biomes extend the pool
|
||||||
|
for standard, flat, and sky-island Ages; Nether region biomes extend Cave Age
|
||||||
|
pools and are valid authored Cave biome pages. Vanilla Nether-tagged biomes
|
||||||
|
are also valid Cave biomes. This is generic: no Biomes O' Plenty IDs are
|
||||||
|
hard-coded.
|
||||||
|
|
||||||
|
Every registered biome receives a generated page in Rivencraft's Biome or Cave
|
||||||
|
Biome creative tab, and in JEI when JEI is installed. Cave-tagged, Nether-tagged,
|
||||||
|
and TerraBlender Nether-region biomes go in the Cave Biome tab. Existing vanilla page IDs such as
|
||||||
|
`rivencraft:biome/desert` are unchanged; modded biome IDs include their
|
||||||
|
namespace, for example `rivencraft:biome/example/orchard` for a biome named
|
||||||
|
`example:orchard`.
|
||||||
|
Authoring still validates the exact biome registry key. New Age plans freeze
|
||||||
|
the selected biome IDs, distribution, and seed, so a reload with the same mods
|
||||||
|
retains the result. If a modded biome later disappears, the Age loader warns
|
||||||
|
and uses an eligible fallback for that load without rewriting its frozen plan.
|
||||||
|
Restore the mod to recover the authored biome. Do not remove biome mods from
|
||||||
|
an existing play world without a backup.
|
||||||
|
|
||||||
|
## Compatibility matrix
|
||||||
|
|
||||||
|
| Setup | Expected result | Validation |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| Rivencraft without TerraBlender | Vanilla biome pages and Age generation remain functional; no TerraBlender classes load on the core path. | Default GameTest server and build. |
|
||||||
|
| Rivencraft with TerraBlender 4.1.0.8, no biome addon | Same baseline pool; default TerraBlender regions add no modded biome IDs. | GameTest server with `-PwithTerraBlender=true`. |
|
||||||
|
| Rivencraft + TerraBlender + Biomes O' Plenty 1.21.1 | BOP registry biomes appear as distinct Biome pages, with Nether-region pages in the Cave Biome tab. Its Overworld regions can enter composed standard/sky-island Age pools; its Nether regions can enter Cave Age pools. | In-game check below; this combination is not bundled in automated tests. |
|
||||||
|
| TerraBlender present but its region API cannot be read | Log one warning and use Rivencraft's normal biome pool. | Guarded adapter fallback; intentionally not forced by GameTest. |
|
||||||
|
|
||||||
|
## In-game check requested for Biomes O' Plenty
|
||||||
|
|
||||||
|
Use a **new test world** with compatible NeoForge 1.21.1 builds of
|
||||||
|
TerraBlender and Biomes O' Plenty installed on both sides.
|
||||||
|
|
||||||
|
1. In the Rivencraft Biome and Cave Biome Pages creative tabs (and JEI, if installed), find
|
||||||
|
at least one BOP Overworld biome and one BOP Nether biome, respectively. The page tooltip
|
||||||
|
should identify the biome and not show an unresolved symbol.
|
||||||
|
2. Bind a Descriptive Book with a Link Panel, Standard Terrain, a two-biome
|
||||||
|
distribution page, and two different BOP Overworld biome pages. Travel to
|
||||||
|
the Age and confirm both named biomes can occur. Reopen the same world and
|
||||||
|
confirm the Age still uses the same authored biome pool.
|
||||||
|
3. Bind a second book using Cave Terrain and a BOP Nether biome page. The
|
||||||
|
Binder must accept the page, and the resulting Cave Age must use the
|
||||||
|
selected Nether biome rather than rejecting it as non-cave.
|
||||||
|
4. Separately, run Rivencraft without TerraBlender and confirm a Link-Panel-
|
||||||
|
only random Age can still be created and entered. Do not reuse the BOP test
|
||||||
|
world for this absence check.
|
||||||
|
|
||||||
|
The previous broad registry-enumeration GameTest stalled in the test server,
|
||||||
|
so the BOP-specific and client-side checks are deliberately handed off for
|
||||||
|
manual testing instead of retaining that stalled test.
|
||||||
+4
-1
@@ -36,8 +36,11 @@ 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.4.6.9
|
mod_version=0.4.9.2
|
||||||
immersive_portals_version=6.0.7
|
immersive_portals_version=6.0.7
|
||||||
|
terrablender_version=4.1.0.8
|
||||||
|
serene_seasons_version_id=B6nTjh4b
|
||||||
|
glitchcore_version_id=S2TfWrZR
|
||||||
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
||||||
# This should match the base package used for the mod sources.
|
# This should match the base package used for the mod sources.
|
||||||
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import net.dnorberg.rivencraft.command.RivencraftCommands;
|
|||||||
import net.dnorberg.rivencraft.network.ModNetworking;
|
import net.dnorberg.rivencraft.network.ModNetworking;
|
||||||
import net.dnorberg.rivencraft.config.RivencraftConfig;
|
import net.dnorberg.rivencraft.config.RivencraftConfig;
|
||||||
import net.dnorberg.rivencraft.config.RivencraftClientConfig;
|
import net.dnorberg.rivencraft.config.RivencraftClientConfig;
|
||||||
|
import net.dnorberg.rivencraft.compat.SereneSeasonsCompatibility;
|
||||||
import net.dnorberg.rivencraft.book.AgeDimensionService;
|
import net.dnorberg.rivencraft.book.AgeDimensionService;
|
||||||
import net.dnorberg.rivencraft.book.AgeWeatherService;
|
import net.dnorberg.rivencraft.book.AgeWeatherService;
|
||||||
import net.dnorberg.rivencraft.book.AgeRuntimeProfiles;
|
import net.dnorberg.rivencraft.book.AgeRuntimeProfiles;
|
||||||
@@ -51,6 +52,7 @@ public final class Rivencraft {
|
|||||||
ModCreativeTabs.register(modEventBus);
|
ModCreativeTabs.register(modEventBus);
|
||||||
NeoForge.EVENT_BUS.addListener(BookStandConversionHandler::onRightClickBlock);
|
NeoForge.EVENT_BUS.addListener(BookStandConversionHandler::onRightClickBlock);
|
||||||
NeoForge.EVENT_BUS.addListener(AgeWeatherService::onLevelTickPost);
|
NeoForge.EVENT_BUS.addListener(AgeWeatherService::onLevelTickPost);
|
||||||
|
NeoForge.EVENT_BUS.addListener(SereneSeasonsCompatibility::onLevelTickPost);
|
||||||
NeoForge.EVENT_BUS.addListener(AgeCelestialAngleSync::onPlayerLoggedIn);
|
NeoForge.EVENT_BUS.addListener(AgeCelestialAngleSync::onPlayerLoggedIn);
|
||||||
NeoForge.EVENT_BUS.addListener(AgeCelestialAngleSync::onPlayerChangedDimension);
|
NeoForge.EVENT_BUS.addListener(AgeCelestialAngleSync::onPlayerChangedDimension);
|
||||||
NeoForge.EVENT_BUS.addListener(AgeLifecycleEvents::onPlayerLoggedOut);
|
NeoForge.EVENT_BUS.addListener(AgeLifecycleEvents::onPlayerLoggedOut);
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import net.minecraft.core.registries.Registries;
|
|||||||
import net.minecraft.resources.ResourceKey;
|
import net.minecraft.resources.ResourceKey;
|
||||||
import net.dnorberg.rivencraft.book.AgeBiomeSelection;
|
import net.dnorberg.rivencraft.book.AgeBiomeSelection;
|
||||||
import net.dnorberg.rivencraft.book.AgeFeatureSelection;
|
import net.dnorberg.rivencraft.book.AgeFeatureSelection;
|
||||||
import net.minecraft.tags.BiomeTags;
|
|
||||||
import net.minecraft.core.component.DataComponents;
|
import net.minecraft.core.component.DataComponents;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
@@ -163,8 +162,8 @@ public final class BookBinderBlockEntity extends BlockEntity implements Containe
|
|||||||
if (holder.isEmpty()) {
|
if (holder.isEmpty()) {
|
||||||
diagnostics.add(new WritingGrammar.Diagnostic(WritingGrammar.Code.UNKNOWN_BIOME,
|
diagnostics.add(new WritingGrammar.Diagnostic(WritingGrammar.Code.UNKNOWN_BIOME,
|
||||||
symbol.index(), "Restore biome " + id + " or remove this page"));
|
symbol.index(), "Restore biome " + id + " or remove this page"));
|
||||||
} else if (cave && !holder.orElseThrow().is(AgeBiomeSelection.CAVE_BIOMES)
|
} else if (cave && !AgeBiomeSelection.isCaveBiome(level.registryAccess(),
|
||||||
&& !holder.orElseThrow().is(BiomeTags.IS_NETHER)) {
|
holder.orElseThrow())) {
|
||||||
diagnostics.add(new WritingGrammar.Diagnostic(WritingGrammar.Code.UNSUPPORTED_BIOME,
|
diagnostics.add(new WritingGrammar.Diagnostic(WritingGrammar.Code.UNSUPPORTED_BIOME,
|
||||||
symbol.index(), "Cave Ages require cave or Nether biomes; remove " + id));
|
symbol.index(), "Cave Ages require cave or Nether biomes; remove " + id));
|
||||||
}
|
}
|
||||||
@@ -238,6 +237,11 @@ public final class BookBinderBlockEntity extends BlockEntity implements Containe
|
|||||||
ItemStack book = new ItemStack(ModItems.DESCRIPTIVE_BOOK.get());
|
ItemStack book = new ItemStack(ModItems.DESCRIPTIVE_BOOK.get());
|
||||||
book.set(ModDataComponents.AGE_REFERENCE.get(), new AgeReference(pendingAgeId, title));
|
book.set(ModDataComponents.AGE_REFERENCE.get(), new AgeReference(pendingAgeId, title));
|
||||||
book.set(ModDataComponents.BOOK_WRITING.get(), currentWriting());
|
book.set(ModDataComponents.BOOK_WRITING.get(), currentWriting());
|
||||||
|
if (items.get(LINK_PANEL).has(ModDataComponents.LINK_PROPERTIES.get())) {
|
||||||
|
var properties = items.get(LINK_PANEL).get(ModDataComponents.LINK_PROPERTIES.get())
|
||||||
|
.forDescriptiveBook();
|
||||||
|
if (properties.flags() != 0) book.set(ModDataComponents.LINK_PROPERTIES.get(), properties);
|
||||||
|
}
|
||||||
book.set(DataComponents.CUSTOM_NAME, Component.literal(title));
|
book.set(DataComponents.CUSTOM_NAME, Component.literal(title));
|
||||||
return book;
|
return book;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
package net.dnorberg.rivencraft.block.entity;
|
package net.dnorberg.rivencraft.block.entity;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
import net.dnorberg.rivencraft.book.LinkProperties;
|
||||||
import net.dnorberg.rivencraft.item.InkVialItem;
|
import net.dnorberg.rivencraft.item.InkVialItem;
|
||||||
|
import net.dnorberg.rivencraft.item.PageItem;
|
||||||
import net.dnorberg.rivencraft.writing.InkVialExchange;
|
import net.dnorberg.rivencraft.writing.InkVialExchange;
|
||||||
|
import net.dnorberg.rivencraft.writing.InkModifierIngredients;
|
||||||
import net.dnorberg.rivencraft.registry.ModBlockEntities;
|
import net.dnorberg.rivencraft.registry.ModBlockEntities;
|
||||||
|
import net.dnorberg.rivencraft.registry.ModDataComponents;
|
||||||
import net.dnorberg.rivencraft.registry.ModItems;
|
import net.dnorberg.rivencraft.registry.ModItems;
|
||||||
import net.dnorberg.rivencraft.writing.WritingInkService;
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.HolderLookup;
|
import net.minecraft.core.HolderLookup;
|
||||||
import net.minecraft.core.NonNullList;
|
import net.minecraft.core.NonNullList;
|
||||||
@@ -18,7 +22,7 @@ import net.minecraft.world.level.Level;
|
|||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
|
||||||
/** Baseline Link Panel mixer. Modifier ingredients belong to the symbol/ink-effects milestone. */
|
/** Server-owned Link Panel mixer with a persistent, Legacy-style additive mixture. */
|
||||||
public final class InkMixerBlockEntity extends BlockEntity implements Container {
|
public final class InkMixerBlockEntity extends BlockEntity implements Container {
|
||||||
public static final int INK = 0;
|
public static final int INK = 0;
|
||||||
public static final int PAPER = 1;
|
public static final int PAPER = 1;
|
||||||
@@ -27,6 +31,12 @@ public final class InkMixerBlockEntity extends BlockEntity implements Container
|
|||||||
|
|
||||||
private NonNullList<ItemStack> items = NonNullList.withSize(SIZE, ItemStack.EMPTY);
|
private NonNullList<ItemStack> items = NonNullList.withSize(SIZE, ItemStack.EMPTY);
|
||||||
private int inkRemaining;
|
private int inkRemaining;
|
||||||
|
private long nextModifierSeed = new Random().nextLong();
|
||||||
|
private final double[] modifierChances = new double[3];
|
||||||
|
private static final int[] FLAGS = {LinkProperties.DISARM,
|
||||||
|
LinkProperties.MAINTAIN_MOMENTUM, LinkProperties.INTRA_LINKING};
|
||||||
|
private static final String[] CHANCE_KEYS = {"DisarmChance", "MomentumChance", "IntraLinkingChance"};
|
||||||
|
private static final int[] OLD_CHANCE_INDEX = {0, 2, 3};
|
||||||
|
|
||||||
public InkMixerBlockEntity(BlockPos pos, BlockState state) {
|
public InkMixerBlockEntity(BlockPos pos, BlockState state) {
|
||||||
super(ModBlockEntities.INK_MIXER.get(), pos, state);
|
super(ModBlockEntities.INK_MIXER.get(), pos, state);
|
||||||
@@ -34,6 +44,44 @@ public final class InkMixerBlockEntity extends BlockEntity implements Container
|
|||||||
|
|
||||||
public int inkRemaining() { return inkRemaining; }
|
public int inkRemaining() { return inkRemaining; }
|
||||||
|
|
||||||
|
public int modifierChancePermille(int index) {
|
||||||
|
return Math.clamp((int) Math.round(modifierChances[index] * 1000), 0, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Infuses a carried ingredient into the current ink pool; only the server calls this. */
|
||||||
|
public boolean addModifier(ItemStack carried, int amount) {
|
||||||
|
InkModifierIngredients.Ingredient ingredient = InkModifierIngredients.find(carried);
|
||||||
|
if (ingredient == null || inkRemaining == 0 || amount <= 0 || carried.getCount() < amount)
|
||||||
|
return false;
|
||||||
|
for (InkModifierIngredients.Effect effect : ingredient.effects())
|
||||||
|
for (int index = 0; index < FLAGS.length; index++)
|
||||||
|
if (FLAGS[index] == effect.flag())
|
||||||
|
modifierChances[index] = 1.0 - (1.0 - modifierChances[index])
|
||||||
|
* Math.pow(1.0 - effect.chance(), amount);
|
||||||
|
carried.shrink(amount);
|
||||||
|
setChanged();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack previewLinkPanel() {
|
||||||
|
if (!canCreateLinkPanel()) return ItemStack.EMPTY;
|
||||||
|
ItemStack panel = PageItem.createLinkPanelPage();
|
||||||
|
LinkProperties properties = rollProperties(nextModifierSeed).properties();
|
||||||
|
if (properties.flags() != 0) panel.set(ModDataComponents.LINK_PROPERTIES.get(), properties);
|
||||||
|
return panel;
|
||||||
|
}
|
||||||
|
|
||||||
|
private record Roll(LinkProperties properties, long nextSeed) {}
|
||||||
|
|
||||||
|
private Roll rollProperties(long seed) {
|
||||||
|
Random random = new Random(seed);
|
||||||
|
int selected = 0;
|
||||||
|
for (int index = 0; index < FLAGS.length; index++)
|
||||||
|
if (modifierChances[index] > 0 && random.nextDouble() < modifierChances[index])
|
||||||
|
selected |= FLAGS[index];
|
||||||
|
return new Roll(new LinkProperties(selected), random.nextLong());
|
||||||
|
}
|
||||||
|
|
||||||
@Override public int getContainerSize() { return SIZE; }
|
@Override public int getContainerSize() { return SIZE; }
|
||||||
@Override public boolean isEmpty() { return items.stream().allMatch(ItemStack::isEmpty); }
|
@Override public boolean isEmpty() { return items.stream().allMatch(ItemStack::isEmpty); }
|
||||||
@Override public ItemStack getItem(int slot) { return items.get(slot); }
|
@Override public ItemStack getItem(int slot) { return items.get(slot); }
|
||||||
@@ -78,20 +126,21 @@ public final class InkMixerBlockEntity extends BlockEntity implements Container
|
|||||||
|
|
||||||
public boolean canCreateLinkPanel() {
|
public boolean canCreateLinkPanel() {
|
||||||
if (!items.get(PAPER).is(Items.PAPER)) return false;
|
if (!items.get(PAPER).is(Items.PAPER)) return false;
|
||||||
int cost = WritingInkService.linkPanelCost();
|
return InkVialExchange.canPay(items, INK, BOTTLES, inkRemaining, InkVialItem.CAPACITY);
|
||||||
return InkVialExchange.canPay(items, INK, BOTTLES, inkRemaining, cost);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Commit inputs only when a virtual output is actually taken. */
|
/** Commit inputs only when a virtual output is actually taken. */
|
||||||
public boolean consumeLinkPanelMaterials() {
|
public boolean consumeLinkPanelMaterials() {
|
||||||
if (!canCreateLinkPanel()) return false;
|
if (!canCreateLinkPanel()) return false;
|
||||||
int cost = WritingInkService.linkPanelCost();
|
int cost = InkVialItem.CAPACITY;
|
||||||
if (inkRemaining < cost) {
|
if (inkRemaining < cost) {
|
||||||
inkRemaining += InkVialExchange.exchange(items, INK, BOTTLES);
|
inkRemaining += InkVialExchange.exchange(items, INK, BOTTLES);
|
||||||
}
|
}
|
||||||
inkRemaining -= cost;
|
inkRemaining -= cost;
|
||||||
items.get(PAPER).shrink(1);
|
items.get(PAPER).shrink(1);
|
||||||
if (items.get(PAPER).isEmpty()) items.set(PAPER, ItemStack.EMPTY);
|
if (items.get(PAPER).isEmpty()) items.set(PAPER, ItemStack.EMPTY);
|
||||||
|
nextModifierSeed = rollProperties(nextModifierSeed).nextSeed();
|
||||||
|
java.util.Arrays.fill(modifierChances, 0);
|
||||||
setChanged();
|
setChanged();
|
||||||
if (inkRemaining == 0) refillEmptyBasin();
|
if (inkRemaining == 0) refillEmptyBasin();
|
||||||
return true;
|
return true;
|
||||||
@@ -104,6 +153,7 @@ public final class InkMixerBlockEntity extends BlockEntity implements Container
|
|||||||
@Override public void clearContent() {
|
@Override public void clearContent() {
|
||||||
items = NonNullList.withSize(SIZE, ItemStack.EMPTY);
|
items = NonNullList.withSize(SIZE, ItemStack.EMPTY);
|
||||||
inkRemaining = 0;
|
inkRemaining = 0;
|
||||||
|
java.util.Arrays.fill(modifierChances, 0);
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
@Override protected void loadAdditional(CompoundTag tag, HolderLookup.Provider registries) {
|
@Override protected void loadAdditional(CompoundTag tag, HolderLookup.Provider registries) {
|
||||||
@@ -111,11 +161,20 @@ public final class InkMixerBlockEntity extends BlockEntity implements Container
|
|||||||
items = NonNullList.withSize(SIZE, ItemStack.EMPTY);
|
items = NonNullList.withSize(SIZE, ItemStack.EMPTY);
|
||||||
ContainerHelper.loadAllItems(tag, items, registries);
|
ContainerHelper.loadAllItems(tag, items, registries);
|
||||||
inkRemaining = Math.clamp(tag.getInt("InkRemaining"), 0, InkVialItem.CAPACITY);
|
inkRemaining = Math.clamp(tag.getInt("InkRemaining"), 0, InkVialItem.CAPACITY);
|
||||||
|
if (tag.contains("NextModifierSeed")) nextModifierSeed = tag.getLong("NextModifierSeed");
|
||||||
|
for (int index = 0; index < modifierChances.length; index++) {
|
||||||
|
double chance = tag.contains(CHANCE_KEYS[index]) ? tag.getDouble(CHANCE_KEYS[index])
|
||||||
|
: tag.getDouble("ModifierChance" + OLD_CHANCE_INDEX[index]);
|
||||||
|
modifierChances[index] = Math.clamp(chance, 0.0, 1.0);
|
||||||
|
}
|
||||||
refillEmptyBasin();
|
refillEmptyBasin();
|
||||||
}
|
}
|
||||||
@Override protected void saveAdditional(CompoundTag tag, HolderLookup.Provider registries) {
|
@Override protected void saveAdditional(CompoundTag tag, HolderLookup.Provider registries) {
|
||||||
super.saveAdditional(tag, registries);
|
super.saveAdditional(tag, registries);
|
||||||
ContainerHelper.saveAllItems(tag, items, registries);
|
ContainerHelper.saveAllItems(tag, items, registries);
|
||||||
tag.putInt("InkRemaining", inkRemaining);
|
tag.putInt("InkRemaining", inkRemaining);
|
||||||
|
tag.putLong("NextModifierSeed", nextModifierSeed);
|
||||||
|
for (int index = 0; index < modifierChances.length; index++)
|
||||||
|
tag.putDouble(CHANCE_KEYS[index], modifierChances[index]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,12 @@
|
|||||||
package net.dnorberg.rivencraft.block.entity;
|
package net.dnorberg.rivencraft.block.entity;
|
||||||
|
|
||||||
import net.dnorberg.rivencraft.item.InkVialItem;
|
import net.dnorberg.rivencraft.item.InkVialItem;
|
||||||
|
import net.dnorberg.rivencraft.item.PageItem;
|
||||||
import net.dnorberg.rivencraft.writing.InkVialExchange;
|
import net.dnorberg.rivencraft.writing.InkVialExchange;
|
||||||
import net.dnorberg.rivencraft.writing.WritingInkService;
|
import net.dnorberg.rivencraft.writing.WritingInkService;
|
||||||
|
import net.dnorberg.rivencraft.writing.PageContent;
|
||||||
|
import net.dnorberg.rivencraft.writing.NotebookContents;
|
||||||
|
import net.dnorberg.rivencraft.registry.ModDataComponents;
|
||||||
import net.dnorberg.rivencraft.registry.ModBlockEntities;
|
import net.dnorberg.rivencraft.registry.ModBlockEntities;
|
||||||
import net.dnorberg.rivencraft.registry.ModItems;
|
import net.dnorberg.rivencraft.registry.ModItems;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
@@ -83,7 +87,11 @@ public final class WritingDeskBlockEntity extends BlockEntity implements Contain
|
|||||||
worldPosition.getZ() + 0.5) <= 64.0;
|
worldPosition.getZ() + 0.5) <= 64.0;
|
||||||
}
|
}
|
||||||
@Override public boolean canPlaceItem(int slot, ItemStack stack) {
|
@Override public boolean canPlaceItem(int slot, ItemStack stack) {
|
||||||
if (slot < COLLECTIONS) return stack.is(ModItems.NOTEBOOK.get()) || stack.is(ModItems.PAGE.get());
|
if (slot < COLLECTIONS) return stack.is(ModItems.NOTEBOOK.get())
|
||||||
|
&& stack.getOrDefault(ModDataComponents.NOTEBOOK_CONTENTS.get(), NotebookContents.EMPTY)
|
||||||
|
.pages().stream().noneMatch(page -> PageItem.content(page).kind() == PageContent.Kind.LINK_PANEL)
|
||||||
|
|| stack.is(ModItems.PAGE.get())
|
||||||
|
&& PageItem.content(stack).kind() != PageContent.Kind.LINK_PANEL;
|
||||||
return switch (slot) {
|
return switch (slot) {
|
||||||
case INK -> stack.is(ModItems.INK_VIAL.get());
|
case INK -> stack.is(ModItems.INK_VIAL.get());
|
||||||
case RETURN -> false;
|
case RETURN -> false;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import java.util.List;
|
|||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import net.dnorberg.rivencraft.Rivencraft;
|
import net.dnorberg.rivencraft.Rivencraft;
|
||||||
|
import net.dnorberg.rivencraft.compat.TerraBlenderBiomes;
|
||||||
import net.dnorberg.rivencraft.writing.SymbolSemantics;
|
import net.dnorberg.rivencraft.writing.SymbolSemantics;
|
||||||
import net.dnorberg.rivencraft.writing.WritingGrammar;
|
import net.dnorberg.rivencraft.writing.WritingGrammar;
|
||||||
import net.minecraft.core.Holder;
|
import net.minecraft.core.Holder;
|
||||||
@@ -59,9 +60,10 @@ public record AgeBiomeSelection(AgeTraits.BiomeDistribution distribution, List<R
|
|||||||
for (ResourceLocation id : authored) {
|
for (ResourceLocation id : authored) {
|
||||||
Holder.Reference<Biome> holder = registry.get(ResourceKey.create(Registries.BIOME, id))
|
Holder.Reference<Biome> holder = registry.get(ResourceKey.create(Registries.BIOME, id))
|
||||||
.orElseThrow(() -> new IllegalArgumentException("Unknown biome " + id + "; restore its data pack or remove its page"));
|
.orElseThrow(() -> new IllegalArgumentException("Unknown biome " + id + "; restore its data pack or remove its page"));
|
||||||
if (cave && !holder.is(CAVE_BIOMES) && !holder.is(BiomeTags.IS_NETHER)) {
|
if (cave && !isCaveBiome(registries, holder)) {
|
||||||
throw new IllegalArgumentException("Biome " + id
|
throw new IllegalArgumentException("Biome " + id
|
||||||
+ " is not a cave or Nether biome; use #rivencraft:cave_biomes or #minecraft:is_nether");
|
+ " is not a cave or Nether biome; use #rivencraft:cave_biomes, #minecraft:is_nether,"
|
||||||
|
+ " or a TerraBlender Nether region");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<ResourceLocation> availableBiomes = eligible(registries, profile);
|
List<ResourceLocation> availableBiomes = eligible(registries, profile);
|
||||||
@@ -69,15 +71,16 @@ public record AgeBiomeSelection(AgeTraits.BiomeDistribution distribution, List<R
|
|||||||
if (distribution == AgeTraits.BiomeDistribution.NATIVE) {
|
if (distribution == AgeTraits.BiomeDistribution.NATIVE) {
|
||||||
if (!authored.isEmpty()) throw new IllegalArgumentException("Native biome distribution cannot use biome pages");
|
if (!authored.isEmpty()) throw new IllegalArgumentException("Native biome distribution cannot use biome pages");
|
||||||
return new AgeBiomeSelection(distribution, profile.terrain() == AgeRuntimeProfile.Terrain.FLAT
|
return new AgeBiomeSelection(distribution, profile.terrain() == AgeRuntimeProfile.Terrain.FLAT
|
||||||
? List.of(ResourceLocation.withDefaultNamespace("plains")) : availableBiomes);
|
? List.of(ResourceLocation.withDefaultNamespace("plains"))
|
||||||
|
: isCave(profile) ? availableBiomes : presetBiomes(registries, profile));
|
||||||
}
|
}
|
||||||
List<ResourceLocation> selected = new ArrayList<>(authored);
|
List<ResourceLocation> selected = new ArrayList<>(authored);
|
||||||
Set<ResourceLocation> distinct = new LinkedHashSet<>(selected);
|
Set<ResourceLocation> distinct = new LinkedHashSet<>(selected);
|
||||||
int minimum = minimum(distribution);
|
int minimum = minimum(distribution);
|
||||||
int target = minimum;
|
int target = minimum;
|
||||||
if (authored.isEmpty()) {
|
if (authored.isEmpty()) {
|
||||||
// The terrain's available pool is the upper bound. For Cave terrain,
|
// The terrain's available pool is the upper bound, including any
|
||||||
// eligible() returns the cave tag; other terrains use their preset.
|
// compatible TerraBlender region biomes present at creation time.
|
||||||
int availableBiomeCount = new LinkedHashSet<>(availableBiomes).size();
|
int availableBiomeCount = new LinkedHashSet<>(availableBiomes).size();
|
||||||
int maximum = distribution == AgeTraits.BiomeDistribution.SINGLE ? 1 : availableBiomeCount;
|
int maximum = distribution == AgeTraits.BiomeDistribution.SINGLE ? 1 : availableBiomeCount;
|
||||||
if (maximum >= minimum) {
|
if (maximum >= minimum) {
|
||||||
@@ -102,14 +105,26 @@ public record AgeBiomeSelection(AgeTraits.BiomeDistribution distribution, List<R
|
|||||||
if (isCave(profile)) {
|
if (isCave(profile)) {
|
||||||
List<ResourceLocation> tagged = registry.listElements().filter(holder -> holder.is(CAVE_BIOMES))
|
List<ResourceLocation> tagged = registry.listElements().filter(holder -> holder.is(CAVE_BIOMES))
|
||||||
.map(holder -> holder.key().location()).sorted().toList();
|
.map(holder -> holder.key().location()).sorted().toList();
|
||||||
if (!tagged.isEmpty()) return tagged;
|
List<ResourceLocation> vanilla = !tagged.isEmpty() ? tagged : List.of("minecraft:deep_dark", "minecraft:dripstone_caves", "minecraft:lush_caves")
|
||||||
return List.of("minecraft:deep_dark", "minecraft:dripstone_caves", "minecraft:lush_caves")
|
|
||||||
.stream().map(ResourceLocation::parse)
|
.stream().map(ResourceLocation::parse)
|
||||||
.filter(id -> registry.get(ResourceKey.create(Registries.BIOME, id)).isPresent()).toList();
|
.filter(id -> registry.get(ResourceKey.create(Registries.BIOME, id)).isPresent()).toList();
|
||||||
|
List<ResourceLocation> nether = registry.listElements().filter(holder -> holder.is(BiomeTags.IS_NETHER))
|
||||||
|
.map(holder -> holder.key().location()).toList();
|
||||||
|
return merge(merge(vanilla, nether), TerraBlenderBiomes.nether(registries));
|
||||||
}
|
}
|
||||||
if (profile.terrain() == AgeRuntimeProfile.Terrain.VOID) {
|
if (profile.terrain() == AgeRuntimeProfile.Terrain.VOID) {
|
||||||
return List.of(ResourceLocation.withDefaultNamespace("the_void"));
|
return List.of(ResourceLocation.withDefaultNamespace("the_void"));
|
||||||
}
|
}
|
||||||
|
ResourceLocation preset = profile.terrain() == AgeRuntimeProfile.Terrain.FLAT
|
||||||
|
? ResourceLocation.withDefaultNamespace("overworld") : profile.biomePreset();
|
||||||
|
List<ResourceLocation> nativeBiomes = presetBiomes(registries, profile);
|
||||||
|
return merge(nativeBiomes, preset.equals(ResourceLocation.withDefaultNamespace("nether"))
|
||||||
|
? TerraBlenderBiomes.nether(registries) : TerraBlenderBiomes.overworld(registries));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<ResourceLocation> presetBiomes(RegistryAccess registries, AgeRuntimeProfile profile) {
|
||||||
|
if (profile.terrain() == AgeRuntimeProfile.Terrain.VOID)
|
||||||
|
return List.of(ResourceLocation.withDefaultNamespace("the_void"));
|
||||||
ResourceLocation preset = profile.terrain() == AgeRuntimeProfile.Terrain.FLAT
|
ResourceLocation preset = profile.terrain() == AgeRuntimeProfile.Terrain.FLAT
|
||||||
? ResourceLocation.withDefaultNamespace("overworld") : profile.biomePreset();
|
? ResourceLocation.withDefaultNamespace("overworld") : profile.biomePreset();
|
||||||
var parameters = registries.lookupOrThrow(Registries.MULTI_NOISE_BIOME_SOURCE_PARAMETER_LIST)
|
var parameters = registries.lookupOrThrow(Registries.MULTI_NOISE_BIOME_SOURCE_PARAMETER_LIST)
|
||||||
@@ -119,6 +134,15 @@ public record AgeBiomeSelection(AgeTraits.BiomeDistribution distribution, List<R
|
|||||||
.sorted(Comparator.naturalOrder()).toList();
|
.sorted(Comparator.naturalOrder()).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isCaveBiome(RegistryAccess registries, Holder.Reference<Biome> holder) {
|
||||||
|
return holder.is(CAVE_BIOMES) || holder.is(BiomeTags.IS_NETHER)
|
||||||
|
|| TerraBlenderBiomes.nether(registries).contains(holder.key().location());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<ResourceLocation> merge(List<ResourceLocation> vanilla, List<ResourceLocation> additions) {
|
||||||
|
return java.util.stream.Stream.concat(vanilla.stream(), additions.stream()).distinct().sorted().toList();
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isCave(AgeRuntimeProfile profile) {
|
public static boolean isCave(AgeRuntimeProfile profile) {
|
||||||
return profile.terrain() == AgeRuntimeProfile.Terrain.NOISE
|
return profile.terrain() == AgeRuntimeProfile.Terrain.NOISE
|
||||||
&& profile.noiseSettings().equals(ResourceLocation.withDefaultNamespace("caves"));
|
&& profile.noiseSettings().equals(ResourceLocation.withDefaultNamespace("caves"));
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import java.util.Comparator;
|
|||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import net.dnorberg.rivencraft.Rivencraft;
|
import net.dnorberg.rivencraft.Rivencraft;
|
||||||
import net.dnorberg.rivencraft.compat.ImmersivePortalsChunkLoaders;
|
import net.dnorberg.rivencraft.compat.ImmersivePortalsChunkLoaders;
|
||||||
|
import net.dnorberg.rivencraft.compat.SereneSeasonsCompatibility;
|
||||||
import net.dnorberg.rivencraft.writing.OrderedWriting;
|
import net.dnorberg.rivencraft.writing.OrderedWriting;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.GlobalPos;
|
import net.minecraft.core.GlobalPos;
|
||||||
@@ -74,6 +75,7 @@ public final class AgeDimensionService {
|
|||||||
);
|
);
|
||||||
if (level != null) {
|
if (level != null) {
|
||||||
applyCelestialClock(level, age);
|
applyCelestialClock(level, age);
|
||||||
|
SereneSeasonsCompatibility.registerAge(server, age);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
synchronizeImmersivePortals(server);
|
synchronizeImmersivePortals(server);
|
||||||
@@ -110,6 +112,7 @@ public final class AgeDimensionService {
|
|||||||
ServerLevel existing = server.getLevel(key);
|
ServerLevel existing = server.getLevel(key);
|
||||||
if (existing != null) {
|
if (existing != null) {
|
||||||
applyCelestialClock(existing, definition);
|
applyCelestialClock(existing, definition);
|
||||||
|
SereneSeasonsCompatibility.registerAge(server, definition);
|
||||||
return existing;
|
return existing;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,6 +128,7 @@ public final class AgeDimensionService {
|
|||||||
Rivencraft.LOGGER.error("Failed to load Age {} as {}", definition.id(), definition.dimensionId());
|
Rivencraft.LOGGER.error("Failed to load Age {} as {}", definition.id(), definition.dimensionId());
|
||||||
} else {
|
} else {
|
||||||
applyCelestialClock(loaded, definition);
|
applyCelestialClock(loaded, definition);
|
||||||
|
SereneSeasonsCompatibility.registerAge(server, definition);
|
||||||
synchronizeImmersivePortals(server);
|
synchronizeImmersivePortals(server);
|
||||||
}
|
}
|
||||||
return loaded;
|
return loaded;
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ public record AgeGenerationPlan(int version, long ageSeed, OrderedWriting writin
|
|||||||
symbol.index(), symbol.reference(), symbol.semantics())).toList(),
|
symbol.index(), symbol.reference(), symbol.semantics())).toList(),
|
||||||
profile, biomes);
|
profile, biomes);
|
||||||
AgeEnvironmentCompiler.apply(plan, traits);
|
AgeEnvironmentCompiler.apply(plan, traits);
|
||||||
|
AgeSeasonMode.validate(plan);
|
||||||
return plan;
|
return plan;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package net.dnorberg.rivencraft.book;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
import net.dnorberg.rivencraft.writing.SymbolSemantics;
|
||||||
|
import net.neoforged.fml.ModList;
|
||||||
|
|
||||||
|
/** One authored season policy per Age; unspecified Ages retain the normal cycle. */
|
||||||
|
public enum AgeSeasonMode {
|
||||||
|
NO_SEASONS,
|
||||||
|
SEASONS,
|
||||||
|
ETERNAL_WINTER,
|
||||||
|
ETERNAL_SUMMER,
|
||||||
|
ETERNAL_FALL,
|
||||||
|
ETERNAL_SPRING;
|
||||||
|
|
||||||
|
public static AgeSeasonMode from(AgeGenerationPlan plan) {
|
||||||
|
if (plan == null) return SEASONS;
|
||||||
|
return plan.symbols().stream()
|
||||||
|
.filter(symbol -> symbol.semantics().role() == SymbolSemantics.Role.SEASON)
|
||||||
|
.map(symbol -> valueOf(((SymbolSemantics.ChoiceValue) symbol.semantics().value())
|
||||||
|
.id().toUpperCase(Locale.ROOT)))
|
||||||
|
.findFirst().orElse(SEASONS);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void validate(AgeGenerationPlan plan) {
|
||||||
|
if (plan == null) return;
|
||||||
|
boolean authored = plan.symbols().stream()
|
||||||
|
.anyMatch(symbol -> symbol.semantics().role() == SymbolSemantics.Role.SEASON);
|
||||||
|
if (authored && from(plan) != NO_SEASONS
|
||||||
|
&& !ModList.get().isLoaded("sereneseasons")) {
|
||||||
|
throw new IllegalArgumentException("This seasonal page requires Serene Seasons to create the Age");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean eternal() {
|
||||||
|
return this != NO_SEASONS && this != SEASONS;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,17 +1,16 @@
|
|||||||
package net.dnorberg.rivencraft.book;
|
package net.dnorberg.rivencraft.book;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import net.dnorberg.rivencraft.item.PageItem;
|
import net.dnorberg.rivencraft.item.PageItem;
|
||||||
import net.dnorberg.rivencraft.registry.ModCreativeTabs;
|
|
||||||
import net.dnorberg.rivencraft.writing.OrderedWriting;
|
import net.dnorberg.rivencraft.writing.OrderedWriting;
|
||||||
import net.dnorberg.rivencraft.writing.PageContent;
|
import net.dnorberg.rivencraft.writing.PageContent;
|
||||||
import net.dnorberg.rivencraft.writing.SymbolCatalog;
|
import net.dnorberg.rivencraft.writing.SymbolCatalog;
|
||||||
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.dnorberg.rivencraft.writing.WritingGrammar;
|
||||||
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.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
@@ -26,38 +25,23 @@ public final class EnvironmentWritingGameTests {
|
|||||||
private EnvironmentWritingGameTests() {}
|
private EnvironmentWritingGameTests() {}
|
||||||
|
|
||||||
@GameTest(template = "empty")
|
@GameTest(template = "empty")
|
||||||
public static void symbolCategoriesPartitionCreativePages(GameTestHelper helper) {
|
public static void caveBiomesHaveSeparateCreativePages(GameTestHelper helper) {
|
||||||
var registries = helper.getLevel().registryAccess();
|
var registries = helper.getLevel().registryAccess();
|
||||||
var allPages = PageItem.creativeSymbolPages(registries);
|
|
||||||
Set<ResourceLocation> collected = new HashSet<>();
|
|
||||||
helper.assertTrue(ModCreativeTabs.SYMBOL_PAGES.keySet().containsAll(PageItem.bundledCreativeCategories()),
|
|
||||||
"Every bundled page category must receive a creative tab");
|
|
||||||
for (ResourceLocation category : PageItem.bundledCreativeCategories()) {
|
|
||||||
var categoryPages = PageItem.creativeSymbolPages(registries, category);
|
|
||||||
helper.assertFalse(categoryPages.isEmpty(), "Every category tab must contain pages: " + category);
|
|
||||||
for (var page : categoryPages) {
|
|
||||||
helper.assertValueEqual(PageItem.creativeCategory(page), category,
|
|
||||||
"Category tabs must not mix symbol pages");
|
|
||||||
helper.assertTrue(collected.add(PageItem.content(page).symbol().orElseThrow().id()),
|
|
||||||
"A symbol page must appear in exactly one category tab");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
helper.assertValueEqual(collected.size(), allPages.size(),
|
|
||||||
"Category tabs must contain every bundled and generated biome page");
|
|
||||||
var biomePages = PageItem.creativeSymbolPages(registries,
|
var biomePages = PageItem.creativeSymbolPages(registries,
|
||||||
ResourceLocation.fromNamespaceAndPath("rivencraft", "biome"));
|
ResourceLocation.fromNamespaceAndPath("rivencraft", "biome"));
|
||||||
var generationPages = PageItem.creativeSymbolPages(registries,
|
var cavePages = PageItem.creativeSymbolPages(registries,
|
||||||
ResourceLocation.fromNamespaceAndPath("rivencraft", "biome_generation"));
|
ResourceLocation.fromNamespaceAndPath("rivencraft", "cave_biome"));
|
||||||
|
helper.assertTrue(PageItem.bundledCreativeCategories().contains(
|
||||||
|
ResourceLocation.fromNamespaceAndPath("rivencraft", "cave_biome")),
|
||||||
|
"The cave biome creative tab must be registered");
|
||||||
helper.assertTrue(biomePages.stream().anyMatch(page -> PageItem.content(page).symbol().orElseThrow()
|
helper.assertTrue(biomePages.stream().anyMatch(page -> PageItem.content(page).symbol().orElseThrow()
|
||||||
.id().getPath().equals("biome/desert")), "Biome pages must remain in the Biome tab");
|
.id().getPath().equals("biome/desert")), "Biome pages must remain in the Biome tab");
|
||||||
|
helper.assertTrue(cavePages.stream().anyMatch(page -> PageItem.content(page).symbol().orElseThrow()
|
||||||
|
.id().getPath().equals("biome/lush_caves")), "Cave biomes need their own tab");
|
||||||
|
helper.assertTrue(cavePages.stream().anyMatch(page -> PageItem.content(page).symbol().orElseThrow()
|
||||||
|
.id().getPath().equals("biome/crimson_forest")), "Nether biomes belong in the Cave tab");
|
||||||
helper.assertFalse(biomePages.stream().anyMatch(page -> PageItem.content(page).symbol().orElseThrow()
|
helper.assertFalse(biomePages.stream().anyMatch(page -> PageItem.content(page).symbol().orElseThrow()
|
||||||
.id().getPath().equals("biome/tiny")), "Biome generation types must leave the Biome tab");
|
.id().getPath().equals("biome/lush_caves")), "Cave biomes must leave the general Biome tab");
|
||||||
helper.assertTrue(generationPages.stream().anyMatch(page -> PageItem.content(page).symbol().orElseThrow()
|
|
||||||
.id().getPath().equals("biome/tiny")), "Biome generation types need their own tab");
|
|
||||||
helper.assertTrue(allPages.stream().noneMatch(page -> PageItem.content(page).kind() == PageContent.Kind.BLANK),
|
|
||||||
"Blank pages must not enter the creative or JEI symbol-page feed");
|
|
||||||
helper.assertValueEqual(PageItem.content(PageItem.createLinkPanelPage()).kind(), PageContent.Kind.LINK_PANEL,
|
|
||||||
"Link pages must stay separate from symbol categories");
|
|
||||||
helper.succeed();
|
helper.succeed();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,6 +52,8 @@ public final class EnvironmentWritingGameTests {
|
|||||||
"sky/overworld", "sky/nether", "sky/end",
|
"sky/overworld", "sky/nether", "sky/end",
|
||||||
"weather/normal", "weather/fast", "weather/slow", "weather/off",
|
"weather/normal", "weather/fast", "weather/slow", "weather/off",
|
||||||
"weather/always", "weather/storm", "celestial/normal_time",
|
"weather/always", "weather/storm", "celestial/normal_time",
|
||||||
|
"season/no_seasons", "season/seasons", "season/eternal_winter",
|
||||||
|
"season/eternal_summer", "season/eternal_fall", "season/eternal_spring",
|
||||||
"period/zero", "period/half", "period/full", "period/double",
|
"period/zero", "period/half", "period/full", "period/double",
|
||||||
"phase/nadir", "phase/rising", "phase/zenith", "phase/setting");
|
"phase/nadir", "phase/rising", "phase/zenith", "phase/setting");
|
||||||
Set<String> creative = PageItem.creativeSymbolPages(helper.getLevel().registryAccess()).stream()
|
Set<String> creative = PageItem.creativeSymbolPages(helper.getLevel().registryAccess()).stream()
|
||||||
@@ -90,6 +76,23 @@ public final class EnvironmentWritingGameTests {
|
|||||||
helper.succeed();
|
helper.succeed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GameTest(template = "empty")
|
||||||
|
public static void seasonalPagesAreExclusiveAndPersist(GameTestHelper helper) {
|
||||||
|
OrderedWriting noSeasons = new OrderedWriting(List.of(
|
||||||
|
WritingEntry.linkPanel(), page("season/no_seasons")));
|
||||||
|
var plan = AgeGenerationPlan.compile(noSeasons, 42L, AgeGenerationProfiles.STANDARD,
|
||||||
|
AgeTraits.select(42L), helper.getLevel().registryAccess());
|
||||||
|
helper.assertValueEqual(AgeSeasonMode.from(plan), AgeSeasonMode.NO_SEASONS,
|
||||||
|
"No Seasons must compile without an installed season mod");
|
||||||
|
helper.assertValueEqual(AgeSeasonMode.from(AgeGenerationPlan.load(plan.save())),
|
||||||
|
AgeSeasonMode.NO_SEASONS, "The Age's seasonal policy must survive reload");
|
||||||
|
OrderedWriting conflict = new OrderedWriting(List.of(WritingEntry.linkPanel(),
|
||||||
|
page("season/no_seasons"), page("season/eternal_winter")));
|
||||||
|
helper.assertFalse(WritingGrammar.parse(conflict).canCreate(),
|
||||||
|
"Only one seasonal page may be used in an Age");
|
||||||
|
helper.succeed();
|
||||||
|
}
|
||||||
|
|
||||||
@GameTest(template = "empty")
|
@GameTest(template = "empty")
|
||||||
public static void writtenEnvironmentPersistsAndPageFreeAgesStaySeeded(GameTestHelper helper) {
|
public static void writtenEnvironmentPersistsAndPageFreeAgesStaySeeded(GameTestHelper helper) {
|
||||||
OrderedWriting writing = new OrderedWriting(List.of(
|
OrderedWriting writing = new OrderedWriting(List.of(
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
package net.dnorberg.rivencraft.book;
|
||||||
|
|
||||||
|
import com.mojang.serialization.Codec;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import java.util.List;
|
||||||
|
import net.minecraft.ChatFormatting;
|
||||||
|
import net.minecraft.network.codec.ByteBufCodecs;
|
||||||
|
import net.minecraft.network.codec.StreamCodec;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
|
||||||
|
/** Flags written into a Link Panel and carried by books assembled from it. */
|
||||||
|
public record LinkProperties(int flags) {
|
||||||
|
public static final int DISARM = 1;
|
||||||
|
/** Retained only to read pre-0.4.7.1 test books; no longer generated or applied. */
|
||||||
|
public static final int GENERATE_PLATFORM = 2;
|
||||||
|
public static final int MAINTAIN_MOMENTUM = 4;
|
||||||
|
public static final int INTRA_LINKING = 8;
|
||||||
|
private static final int ALL_FLAGS = DISARM | GENERATE_PLATFORM | MAINTAIN_MOMENTUM | INTRA_LINKING;
|
||||||
|
public static final LinkProperties NONE = new LinkProperties(0);
|
||||||
|
public static final Codec<LinkProperties> CODEC = Codec.intRange(0, ALL_FLAGS).xmap(
|
||||||
|
LinkProperties::new, LinkProperties::flags);
|
||||||
|
public static final StreamCodec<ByteBuf, LinkProperties> STREAM_CODEC = StreamCodec.of(
|
||||||
|
(buffer, value) -> ByteBufCodecs.VAR_INT.encode(buffer, value.flags),
|
||||||
|
buffer -> new LinkProperties(ByteBufCodecs.VAR_INT.decode(buffer)));
|
||||||
|
|
||||||
|
public LinkProperties {
|
||||||
|
if ((flags & ~ALL_FLAGS) != 0 || flags < 0) {
|
||||||
|
throw new IllegalArgumentException("Unknown Link Panel flags: " + flags);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean has(int flag) {
|
||||||
|
return (flags & flag) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Intra Linking only governs Linking Books; a Descriptive Book treats that panel as ordinary. */
|
||||||
|
public LinkProperties forDescriptiveBook() {
|
||||||
|
return new LinkProperties(flags & ~INTRA_LINKING);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void appendTooltip(List<Component> lines) {
|
||||||
|
if (has(DISARM)) lines.add(propertyName("disarm"));
|
||||||
|
if (has(MAINTAIN_MOMENTUM)) lines.add(propertyName("maintain_momentum"));
|
||||||
|
if (has(INTRA_LINKING)) lines.add(propertyName("intra_linking"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Component propertyName(String name) {
|
||||||
|
return Component.translatable("item.rivencraft.link_property." + name)
|
||||||
|
.withStyle(ChatFormatting.DARK_PURPLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Component name(int flag) {
|
||||||
|
return switch (flag) {
|
||||||
|
case DISARM -> propertyName("disarm");
|
||||||
|
case MAINTAIN_MOMENTUM -> propertyName("maintain_momentum");
|
||||||
|
case INTRA_LINKING -> propertyName("intra_linking");
|
||||||
|
default -> throw new IllegalArgumentException("Unknown link property flag: " + flag);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -25,7 +25,11 @@ public final class LinkingService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static LinkResult travel(ServerPlayer player, LinkTarget target) {
|
public static LinkResult travel(ServerPlayer player, LinkTarget target) {
|
||||||
return travel(player, target, false);
|
return travel(player, target, LinkProperties.NONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static LinkResult travel(ServerPlayer player, LinkTarget target, LinkProperties properties) {
|
||||||
|
return travel(player, target, false, properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Optional<Vec3> resolveDestination(ServerLevel level, BlockPos origin, boolean ageArrival) {
|
public static Optional<Vec3> resolveDestination(ServerLevel level, BlockPos origin, boolean ageArrival) {
|
||||||
@@ -36,27 +40,36 @@ public final class LinkingService {
|
|||||||
|
|
||||||
/** Travels to an Age-style destination, which must have solid footing. */
|
/** Travels to an Age-style destination, which must have solid footing. */
|
||||||
public static LinkResult travelWithFooting(ServerPlayer player, LinkTarget target) {
|
public static LinkResult travelWithFooting(ServerPlayer player, LinkTarget target) {
|
||||||
|
return travelWithFooting(player, target, LinkProperties.NONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static LinkResult travelWithFooting(ServerPlayer player, LinkTarget target, LinkProperties properties) {
|
||||||
ServerLevel destinationLevel = player.getServer().getLevel(target.location().dimension());
|
ServerLevel destinationLevel = player.getServer().getLevel(target.location().dimension());
|
||||||
if (destinationLevel == null) {
|
if (destinationLevel == null) {
|
||||||
return LinkResult.MISSING_DIMENSION;
|
return LinkResult.MISSING_DIMENSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<Vec3> destination = resolveDestination(destinationLevel, target.location().pos(), true);
|
Optional<Vec3> destination = resolveDestination(destinationLevel, target.location().pos(), true);
|
||||||
if (destination.isEmpty()) {
|
if (destination.isEmpty()) {
|
||||||
return LinkResult.NO_SAFE_DESTINATION;
|
return LinkResult.NO_SAFE_DESTINATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3 position = destination.get();
|
Vec3 position = destination.get();
|
||||||
|
Vec3 momentum = player.getDeltaMovement();
|
||||||
|
if (properties.has(LinkProperties.DISARM)) dropInventoryAtSource(player);
|
||||||
teleport(player, destinationLevel, position, target);
|
teleport(player, destinationLevel, position, target);
|
||||||
|
if (properties.has(LinkProperties.MAINTAIN_MOMENTUM)) player.setDeltaMovement(momentum);
|
||||||
player.resetFallDistance();
|
player.resetFallDistance();
|
||||||
return LinkResult.SUCCESS;
|
return LinkResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static LinkResult travel(ServerPlayer player, LinkTarget target, boolean requiresFooting) {
|
private static LinkResult travel(ServerPlayer player, LinkTarget target, boolean requiresFooting,
|
||||||
|
LinkProperties properties) {
|
||||||
ServerLevel destinationLevel = player.getServer().getLevel(target.location().dimension());
|
ServerLevel destinationLevel = player.getServer().getLevel(target.location().dimension());
|
||||||
if (destinationLevel == null) {
|
if (destinationLevel == null) {
|
||||||
return LinkResult.MISSING_DIMENSION;
|
return LinkResult.MISSING_DIMENSION;
|
||||||
}
|
}
|
||||||
|
if (destinationLevel == player.level() && !properties.has(LinkProperties.INTRA_LINKING))
|
||||||
|
return LinkResult.INTRA_LINKING_REQUIRED;
|
||||||
|
|
||||||
Optional<Vec3> destination = resolveDestination(destinationLevel, target.location().pos(), requiresFooting);
|
Optional<Vec3> destination = resolveDestination(destinationLevel, target.location().pos(), requiresFooting);
|
||||||
if (destination.isEmpty()) {
|
if (destination.isEmpty()) {
|
||||||
@@ -64,11 +77,26 @@ public final class LinkingService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Vec3 position = destination.get();
|
Vec3 position = destination.get();
|
||||||
|
Vec3 momentum = player.getDeltaMovement();
|
||||||
|
if (properties.has(LinkProperties.DISARM)) dropInventoryAtSource(player);
|
||||||
teleport(player, destinationLevel, position, target);
|
teleport(player, destinationLevel, position, target);
|
||||||
|
if (properties.has(LinkProperties.MAINTAIN_MOMENTUM)) player.setDeltaMovement(momentum);
|
||||||
player.resetFallDistance();
|
player.resetFallDistance();
|
||||||
return LinkResult.SUCCESS;
|
return LinkResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Drop each inventory stack as an item entity at the departure point. */
|
||||||
|
private static void dropInventoryAtSource(ServerPlayer player) {
|
||||||
|
var inventory = player.getInventory();
|
||||||
|
for (int slot = 0; slot < inventory.getContainerSize(); slot++) {
|
||||||
|
var stack = inventory.getItem(slot);
|
||||||
|
if (stack.isEmpty()) continue;
|
||||||
|
inventory.setItem(slot, net.minecraft.world.item.ItemStack.EMPTY);
|
||||||
|
player.drop(stack, false);
|
||||||
|
}
|
||||||
|
player.containerMenu.broadcastChanges();
|
||||||
|
}
|
||||||
|
|
||||||
private static void teleport(
|
private static void teleport(
|
||||||
ServerPlayer player,
|
ServerPlayer player,
|
||||||
ServerLevel destinationLevel,
|
ServerLevel destinationLevel,
|
||||||
@@ -166,6 +194,7 @@ public final class LinkingService {
|
|||||||
public enum LinkResult {
|
public enum LinkResult {
|
||||||
SUCCESS,
|
SUCCESS,
|
||||||
MISSING_DIMENSION,
|
MISSING_DIMENSION,
|
||||||
|
INTRA_LINKING_REQUIRED,
|
||||||
NO_SAFE_DESTINATION
|
NO_SAFE_DESTINATION
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package net.dnorberg.rivencraft.client;
|
||||||
|
|
||||||
|
import net.dnorberg.rivencraft.compat.SereneSeasonsCompatibility;
|
||||||
|
import net.dnorberg.rivencraft.network.SereneAgeWhitelistPayload;
|
||||||
|
import net.neoforged.neoforge.network.handling.IPayloadContext;
|
||||||
|
|
||||||
|
/** Applies incremental Serene whitelist updates on the client main thread. */
|
||||||
|
public final class ClientSereneAgeWhitelist {
|
||||||
|
private ClientSereneAgeWhitelist() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void handle(SereneAgeWhitelistPayload payload, IPayloadContext context) {
|
||||||
|
context.enqueueWork(() -> SereneSeasonsCompatibility.acceptClient(payload.dimensionId(), payload.enabled()));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,11 +8,20 @@ import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
|||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
|
import net.minecraft.world.inventory.ClickType;
|
||||||
|
|
||||||
/** Legacy Ink Mixer atlas with a server-synced, sixteen-use basin. */
|
/** Legacy Ink Mixer atlas with a server-synced, sixteen-use basin. */
|
||||||
public final class InkMixerScreen extends AbstractContainerScreen<InkMixerMenu> {
|
public final class InkMixerScreen extends AbstractContainerScreen<InkMixerMenu> {
|
||||||
private static final ResourceLocation BACKGROUND = ResourceLocation.fromNamespaceAndPath(
|
private static final ResourceLocation BACKGROUND = ResourceLocation.fromNamespaceAndPath(
|
||||||
Rivencraft.MOD_ID, "textures/gui/ink_mixer_legacy.png");
|
Rivencraft.MOD_ID, "textures/gui/ink_mixer_legacy.png");
|
||||||
|
private static final int BASIN_X = 88;
|
||||||
|
private static final int BASIN_Y = 49;
|
||||||
|
private static final int BASIN_RADIUS = 30;
|
||||||
|
// Legacy's registered property colors: Disarm red, Momentum blue, Intra green.
|
||||||
|
private static final int[] PROPERTY_COLORS = {0xFFE84848, 0xFF5555FF, 0xFF55EF55};
|
||||||
|
private final int[] lastChances = new int[3];
|
||||||
|
private boolean basinClickPendingRelease;
|
||||||
|
private long lastAdditionTime;
|
||||||
|
|
||||||
public InkMixerScreen(InkMixerMenu menu, Inventory inventory, Component title) {
|
public InkMixerScreen(InkMixerMenu menu, Inventory inventory, Component title) {
|
||||||
super(menu, inventory, title);
|
super(menu, inventory, title);
|
||||||
@@ -26,16 +35,14 @@ public final class InkMixerScreen extends AbstractContainerScreen<InkMixerMenu>
|
|||||||
renderBg(graphics, partialTick, mouseX, mouseY);
|
renderBg(graphics, partialTick, mouseX, mouseY);
|
||||||
}
|
}
|
||||||
@Override protected void renderBg(GuiGraphics graphics, float partialTick, int mouseX, int mouseY) {
|
@Override protected void renderBg(GuiGraphics graphics, float partialTick, int mouseX, int mouseY) {
|
||||||
graphics.blit(BACKGROUND, leftPos, topPos, 0, 0, imageWidth, imageHeight, 256, 256);
|
// Legacy draws this inset behind the transparent center of the main atlas.
|
||||||
int centerX = leftPos + 88;
|
graphics.blit(BACKGROUND, leftPos + 54, topPos + 16, 179, 16, 66, 65, 256, 256);
|
||||||
int centerY = topPos + 49;
|
|
||||||
int fillTop = centerY + 26 - Math.round(menu.inkRemaining() / (float) InkVialItem.CAPACITY * 52);
|
|
||||||
if (menu.inkRemaining() > 0) {
|
if (menu.inkRemaining() > 0) {
|
||||||
for (int y = Math.max(centerY - 26, fillTop); y <= centerY + 26; y++) {
|
// Ink is a full dark basin in Legacy, rather than a vertical meter.
|
||||||
int halfWidth = (int) Math.sqrt(26 * 26 - (y - centerY) * (y - centerY));
|
graphics.fill(leftPos + 54, topPos + 16, leftPos + 120, topPos + 81, 0xFF101014);
|
||||||
graphics.fill(centerX - halfWidth, y, centerX + halfWidth + 1, y + 1, 0xFF241228);
|
renderPropertyGlyph(graphics);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
graphics.blit(BACKGROUND, leftPos, topPos, 0, 0, imageWidth, imageHeight, 256, 256);
|
||||||
}
|
}
|
||||||
@Override protected void renderLabels(GuiGraphics graphics, int mouseX, int mouseY) {
|
@Override protected void renderLabels(GuiGraphics graphics, int mouseX, int mouseY) {
|
||||||
graphics.drawString(font, playerInventoryTitle, inventoryLabelX, inventoryLabelY, 0x404040, false);
|
graphics.drawString(font, playerInventoryTitle, inventoryLabelX, inventoryLabelY, 0x404040, false);
|
||||||
@@ -43,10 +50,112 @@ public final class InkMixerScreen extends AbstractContainerScreen<InkMixerMenu>
|
|||||||
@Override public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTick) {
|
@Override public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTick) {
|
||||||
super.render(graphics, mouseX, mouseY, partialTick);
|
super.render(graphics, mouseX, mouseY, partialTick);
|
||||||
renderTooltip(graphics, mouseX, mouseY);
|
renderTooltip(graphics, mouseX, mouseY);
|
||||||
int x = mouseX - (leftPos + 88);
|
if (overBasin(mouseX, mouseY)) {
|
||||||
int y = mouseY - (topPos + 49);
|
var lines = new java.util.ArrayList<Component>();
|
||||||
if (x * x + y * y <= 26 * 26)
|
lines.add(Component.translatable("screen.rivencraft.ink_mixer.ink",
|
||||||
graphics.renderTooltip(font, Component.translatable("screen.rivencraft.ink_mixer.ink",
|
menu.inkRemaining(), InkVialItem.CAPACITY));
|
||||||
menu.inkRemaining(), InkVialItem.CAPACITY), mouseX, mouseY);
|
lines.add(Component.translatable("screen.rivencraft.ink_mixer.additive_hint"));
|
||||||
|
for (int index = 0; index < 3; index++) {
|
||||||
|
int chance = menu.modifierChancePermille(index);
|
||||||
|
if (chance > 0) lines.add(Component.translatable("screen.rivencraft.ink_mixer.chance",
|
||||||
|
switch (index) {
|
||||||
|
case 0 -> Component.translatable("item.rivencraft.link_property.disarm");
|
||||||
|
case 1 -> Component.translatable("item.rivencraft.link_property.maintain_momentum");
|
||||||
|
default -> Component.translatable("item.rivencraft.link_property.intra_linking");
|
||||||
|
}, chance / 10.0));
|
||||||
|
}
|
||||||
|
graphics.renderTooltip(font, lines, java.util.Optional.empty(), mouseX, mouseY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||||
|
if ((button == 0 || button == 1) && overBasin(mouseX, mouseY)
|
||||||
|
&& !menu.getCarried().isEmpty()) {
|
||||||
|
slotClicked(menu.getSlot(InkMixerMenu.MODIFIER), InkMixerMenu.MODIFIER, button, ClickType.PICKUP);
|
||||||
|
basinClickPendingRelease = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return super.mouseClicked(mouseX, mouseY, button);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public boolean mouseReleased(double mouseX, double mouseY, int button) {
|
||||||
|
if (basinClickPendingRelease) {
|
||||||
|
basinClickPendingRelease = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return super.mouseReleased(mouseX, mouseY, button);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean overBasin(double mouseX, double mouseY) {
|
||||||
|
double x = mouseX - leftPos - BASIN_X;
|
||||||
|
double y = mouseY - topPos - BASIN_Y;
|
||||||
|
return x * x + y * y < BASIN_RADIUS * BASIN_RADIUS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A GUI-scale projection of Legacy's colored, rotating D'ni ink effect. */
|
||||||
|
private void renderPropertyGlyph(GuiGraphics graphics) {
|
||||||
|
long now = System.currentTimeMillis();
|
||||||
|
int[] active = new int[3];
|
||||||
|
int count = 0;
|
||||||
|
int strongest = 0;
|
||||||
|
for (int index = 0; index < lastChances.length; index++) {
|
||||||
|
int chance = menu.modifierChancePermille(index);
|
||||||
|
if (chance > lastChances[index]) lastAdditionTime = now;
|
||||||
|
lastChances[index] = chance;
|
||||||
|
if (chance > 0) {
|
||||||
|
active[count++] = index;
|
||||||
|
strongest = Math.max(strongest, chance);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (count == 0) {
|
||||||
|
lastAdditionTime = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
double cycle = now / 1800.0;
|
||||||
|
int first = active[(int) cycle % count];
|
||||||
|
int second = active[((int) cycle + 1) % count];
|
||||||
|
double blend = (1.0 - Math.cos((cycle % 1.0) * Math.PI)) / 2.0;
|
||||||
|
int rgb = blendRgb(PROPERTY_COLORS[first], PROPERTY_COLORS[second], blend);
|
||||||
|
double pulse = Math.max(0.0, 1.0 - (now - lastAdditionTime) / 700.0);
|
||||||
|
int alpha = Math.clamp((int) (70 + strongest * 0.14 + pulse * 45), 0, 255);
|
||||||
|
int color = alpha << 24 | rgb;
|
||||||
|
int centerX = leftPos + BASIN_X;
|
||||||
|
int centerY = topPos + BASIN_Y;
|
||||||
|
double turn = now / 1200.0;
|
||||||
|
|
||||||
|
for (int spoke = 0; spoke < 4; spoke++) {
|
||||||
|
for (int step = 0; step <= 30; step++) {
|
||||||
|
double progress = step / 30.0;
|
||||||
|
double angle = turn + spoke * Math.PI / 2.0 + progress * 0.9;
|
||||||
|
double radius = 3.0 + progress * (15.0 + pulse * 3.0);
|
||||||
|
plot(graphics, centerX + Math.cos(angle) * radius,
|
||||||
|
centerY + Math.sin(angle) * radius, color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int step = 0; step < 96; step++) {
|
||||||
|
double angle = step * Math.PI / 48.0 + turn * 0.3;
|
||||||
|
plot(graphics, centerX + Math.cos(angle) * 19.0,
|
||||||
|
centerY + Math.sin(angle) * 19.0, color);
|
||||||
|
if (strongest >= 990 && step % 2 == 0) {
|
||||||
|
plot(graphics, centerX + Math.cos(angle) * 23.0,
|
||||||
|
centerY + Math.sin(angle) * 23.0, color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int blendRgb(int first, int second, double amount) {
|
||||||
|
int red = (int) (((first >> 16) & 0xFF) * (1.0 - amount)
|
||||||
|
+ ((second >> 16) & 0xFF) * amount);
|
||||||
|
int green = (int) (((first >> 8) & 0xFF) * (1.0 - amount)
|
||||||
|
+ ((second >> 8) & 0xFF) * amount);
|
||||||
|
int blue = (int) ((first & 0xFF) * (1.0 - amount) + (second & 0xFF) * amount);
|
||||||
|
return red << 16 | green << 8 | blue;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void plot(GuiGraphics graphics, double x, double y, int color) {
|
||||||
|
int pixelX = (int) Math.round(x);
|
||||||
|
int pixelY = (int) Math.round(y);
|
||||||
|
graphics.fill(pixelX, pixelY, pixelX + 1, pixelY + 1, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,6 +6,7 @@ import net.dnorberg.rivencraft.item.PageItem;
|
|||||||
import net.dnorberg.rivencraft.client.SymbolPageTextures;
|
import net.dnorberg.rivencraft.client.SymbolPageTextures;
|
||||||
import net.dnorberg.rivencraft.menu.NotebookMenu;
|
import net.dnorberg.rivencraft.menu.NotebookMenu;
|
||||||
import net.dnorberg.rivencraft.registry.ModItems;
|
import net.dnorberg.rivencraft.registry.ModItems;
|
||||||
|
import net.dnorberg.rivencraft.writing.PageContent;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
import net.minecraft.client.gui.components.Button;
|
import net.minecraft.client.gui.components.Button;
|
||||||
import net.minecraft.client.gui.components.EditBox;
|
import net.minecraft.client.gui.components.EditBox;
|
||||||
@@ -115,7 +116,8 @@ public final class NotebookScreen extends AbstractContainerScreen<NotebookMenu>
|
|||||||
if (index >= 0 && (button == 0 || button == 1)) {
|
if (index >= 0 && (button == 0 || button == 1)) {
|
||||||
ItemStack page = menu.getSlot(index).getItem();
|
ItemStack page = menu.getSlot(index).getItem();
|
||||||
if ((!page.isEmpty() && !matchesSearch(page))
|
if ((!page.isEmpty() && !matchesSearch(page))
|
||||||
|| (page.isEmpty() && !menu.getCarried().is(ModItems.PAGE.get()))) {
|
|| (page.isEmpty() && (!menu.getCarried().is(ModItems.PAGE.get())
|
||||||
|
|| PageItem.content(menu.getCarried()).kind() == PageContent.Kind.LINK_PANEL))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
setFocused(null);
|
setFocused(null);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import java.util.Comparator;
|
|||||||
import net.dnorberg.rivencraft.Rivencraft;
|
import net.dnorberg.rivencraft.Rivencraft;
|
||||||
import net.dnorberg.rivencraft.client.SymbolPageTextures;
|
import net.dnorberg.rivencraft.client.SymbolPageTextures;
|
||||||
import net.dnorberg.rivencraft.item.PageItem;
|
import net.dnorberg.rivencraft.item.PageItem;
|
||||||
|
import net.dnorberg.rivencraft.writing.PageContent;
|
||||||
import net.dnorberg.rivencraft.menu.WritingDeskMenu;
|
import net.dnorberg.rivencraft.menu.WritingDeskMenu;
|
||||||
import net.dnorberg.rivencraft.block.entity.WritingDeskBlockEntity;
|
import net.dnorberg.rivencraft.block.entity.WritingDeskBlockEntity;
|
||||||
import net.dnorberg.rivencraft.registry.ModDataComponents;
|
import net.dnorberg.rivencraft.registry.ModDataComponents;
|
||||||
@@ -329,7 +330,9 @@ public final class WritingDeskScreen extends AbstractContainerScreen<WritingDesk
|
|||||||
int surfaceY = (int) Math.floor(mouseY - topPos - 20);
|
int surfaceY = (int) Math.floor(mouseY - topPos - 20);
|
||||||
if ((button == 0 || button == 1) && !menu.getCarried().isEmpty()
|
if ((button == 0 || button == 1) && !menu.getCarried().isEmpty()
|
||||||
&& surfaceX >= 0 && surfaceX < 155 && surfaceY >= 0 && surfaceY < 164) {
|
&& surfaceX >= 0 && surfaceX < 155 && surfaceY >= 0 && surfaceY < 164) {
|
||||||
if (menu.getCarried().is(ModItems.PAGE.get()) && surfaceX % 31 < 30 && surfaceY % 41 < 40) {
|
if (menu.getCarried().is(ModItems.PAGE.get())
|
||||||
|
&& PageItem.content(menu.getCarried()).kind() != PageContent.Kind.LINK_PANEL
|
||||||
|
&& surfaceX % 31 < 30 && surfaceY % 41 < 40) {
|
||||||
int index = (surfaceY / 41 + scrollRows) * 5 + surfaceX / 31;
|
int index = (surfaceY / 41 + scrollRows) * 5 + surfaceX / 31;
|
||||||
List<DisplayPage> entries = filteredPages();
|
List<DisplayPage> entries = filteredPages();
|
||||||
// Only displayed positions are addressable. Filtering never turns
|
// Only displayed positions are addressable. Filtering never turns
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
package net.dnorberg.rivencraft.compat;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import net.dnorberg.rivencraft.book.AgeSeasonMode;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.server.level.ServerLevel;
|
||||||
|
import sereneseasons.api.season.Season;
|
||||||
|
import sereneseasons.config.SeasonsConfig;
|
||||||
|
import sereneseasons.init.ModConfig;
|
||||||
|
import sereneseasons.season.SeasonHandler;
|
||||||
|
import sereneseasons.season.SeasonSavedData;
|
||||||
|
import sereneseasons.season.SeasonTime;
|
||||||
|
|
||||||
|
/** Isolates references to optional Serene Seasons and GlitchCore classes. */
|
||||||
|
final class SereneSeasonsAdapter {
|
||||||
|
private static final String WHITELIST_KEY = "dimension_settings.whitelisted_dimensions";
|
||||||
|
|
||||||
|
private SereneSeasonsAdapter() {
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean setServerWhitelist(ResourceLocation dimensionId, boolean enabled) {
|
||||||
|
SeasonsConfig config = ModConfig.seasons;
|
||||||
|
if (config == null || config.whitelistedDimensions.contains(dimensionId.toString()) == enabled) return false;
|
||||||
|
List<String> dimensions = new ArrayList<>(config.whitelistedDimensions);
|
||||||
|
if (enabled) dimensions.add(dimensionId.toString());
|
||||||
|
else dimensions.removeIf(dimensionId.toString()::equals);
|
||||||
|
// GlitchCore rereads this config from disk before synchronizing new clients.
|
||||||
|
config.set(WHITELIST_KEY, dimensions);
|
||||||
|
config.write();
|
||||||
|
config.whitelistedDimensions = dimensions;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void setClientWhitelist(ResourceLocation dimensionId, boolean enabled) {
|
||||||
|
SeasonsConfig config = ModConfig.seasons;
|
||||||
|
if (config == null || config.whitelistedDimensions.contains(dimensionId.toString()) == enabled) return;
|
||||||
|
List<String> dimensions = new ArrayList<>(config.whitelistedDimensions);
|
||||||
|
if (enabled) dimensions.add(dimensionId.toString());
|
||||||
|
else dimensions.removeIf(dimensionId.toString()::equals);
|
||||||
|
config.whitelistedDimensions = dimensions;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void holdSeason(ServerLevel level, AgeSeasonMode mode) {
|
||||||
|
SeasonSavedData data = SeasonHandler.getSeasonSavedData(level);
|
||||||
|
Season.SubSeason target = switch (mode) {
|
||||||
|
case ETERNAL_SPRING -> Season.SubSeason.MID_SPRING;
|
||||||
|
case ETERNAL_SUMMER -> Season.SubSeason.MID_SUMMER;
|
||||||
|
case ETERNAL_FALL -> Season.SubSeason.MID_AUTUMN;
|
||||||
|
case ETERNAL_WINTER -> Season.SubSeason.MID_WINTER;
|
||||||
|
default -> throw new IllegalArgumentException("Not an eternal season: " + mode);
|
||||||
|
};
|
||||||
|
int duration = SeasonTime.ZERO.getSubSeasonDuration();
|
||||||
|
int midpoint = target.ordinal() * duration + duration / 2;
|
||||||
|
// Reset well before the end of MID_* so the client never observes a
|
||||||
|
// different sub-season; avoid marking saved data dirty every tick.
|
||||||
|
int current = data.seasonCycleTicks;
|
||||||
|
if (current >= midpoint && current < midpoint + duration / 4) return;
|
||||||
|
data.seasonCycleTicks = midpoint;
|
||||||
|
data.setDirty();
|
||||||
|
SeasonHandler.sendSeasonUpdate(level);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
package net.dnorberg.rivencraft.compat;
|
||||||
|
|
||||||
|
import net.dnorberg.rivencraft.Rivencraft;
|
||||||
|
import net.dnorberg.rivencraft.book.AgeDefinition;
|
||||||
|
import net.dnorberg.rivencraft.book.AgeDimensionService;
|
||||||
|
import net.dnorberg.rivencraft.book.AgeRegistrySavedData;
|
||||||
|
import net.dnorberg.rivencraft.book.AgeSeasonMode;
|
||||||
|
import net.dnorberg.rivencraft.config.RivencraftConfig;
|
||||||
|
import net.dnorberg.rivencraft.network.SereneAgeWhitelistPayload;
|
||||||
|
import net.dnorberg.rivencraft.writing.SymbolSemantics;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
import net.minecraft.server.level.ServerLevel;
|
||||||
|
import net.neoforged.fml.ModList;
|
||||||
|
import net.neoforged.neoforge.network.PacketDistributor;
|
||||||
|
import net.neoforged.neoforge.network.registration.NetworkRegistry;
|
||||||
|
import net.neoforged.neoforge.event.tick.LevelTickEvent;
|
||||||
|
|
||||||
|
/** Optional, guarded bridge for Serene Seasons' per-dimension whitelist. */
|
||||||
|
public final class SereneSeasonsCompatibility {
|
||||||
|
private SereneSeasonsCompatibility() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void registerAge(MinecraftServer server, AgeDefinition age) {
|
||||||
|
if (!available() || !isAge(age.dimensionId())) return;
|
||||||
|
AgeSeasonMode mode = AgeSeasonMode.from(age.plan());
|
||||||
|
boolean explicit = age.plan() != null && age.plan().symbols().stream()
|
||||||
|
.anyMatch(symbol -> symbol.semantics().role() == SymbolSemantics.Role.SEASON);
|
||||||
|
if (mode != AgeSeasonMode.NO_SEASONS && !explicit && !RivencraftConfig.autoWhitelistSereneAges()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
boolean enabled = mode != AgeSeasonMode.NO_SEASONS;
|
||||||
|
try {
|
||||||
|
if (SereneSeasonsAdapter.setServerWhitelist(age.dimensionId(), enabled)) {
|
||||||
|
for (ServerPlayer player : server.getPlayerList().getPlayers()) {
|
||||||
|
send(player, age.dimensionId(), enabled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (enabled && mode.eternal()) {
|
||||||
|
ServerLevel level = server.getLevel(AgeDimensionService.dimensionKey(age));
|
||||||
|
if (level != null) SereneSeasonsAdapter.holdSeason(level, mode);
|
||||||
|
}
|
||||||
|
} catch (RuntimeException exception) {
|
||||||
|
Rivencraft.LOGGER.warn("Could not apply Serene Seasons policy for Age {}", age.dimensionId(), exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onLevelTickPost(LevelTickEvent.Post event) {
|
||||||
|
if (!(event.getLevel() instanceof ServerLevel level) || !available()
|
||||||
|
|| !isAge(level.dimension().location())) return;
|
||||||
|
AgeDefinition age = AgeRegistrySavedData.get(level)
|
||||||
|
.findByDimension(level.dimension().location()).orElse(null);
|
||||||
|
if (age == null) return;
|
||||||
|
AgeSeasonMode mode = AgeSeasonMode.from(age.plan());
|
||||||
|
if (!mode.eternal()) return;
|
||||||
|
try {
|
||||||
|
SereneSeasonsAdapter.holdSeason(level, mode);
|
||||||
|
} catch (RuntimeException exception) {
|
||||||
|
Rivencraft.LOGGER.warn("Could not hold Serene season in Age {}", age.dimensionId(), exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void acceptClient(ResourceLocation dimensionId, boolean enabled) {
|
||||||
|
if (available() && isAge(dimensionId)) {
|
||||||
|
SereneSeasonsAdapter.setClientWhitelist(dimensionId, enabled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void send(ServerPlayer player, ResourceLocation dimensionId, boolean enabled) {
|
||||||
|
if (NetworkRegistry.hasChannel(player.connection, SereneAgeWhitelistPayload.TYPE.id())) {
|
||||||
|
PacketDistributor.sendToPlayer(player, new SereneAgeWhitelistPayload(dimensionId, enabled));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean available() {
|
||||||
|
return ModList.get().isLoaded("sereneseasons");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isAge(ResourceLocation dimensionId) {
|
||||||
|
return dimensionId.getNamespace().equals(Rivencraft.MOD_ID)
|
||||||
|
&& dimensionId.getPath().startsWith("age/");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package net.dnorberg.rivencraft.compat;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
import net.dnorberg.rivencraft.Rivencraft;
|
||||||
|
import net.minecraft.core.RegistryAccess;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.neoforged.fml.ModList;
|
||||||
|
|
||||||
|
/** Optional boundary: core Age code never loads TerraBlender API classes. */
|
||||||
|
public final class TerraBlenderBiomes {
|
||||||
|
private static final AtomicBoolean WARNED = new AtomicBoolean();
|
||||||
|
private TerraBlenderBiomes() {}
|
||||||
|
|
||||||
|
public static List<ResourceLocation> overworld(RegistryAccess registries) {
|
||||||
|
return collect(registries, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<ResourceLocation> nether(RegistryAccess registries) {
|
||||||
|
return collect(registries, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<ResourceLocation> collect(RegistryAccess registries, boolean nether) {
|
||||||
|
if (!ModList.get().isLoaded("terrablender")) return List.of();
|
||||||
|
try {
|
||||||
|
return TerraBlenderRegionAdapter.collect(registries, nether);
|
||||||
|
} catch (RuntimeException | LinkageError exception) {
|
||||||
|
if (WARNED.compareAndSet(false, true))
|
||||||
|
Rivencraft.LOGGER.warn("TerraBlender biome regions could not be read; using Rivencraft's biome pool", exception);
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package net.dnorberg.rivencraft.compat;
|
||||||
|
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import net.minecraft.core.RegistryAccess;
|
||||||
|
import net.minecraft.core.registries.Registries;
|
||||||
|
import net.minecraft.resources.ResourceKey;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.world.level.biome.Biome;
|
||||||
|
import terrablender.api.Region;
|
||||||
|
import terrablender.api.RegionType;
|
||||||
|
import terrablender.api.Regions;
|
||||||
|
|
||||||
|
/** Loaded only after the optional TerraBlender mod is confirmed present. */
|
||||||
|
final class TerraBlenderRegionAdapter {
|
||||||
|
private TerraBlenderRegionAdapter() {}
|
||||||
|
|
||||||
|
static List<ResourceLocation> collect(RegistryAccess registries, boolean nether) {
|
||||||
|
var biomes = registries.registryOrThrow(Registries.BIOME);
|
||||||
|
RegionType type = nether ? RegionType.NETHER : RegionType.OVERWORLD;
|
||||||
|
Set<ResourceLocation> ids = new LinkedHashSet<>();
|
||||||
|
for (Region region : Regions.get(type)) {
|
||||||
|
region.addBiomes(biomes, mapping -> {
|
||||||
|
ResourceKey<Biome> key = mapping.getSecond();
|
||||||
|
ResourceLocation id = key.location();
|
||||||
|
// Vanilla's default region is always present. Only additions from
|
||||||
|
// other mods extend an Age's existing deterministic biome pool.
|
||||||
|
if (!id.getNamespace().equals("minecraft") && biomes.containsKey(id)) ids.add(id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return ids.stream().sorted().toList();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -23,11 +23,16 @@ import mezz.jei.api.ingredients.subtypes.UidContext;
|
|||||||
import mezz.jei.api.runtime.IJeiRuntime;
|
import mezz.jei.api.runtime.IJeiRuntime;
|
||||||
import net.dnorberg.rivencraft.Rivencraft;
|
import net.dnorberg.rivencraft.Rivencraft;
|
||||||
import net.dnorberg.rivencraft.item.PageItem;
|
import net.dnorberg.rivencraft.item.PageItem;
|
||||||
|
import net.dnorberg.rivencraft.book.LinkProperties;
|
||||||
|
import net.dnorberg.rivencraft.registry.ModDataComponents;
|
||||||
|
import net.dnorberg.rivencraft.writing.InkModifierIngredients;
|
||||||
import net.dnorberg.rivencraft.writing.PageContent;
|
import net.dnorberg.rivencraft.writing.PageContent;
|
||||||
|
import net.dnorberg.rivencraft.writing.SymbolReference;
|
||||||
import net.dnorberg.rivencraft.registry.ModItems;
|
import net.dnorberg.rivencraft.registry.ModItems;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.network.chat.MutableComponent;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.Items;
|
import net.minecraft.world.item.Items;
|
||||||
@@ -52,7 +57,8 @@ public final class RivencraftJeiPlugin implements IModPlugin {
|
|||||||
PageContent content = PageItem.content(stack);
|
PageContent content = PageItem.content(stack);
|
||||||
return switch (content.kind()) {
|
return switch (content.kind()) {
|
||||||
case BLANK -> "blank";
|
case BLANK -> "blank";
|
||||||
case LINK_PANEL -> "link_panel";
|
case LINK_PANEL -> "link_panel:" + stack.getOrDefault(
|
||||||
|
ModDataComponents.LINK_PROPERTIES.get(), LinkProperties.NONE).flags();
|
||||||
case SYMBOL -> "symbol:" + content.symbol().orElseThrow().id();
|
case SYMBOL -> "symbol:" + content.symbol().orElseThrow().id();
|
||||||
case UNRESOLVED_SYMBOL -> "unresolved:" + content.symbol().orElseThrow().id();
|
case UNRESOLVED_SYMBOL -> "unresolved:" + content.symbol().orElseThrow().id();
|
||||||
};
|
};
|
||||||
@@ -103,17 +109,23 @@ public final class RivencraftJeiPlugin implements IModPlugin {
|
|||||||
@Override
|
@Override
|
||||||
public void registerRecipes(IRecipeRegistration registration) {
|
public void registerRecipes(IRecipeRegistration registration) {
|
||||||
ItemStack panel = PageItem.createLinkPanelPage();
|
ItemStack panel = PageItem.createLinkPanelPage();
|
||||||
|
ItemStack symbolPage = PageItem.createSymbolPage(new SymbolReference(
|
||||||
|
ResourceLocation.fromNamespaceAndPath(Rivencraft.MOD_ID, "terrain/standard")));
|
||||||
registration.addRecipes(WRITING, List.of(
|
registration.addRecipes(WRITING, List.of(
|
||||||
new WritingGuide(List.of(new ItemStack(Items.PAPER), new ItemStack(ModItems.INK_VIAL.get())),
|
new WritingGuide(List.of(new ItemStack(Items.PAPER), new ItemStack(ModItems.INK_VIAL.get())),
|
||||||
panel, "jei.rivencraft.writing.link_panel_hand"),
|
panel, "jei.rivencraft.writing.link_panel_hand"),
|
||||||
new WritingGuide(List.of(panel, new ItemStack(Items.PAPER), new ItemStack(ModItems.INK_VIAL.get())),
|
new WritingGuide(List.of(symbolPage, new ItemStack(Items.PAPER), new ItemStack(ModItems.INK_VIAL.get())),
|
||||||
panel, "jei.rivencraft.writing.copy"),
|
symbolPage, "jei.rivencraft.writing.copy"),
|
||||||
new WritingGuide(List.of(new ItemStack(Items.LEATHER), panel),
|
new WritingGuide(List.of(new ItemStack(Items.LEATHER), panel),
|
||||||
new ItemStack(ModItems.DESCRIPTIVE_BOOK.get()), "jei.rivencraft.writing.bind"),
|
new ItemStack(ModItems.DESCRIPTIVE_BOOK.get()), "jei.rivencraft.writing.bind"),
|
||||||
new WritingGuide(List.of(panel, new ItemStack(Items.LEATHER)),
|
new WritingGuide(List.of(panel, new ItemStack(Items.LEATHER)),
|
||||||
new ItemStack(ModItems.LINKING_BOOK.get()), "jei.rivencraft.writing.linking_book")
|
new ItemStack(ModItems.LINKING_BOOK.get()), "jei.rivencraft.writing.linking_book")
|
||||||
));
|
));
|
||||||
registration.addRecipes(INK_MIXER, List.of(new InkMixerGuide(panel)));
|
List<InkMixerGuide> mixerGuides = new ArrayList<>();
|
||||||
|
mixerGuides.add(new InkMixerGuide(panel, null));
|
||||||
|
InkModifierIngredients.builtIn().forEach(ingredient ->
|
||||||
|
mixerGuides.add(new InkMixerGuide(panel, ingredient)));
|
||||||
|
registration.addRecipes(INK_MIXER, mixerGuides);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -124,7 +136,7 @@ public final class RivencraftJeiPlugin implements IModPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private record WritingGuide(List<ItemStack> inputs, ItemStack output, String instructionKey) {}
|
private record WritingGuide(List<ItemStack> inputs, ItemStack output, String instructionKey) {}
|
||||||
private record InkMixerGuide(ItemStack panel) {}
|
private record InkMixerGuide(ItemStack panel, InkModifierIngredients.Ingredient additive) {}
|
||||||
|
|
||||||
private static final class InkMixerCategory extends AbstractRecipeCategory<InkMixerGuide> {
|
private static final class InkMixerCategory extends AbstractRecipeCategory<InkMixerGuide> {
|
||||||
InkMixerCategory(IGuiHelper guiHelper) {
|
InkMixerCategory(IGuiHelper guiHelper) {
|
||||||
@@ -138,6 +150,9 @@ public final class RivencraftJeiPlugin implements IModPlugin {
|
|||||||
builder.addInputSlot(2, 3).setStandardSlotBackground().addItemStack(new ItemStack(Items.PAPER));
|
builder.addInputSlot(2, 3).setStandardSlotBackground().addItemStack(new ItemStack(Items.PAPER));
|
||||||
builder.addInputSlot(23, 3).setStandardSlotBackground()
|
builder.addInputSlot(23, 3).setStandardSlotBackground()
|
||||||
.addItemStack(new ItemStack(ModItems.INK_VIAL.get()));
|
.addItemStack(new ItemStack(ModItems.INK_VIAL.get()));
|
||||||
|
if (recipe.additive() != null)
|
||||||
|
builder.addInputSlot(44, 3).setStandardSlotBackground()
|
||||||
|
.addItemStack(recipe.additive().item());
|
||||||
builder.addOutputSlot(112, 3).setOutputSlotBackground().addItemStack(recipe.panel());
|
builder.addOutputSlot(112, 3).setOutputSlotBackground().addItemStack(recipe.panel());
|
||||||
builder.addOutputSlot(112, 46).setStandardSlotBackground()
|
builder.addOutputSlot(112, 46).setStandardSlotBackground()
|
||||||
.addItemStack(new ItemStack(Items.GLASS_BOTTLE));
|
.addItemStack(new ItemStack(Items.GLASS_BOTTLE));
|
||||||
@@ -146,8 +161,20 @@ public final class RivencraftJeiPlugin implements IModPlugin {
|
|||||||
@Override
|
@Override
|
||||||
public void draw(InkMixerGuide recipe, IRecipeSlotsView slots, GuiGraphics graphics,
|
public void draw(InkMixerGuide recipe, IRecipeSlotsView slots, GuiGraphics graphics,
|
||||||
double mouseX, double mouseY) {
|
double mouseX, double mouseY) {
|
||||||
graphics.drawWordWrap(Minecraft.getInstance().font,
|
Component instructions = recipe.additive() == null
|
||||||
Component.translatable("jei.rivencraft.ink_mixer.usage"), 2, 27, 104, 0x404040);
|
? Component.translatable("jei.rivencraft.ink_mixer.usage")
|
||||||
|
: additiveInstructions(recipe.additive());
|
||||||
|
graphics.drawWordWrap(Minecraft.getInstance().font, instructions, 2, 27, 104, 0x404040);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Component additiveInstructions(InkModifierIngredients.Ingredient additive) {
|
||||||
|
MutableComponent effects = Component.empty();
|
||||||
|
for (InkModifierIngredients.Effect effect : additive.effects()) {
|
||||||
|
if (!effects.getSiblings().isEmpty()) effects.append(", ");
|
||||||
|
effects.append(Component.translatable("jei.rivencraft.ink_mixer.effect",
|
||||||
|
LinkProperties.name(effect.flag()), Math.round(effect.chance() * 100)));
|
||||||
|
}
|
||||||
|
return Component.translatable("jei.rivencraft.ink_mixer.additive", effects);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ public final class RivencraftConfig {
|
|||||||
private static final ModConfigSpec.EnumValue<ReturnLinkMode> RETURN_LINK_MODE;
|
private static final ModConfigSpec.EnumValue<ReturnLinkMode> RETURN_LINK_MODE;
|
||||||
private static final ModConfigSpec.IntValue SYMBOL_INK_COST;
|
private static final ModConfigSpec.IntValue SYMBOL_INK_COST;
|
||||||
private static final ModConfigSpec.IntValue LINK_PANEL_INK_COST;
|
private static final ModConfigSpec.IntValue LINK_PANEL_INK_COST;
|
||||||
|
private static final ModConfigSpec.BooleanValue AUTO_WHITELIST_SERENE_AGES;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
ModConfigSpec.Builder builder = new ModConfigSpec.Builder();
|
ModConfigSpec.Builder builder = new ModConfigSpec.Builder();
|
||||||
@@ -33,6 +34,12 @@ public final class RivencraftConfig {
|
|||||||
LINK_PANEL_INK_COST = builder.comment("Ink units consumed when preparing one baseline link-panel page.")
|
LINK_PANEL_INK_COST = builder.comment("Ink units consumed when preparing one baseline link-panel page.")
|
||||||
.defineInRange("link_panel_ink_cost", 2, 1, 16);
|
.defineInRange("link_panel_ink_cost", 2, 1, 16);
|
||||||
builder.pop();
|
builder.pop();
|
||||||
|
builder.push("serene_seasons");
|
||||||
|
AUTO_WHITELIST_SERENE_AGES = builder.comment(
|
||||||
|
"Automatically add Rivencraft Ages to Serene Seasons' dimension whitelist when loaded.",
|
||||||
|
"Existing entries are preserved; disabling this does not remove previously added Ages."
|
||||||
|
).define("auto_whitelist_ages", true);
|
||||||
|
builder.pop();
|
||||||
SPEC = builder.build();
|
SPEC = builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,4 +57,8 @@ public final class RivencraftConfig {
|
|||||||
public static int linkPanelInkCost() {
|
public static int linkPanelInkCost() {
|
||||||
return LINK_PANEL_INK_COST.get();
|
return LINK_PANEL_INK_COST.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean autoWhitelistSereneAges() {
|
||||||
|
return AUTO_WHITELIST_SERENE_AGES.get();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -6,6 +6,9 @@ import net.dnorberg.rivencraft.block.entity.BookBinderBlockEntity;
|
|||||||
import net.dnorberg.rivencraft.book.AgeReference;
|
import net.dnorberg.rivencraft.book.AgeReference;
|
||||||
import net.dnorberg.rivencraft.book.AgeDimensionService;
|
import net.dnorberg.rivencraft.book.AgeDimensionService;
|
||||||
import net.dnorberg.rivencraft.book.AgeRegistrySavedData;
|
import net.dnorberg.rivencraft.book.AgeRegistrySavedData;
|
||||||
|
import net.dnorberg.rivencraft.book.LinkProperties;
|
||||||
|
import net.dnorberg.rivencraft.book.LinkTarget;
|
||||||
|
import net.dnorberg.rivencraft.book.LinkingService;
|
||||||
import net.dnorberg.rivencraft.item.PageItem;
|
import net.dnorberg.rivencraft.item.PageItem;
|
||||||
import net.dnorberg.rivencraft.menu.BookBinderMenu;
|
import net.dnorberg.rivencraft.menu.BookBinderMenu;
|
||||||
import net.dnorberg.rivencraft.registry.ModBlocks;
|
import net.dnorberg.rivencraft.registry.ModBlocks;
|
||||||
@@ -17,6 +20,7 @@ import net.dnorberg.rivencraft.writing.SymbolReference;
|
|||||||
import net.dnorberg.rivencraft.writing.SymbolCatalog;
|
import net.dnorberg.rivencraft.writing.SymbolCatalog;
|
||||||
import net.dnorberg.rivencraft.writing.WritingEntry;
|
import net.dnorberg.rivencraft.writing.WritingEntry;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.core.GlobalPos;
|
||||||
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.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
@@ -133,7 +137,14 @@ public final class BookBinderGameTests {
|
|||||||
helper.assertFalse(binder.consumeAssembly(), "Failure must consume nothing");
|
helper.assertFalse(binder.consumeAssembly(), "Failure must consume nothing");
|
||||||
helper.assertTrue(binder.getItem(BookBinderBlockEntity.COVER).is(Items.LEATHER),
|
helper.assertTrue(binder.getItem(BookBinderBlockEntity.COVER).is(Items.LEATHER),
|
||||||
"Rejected assembly must preserve cover");
|
"Rejected assembly must preserve cover");
|
||||||
binder.setItem(BookBinderBlockEntity.LINK_PANEL, PageItem.createLinkPanelPage());
|
ItemStack flavoredPanel = PageItem.createLinkPanelPage();
|
||||||
|
flavoredPanel.set(ModDataComponents.LINK_PROPERTIES.get(),
|
||||||
|
new net.dnorberg.rivencraft.book.LinkProperties(
|
||||||
|
net.dnorberg.rivencraft.book.LinkProperties.DISARM
|
||||||
|
| net.dnorberg.rivencraft.book.LinkProperties.MAINTAIN_MOMENTUM
|
||||||
|
| net.dnorberg.rivencraft.book.LinkProperties.INTRA_LINKING));
|
||||||
|
var expectedProperties = flavoredPanel.get(ModDataComponents.LINK_PROPERTIES.get()).forDescriptiveBook();
|
||||||
|
binder.setItem(BookBinderBlockEntity.LINK_PANEL, flavoredPanel);
|
||||||
var player = helper.makeMockServerPlayerInLevel();
|
var player = helper.makeMockServerPlayerInLevel();
|
||||||
player.moveTo(binder.getBlockPos().getX() + 0.5, binder.getBlockPos().getY() + 0.5,
|
player.moveTo(binder.getBlockPos().getX() + 0.5, binder.getBlockPos().getY() + 0.5,
|
||||||
binder.getBlockPos().getZ() + 0.5);
|
binder.getBlockPos().getZ() + 0.5);
|
||||||
@@ -143,6 +154,9 @@ public final class BookBinderGameTests {
|
|||||||
menu.clicked(BookBinderMenu.RESULT, 0, ClickType.PICKUP, player);
|
menu.clicked(BookBinderMenu.RESULT, 0, ClickType.PICKUP, player);
|
||||||
ItemStack book = menu.getCarried();
|
ItemStack book = menu.getCarried();
|
||||||
helper.assertTrue(book.is(ModItems.DESCRIPTIVE_BOOK.get()), "Result must be a Descriptive Book");
|
helper.assertTrue(book.is(ModItems.DESCRIPTIVE_BOOK.get()), "Result must be a Descriptive Book");
|
||||||
|
helper.assertValueEqual(book.get(ModDataComponents.LINK_PROPERTIES.get()),
|
||||||
|
expectedProperties,
|
||||||
|
"Binder must retain Disarm and Momentum but omit Intra Linking");
|
||||||
AgeReference age = book.get(ModDataComponents.AGE_REFERENCE.get());
|
AgeReference age = book.get(ModDataComponents.AGE_REFERENCE.get());
|
||||||
helper.assertTrue(age != null, "Assembled book must already be a written Age book");
|
helper.assertTrue(age != null, "Assembled book must already be a written Age book");
|
||||||
OrderedWriting writing = book.get(ModDataComponents.BOOK_WRITING.get());
|
OrderedWriting writing = book.get(ModDataComponents.BOOK_WRITING.get());
|
||||||
@@ -175,6 +189,50 @@ public final class BookBinderGameTests {
|
|||||||
helper.succeed();
|
helper.succeed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void panelOnlyBookRetainsApplicableModifiers(GameTestHelper helper) {
|
||||||
|
BookBinderBlockEntity binder = place(helper);
|
||||||
|
binder.setTitle("Modified Random Age");
|
||||||
|
binder.setItem(BookBinderBlockEntity.COVER, new ItemStack(Items.LEATHER));
|
||||||
|
ItemStack panel = PageItem.createLinkPanelPage();
|
||||||
|
panel.set(ModDataComponents.LINK_PROPERTIES.get(), new LinkProperties(
|
||||||
|
LinkProperties.DISARM | LinkProperties.MAINTAIN_MOMENTUM | LinkProperties.INTRA_LINKING));
|
||||||
|
var player = helper.makeMockServerPlayerInLevel();
|
||||||
|
player.moveTo(binder.getBlockPos().getX() + 0.5, binder.getBlockPos().getY() + 0.5,
|
||||||
|
binder.getBlockPos().getZ() + 0.5);
|
||||||
|
BookBinderMenu menu = new BookBinderMenu(1, player.getInventory(), binder);
|
||||||
|
menu.setCarried(panel);
|
||||||
|
helper.assertTrue(menu.clickMenuButton(player, BookBinderMenu.STRIP_CLICK_BASE),
|
||||||
|
"The link strip must accept the modified panel without symbol pages");
|
||||||
|
ItemStack result = menu.quickMoveStack(player, BookBinderMenu.RESULT);
|
||||||
|
helper.assertTrue(result.is(ModItems.DESCRIPTIVE_BOOK.get()),
|
||||||
|
"A Link Panel alone must create a random-Age Descriptive Book");
|
||||||
|
LinkProperties expected = new LinkProperties(LinkProperties.DISARM | LinkProperties.MAINTAIN_MOMENTUM);
|
||||||
|
helper.assertValueEqual(result.get(ModDataComponents.LINK_PROPERTIES.get()), expected,
|
||||||
|
"The panel-only book must keep travel modifiers but omit Intra Linking");
|
||||||
|
ItemStack restored = ItemStack.parseOptional(helper.getLevel().registryAccess(),
|
||||||
|
(net.minecraft.nbt.CompoundTag) result.saveOptional(helper.getLevel().registryAccess()));
|
||||||
|
helper.assertValueEqual(restored.get(ModDataComponents.LINK_PROPERTIES.get()), expected,
|
||||||
|
"Panel-only book modifiers must survive save and reload");
|
||||||
|
BlockPos departure = player.blockPosition();
|
||||||
|
BlockPos destination = departure.offset(3, 0, 0);
|
||||||
|
helper.getLevel().setBlock(destination.below(), Blocks.STONE.defaultBlockState(), 3);
|
||||||
|
helper.getLevel().setBlock(destination, Blocks.AIR.defaultBlockState(), 3);
|
||||||
|
helper.getLevel().setBlock(destination.above(), Blocks.AIR.defaultBlockState(), 3);
|
||||||
|
player.getInventory().setItem(4, new ItemStack(Items.DIAMOND, 3));
|
||||||
|
LinkTarget target = new LinkTarget(GlobalPos.of(helper.getLevel().dimension(), destination), 0.0F, 0.0F);
|
||||||
|
helper.assertValueEqual(LinkingService.travelWithFooting(player, target,
|
||||||
|
restored.get(ModDataComponents.LINK_PROPERTIES.get()).forDescriptiveBook()),
|
||||||
|
LinkingService.LinkResult.SUCCESS,
|
||||||
|
"The panel-only book's properties must be accepted by grounded travel");
|
||||||
|
helper.assertTrue(player.getInventory().getItem(4).isEmpty(),
|
||||||
|
"Disarm must remove the carried items during panel-only book travel");
|
||||||
|
helper.assertTrue(helper.getLevel().getEntitiesOfClass(ItemEntity.class,
|
||||||
|
new AABB(departure).inflate(5.0), entity -> entity.getItem().is(Items.DIAMOND))
|
||||||
|
.stream().mapToInt(entity -> entity.getItem().getCount()).sum() >= 3,
|
||||||
|
"Disarm must drop the items at the departure location");
|
||||||
|
helper.succeed();
|
||||||
|
}
|
||||||
|
|
||||||
@GameTest(template = "empty")
|
@GameTest(template = "empty")
|
||||||
public static void linkPanelOnlyCreatesCompletedRandomAgeBook(GameTestHelper helper) {
|
public static void linkPanelOnlyCreatesCompletedRandomAgeBook(GameTestHelper helper) {
|
||||||
BookBinderBlockEntity binder = place(helper);
|
BookBinderBlockEntity binder = place(helper);
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
package net.dnorberg.rivencraft.gametest;
|
package net.dnorberg.rivencraft.gametest;
|
||||||
|
|
||||||
import net.dnorberg.rivencraft.Rivencraft;
|
import net.dnorberg.rivencraft.Rivencraft;
|
||||||
|
import net.dnorberg.rivencraft.writing.BiomeSymbolPages;
|
||||||
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.ResourceLocation;
|
||||||
import net.neoforged.neoforge.gametest.GameTestHolder;
|
import net.neoforged.neoforge.gametest.GameTestHolder;
|
||||||
import net.neoforged.neoforge.gametest.PrefixGameTestTemplate;
|
import net.neoforged.neoforge.gametest.PrefixGameTestTemplate;
|
||||||
|
|
||||||
@@ -87,6 +89,21 @@ public final class CoreGameTests {
|
|||||||
BookBinderGameTests.assemblyIsAtomicAndRetainsPageOrder(helper);
|
BookBinderGameTests.assemblyIsAtomicAndRetainsPageOrder(helper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GameTest(template = "empty")
|
||||||
|
public static void panelOnlyBookModifiers(GameTestHelper helper) {
|
||||||
|
BookBinderGameTests.panelOnlyBookRetainsApplicableModifiers(helper);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GameTest(template = "empty")
|
||||||
|
public static void biomePageNamespaces(GameTestHelper helper) {
|
||||||
|
helper.assertValueEqual(BiomeSymbolPages.symbolId(ResourceLocation.parse("minecraft:desert")),
|
||||||
|
ResourceLocation.parse("rivencraft:biome/desert"), "Vanilla biome page IDs must remain stable");
|
||||||
|
helper.assertFalse(BiomeSymbolPages.symbolId(ResourceLocation.parse("example:orchard"))
|
||||||
|
.equals(BiomeSymbolPages.symbolId(ResourceLocation.parse("another:orchard"))),
|
||||||
|
"Equal biome paths from different mods must not share a page ID");
|
||||||
|
helper.succeed();
|
||||||
|
}
|
||||||
|
|
||||||
@GameTest(template = "empty")
|
@GameTest(template = "empty")
|
||||||
public static void binderRejectsConflictingGrammar(GameTestHelper helper) {
|
public static void binderRejectsConflictingGrammar(GameTestHelper helper) {
|
||||||
BookBinderGameTests.conflictingGrammarKeepsBinderInputsRecoverable(helper);
|
BookBinderGameTests.conflictingGrammarKeepsBinderInputsRecoverable(helper);
|
||||||
@@ -102,6 +119,11 @@ public final class CoreGameTests {
|
|||||||
InkMixerGameTests.linkPanelRequiresTakingOutputAndPersistsInk(helper);
|
InkMixerGameTests.linkPanelRequiresTakingOutputAndPersistsInk(helper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GameTest(template = "empty")
|
||||||
|
public static void mixerModifierTransaction(GameTestHelper helper) {
|
||||||
|
InkMixerGameTests.modifierClickPersistsPreviewAndConsumesOnce(helper);
|
||||||
|
}
|
||||||
|
|
||||||
@GameTest(template = "empty")
|
@GameTest(template = "empty")
|
||||||
public static void linkingBookRecipe(GameTestHelper helper) {
|
public static void linkingBookRecipe(GameTestHelper helper) {
|
||||||
LinkingBookRecipeGameTests.legacyRecipeRequiresExactlyLeatherAndLinkPanel(helper);
|
LinkingBookRecipeGameTests.legacyRecipeRequiresExactlyLeatherAndLinkPanel(helper);
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import net.dnorberg.rivencraft.block.entity.InkMixerBlockEntity;
|
|||||||
import net.dnorberg.rivencraft.menu.InkMixerMenu;
|
import net.dnorberg.rivencraft.menu.InkMixerMenu;
|
||||||
import net.dnorberg.rivencraft.registry.ModBlocks;
|
import net.dnorberg.rivencraft.registry.ModBlocks;
|
||||||
import net.dnorberg.rivencraft.registry.ModItems;
|
import net.dnorberg.rivencraft.registry.ModItems;
|
||||||
import net.dnorberg.rivencraft.writing.WritingInkService;
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.gametest.framework.GameTest;
|
import net.minecraft.gametest.framework.GameTest;
|
||||||
import net.minecraft.gametest.framework.GameTestHelper;
|
import net.minecraft.gametest.framework.GameTestHelper;
|
||||||
@@ -28,6 +27,69 @@ public final class InkMixerGameTests {
|
|||||||
return (InkMixerBlockEntity) helper.getLevel().getBlockEntity(pos);
|
return (InkMixerBlockEntity) helper.getLevel().getBlockEntity(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void modifierClickPersistsPreviewAndConsumesOnce(GameTestHelper helper) {
|
||||||
|
InkMixerBlockEntity mixer = place(helper);
|
||||||
|
mixer.setItem(InkMixerBlockEntity.PAPER, new ItemStack(Items.PAPER, 2));
|
||||||
|
mixer.setItem(InkMixerBlockEntity.INK, new ItemStack(ModItems.INK_VIAL.get()));
|
||||||
|
var player = helper.makeMockServerPlayerInLevel();
|
||||||
|
player.moveTo(mixer.getBlockPos().getX() + 0.5, mixer.getBlockPos().getY() + 0.5,
|
||||||
|
mixer.getBlockPos().getZ() + 0.5);
|
||||||
|
InkMixerMenu menu = new InkMixerMenu(1, player.getInventory(), mixer);
|
||||||
|
menu.setCarried(new ItemStack(Items.GUNPOWDER, 2));
|
||||||
|
menu.clicked(InkMixerMenu.MODIFIER, 1, ClickType.PICKUP, player);
|
||||||
|
helper.assertValueEqual(menu.getCarried().getCount(), 1, "Right click must consume one additive");
|
||||||
|
helper.assertValueEqual(mixer.modifierChancePermille(0), 200,
|
||||||
|
"Gunpowder must add Legacy's 20% Disarm chance");
|
||||||
|
menu.setCarried(new ItemStack(Items.STONE));
|
||||||
|
menu.clicked(InkMixerMenu.MODIFIER, 0, ClickType.PICKUP, player);
|
||||||
|
helper.assertValueEqual(menu.getCarried().getCount(), 1, "Invalid additive must remain carried");
|
||||||
|
helper.assertValueEqual(mixer.modifierChancePermille(0), 200,
|
||||||
|
"Invalid additive must not change the mixture");
|
||||||
|
ItemStack preview = mixer.previewLinkPanel();
|
||||||
|
var saved = mixer.saveWithoutMetadata(helper.getLevel().registryAccess());
|
||||||
|
var restored = new InkMixerBlockEntity(mixer.getBlockPos(), ModBlocks.INK_MIXER.get().defaultBlockState());
|
||||||
|
restored.loadWithComponents(saved, helper.getLevel().registryAccess());
|
||||||
|
helper.assertTrue(ItemStack.matches(preview, restored.previewLinkPanel()),
|
||||||
|
"Saving must retain the mixture and deterministic next-panel preview");
|
||||||
|
menu.setCarried(ItemStack.EMPTY);
|
||||||
|
menu.clicked(InkMixerMenu.RESULT, 0, ClickType.PICKUP, player);
|
||||||
|
helper.assertTrue(menu.getCarried().is(ModItems.PAGE.get()), "Taking result must give a panel");
|
||||||
|
helper.assertValueEqual(mixer.modifierChancePermille(0), 0,
|
||||||
|
"Mixture must be spent only when a panel is taken");
|
||||||
|
helper.assertValueEqual(mixer.getItem(InkMixerBlockEntity.PAPER).getCount(), 1,
|
||||||
|
"Taking the panel must consume exactly one paper");
|
||||||
|
helper.succeed();
|
||||||
|
}
|
||||||
|
|
||||||
|
@GameTest(template = "empty")
|
||||||
|
public static void enderPearlsRaiseBothPropertiesIndependentlyAndResetOnOutput(GameTestHelper helper) {
|
||||||
|
InkMixerBlockEntity mixer = place(helper);
|
||||||
|
mixer.setItem(InkMixerBlockEntity.PAPER, new ItemStack(Items.PAPER, 2));
|
||||||
|
mixer.setItem(InkMixerBlockEntity.INK, new ItemStack(ModItems.INK_VIAL.get()));
|
||||||
|
ItemStack pearls = new ItemStack(Items.ENDER_PEARL, 20);
|
||||||
|
helper.assertTrue(mixer.addModifier(pearls, 20), "Ender Pearls must infuse the basin");
|
||||||
|
helper.assertTrue(pearls.isEmpty(), "Twenty pearls must be consumed exactly once");
|
||||||
|
helper.assertValueEqual(mixer.modifierChancePermille(0), 961,
|
||||||
|
"Disarm must approach 100% independently");
|
||||||
|
helper.assertValueEqual(mixer.modifierChancePermille(2), 961,
|
||||||
|
"Intra Linking must approach 100% independently");
|
||||||
|
helper.assertValueEqual(mixer.modifierChancePermille(1), 0,
|
||||||
|
"Ender Pearls must not add Momentum");
|
||||||
|
|
||||||
|
var player = helper.makeMockServerPlayerInLevel();
|
||||||
|
player.moveTo(mixer.getBlockPos().getX() + 0.5, mixer.getBlockPos().getY() + 0.5,
|
||||||
|
mixer.getBlockPos().getZ() + 0.5);
|
||||||
|
InkMixerMenu menu = new InkMixerMenu(1, player.getInventory(), mixer);
|
||||||
|
menu.clicked(InkMixerMenu.RESULT, 0, ClickType.PICKUP, player);
|
||||||
|
helper.assertTrue(menu.getCarried().is(ModItems.PAGE.get()), "Taking output must yield one panel");
|
||||||
|
for (int index = 0; index < 3; index++)
|
||||||
|
helper.assertValueEqual(mixer.modifierChancePermille(index), 0,
|
||||||
|
"Every modifier chance must reset when output is taken");
|
||||||
|
helper.assertValueEqual(mixer.getItem(InkMixerBlockEntity.PAPER).getCount(), 1,
|
||||||
|
"Taking output must consume one paper");
|
||||||
|
helper.succeed();
|
||||||
|
}
|
||||||
|
|
||||||
public static void linkPanelRequiresTakingOutputAndPersistsInk(GameTestHelper helper) {
|
public static void linkPanelRequiresTakingOutputAndPersistsInk(GameTestHelper helper) {
|
||||||
InkMixerBlockEntity mixer = place(helper);
|
InkMixerBlockEntity mixer = place(helper);
|
||||||
mixer.setItem(InkMixerBlockEntity.PAPER, new ItemStack(Items.PAPER, 2));
|
mixer.setItem(InkMixerBlockEntity.PAPER, new ItemStack(Items.PAPER, 2));
|
||||||
@@ -48,8 +110,9 @@ public final class InkMixerGameTests {
|
|||||||
helper.assertTrue(menu.getCarried().is(ModItems.PAGE.get()), "Taking result must give a Link Panel");
|
helper.assertTrue(menu.getCarried().is(ModItems.PAGE.get()), "Taking result must give a Link Panel");
|
||||||
helper.assertValueEqual(mixer.getItem(InkMixerBlockEntity.PAPER).getCount(), 1,
|
helper.assertValueEqual(mixer.getItem(InkMixerBlockEntity.PAPER).getCount(), 1,
|
||||||
"Taking result must use exactly one paper");
|
"Taking result must use exactly one paper");
|
||||||
helper.assertValueEqual(mixer.inkRemaining(), 16 - WritingInkService.linkPanelCost(),
|
helper.assertValueEqual(mixer.inkRemaining(), 0,
|
||||||
"Taking result must spend the configured ink cost");
|
"Taking one panel must spend the entire Ink Vial");
|
||||||
|
helper.assertFalse(mixer.canCreateLinkPanel(), "A second panel needs another Ink Vial");
|
||||||
var saved = mixer.saveWithoutMetadata(helper.getLevel().registryAccess());
|
var saved = mixer.saveWithoutMetadata(helper.getLevel().registryAccess());
|
||||||
var restored = new InkMixerBlockEntity(mixer.getBlockPos(), ModBlocks.INK_MIXER.get().defaultBlockState());
|
var restored = new InkMixerBlockEntity(mixer.getBlockPos(), ModBlocks.INK_MIXER.get().defaultBlockState());
|
||||||
restored.loadWithComponents(saved, helper.getLevel().registryAccess());
|
restored.loadWithComponents(saved, helper.getLevel().registryAccess());
|
||||||
@@ -59,6 +122,24 @@ public final class InkMixerGameTests {
|
|||||||
helper.succeed();
|
helper.succeed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GameTest(template = "empty")
|
||||||
|
public static void eachLinkPanelConsumesOneInkVial(GameTestHelper helper) {
|
||||||
|
InkMixerBlockEntity mixer = place(helper);
|
||||||
|
mixer.setItem(InkMixerBlockEntity.PAPER, new ItemStack(Items.PAPER, 3));
|
||||||
|
mixer.setItem(InkMixerBlockEntity.INK, new ItemStack(ModItems.INK_VIAL.get(), 2));
|
||||||
|
helper.assertTrue(mixer.canCreateLinkPanel(), "First vial must enable the first panel");
|
||||||
|
helper.assertTrue(mixer.consumeLinkPanelMaterials(), "First panel must be produced");
|
||||||
|
helper.assertValueEqual(mixer.inkRemaining(), 16, "Second vial must refill after first panel");
|
||||||
|
helper.assertValueEqual(mixer.getItem(InkMixerBlockEntity.BOTTLES).getCount(), 2,
|
||||||
|
"Both spent vials must return bottles");
|
||||||
|
helper.assertTrue(mixer.consumeLinkPanelMaterials(), "Second panel must be produced");
|
||||||
|
helper.assertValueEqual(mixer.inkRemaining(), 0, "Second panel must use the whole second vial");
|
||||||
|
helper.assertFalse(mixer.canCreateLinkPanel(), "Two vials must not make a third panel");
|
||||||
|
helper.assertValueEqual(mixer.getItem(InkMixerBlockEntity.PAPER).getCount(), 1,
|
||||||
|
"Each panel must also use one paper");
|
||||||
|
helper.succeed();
|
||||||
|
}
|
||||||
|
|
||||||
@GameTest(template = "empty")
|
@GameTest(template = "empty")
|
||||||
public static void bottleCapacityBlocksAndThenPermitsRefill(GameTestHelper helper) {
|
public static void bottleCapacityBlocksAndThenPermitsRefill(GameTestHelper helper) {
|
||||||
InkMixerBlockEntity mixer = place(helper);
|
InkMixerBlockEntity mixer = place(helper);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package net.dnorberg.rivencraft.gametest;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import net.dnorberg.rivencraft.Rivencraft;
|
import net.dnorberg.rivencraft.Rivencraft;
|
||||||
|
import net.dnorberg.rivencraft.book.LinkProperties;
|
||||||
import net.dnorberg.rivencraft.item.PageItem;
|
import net.dnorberg.rivencraft.item.PageItem;
|
||||||
import net.dnorberg.rivencraft.registry.ModDataComponents;
|
import net.dnorberg.rivencraft.registry.ModDataComponents;
|
||||||
import net.dnorberg.rivencraft.registry.ModItems;
|
import net.dnorberg.rivencraft.registry.ModItems;
|
||||||
@@ -48,6 +49,8 @@ public final class LinkingBookRecipeGameTests {
|
|||||||
public static void outputIsUnwrittenAndRegisteredRecipeLoads(GameTestHelper helper) {
|
public static void outputIsUnwrittenAndRegisteredRecipeLoads(GameTestHelper helper) {
|
||||||
ItemStack panel = PageItem.createLinkPanelPage();
|
ItemStack panel = PageItem.createLinkPanelPage();
|
||||||
panel.set(DataComponents.CUSTOM_NAME, Component.literal("Home Panel"));
|
panel.set(DataComponents.CUSTOM_NAME, Component.literal("Home Panel"));
|
||||||
|
panel.set(ModDataComponents.LINK_PROPERTIES.get(),
|
||||||
|
new LinkProperties(LinkProperties.INTRA_LINKING | LinkProperties.MAINTAIN_MOMENTUM));
|
||||||
CraftingInput input = CraftingInput.of(2, 1, List.of(panel, new ItemStack(Items.LEATHER)));
|
CraftingInput input = CraftingInput.of(2, 1, List.of(panel, new ItemStack(Items.LEATHER)));
|
||||||
var holder = helper.getLevel().getRecipeManager()
|
var holder = helper.getLevel().getRecipeManager()
|
||||||
.getRecipeFor(RecipeType.CRAFTING, input, helper.getLevel()).orElseThrow();
|
.getRecipeFor(RecipeType.CRAFTING, input, helper.getLevel()).orElseThrow();
|
||||||
@@ -60,6 +63,14 @@ public final class LinkingBookRecipeGameTests {
|
|||||||
helper.assertFalse(result.has(ModDataComponents.PAGE_CONTENT.get()), "Page identity must not leak onto the book");
|
helper.assertFalse(result.has(ModDataComponents.PAGE_CONTENT.get()), "Page identity must not leak onto the book");
|
||||||
helper.assertValueEqual(result.get(DataComponents.CUSTOM_NAME), Component.literal("Home Panel"),
|
helper.assertValueEqual(result.get(DataComponents.CUSTOM_NAME), Component.literal("Home Panel"),
|
||||||
"The panel's custom name must survive crafting");
|
"The panel's custom name must survive crafting");
|
||||||
|
helper.assertValueEqual(result.get(ModDataComponents.LINK_PROPERTIES.get()),
|
||||||
|
panel.get(ModDataComponents.LINK_PROPERTIES.get()),
|
||||||
|
"The panel's link properties must survive crafting");
|
||||||
|
ItemStack restored = ItemStack.parseOptional(helper.getLevel().registryAccess(),
|
||||||
|
(net.minecraft.nbt.CompoundTag) result.saveOptional(helper.getLevel().registryAccess()));
|
||||||
|
helper.assertValueEqual(restored.get(ModDataComponents.LINK_PROPERTIES.get()),
|
||||||
|
panel.get(ModDataComponents.LINK_PROPERTIES.get()),
|
||||||
|
"The crafted book's link properties must persist through save/load");
|
||||||
helper.succeed();
|
helper.succeed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,6 +11,7 @@ import net.dnorberg.rivencraft.book.AgeRegistrySavedData;
|
|||||||
import net.dnorberg.rivencraft.book.AgeRuntimeProfile;
|
import net.dnorberg.rivencraft.book.AgeRuntimeProfile;
|
||||||
import net.dnorberg.rivencraft.book.AgeRuntimeProfiles;
|
import net.dnorberg.rivencraft.book.AgeRuntimeProfiles;
|
||||||
import net.dnorberg.rivencraft.book.LinkTarget;
|
import net.dnorberg.rivencraft.book.LinkTarget;
|
||||||
|
import net.dnorberg.rivencraft.book.LinkProperties;
|
||||||
import net.dnorberg.rivencraft.book.LinkingService;
|
import net.dnorberg.rivencraft.book.LinkingService;
|
||||||
import net.dnorberg.rivencraft.book.AgeVisitSavedData;
|
import net.dnorberg.rivencraft.book.AgeVisitSavedData;
|
||||||
import net.dnorberg.rivencraft.book.AgeTraits;
|
import net.dnorberg.rivencraft.book.AgeTraits;
|
||||||
@@ -578,7 +579,8 @@ public final class LinkingGameTests {
|
|||||||
ServerPlayer player = helper.makeMockServerPlayerInLevel();
|
ServerPlayer player = helper.makeMockServerPlayerInLevel();
|
||||||
LinkTarget target = new LinkTarget(GlobalPos.of(helper.getLevel().dimension(), destination), 90.0F, 15.0F);
|
LinkTarget target = new LinkTarget(GlobalPos.of(helper.getLevel().dimension(), destination), 90.0F, 15.0F);
|
||||||
|
|
||||||
LinkingService.LinkResult result = LinkingService.travel(player, target);
|
LinkingService.LinkResult result = LinkingService.travel(player, target,
|
||||||
|
new LinkProperties(LinkProperties.INTRA_LINKING));
|
||||||
|
|
||||||
helper.assertValueEqual(result, LinkingService.LinkResult.SUCCESS,
|
helper.assertValueEqual(result, LinkingService.LinkResult.SUCCESS,
|
||||||
"A Linking Book must accept leaf blocks even without a floor");
|
"A Linking Book must accept leaf blocks even without a floor");
|
||||||
@@ -603,7 +605,8 @@ public final class LinkingGameTests {
|
|||||||
ServerPlayer player = helper.makeMockServerPlayerInLevel();
|
ServerPlayer player = helper.makeMockServerPlayerInLevel();
|
||||||
LinkTarget target = new LinkTarget(GlobalPos.of(helper.getLevel().dimension(), absoluteOrigin), 0.0F, 0.0F);
|
LinkTarget target = new LinkTarget(GlobalPos.of(helper.getLevel().dimension(), absoluteOrigin), 0.0F, 0.0F);
|
||||||
|
|
||||||
helper.assertValueEqual(LinkingService.travelWithFooting(player, target), LinkingService.LinkResult.SUCCESS,
|
helper.assertValueEqual(LinkingService.travelWithFooting(player, target,
|
||||||
|
new LinkProperties(LinkProperties.INTRA_LINKING)), LinkingService.LinkResult.SUCCESS,
|
||||||
"Descriptive Book travel must find an alternate grounded arrival");
|
"Descriptive Book travel must find an alternate grounded arrival");
|
||||||
BlockPos landing = player.blockPosition();
|
BlockPos landing = player.blockPosition();
|
||||||
helper.assertTrue(helper.getLevel().getBlockState(landing.below()).isFaceSturdy(
|
helper.assertTrue(helper.getLevel().getBlockState(landing.below()).isFaceSturdy(
|
||||||
@@ -624,8 +627,10 @@ public final class LinkingGameTests {
|
|||||||
ServerPlayer player = helper.makeMockServerPlayerInLevel();
|
ServerPlayer player = helper.makeMockServerPlayerInLevel();
|
||||||
LinkTarget target = new LinkTarget(GlobalPos.of(helper.getLevel().dimension(), absoluteOrigin), 0.0F, 0.0F);
|
LinkTarget target = new LinkTarget(GlobalPos.of(helper.getLevel().dimension(), absoluteOrigin), 0.0F, 0.0F);
|
||||||
|
|
||||||
helper.assertValueEqual(LinkingService.travel(player, target), LinkingService.LinkResult.NO_SAFE_DESTINATION,
|
helper.assertValueEqual(LinkingService.travel(player, target,
|
||||||
|
new LinkProperties(LinkProperties.INTRA_LINKING)), LinkingService.LinkResult.NO_SAFE_DESTINATION,
|
||||||
"Linking must fail rather than placing a player inside a blocked destination");
|
"Linking must fail rather than placing a player inside a blocked destination");
|
||||||
helper.succeed();
|
helper.succeed();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -287,6 +287,8 @@ public final class WritingDataGameTests {
|
|||||||
|
|
||||||
helper.assertFalse(menu.getSlot(0).mayPlace(new ItemStack(Items.DIRT)),
|
helper.assertFalse(menu.getSlot(0).mayPlace(new ItemStack(Items.DIRT)),
|
||||||
"Notebook slots must reject non-Page items");
|
"Notebook slots must reject non-Page items");
|
||||||
|
helper.assertFalse(menu.getSlot(0).mayPlace(PageItem.createLinkPanelPage()),
|
||||||
|
"Notebook slots must reject Link Panels");
|
||||||
menu.getSlot(0).set(first);
|
menu.getSlot(0).set(first);
|
||||||
menu.getSlot(1).set(second);
|
menu.getSlot(1).set(second);
|
||||||
helper.assertTrue(menu.clickMenuButton(player, NotebookMenu.MOVE_NEXT_BASE),
|
helper.assertTrue(menu.clickMenuButton(player, NotebookMenu.MOVE_NEXT_BASE),
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ public final class WritingDeskGameTests {
|
|||||||
BlockPos pos = helper.absolutePos(new BlockPos(1, 1, 1));
|
BlockPos pos = helper.absolutePos(new BlockPos(1, 1, 1));
|
||||||
helper.getLevel().setBlock(pos, ModBlocks.WRITING_DESK.get().defaultBlockState(), 3);
|
helper.getLevel().setBlock(pos, ModBlocks.WRITING_DESK.get().defaultBlockState(), 3);
|
||||||
WritingDeskBlockEntity desk = (WritingDeskBlockEntity) helper.getLevel().getBlockEntity(pos);
|
WritingDeskBlockEntity desk = (WritingDeskBlockEntity) helper.getLevel().getBlockEntity(pos);
|
||||||
ItemStack source = PageItem.createLinkPanelPage();
|
ItemStack source = terrainPage();
|
||||||
desk.setItem(0, source.copy());
|
desk.setItem(0, source.copy());
|
||||||
desk.setItem(WritingDeskBlockEntity.PAPER, new ItemStack(Items.PAPER, 2));
|
desk.setItem(WritingDeskBlockEntity.PAPER, new ItemStack(Items.PAPER, 2));
|
||||||
desk.setItem(WritingDeskBlockEntity.INK, new ItemStack(ModItems.INK_VIAL.get()));
|
desk.setItem(WritingDeskBlockEntity.INK, new ItemStack(ModItems.INK_VIAL.get()));
|
||||||
@@ -180,7 +180,7 @@ public final class WritingDeskGameTests {
|
|||||||
BlockPos pos = helper.absolutePos(new BlockPos(1, 1, 1));
|
BlockPos pos = helper.absolutePos(new BlockPos(1, 1, 1));
|
||||||
helper.getLevel().setBlock(pos, ModBlocks.WRITING_DESK.get().defaultBlockState(), 3);
|
helper.getLevel().setBlock(pos, ModBlocks.WRITING_DESK.get().defaultBlockState(), 3);
|
||||||
WritingDeskBlockEntity desk = (WritingDeskBlockEntity) helper.getLevel().getBlockEntity(pos);
|
WritingDeskBlockEntity desk = (WritingDeskBlockEntity) helper.getLevel().getBlockEntity(pos);
|
||||||
desk.setItem(0, PageItem.createLinkPanelPage());
|
desk.setItem(0, terrainPage());
|
||||||
desk.setItem(WritingDeskBlockEntity.PAPER, new ItemStack(Items.PAPER, 2));
|
desk.setItem(WritingDeskBlockEntity.PAPER, new ItemStack(Items.PAPER, 2));
|
||||||
desk.setItem(WritingDeskBlockEntity.RETURN, new ItemStack(Items.GLASS_BOTTLE, 64));
|
desk.setItem(WritingDeskBlockEntity.RETURN, new ItemStack(Items.GLASS_BOTTLE, 64));
|
||||||
desk.setItem(WritingDeskBlockEntity.INK, new ItemStack(ModItems.INK_VIAL.get()));
|
desk.setItem(WritingDeskBlockEntity.INK, new ItemStack(ModItems.INK_VIAL.get()));
|
||||||
@@ -210,7 +210,7 @@ public final class WritingDeskGameTests {
|
|||||||
WritingDeskBlockEntity desk = (WritingDeskBlockEntity) helper.getLevel().getBlockEntity(pos);
|
WritingDeskBlockEntity desk = (WritingDeskBlockEntity) helper.getLevel().getBlockEntity(pos);
|
||||||
ItemStack notebook = new ItemStack(ModItems.NOTEBOOK.get());
|
ItemStack notebook = new ItemStack(ModItems.NOTEBOOK.get());
|
||||||
notebook.set(ModDataComponents.NOTEBOOK_CONTENTS.get(),
|
notebook.set(ModDataComponents.NOTEBOOK_CONTENTS.get(),
|
||||||
new NotebookContents(List.of(ItemStack.EMPTY, PageItem.createLinkPanelPage())));
|
new NotebookContents(List.of(ItemStack.EMPTY, terrainPage())));
|
||||||
desk.setItem(0, notebook);
|
desk.setItem(0, notebook);
|
||||||
desk.setItem(WritingDeskBlockEntity.PAPER, new ItemStack(Items.PAPER));
|
desk.setItem(WritingDeskBlockEntity.PAPER, new ItemStack(Items.PAPER));
|
||||||
desk.setItem(WritingDeskBlockEntity.INK, new ItemStack(ModItems.INK_VIAL.get()));
|
desk.setItem(WritingDeskBlockEntity.INK, new ItemStack(ModItems.INK_VIAL.get()));
|
||||||
@@ -232,7 +232,7 @@ public final class WritingDeskGameTests {
|
|||||||
BlockPos pos = helper.absolutePos(new BlockPos(1, 1, 1));
|
BlockPos pos = helper.absolutePos(new BlockPos(1, 1, 1));
|
||||||
helper.getLevel().setBlock(pos, ModBlocks.WRITING_DESK.get().defaultBlockState(), 3);
|
helper.getLevel().setBlock(pos, ModBlocks.WRITING_DESK.get().defaultBlockState(), 3);
|
||||||
WritingDeskBlockEntity desk = (WritingDeskBlockEntity) helper.getLevel().getBlockEntity(pos);
|
WritingDeskBlockEntity desk = (WritingDeskBlockEntity) helper.getLevel().getBlockEntity(pos);
|
||||||
desk.setItem(0, PageItem.createLinkPanelPage());
|
desk.setItem(0, terrainPage());
|
||||||
desk.setItem(WritingDeskBlockEntity.PAPER, new ItemStack(Items.PAPER));
|
desk.setItem(WritingDeskBlockEntity.PAPER, new ItemStack(Items.PAPER));
|
||||||
desk.setItem(WritingDeskBlockEntity.INK, new ItemStack(ModItems.INK_VIAL.get()));
|
desk.setItem(WritingDeskBlockEntity.INK, new ItemStack(ModItems.INK_VIAL.get()));
|
||||||
var first = helper.makeMockServerPlayerInLevel();
|
var first = helper.makeMockServerPlayerInLevel();
|
||||||
@@ -258,7 +258,7 @@ public final class WritingDeskGameTests {
|
|||||||
BlockPos pos = helper.absolutePos(new BlockPos(1, 1, 1));
|
BlockPos pos = helper.absolutePos(new BlockPos(1, 1, 1));
|
||||||
helper.getLevel().setBlock(pos, ModBlocks.WRITING_DESK.get().defaultBlockState(), 3);
|
helper.getLevel().setBlock(pos, ModBlocks.WRITING_DESK.get().defaultBlockState(), 3);
|
||||||
WritingDeskBlockEntity desk = (WritingDeskBlockEntity) helper.getLevel().getBlockEntity(pos);
|
WritingDeskBlockEntity desk = (WritingDeskBlockEntity) helper.getLevel().getBlockEntity(pos);
|
||||||
desk.setItem(0, PageItem.createLinkPanelPage());
|
desk.setItem(0, terrainPage());
|
||||||
desk.setItem(WritingDeskBlockEntity.PAPER, new ItemStack(Items.PAPER));
|
desk.setItem(WritingDeskBlockEntity.PAPER, new ItemStack(Items.PAPER));
|
||||||
desk.setItem(WritingDeskBlockEntity.INK, new ItemStack(ModItems.INK_VIAL.get()));
|
desk.setItem(WritingDeskBlockEntity.INK, new ItemStack(ModItems.INK_VIAL.get()));
|
||||||
var player = helper.makeMockServerPlayerInLevel();
|
var player = helper.makeMockServerPlayerInLevel();
|
||||||
@@ -319,7 +319,7 @@ public final class WritingDeskGameTests {
|
|||||||
BlockPos pos = helper.absolutePos(new BlockPos(1, 1, 1));
|
BlockPos pos = helper.absolutePos(new BlockPos(1, 1, 1));
|
||||||
helper.getLevel().setBlock(pos, ModBlocks.WRITING_DESK.get().defaultBlockState(), 3);
|
helper.getLevel().setBlock(pos, ModBlocks.WRITING_DESK.get().defaultBlockState(), 3);
|
||||||
WritingDeskBlockEntity desk = (WritingDeskBlockEntity) helper.getLevel().getBlockEntity(pos);
|
WritingDeskBlockEntity desk = (WritingDeskBlockEntity) helper.getLevel().getBlockEntity(pos);
|
||||||
desk.setItem(0, PageItem.createLinkPanelPage());
|
desk.setItem(0, terrainPage());
|
||||||
desk.setItem(WritingDeskBlockEntity.PAPER, new ItemStack(Items.PAPER));
|
desk.setItem(WritingDeskBlockEntity.PAPER, new ItemStack(Items.PAPER));
|
||||||
desk.setItem(WritingDeskBlockEntity.INK, new ItemStack(ModItems.INK_VIAL.get()));
|
desk.setItem(WritingDeskBlockEntity.INK, new ItemStack(ModItems.INK_VIAL.get()));
|
||||||
var player = helper.makeMockServerPlayerInLevel();
|
var player = helper.makeMockServerPlayerInLevel();
|
||||||
@@ -446,7 +446,7 @@ public final class WritingDeskGameTests {
|
|||||||
helper.assertTrue(menu.clickMenuButton(player, 87), "Tab 88 must be selectable without page-ID collisions");
|
helper.assertTrue(menu.clickMenuButton(player, 87), "Tab 88 must be selectable without page-ID collisions");
|
||||||
helper.assertValueEqual(desk.activeCollection(), 87, "Tab 88 must become active");
|
helper.assertValueEqual(desk.activeCollection(), 87, "Tab 88 must become active");
|
||||||
helper.assertFalse(menu.clickMenuButton(player, 88), "Tab 89 must not exist");
|
helper.assertFalse(menu.clickMenuButton(player, 88), "Tab 89 must not exist");
|
||||||
desk.setItem(87, PageItem.createLinkPanelPage());
|
desk.setItem(87, terrainPage());
|
||||||
desk.setItem(WritingDeskBlockEntity.PAPER, new ItemStack(Items.PAPER));
|
desk.setItem(WritingDeskBlockEntity.PAPER, new ItemStack(Items.PAPER));
|
||||||
desk.setItem(WritingDeskBlockEntity.INK, new ItemStack(ModItems.INK_VIAL.get()));
|
desk.setItem(WritingDeskBlockEntity.INK, new ItemStack(ModItems.INK_VIAL.get()));
|
||||||
helper.assertTrue(menu.clickMenuButton(player, WritingDeskMenu.ALL_PAGE_BUTTON_BASE + 87 * NotebookContents.MAX_PAGES),
|
helper.assertTrue(menu.clickMenuButton(player, WritingDeskMenu.ALL_PAGE_BUTTON_BASE + 87 * NotebookContents.MAX_PAGES),
|
||||||
@@ -502,7 +502,7 @@ public final class WritingDeskGameTests {
|
|||||||
var player = helper.makeMockServerPlayerInLevel();
|
var player = helper.makeMockServerPlayerInLevel();
|
||||||
player.moveTo(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
|
player.moveTo(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
|
||||||
var menu = new WritingDeskMenu(1, player.getInventory(), desk);
|
var menu = new WritingDeskMenu(1, player.getInventory(), desk);
|
||||||
ItemStack held = PageItem.createLinkPanelPage().copyWithCount(3);
|
ItemStack held = terrainPage().copyWithCount(3);
|
||||||
ItemStack expectedPage = held.copyWithCount(1);
|
ItemStack expectedPage = held.copyWithCount(1);
|
||||||
player.getInventory().setItem(9, held);
|
player.getInventory().setItem(9, held);
|
||||||
menu.clicked(WritingDeskMenu.COPY_RESULT + 1, 0, ClickType.PICKUP, player);
|
menu.clicked(WritingDeskMenu.COPY_RESULT + 1, 0, ClickType.PICKUP, player);
|
||||||
@@ -520,7 +520,7 @@ public final class WritingDeskGameTests {
|
|||||||
helper.assertValueEqual(menu.pageCapacity(87), NotebookContents.MAX_PAGES, "Notebook tab must expose normal notebook capacity");
|
helper.assertValueEqual(menu.pageCapacity(87), NotebookContents.MAX_PAGES, "Notebook tab must expose normal notebook capacity");
|
||||||
helper.assertValueEqual(menu.pageCapacity(0), 0, "Empty tab has no page storage");
|
helper.assertValueEqual(menu.pageCapacity(0), 0, "Empty tab has no page storage");
|
||||||
helper.assertFalse(menu.clickMenuButton(player, WritingDeskMenu.PLACE_PAGE_BUTTON_BASE), "Empty tab must require a collection first");
|
helper.assertFalse(menu.clickMenuButton(player, WritingDeskMenu.PLACE_PAGE_BUTTON_BASE), "Empty tab must require a collection first");
|
||||||
desk.setItem(0, PageItem.createLinkPanelPage());
|
desk.setItem(0, terrainPage());
|
||||||
helper.assertValueEqual(menu.pageCapacity(0), 1, "Loose page tab must expose exactly one position");
|
helper.assertValueEqual(menu.pageCapacity(0), 1, "Loose page tab must expose exactly one position");
|
||||||
helper.assertFalse(menu.clickMenuButton(player, WritingDeskMenu.PLACE_PAGE_BUTTON_BASE), "Loose page must not be replaced");
|
helper.assertFalse(menu.clickMenuButton(player, WritingDeskMenu.PLACE_PAGE_BUTTON_BASE), "Loose page must not be replaced");
|
||||||
helper.assertFalse(menu.clickMenuButton(player, WritingDeskMenu.PLACE_PAGE_BUTTON_BASE + 1), "Loose page tab must not grow extra positions");
|
helper.assertFalse(menu.clickMenuButton(player, WritingDeskMenu.PLACE_PAGE_BUTTON_BASE + 1), "Loose page tab must not grow extra positions");
|
||||||
@@ -543,14 +543,13 @@ public final class WritingDeskGameTests {
|
|||||||
BlockPos pos = helper.absolutePos(new BlockPos(1, 1, 1));
|
BlockPos pos = helper.absolutePos(new BlockPos(1, 1, 1));
|
||||||
helper.getLevel().setBlock(pos, ModBlocks.WRITING_DESK.get().defaultBlockState(), 3);
|
helper.getLevel().setBlock(pos, ModBlocks.WRITING_DESK.get().defaultBlockState(), 3);
|
||||||
var desk = (WritingDeskBlockEntity) helper.getLevel().getBlockEntity(pos);
|
var desk = (WritingDeskBlockEntity) helper.getLevel().getBlockEntity(pos);
|
||||||
ItemStack linkPanel = PageItem.createLinkPanelPage();
|
ItemStack movingPage = terrainPage();
|
||||||
ItemStack terrain = PageItem.createSymbolPage(new SymbolReference(
|
ItemStack terrain = terrainPage();
|
||||||
ResourceLocation.parse("rivencraft:terrain/standard")));
|
|
||||||
ItemStack firstBook = new ItemStack(ModItems.NOTEBOOK.get());
|
ItemStack firstBook = new ItemStack(ModItems.NOTEBOOK.get());
|
||||||
firstBook.set(ModDataComponents.NOTEBOOK_CONTENTS.get(), new NotebookContents(List.of(linkPanel, terrain)));
|
firstBook.set(ModDataComponents.NOTEBOOK_CONTENTS.get(), new NotebookContents(List.of(movingPage, terrain)));
|
||||||
desk.setItem(0, firstBook);
|
desk.setItem(0, firstBook);
|
||||||
desk.setItem(1, new ItemStack(ModItems.NOTEBOOK.get()));
|
desk.setItem(1, new ItemStack(ModItems.NOTEBOOK.get()));
|
||||||
desk.setItem(2, PageItem.createLinkPanelPage());
|
desk.setItem(2, terrainPage());
|
||||||
var player = helper.makeMockServerPlayerInLevel();
|
var player = helper.makeMockServerPlayerInLevel();
|
||||||
player.moveTo(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
|
player.moveTo(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
|
||||||
var menu = new WritingDeskMenu(1, player.getInventory(), desk);
|
var menu = new WritingDeskMenu(1, player.getInventory(), desk);
|
||||||
@@ -558,18 +557,18 @@ public final class WritingDeskGameTests {
|
|||||||
helper.assertTrue(menu.clickMenuButton(player, moveToEmpty), "Drag must move to a distant empty notebook position");
|
helper.assertTrue(menu.clickMenuButton(player, moveToEmpty), "Drag must move to a distant empty notebook position");
|
||||||
var pages = desk.getItem(0).get(ModDataComponents.NOTEBOOK_CONTENTS.get()).pages();
|
var pages = desk.getItem(0).get(ModDataComponents.NOTEBOOK_CONTENTS.get()).pages();
|
||||||
helper.assertTrue(pages.get(0).isEmpty(), "Moving must clear the source position");
|
helper.assertTrue(pages.get(0).isEmpty(), "Moving must clear the source position");
|
||||||
helper.assertTrue(ItemStack.matches(pages.get(26), linkPanel), "Moving must preserve page components");
|
helper.assertTrue(ItemStack.matches(pages.get(26), movingPage), "Moving must preserve page components");
|
||||||
helper.assertValueEqual(desk.getItem(0).get(ModDataComponents.NOTEBOOK_CONTENTS.get()).pageCount(), 2,
|
helper.assertValueEqual(desk.getItem(0).get(ModDataComponents.NOTEBOOK_CONTENTS.get()).pageCount(), 2,
|
||||||
"Moving must preserve total page count");
|
"Moving must preserve total page count");
|
||||||
helper.assertTrue(menu.clickMenuButton(player, WritingDeskMenu.movePageButtonId(0, 26, 0, 1)),
|
helper.assertTrue(menu.clickMenuButton(player, WritingDeskMenu.movePageButtonId(0, 26, 0, 1)),
|
||||||
"Drag onto an occupied position must swap pages");
|
"Drag onto an occupied position must swap pages");
|
||||||
pages = desk.getItem(0).get(ModDataComponents.NOTEBOOK_CONTENTS.get()).pages();
|
pages = desk.getItem(0).get(ModDataComponents.NOTEBOOK_CONTENTS.get()).pages();
|
||||||
helper.assertTrue(ItemStack.matches(pages.get(1), linkPanel) && ItemStack.matches(pages.get(26), terrain),
|
helper.assertTrue(ItemStack.matches(pages.get(1), movingPage) && ItemStack.matches(pages.get(26), terrain),
|
||||||
"Swap must preserve both pages");
|
"Swap must preserve both pages");
|
||||||
helper.assertTrue(menu.clickMenuButton(player, WritingDeskMenu.movePageButtonId(0, 1, 1, 5)),
|
helper.assertTrue(menu.clickMenuButton(player, WritingDeskMenu.movePageButtonId(0, 1, 1, 5)),
|
||||||
"Drag into another notebook must work");
|
"Drag into another notebook must work");
|
||||||
var otherPages = desk.getItem(1).get(ModDataComponents.NOTEBOOK_CONTENTS.get()).pages();
|
var otherPages = desk.getItem(1).get(ModDataComponents.NOTEBOOK_CONTENTS.get()).pages();
|
||||||
helper.assertTrue(ItemStack.matches(otherPages.get(5), linkPanel)
|
helper.assertTrue(ItemStack.matches(otherPages.get(5), movingPage)
|
||||||
&& desk.getItem(0).get(ModDataComponents.NOTEBOOK_CONTENTS.get()).pages().get(1).isEmpty(),
|
&& desk.getItem(0).get(ModDataComponents.NOTEBOOK_CONTENTS.get()).pages().get(1).isEmpty(),
|
||||||
"Cross notebook move must have one destination and no old source");
|
"Cross notebook move must have one destination and no old source");
|
||||||
helper.assertFalse(menu.clickMenuButton(player, WritingDeskMenu.movePageButtonId(0, 1, 1, 6)),
|
helper.assertFalse(menu.clickMenuButton(player, WritingDeskMenu.movePageButtonId(0, 1, 1, 6)),
|
||||||
@@ -584,7 +583,7 @@ public final class WritingDeskGameTests {
|
|||||||
menu.setCarried(new ItemStack(Items.DIAMOND));
|
menu.setCarried(new ItemStack(Items.DIAMOND));
|
||||||
helper.assertFalse(menu.clickMenuButton(player, WritingDeskMenu.movePageButtonId(1, 5, 1, 6)),
|
helper.assertFalse(menu.clickMenuButton(player, WritingDeskMenu.movePageButtonId(1, 5, 1, 6)),
|
||||||
"Held inventory items must not be moved by a panel drag");
|
"Held inventory items must not be moved by a panel drag");
|
||||||
helper.assertTrue(ItemStack.matches(desk.getItem(1).get(ModDataComponents.NOTEBOOK_CONTENTS.get()).pages().get(5), linkPanel),
|
helper.assertTrue(ItemStack.matches(desk.getItem(1).get(ModDataComponents.NOTEBOOK_CONTENTS.get()).pages().get(5), movingPage),
|
||||||
"Rejected drags must leave notebook data intact");
|
"Rejected drags must leave notebook data intact");
|
||||||
helper.succeed();
|
helper.succeed();
|
||||||
}
|
}
|
||||||
@@ -594,7 +593,7 @@ public final class WritingDeskGameTests {
|
|||||||
BlockPos pos = helper.absolutePos(new BlockPos(1, 1, 1));
|
BlockPos pos = helper.absolutePos(new BlockPos(1, 1, 1));
|
||||||
helper.getLevel().setBlock(pos, ModBlocks.WRITING_DESK.get().defaultBlockState(), 3);
|
helper.getLevel().setBlock(pos, ModBlocks.WRITING_DESK.get().defaultBlockState(), 3);
|
||||||
var desk = (WritingDeskBlockEntity) helper.getLevel().getBlockEntity(pos);
|
var desk = (WritingDeskBlockEntity) helper.getLevel().getBlockEntity(pos);
|
||||||
ItemStack page = PageItem.createLinkPanelPage();
|
ItemStack page = terrainPage();
|
||||||
ItemStack source = new ItemStack(ModItems.NOTEBOOK.get());
|
ItemStack source = new ItemStack(ModItems.NOTEBOOK.get());
|
||||||
source.set(ModDataComponents.NOTEBOOK_CONTENTS.get(),
|
source.set(ModDataComponents.NOTEBOOK_CONTENTS.get(),
|
||||||
new NotebookContents(List.of(page, page, page, page, page, page)));
|
new NotebookContents(List.of(page, page, page, page, page, page)));
|
||||||
@@ -643,4 +642,47 @@ public final class WritingDeskGameTests {
|
|||||||
"Extracting a loose page must empty its tab and return the same item");
|
"Extracting a loose page must empty its tab and return the same item");
|
||||||
helper.succeed();
|
helper.succeed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GameTest(template = "empty")
|
||||||
|
public static void linkPanelsCannotBeStoredOrCopiedButOldPanelsCanBeRecovered(GameTestHelper helper) {
|
||||||
|
BlockPos pos = helper.absolutePos(new BlockPos(1, 1, 1));
|
||||||
|
helper.getLevel().setBlock(pos, ModBlocks.WRITING_DESK.get().defaultBlockState(), 3);
|
||||||
|
var desk = (WritingDeskBlockEntity) helper.getLevel().getBlockEntity(pos);
|
||||||
|
ItemStack panel = PageItem.createLinkPanelPage();
|
||||||
|
ItemStack oldNotebook = new ItemStack(ModItems.NOTEBOOK.get());
|
||||||
|
oldNotebook.set(ModDataComponents.NOTEBOOK_CONTENTS.get(), new NotebookContents(List.of(panel)));
|
||||||
|
helper.assertFalse(desk.canPlaceItem(0, panel), "Desk tab must reject a Link Panel");
|
||||||
|
helper.assertFalse(desk.canPlaceItem(0, oldNotebook),
|
||||||
|
"Desk tab must reject a Notebook containing an old Link Panel");
|
||||||
|
|
||||||
|
// A preexisting desk is loaded without discarding its contents.
|
||||||
|
desk.setItem(0, panel.copy());
|
||||||
|
desk.setItem(1, new ItemStack(ModItems.NOTEBOOK.get()));
|
||||||
|
desk.setItem(WritingDeskBlockEntity.PAPER, new ItemStack(Items.PAPER));
|
||||||
|
desk.setItem(WritingDeskBlockEntity.INK, new ItemStack(ModItems.INK_VIAL.get()));
|
||||||
|
var player = helper.makeMockServerPlayerInLevel();
|
||||||
|
player.moveTo(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
|
||||||
|
var menu = new WritingDeskMenu(1, player.getInventory(), desk);
|
||||||
|
menu.broadcastChanges();
|
||||||
|
helper.assertTrue(menu.getSlot(WritingDeskMenu.COPY_RESULT).getItem().isEmpty(),
|
||||||
|
"Existing Link Panels must not produce a Desk copy");
|
||||||
|
helper.assertTrue(menu.quickMoveStack(player, WritingDeskMenu.COPY_RESULT).isEmpty(),
|
||||||
|
"Shift-click must not bypass the Link Panel copy rule");
|
||||||
|
helper.assertFalse(menu.clickMenuButton(player, WritingDeskMenu.movePageButtonId(0, 0, 1, 0)),
|
||||||
|
"An old Link Panel must not move into a Notebook");
|
||||||
|
menu.setCarried(panel.copy());
|
||||||
|
helper.assertFalse(menu.clickMenuButton(player, WritingDeskMenu.PLACE_PAGE_BUTTON_BASE
|
||||||
|
+ NotebookContents.MAX_PAGES), "A carried Link Panel must not enter a Notebook");
|
||||||
|
menu.setCarried(ItemStack.EMPTY);
|
||||||
|
helper.assertTrue(menu.clickMenuButton(player, WritingDeskMenu.extractPageButtonId(0, 0, -1)),
|
||||||
|
"A stored legacy Link Panel must remain recoverable to the cursor");
|
||||||
|
helper.assertTrue(ItemStack.matches(menu.getCarried(), panel),
|
||||||
|
"Recovery must preserve the original Link Panel");
|
||||||
|
helper.succeed();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ItemStack terrainPage() {
|
||||||
|
return PageItem.createSymbolPage(new SymbolReference(
|
||||||
|
ResourceLocation.parse("rivencraft:terrain/standard")));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -4,6 +4,7 @@ import java.util.List;
|
|||||||
import net.dnorberg.rivencraft.book.AgeReference;
|
import net.dnorberg.rivencraft.book.AgeReference;
|
||||||
import net.dnorberg.rivencraft.book.AgeVisitSavedData;
|
import net.dnorberg.rivencraft.book.AgeVisitSavedData;
|
||||||
import net.dnorberg.rivencraft.book.LinkTarget;
|
import net.dnorberg.rivencraft.book.LinkTarget;
|
||||||
|
import net.dnorberg.rivencraft.book.LinkProperties;
|
||||||
import net.dnorberg.rivencraft.book.LinkingService;
|
import net.dnorberg.rivencraft.book.LinkingService;
|
||||||
import net.dnorberg.rivencraft.book.AgeDimensionService;
|
import net.dnorberg.rivencraft.book.AgeDimensionService;
|
||||||
import net.dnorberg.rivencraft.config.RivencraftConfig;
|
import net.dnorberg.rivencraft.config.RivencraftConfig;
|
||||||
@@ -54,7 +55,9 @@ public final class DescriptiveBookItem extends Item {
|
|||||||
|
|
||||||
ServerLevel sourceLevel = player.serverLevel();
|
ServerLevel sourceLevel = player.serverLevel();
|
||||||
var sourcePosition = player.blockPosition();
|
var sourcePosition = player.blockPosition();
|
||||||
LinkingService.LinkResult result = LinkingService.travelWithFooting(player, ageTarget);
|
LinkProperties properties = stack.getOrDefault(ModDataComponents.LINK_PROPERTIES.get(), LinkProperties.NONE)
|
||||||
|
.forDescriptiveBook();
|
||||||
|
LinkingService.LinkResult result = LinkingService.travelWithFooting(player, ageTarget, properties);
|
||||||
if (result != LinkingService.LinkResult.SUCCESS) {
|
if (result != LinkingService.LinkResult.SUCCESS) {
|
||||||
player.displayClientMessage(Component.translatable("message.rivencraft.descriptive_book.unsafe"), true);
|
player.displayClientMessage(Component.translatable("message.rivencraft.descriptive_book.unsafe"), true);
|
||||||
return false;
|
return false;
|
||||||
@@ -109,5 +112,7 @@ public final class DescriptiveBookItem extends Item {
|
|||||||
? Component.translatable("item.rivencraft.descriptive_book.unwritten")
|
? Component.translatable("item.rivencraft.descriptive_book.unwritten")
|
||||||
: Component.translatable("item.rivencraft.descriptive_book.age", age.name());
|
: Component.translatable("item.rivencraft.descriptive_book.age", age.name());
|
||||||
tooltipComponents.add(status.withStyle(ChatFormatting.GRAY));
|
tooltipComponents.add(status.withStyle(ChatFormatting.GRAY));
|
||||||
|
stack.getOrDefault(ModDataComponents.LINK_PROPERTIES.get(), LinkProperties.NONE)
|
||||||
|
.forDescriptiveBook().appendTooltip(tooltipComponents);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,6 +4,7 @@ import java.util.List;
|
|||||||
import net.dnorberg.rivencraft.book.LinkTarget;
|
import net.dnorberg.rivencraft.book.LinkTarget;
|
||||||
import net.dnorberg.rivencraft.book.AgeRegistrySavedData;
|
import net.dnorberg.rivencraft.book.AgeRegistrySavedData;
|
||||||
import net.dnorberg.rivencraft.book.LinkingService;
|
import net.dnorberg.rivencraft.book.LinkingService;
|
||||||
|
import net.dnorberg.rivencraft.book.LinkProperties;
|
||||||
import net.dnorberg.rivencraft.registry.ModDataComponents;
|
import net.dnorberg.rivencraft.registry.ModDataComponents;
|
||||||
import net.dnorberg.rivencraft.registry.ModSounds;
|
import net.dnorberg.rivencraft.registry.ModSounds;
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
@@ -49,7 +50,8 @@ public final class LinkingBookItem extends Item {
|
|||||||
|
|
||||||
Level sourceLevel = player.level();
|
Level sourceLevel = player.level();
|
||||||
BlockPos sourcePosition = player.blockPosition();
|
BlockPos sourcePosition = player.blockPosition();
|
||||||
LinkingService.LinkResult result = LinkingService.travel(player, target);
|
LinkProperties properties = stack.getOrDefault(ModDataComponents.LINK_PROPERTIES.get(), LinkProperties.NONE);
|
||||||
|
LinkingService.LinkResult result = LinkingService.travel(player, target, properties);
|
||||||
if (result == LinkingService.LinkResult.SUCCESS) {
|
if (result == LinkingService.LinkResult.SUCCESS) {
|
||||||
sourceLevel.playSound(null, sourcePosition, ModSounds.LINK.get(), SoundSource.PLAYERS,
|
sourceLevel.playSound(null, sourcePosition, ModSounds.LINK.get(), SoundSource.PLAYERS,
|
||||||
0.8F, sourceLevel.random.nextFloat() * 0.2F + 0.9F);
|
0.8F, sourceLevel.random.nextFloat() * 0.2F + 0.9F);
|
||||||
@@ -65,9 +67,11 @@ public final class LinkingBookItem extends Item {
|
|||||||
return InteractionResultHolder.success(stack);
|
return InteractionResultHolder.success(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
String errorKey = result == LinkingService.LinkResult.MISSING_DIMENSION
|
String errorKey = switch (result) {
|
||||||
? "message.rivencraft.linking_book.missing_dimension"
|
case MISSING_DIMENSION -> "message.rivencraft.linking_book.missing_dimension";
|
||||||
: "message.rivencraft.linking_book.unsafe";
|
case INTRA_LINKING_REQUIRED -> "message.rivencraft.linking_book.intra_required";
|
||||||
|
default -> "message.rivencraft.linking_book.unsafe";
|
||||||
|
};
|
||||||
player.displayClientMessage(Component.translatable(errorKey), true);
|
player.displayClientMessage(Component.translatable(errorKey), true);
|
||||||
return InteractionResultHolder.fail(stack);
|
return InteractionResultHolder.fail(stack);
|
||||||
}
|
}
|
||||||
@@ -85,9 +89,11 @@ public final class LinkingBookItem extends Item {
|
|||||||
TooltipFlag tooltipFlag
|
TooltipFlag tooltipFlag
|
||||||
) {
|
) {
|
||||||
LinkTarget target = stack.get(ModDataComponents.LINK_TARGET.get());
|
LinkTarget target = stack.get(ModDataComponents.LINK_TARGET.get());
|
||||||
|
LinkProperties properties = stack.getOrDefault(ModDataComponents.LINK_PROPERTIES.get(), LinkProperties.NONE);
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
tooltipComponents.add(Component.translatable("item.rivencraft.linking_book.unbound")
|
tooltipComponents.add(Component.translatable("item.rivencraft.linking_book.unbound")
|
||||||
.withStyle(ChatFormatting.GRAY));
|
.withStyle(ChatFormatting.GRAY));
|
||||||
|
properties.appendTooltip(tooltipComponents);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,6 +107,7 @@ public final class LinkingBookItem extends Item {
|
|||||||
position.getZ()
|
position.getZ()
|
||||||
)
|
)
|
||||||
.withStyle(ChatFormatting.GRAY));
|
.withStyle(ChatFormatting.GRAY));
|
||||||
|
properties.appendTooltip(tooltipComponents);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String destinationName(ServerLevel level) {
|
public static String destinationName(ServerLevel level) {
|
||||||
|
|||||||
@@ -11,6 +11,9 @@ import java.util.ArrayList;
|
|||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import net.dnorberg.rivencraft.Rivencraft;
|
import net.dnorberg.rivencraft.Rivencraft;
|
||||||
|
import net.dnorberg.rivencraft.book.AgeBiomeSelection;
|
||||||
|
import net.dnorberg.rivencraft.book.LinkProperties;
|
||||||
|
import net.dnorberg.rivencraft.compat.TerraBlenderBiomes;
|
||||||
import net.dnorberg.rivencraft.registry.ModDataComponents;
|
import net.dnorberg.rivencraft.registry.ModDataComponents;
|
||||||
import net.dnorberg.rivencraft.registry.ModItems;
|
import net.dnorberg.rivencraft.registry.ModItems;
|
||||||
import net.dnorberg.rivencraft.writing.PageContent;
|
import net.dnorberg.rivencraft.writing.PageContent;
|
||||||
@@ -24,9 +27,11 @@ import net.dnorberg.rivencraft.writing.SymbolSemantics;
|
|||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.core.component.DataComponents;
|
import net.minecraft.core.component.DataComponents;
|
||||||
import net.minecraft.core.HolderLookup;
|
import net.minecraft.core.HolderLookup;
|
||||||
|
import net.minecraft.core.RegistryAccess;
|
||||||
import net.minecraft.core.registries.Registries;
|
import net.minecraft.core.registries.Registries;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.tags.BiomeTags;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.TooltipFlag;
|
import net.minecraft.world.item.TooltipFlag;
|
||||||
@@ -35,6 +40,10 @@ import net.minecraft.world.item.TooltipFlag;
|
|||||||
public final class PageItem extends Item {
|
public final class PageItem extends Item {
|
||||||
private static final ResourceLocation BIOME_GENERATION_CATEGORY =
|
private static final ResourceLocation BIOME_GENERATION_CATEGORY =
|
||||||
ResourceLocation.fromNamespaceAndPath(Rivencraft.MOD_ID, "biome_generation");
|
ResourceLocation.fromNamespaceAndPath(Rivencraft.MOD_ID, "biome_generation");
|
||||||
|
private static final ResourceLocation CAVE_BIOME_CATEGORY =
|
||||||
|
ResourceLocation.fromNamespaceAndPath(Rivencraft.MOD_ID, "cave_biome");
|
||||||
|
private static final ResourceLocation BIOME_CATEGORY =
|
||||||
|
ResourceLocation.fromNamespaceAndPath(Rivencraft.MOD_ID, "biome");
|
||||||
private static final Map<String, CreativeSymbol> CREATIVE_SYMBOLS = loadCreativeSymbols();
|
private static final Map<String, CreativeSymbol> CREATIVE_SYMBOLS = loadCreativeSymbols();
|
||||||
|
|
||||||
private record CreativeSymbol(SymbolDisplayMetadata display, ResourceLocation creativeCategory) {}
|
private record CreativeSymbol(SymbolDisplayMetadata display, ResourceLocation creativeCategory) {}
|
||||||
@@ -61,10 +70,14 @@ public final class PageItem extends Item {
|
|||||||
.collect(java.util.stream.Collectors.toCollection(LinkedHashSet::new));
|
.collect(java.util.stream.Collectors.toCollection(LinkedHashSet::new));
|
||||||
categories.add(BlockSymbolPages.CATEGORY);
|
categories.add(BlockSymbolPages.CATEGORY);
|
||||||
categories.add(BlockSymbolPages.FLUID_CATEGORY);
|
categories.add(BlockSymbolPages.FLUID_CATEGORY);
|
||||||
|
categories.add(CAVE_BIOME_CATEGORY);
|
||||||
return List.copyOf(categories);
|
return List.copyOf(categories);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemStack bundledCreativeCategoryIcon(ResourceLocation category) {
|
public static ItemStack bundledCreativeCategoryIcon(ResourceLocation category) {
|
||||||
|
if (category.equals(CAVE_BIOME_CATEGORY)) {
|
||||||
|
return createCreativeBiomePage(ResourceLocation.withDefaultNamespace("lush_caves"));
|
||||||
|
}
|
||||||
if (category.equals(BlockSymbolPages.CATEGORY) || category.equals(BlockSymbolPages.FLUID_CATEGORY)) {
|
if (category.equals(BlockSymbolPages.CATEGORY) || category.equals(BlockSymbolPages.FLUID_CATEGORY)) {
|
||||||
return createCreativeBlockPage(ResourceLocation.withDefaultNamespace(
|
return createCreativeBlockPage(ResourceLocation.withDefaultNamespace(
|
||||||
category.equals(BlockSymbolPages.FLUID_CATEGORY) ? "water" : "stone"));
|
category.equals(BlockSymbolPages.FLUID_CATEGORY) ? "water" : "stone"));
|
||||||
@@ -89,8 +102,7 @@ public final class PageItem extends Item {
|
|||||||
Set<String> bundled = CREATIVE_SYMBOLS.keySet();
|
Set<String> bundled = CREATIVE_SYMBOLS.keySet();
|
||||||
registries.lookupOrThrow(Registries.BIOME).listElements()
|
registries.lookupOrThrow(Registries.BIOME).listElements()
|
||||||
.map(holder -> holder.key().location())
|
.map(holder -> holder.key().location())
|
||||||
.filter(id -> id.getNamespace().equals("minecraft"))
|
.filter(id -> !bundled.contains(BiomeSymbolPages.symbolId(id).getPath()))
|
||||||
.filter(id -> !bundled.contains("biome/" + id.getPath()))
|
|
||||||
.sorted()
|
.sorted()
|
||||||
.forEach(id -> pages.add(createCreativeBiomePage(id)));
|
.forEach(id -> pages.add(createCreativeBiomePage(id)));
|
||||||
return pages;
|
return pages;
|
||||||
@@ -102,11 +114,34 @@ public final class PageItem extends Item {
|
|||||||
return BlockSymbolPages.availableBlocks(category).stream()
|
return BlockSymbolPages.availableBlocks(category).stream()
|
||||||
.map(PageItem::createCreativeBlockPage).toList();
|
.map(PageItem::createCreativeBlockPage).toList();
|
||||||
}
|
}
|
||||||
|
Set<ResourceLocation> caveBiomes = category.equals(BIOME_CATEGORY) || category.equals(CAVE_BIOME_CATEGORY)
|
||||||
|
? caveBiomeIds(registries) : Set.of();
|
||||||
return creativeBundledAndBiomePages(registries).stream()
|
return creativeBundledAndBiomePages(registries).stream()
|
||||||
.filter(page -> category.equals(creativeCategory(page)))
|
.filter(page -> category.equals(creativeCategory(page, caveBiomes)))
|
||||||
.toList();
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ResourceLocation creativeCategory(ItemStack page, HolderLookup.Provider registries) {
|
||||||
|
return creativeCategory(page, caveBiomeIds(registries));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ResourceLocation creativeCategory(ItemStack page, Set<ResourceLocation> caveBiomes) {
|
||||||
|
ResourceLocation category = creativeCategory(page);
|
||||||
|
if (!category.equals(BIOME_CATEGORY)) return category;
|
||||||
|
ResourceLocation symbolId = content(page).symbol().orElseThrow().id();
|
||||||
|
ResourceLocation biomeId = BiomeSymbolPages.biomeId(symbolId);
|
||||||
|
return caveBiomes.contains(biomeId) ? CAVE_BIOME_CATEGORY : category;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Set<ResourceLocation> caveBiomeIds(HolderLookup.Provider registries) {
|
||||||
|
LinkedHashSet<ResourceLocation> ids = new LinkedHashSet<>();
|
||||||
|
registries.lookupOrThrow(Registries.BIOME).listElements()
|
||||||
|
.filter(holder -> holder.is(AgeBiomeSelection.CAVE_BIOMES) || holder.is(BiomeTags.IS_NETHER))
|
||||||
|
.forEach(holder -> ids.add(holder.key().location()));
|
||||||
|
if (registries instanceof RegistryAccess access) ids.addAll(TerraBlenderBiomes.nether(access));
|
||||||
|
return ids;
|
||||||
|
}
|
||||||
|
|
||||||
public static ResourceLocation creativeCategory(ItemStack page) {
|
public static ResourceLocation creativeCategory(ItemStack page) {
|
||||||
SymbolDisplayMetadata metadata = page.get(ModDataComponents.PAGE_SYMBOL_DISPLAY.get());
|
SymbolDisplayMetadata metadata = page.get(ModDataComponents.PAGE_SYMBOL_DISPLAY.get());
|
||||||
if (metadata == null) throw new IllegalArgumentException("Page has no symbol display metadata");
|
if (metadata == null) throw new IllegalArgumentException("Page has no symbol display metadata");
|
||||||
@@ -223,6 +258,8 @@ public final class PageItem extends Item {
|
|||||||
if (content.kind() == PageContent.Kind.LINK_PANEL) {
|
if (content.kind() == PageContent.Kind.LINK_PANEL) {
|
||||||
tooltipComponents.add(Component.translatable("item.rivencraft.page.link_panel.description")
|
tooltipComponents.add(Component.translatable("item.rivencraft.page.link_panel.description")
|
||||||
.withStyle(ChatFormatting.GRAY));
|
.withStyle(ChatFormatting.GRAY));
|
||||||
|
stack.getOrDefault(ModDataComponents.LINK_PROPERTIES.get(), LinkProperties.NONE)
|
||||||
|
.appendTooltip(tooltipComponents);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SymbolReference reference = content.symbol().orElseThrow();
|
SymbolReference reference = content.symbol().orElseThrow();
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import net.minecraft.world.SimpleContainer;
|
|||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||||
|
import net.minecraft.world.inventory.ClickType;
|
||||||
import net.minecraft.world.inventory.DataSlot;
|
import net.minecraft.world.inventory.DataSlot;
|
||||||
import net.minecraft.world.inventory.Slot;
|
import net.minecraft.world.inventory.Slot;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
@@ -17,13 +18,15 @@ import net.minecraft.world.item.Items;
|
|||||||
|
|
||||||
/** Server-owned virtual output; taking it spends paper and the configured ink cost once. */
|
/** Server-owned virtual output; taking it spends paper and the configured ink cost once. */
|
||||||
public final class InkMixerMenu extends AbstractContainerMenu {
|
public final class InkMixerMenu extends AbstractContainerMenu {
|
||||||
public static final int RESULT = InkMixerBlockEntity.SIZE;
|
public static final int MODIFIER = InkMixerBlockEntity.SIZE;
|
||||||
|
public static final int RESULT = MODIFIER + 1;
|
||||||
private static final int PLAYER_START = RESULT + 1;
|
private static final int PLAYER_START = RESULT + 1;
|
||||||
private final InkMixerBlockEntity mixer;
|
private final InkMixerBlockEntity mixer;
|
||||||
private final Container inputs;
|
private final Container inputs;
|
||||||
private final SimpleContainer result = new SimpleContainer(1);
|
private final SimpleContainer result = new SimpleContainer(1);
|
||||||
private final boolean clientSide;
|
private final boolean clientSide;
|
||||||
private int inkRemaining;
|
private int inkRemaining;
|
||||||
|
private final int[] modifierChances = new int[3];
|
||||||
|
|
||||||
public InkMixerMenu(int id, Inventory inventory, RegistryFriendlyByteBuf data) {
|
public InkMixerMenu(int id, Inventory inventory, RegistryFriendlyByteBuf data) {
|
||||||
this(id, inventory, inventory.player.level().getBlockEntity(data.readBlockPos())
|
this(id, inventory, inventory.player.level().getBlockEntity(data.readBlockPos())
|
||||||
@@ -39,9 +42,19 @@ public final class InkMixerMenu extends AbstractContainerMenu {
|
|||||||
@Override public int get() { return clientSide ? inkRemaining : mixer.inkRemaining(); }
|
@Override public int get() { return clientSide ? inkRemaining : mixer.inkRemaining(); }
|
||||||
@Override public void set(int value) { inkRemaining = value; }
|
@Override public void set(int value) { inkRemaining = value; }
|
||||||
});
|
});
|
||||||
|
for (int index = 0; index < modifierChances.length; index++) {
|
||||||
|
final int chanceIndex = index;
|
||||||
|
addDataSlot(new DataSlot() {
|
||||||
|
@Override public int get() {
|
||||||
|
return clientSide ? modifierChances[chanceIndex] : mixer.modifierChancePermille(chanceIndex);
|
||||||
|
}
|
||||||
|
@Override public void set(int value) { modifierChances[chanceIndex] = value; }
|
||||||
|
});
|
||||||
|
}
|
||||||
addSlot(new MixerSlot(InkMixerBlockEntity.INK, 8, 27));
|
addSlot(new MixerSlot(InkMixerBlockEntity.INK, 8, 27));
|
||||||
addSlot(new MixerSlot(InkMixerBlockEntity.PAPER, 8, 48));
|
addSlot(new MixerSlot(InkMixerBlockEntity.PAPER, 8, 48));
|
||||||
addSlot(new MixerSlot(InkMixerBlockEntity.BOTTLES, 152, 27));
|
addSlot(new MixerSlot(InkMixerBlockEntity.BOTTLES, 152, 27));
|
||||||
|
addSlot(new ModifierSlot(79, 40));
|
||||||
addSlot(new ResultSlot(152, 48));
|
addSlot(new ResultSlot(152, 48));
|
||||||
for (int row = 0; row < 3; row++)
|
for (int row = 0; row < 3; row++)
|
||||||
for (int column = 0; column < 9; column++)
|
for (int column = 0; column < 9; column++)
|
||||||
@@ -52,6 +65,24 @@ public final class InkMixerMenu extends AbstractContainerMenu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int inkRemaining() { return inkRemaining; }
|
public int inkRemaining() { return inkRemaining; }
|
||||||
|
public int modifierChancePermille(int index) { return modifierChances[index]; }
|
||||||
|
|
||||||
|
@Override public void clicked(int slotId, int button, ClickType clickType, Player player) {
|
||||||
|
if (slotId == MODIFIER) {
|
||||||
|
if (!clientSide && stillValid(player) && clickType == ClickType.PICKUP
|
||||||
|
&& (button == 0 || button == 1)) {
|
||||||
|
ItemStack carried = getCarried();
|
||||||
|
int amount = button == 1 ? 1 : carried.getCount();
|
||||||
|
if (mixer.addModifier(carried, amount)) {
|
||||||
|
setCarried(carried);
|
||||||
|
refreshResult();
|
||||||
|
broadcastChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
super.clicked(slotId, button, clickType, player);
|
||||||
|
}
|
||||||
|
|
||||||
@Override public boolean stillValid(Player player) {
|
@Override public boolean stillValid(Player player) {
|
||||||
return mixer != null && mixer.stillValid(player);
|
return mixer != null && mixer.stillValid(player);
|
||||||
@@ -64,8 +95,7 @@ public final class InkMixerMenu extends AbstractContainerMenu {
|
|||||||
|
|
||||||
private void refreshResult() {
|
private void refreshResult() {
|
||||||
if (clientSide) return;
|
if (clientSide) return;
|
||||||
ItemStack preview = mixer != null && mixer.canCreateLinkPanel()
|
ItemStack preview = mixer == null ? ItemStack.EMPTY : mixer.previewLinkPanel();
|
||||||
? PageItem.createLinkPanelPage() : ItemStack.EMPTY;
|
|
||||||
if (!ItemStack.matches(result.getItem(0), preview)) result.setItem(0, preview);
|
if (!ItemStack.matches(result.getItem(0), preview)) result.setItem(0, preview);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,7 +117,7 @@ public final class InkMixerMenu extends AbstractContainerMenu {
|
|||||||
ItemStack source = slot.getItem();
|
ItemStack source = slot.getItem();
|
||||||
ItemStack original = source.copy();
|
ItemStack original = source.copy();
|
||||||
boolean moved;
|
boolean moved;
|
||||||
if (index < RESULT) moved = moveItemStackTo(source, PLAYER_START, slots.size(), true);
|
if (index < MODIFIER) moved = moveItemStackTo(source, PLAYER_START, slots.size(), true);
|
||||||
else if (source.is(ModItems.INK_VIAL.get()))
|
else if (source.is(ModItems.INK_VIAL.get()))
|
||||||
moved = moveItemStackTo(source, InkMixerBlockEntity.INK, InkMixerBlockEntity.INK + 1, false);
|
moved = moveItemStackTo(source, InkMixerBlockEntity.INK, InkMixerBlockEntity.INK + 1, false);
|
||||||
else if (source.is(Items.PAPER))
|
else if (source.is(Items.PAPER))
|
||||||
@@ -105,6 +135,12 @@ public final class InkMixerMenu extends AbstractContainerMenu {
|
|||||||
@Override public boolean mayPlace(ItemStack stack) { return inputs.canPlaceItem(getContainerSlot(), stack); }
|
@Override public boolean mayPlace(ItemStack stack) { return inputs.canPlaceItem(getContainerSlot(), stack); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final class ModifierSlot extends Slot {
|
||||||
|
ModifierSlot(int x, int y) { super(new SimpleContainer(1), 0, x, y); }
|
||||||
|
@Override public boolean mayPlace(ItemStack stack) { return false; }
|
||||||
|
@Override public boolean mayPickup(Player player) { return false; }
|
||||||
|
}
|
||||||
|
|
||||||
private final class ResultSlot extends Slot {
|
private final class ResultSlot extends Slot {
|
||||||
ResultSlot(int x, int y) { super(result, 0, x, y); }
|
ResultSlot(int x, int y) { super(result, 0, x, y); }
|
||||||
@Override public boolean mayPlace(ItemStack stack) { return false; }
|
@Override public boolean mayPlace(ItemStack stack) { return false; }
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import net.dnorberg.rivencraft.registry.ModDataComponents;
|
|||||||
import net.dnorberg.rivencraft.registry.ModItems;
|
import net.dnorberg.rivencraft.registry.ModItems;
|
||||||
import net.dnorberg.rivencraft.registry.ModMenus;
|
import net.dnorberg.rivencraft.registry.ModMenus;
|
||||||
import net.dnorberg.rivencraft.writing.NotebookContents;
|
import net.dnorberg.rivencraft.writing.NotebookContents;
|
||||||
|
import net.dnorberg.rivencraft.writing.PageContent;
|
||||||
|
import net.dnorberg.rivencraft.item.PageItem;
|
||||||
import net.minecraft.core.NonNullList;
|
import net.minecraft.core.NonNullList;
|
||||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||||
import net.minecraft.world.Container;
|
import net.minecraft.world.Container;
|
||||||
@@ -82,6 +84,7 @@ public final class NotebookMenu extends AbstractContainerMenu {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!source.is(ModItems.PAGE.get())
|
if (!source.is(ModItems.PAGE.get())
|
||||||
|
|| PageItem.content(source).kind() == PageContent.Kind.LINK_PANEL
|
||||||
|| !moveItemStackTo(source, 0, PLAYER_INVENTORY_START, false)) {
|
|| !moveItemStackTo(source, 0, PLAYER_INVENTORY_START, false)) {
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
@@ -135,7 +138,10 @@ public final class NotebookMenu extends AbstractContainerMenu {
|
|||||||
super(container, slot, x, y);
|
super(container, slot, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean mayPlace(ItemStack stack) { return stack.is(ModItems.PAGE.get()); }
|
@Override public boolean mayPlace(ItemStack stack) {
|
||||||
|
return stack.is(ModItems.PAGE.get())
|
||||||
|
&& PageItem.content(stack).kind() != PageContent.Kind.LINK_PANEL;
|
||||||
|
}
|
||||||
@Override public int getMaxStackSize() { return 1; }
|
@Override public int getMaxStackSize() { return 1; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ public final class WritingDeskMenu extends AbstractContainerMenu {
|
|||||||
private boolean placeCarriedPage(int collectionIndex, int pageIndex) {
|
private boolean placeCarriedPage(int collectionIndex, int pageIndex) {
|
||||||
// Resolve the actual storage position on the server, never a filtered list index.
|
// Resolve the actual storage position on the server, never a filtered list index.
|
||||||
ItemStack carried = getCarried();
|
ItemStack carried = getCarried();
|
||||||
if (clientSide || !carried.is(ModItems.PAGE.get())) return false;
|
if (clientSide || !storablePage(carried)) return false;
|
||||||
ItemStack collection = desk.getItem(collectionIndex);
|
ItemStack collection = desk.getItem(collectionIndex);
|
||||||
if (collection.is(ModItems.NOTEBOOK.get())) {
|
if (collection.is(ModItems.NOTEBOOK.get())) {
|
||||||
var pages = new java.util.ArrayList<>(collection.getOrDefault(
|
var pages = new java.util.ArrayList<>(collection.getOrDefault(
|
||||||
@@ -215,12 +215,14 @@ public final class WritingDeskMenu extends AbstractContainerMenu {
|
|||||||
if (sourceNotebook && (sourcePage >= sourcePages.size() || sourcePages.get(sourcePage).isEmpty())) return false;
|
if (sourceNotebook && (sourcePage >= sourcePages.size() || sourcePages.get(sourcePage).isEmpty())) return false;
|
||||||
ItemStack moving = sourceNotebook ? sourcePages.get(sourcePage) : sourceBook;
|
ItemStack moving = sourceNotebook ? sourcePages.get(sourcePage) : sourceBook;
|
||||||
if (moving.getCount() != 1) return false;
|
if (moving.getCount() != 1) return false;
|
||||||
|
if (!storablePage(moving)) return false;
|
||||||
if (!targetNotebook && targetBook.getCount() != 1) return false;
|
if (!targetNotebook && targetBook.getCount() != 1) return false;
|
||||||
var targetPages = targetNotebook ? sourceCollection == targetCollection ? sourcePages
|
var targetPages = targetNotebook ? sourceCollection == targetCollection ? sourcePages
|
||||||
: new java.util.ArrayList<>(targetBook.getOrDefault(
|
: new java.util.ArrayList<>(targetBook.getOrDefault(
|
||||||
ModDataComponents.NOTEBOOK_CONTENTS.get(), NotebookContents.EMPTY).pages()) : null;
|
ModDataComponents.NOTEBOOK_CONTENTS.get(), NotebookContents.EMPTY).pages()) : null;
|
||||||
if (targetNotebook) while (targetPages.size() <= targetPage) targetPages.add(ItemStack.EMPTY);
|
if (targetNotebook) while (targetPages.size() <= targetPage) targetPages.add(ItemStack.EMPTY);
|
||||||
ItemStack displaced = targetNotebook ? targetPages.get(targetPage) : targetBook;
|
ItemStack displaced = targetNotebook ? targetPages.get(targetPage) : targetBook;
|
||||||
|
if (!displaced.isEmpty() && !storablePage(displaced)) return false;
|
||||||
if (targetNotebook) targetPages.set(targetPage, moving);
|
if (targetNotebook) targetPages.set(targetPage, moving);
|
||||||
if (sourceNotebook) {
|
if (sourceNotebook) {
|
||||||
sourcePages.set(sourcePage, displaced);
|
sourcePages.set(sourcePage, displaced);
|
||||||
@@ -256,6 +258,7 @@ public final class WritingDeskMenu extends AbstractContainerMenu {
|
|||||||
setCarried(moving);
|
setCarried(moving);
|
||||||
} else {
|
} else {
|
||||||
if (targetSlot >= WritingDeskBlockEntity.COLLECTIONS && targetSlot < PLAYER_START) return false;
|
if (targetSlot >= WritingDeskBlockEntity.COLLECTIONS && targetSlot < PLAYER_START) return false;
|
||||||
|
if (targetSlot < WritingDeskBlockEntity.COLLECTIONS && !storablePage(moving)) return false;
|
||||||
Slot target = slots.get(targetSlot);
|
Slot target = slots.get(targetSlot);
|
||||||
if (!target.isActive() || !target.mayPlace(moving)) return false;
|
if (!target.isActive() || !target.mayPlace(moving)) return false;
|
||||||
ItemStack current = target.getItem();
|
ItemStack current = target.getItem();
|
||||||
@@ -340,10 +343,15 @@ public final class WritingDeskMenu extends AbstractContainerMenu {
|
|||||||
if (moving.is(Items.PAPER))
|
if (moving.is(Items.PAPER))
|
||||||
return moveItemStackTo(moving, WritingDeskBlockEntity.PAPER,
|
return moveItemStackTo(moving, WritingDeskBlockEntity.PAPER,
|
||||||
WritingDeskBlockEntity.PAPER + 1, false);
|
WritingDeskBlockEntity.PAPER + 1, false);
|
||||||
if (moving.is(ModItems.PAGE.get())) return moveItemStackTo(moving, firstVisibleTab, firstVisibleTab + VISIBLE_TABS, false);
|
if (storablePage(moving)) return moveItemStackTo(moving, firstVisibleTab, firstVisibleTab + VISIBLE_TABS, false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean storablePage(ItemStack stack) {
|
||||||
|
return stack.is(ModItems.PAGE.get())
|
||||||
|
&& PageItem.content(stack).kind() != PageContent.Kind.LINK_PANEL;
|
||||||
|
}
|
||||||
|
|
||||||
private ItemStack selectedSource() {
|
private ItemStack selectedSource() {
|
||||||
if (selectedSymbol != null) {
|
if (selectedSymbol != null) {
|
||||||
SymbolReference reference = new SymbolReference(selectedSymbol);
|
SymbolReference reference = new SymbolReference(selectedSymbol);
|
||||||
@@ -375,6 +383,7 @@ public final class WritingDeskMenu extends AbstractContainerMenu {
|
|||||||
ItemStack source = selectedSource();
|
ItemStack source = selectedSource();
|
||||||
return blockEntity != null && source.is(ModItems.PAGE.get())
|
return blockEntity != null && source.is(ModItems.PAGE.get())
|
||||||
&& PageItem.content(source).kind() != PageContent.Kind.BLANK
|
&& PageItem.content(source).kind() != PageContent.Kind.BLANK
|
||||||
|
&& PageItem.content(source).kind() != PageContent.Kind.LINK_PANEL
|
||||||
&& PageItem.isUsableWriting(source) && blockEntity.canConsumeCopyMaterials();
|
&& PageItem.isUsableWriting(source) && blockEntity.canConsumeCopyMaterials();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import net.dnorberg.rivencraft.block.entity.BookStandBlockEntity;
|
|||||||
import net.dnorberg.rivencraft.client.ClientLinkPreviewHandler;
|
import net.dnorberg.rivencraft.client.ClientLinkPreviewHandler;
|
||||||
import net.dnorberg.rivencraft.client.ClientBookInteractionHandler;
|
import net.dnorberg.rivencraft.client.ClientBookInteractionHandler;
|
||||||
import net.dnorberg.rivencraft.client.ClientAgeCelestialAngles;
|
import net.dnorberg.rivencraft.client.ClientAgeCelestialAngles;
|
||||||
|
import net.dnorberg.rivencraft.client.ClientSereneAgeWhitelist;
|
||||||
import net.dnorberg.rivencraft.client.ClientWritingDeskCatalog;
|
import net.dnorberg.rivencraft.client.ClientWritingDeskCatalog;
|
||||||
import net.dnorberg.rivencraft.event.AgeCelestialAngleSync;
|
import net.dnorberg.rivencraft.event.AgeCelestialAngleSync;
|
||||||
import net.dnorberg.rivencraft.item.DescriptiveBookItem;
|
import net.dnorberg.rivencraft.item.DescriptiveBookItem;
|
||||||
@@ -78,6 +79,8 @@ public final class ModNetworking {
|
|||||||
ClientLinkPreviewHandler::handle);
|
ClientLinkPreviewHandler::handle);
|
||||||
registrar.playToClient(AgeCelestialAnglePayload.TYPE, AgeCelestialAnglePayload.STREAM_CODEC,
|
registrar.playToClient(AgeCelestialAnglePayload.TYPE, AgeCelestialAnglePayload.STREAM_CODEC,
|
||||||
ClientAgeCelestialAngles::handle);
|
ClientAgeCelestialAngles::handle);
|
||||||
|
registrar.playToClient(SereneAgeWhitelistPayload.TYPE, SereneAgeWhitelistPayload.STREAM_CODEC,
|
||||||
|
ClientSereneAgeWhitelist::handle);
|
||||||
registrar.playToClient(WritingDeskCatalogPayload.TYPE, WritingDeskCatalogPayload.STREAM_CODEC,
|
registrar.playToClient(WritingDeskCatalogPayload.TYPE, WritingDeskCatalogPayload.STREAM_CODEC,
|
||||||
ClientWritingDeskCatalog::handle);
|
ClientWritingDeskCatalog::handle);
|
||||||
registrar.playToServer(SetBookBinderTitlePayload.TYPE, SetBookBinderTitlePayload.STREAM_CODEC,
|
registrar.playToServer(SetBookBinderTitlePayload.TYPE, SetBookBinderTitlePayload.STREAM_CODEC,
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package net.dnorberg.rivencraft.network;
|
||||||
|
|
||||||
|
import net.dnorberg.rivencraft.Rivencraft;
|
||||||
|
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||||
|
import net.minecraft.network.codec.StreamCodec;
|
||||||
|
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
|
/** Updates an already connected client's Serene whitelist for one Age. */
|
||||||
|
public record SereneAgeWhitelistPayload(ResourceLocation dimensionId, boolean enabled) implements CustomPacketPayload {
|
||||||
|
public static final Type<SereneAgeWhitelistPayload> TYPE = new Type<>(
|
||||||
|
ResourceLocation.fromNamespaceAndPath(Rivencraft.MOD_ID, "serene_age_whitelist"));
|
||||||
|
public static final StreamCodec<RegistryFriendlyByteBuf, SereneAgeWhitelistPayload> STREAM_CODEC =
|
||||||
|
StreamCodec.of(
|
||||||
|
(buffer, payload) -> {
|
||||||
|
buffer.writeResourceLocation(payload.dimensionId());
|
||||||
|
buffer.writeBoolean(payload.enabled());
|
||||||
|
},
|
||||||
|
buffer -> new SereneAgeWhitelistPayload(buffer.readResourceLocation(), buffer.readBoolean()));
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Type<? extends CustomPacketPayload> type() {
|
||||||
|
return TYPE;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -42,7 +42,7 @@ public final class ModCreativeTabs {
|
|||||||
.build());
|
.build());
|
||||||
|
|
||||||
private static final List<String> CATEGORY_ORDER = List.of(
|
private static final List<String> CATEGORY_ORDER = List.of(
|
||||||
"terrain", "biome", "biome_generation", "weather", "lighting", "sky", "celestial", "block", "fluid", "feature");
|
"terrain", "biome", "cave_biome", "biome_generation", "weather", "season", "lighting", "sky", "celestial", "block", "fluid", "feature");
|
||||||
|
|
||||||
public static final Map<ResourceLocation, DeferredHolder<CreativeModeTab, CreativeModeTab>> SYMBOL_PAGES =
|
public static final Map<ResourceLocation, DeferredHolder<CreativeModeTab, CreativeModeTab>> SYMBOL_PAGES =
|
||||||
registerSymbolPageTabs();
|
registerSymbolPageTabs();
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package net.dnorberg.rivencraft.registry;
|
|||||||
|
|
||||||
import net.dnorberg.rivencraft.Rivencraft;
|
import net.dnorberg.rivencraft.Rivencraft;
|
||||||
import net.dnorberg.rivencraft.book.LinkTarget;
|
import net.dnorberg.rivencraft.book.LinkTarget;
|
||||||
|
import net.dnorberg.rivencraft.book.LinkProperties;
|
||||||
import net.dnorberg.rivencraft.book.AgeReference;
|
import net.dnorberg.rivencraft.book.AgeReference;
|
||||||
import net.dnorberg.rivencraft.writing.PageContent;
|
import net.dnorberg.rivencraft.writing.PageContent;
|
||||||
import net.dnorberg.rivencraft.writing.NotebookContents;
|
import net.dnorberg.rivencraft.writing.NotebookContents;
|
||||||
@@ -26,6 +27,12 @@ public final class ModDataComponents {
|
|||||||
.networkSynchronized(LinkTarget.STREAM_CODEC)
|
.networkSynchronized(LinkTarget.STREAM_CODEC)
|
||||||
.cacheEncoding()
|
.cacheEncoding()
|
||||||
.build());
|
.build());
|
||||||
|
public static final DeferredHolder<DataComponentType<?>, DataComponentType<LinkProperties>> LINK_PROPERTIES =
|
||||||
|
DATA_COMPONENTS.register("link_properties", () -> DataComponentType.<LinkProperties>builder()
|
||||||
|
.persistent(LinkProperties.CODEC)
|
||||||
|
.networkSynchronized(LinkProperties.STREAM_CODEC)
|
||||||
|
.cacheEncoding()
|
||||||
|
.build());
|
||||||
public static final DeferredHolder<DataComponentType<?>, DataComponentType<AgeReference>> AGE_REFERENCE =
|
public static final DeferredHolder<DataComponentType<?>, DataComponentType<AgeReference>> AGE_REFERENCE =
|
||||||
DATA_COMPONENTS.register("age_reference", () -> DataComponentType.<AgeReference>builder()
|
DATA_COMPONENTS.register("age_reference", () -> DataComponentType.<AgeReference>builder()
|
||||||
.persistent(AgeReference.CODEC)
|
.persistent(AgeReference.CODEC)
|
||||||
|
|||||||
@@ -6,14 +6,27 @@ import java.util.Optional;
|
|||||||
import net.dnorberg.rivencraft.Rivencraft;
|
import net.dnorberg.rivencraft.Rivencraft;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
/** Built-in fallback pages for registered vanilla biomes without hand-authored symbol JSON. */
|
/** Registry-derived pages for biomes without hand-authored symbol JSON. */
|
||||||
public final class BiomeSymbolPages {
|
public final class BiomeSymbolPages {
|
||||||
private static final ResourceLocation CATEGORY = ResourceLocation.fromNamespaceAndPath(Rivencraft.MOD_ID, "biome");
|
private static final ResourceLocation CATEGORY = ResourceLocation.fromNamespaceAndPath(Rivencraft.MOD_ID, "biome");
|
||||||
|
|
||||||
private BiomeSymbolPages() { }
|
private BiomeSymbolPages() { }
|
||||||
|
|
||||||
public static ResourceLocation symbolId(ResourceLocation biomeId) {
|
public static ResourceLocation symbolId(ResourceLocation biomeId) {
|
||||||
return ResourceLocation.fromNamespaceAndPath(Rivencraft.MOD_ID, "biome/" + biomeId.getPath());
|
// Preserve old vanilla page IDs, while keeping modded namespaces distinct.
|
||||||
|
return ResourceLocation.fromNamespaceAndPath(Rivencraft.MOD_ID, "biome/"
|
||||||
|
+ (biomeId.getNamespace().equals("minecraft") ? "" : biomeId.getNamespace() + "/")
|
||||||
|
+ biomeId.getPath());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ResourceLocation biomeId(ResourceLocation symbolId) {
|
||||||
|
String path = symbolId.getPath();
|
||||||
|
if (!symbolId.getNamespace().equals(Rivencraft.MOD_ID) || !path.startsWith("biome/"))
|
||||||
|
throw new IllegalArgumentException("Not a biome symbol: " + symbolId);
|
||||||
|
path = path.substring("biome/".length());
|
||||||
|
int separator = path.indexOf('/');
|
||||||
|
return separator < 0 ? ResourceLocation.withDefaultNamespace(path)
|
||||||
|
: ResourceLocation.fromNamespaceAndPath(path.substring(0, separator), path.substring(separator + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SymbolDefinition definition(ResourceLocation biomeId) {
|
public static SymbolDefinition definition(ResourceLocation biomeId) {
|
||||||
@@ -24,8 +37,11 @@ public final class BiomeSymbolPages {
|
|||||||
.map(part -> part.substring(0, 1).toUpperCase(Locale.ROOT) + part.substring(1))
|
.map(part -> part.substring(0, 1).toUpperCase(Locale.ROOT) + part.substring(1))
|
||||||
.reduce("", String::concat);
|
.reduce("", String::concat);
|
||||||
if (glyphWord.isEmpty()) glyphWord = "World";
|
if (glyphWord.isEmpty()) glyphWord = "World";
|
||||||
|
if (glyphWord.length() > 48) glyphWord = glyphWord.substring(0, 48);
|
||||||
return new SymbolDefinition(SymbolDefinition.CURRENT_SCHEMA_VERSION,
|
return new SymbolDefinition(SymbolDefinition.CURRENT_SCHEMA_VERSION,
|
||||||
"symbol.rivencraft.biome." + path,
|
biomeId.getNamespace().equals("minecraft")
|
||||||
|
? "symbol.rivencraft.biome." + path
|
||||||
|
: "biome." + biomeId.getNamespace() + "." + path.replace('/', '.'),
|
||||||
"symbol.rivencraft.biome.generated.description",
|
"symbol.rivencraft.biome.generated.description",
|
||||||
CATEGORY,
|
CATEGORY,
|
||||||
Optional.of(new SymbolSemantics(SymbolSemantics.Role.BIOME,
|
Optional.of(new SymbolSemantics(SymbolSemantics.Role.BIOME,
|
||||||
@@ -35,9 +51,14 @@ public final class BiomeSymbolPages {
|
|||||||
|
|
||||||
public static String fallbackName(ResourceLocation symbolId) {
|
public static String fallbackName(ResourceLocation symbolId) {
|
||||||
String path = symbolId.getPath().substring("biome/".length());
|
String path = symbolId.getPath().substring("biome/".length());
|
||||||
return Arrays.stream(path.split("_"))
|
int separator = path.indexOf('/');
|
||||||
|
String namespace = separator < 0 ? "" : path.substring(0, separator);
|
||||||
|
if (separator >= 0) path = path.substring(separator + 1);
|
||||||
|
String label = path.replace('/', '_');
|
||||||
|
String name = Arrays.stream(label.split("_"))
|
||||||
.filter(part -> !part.isEmpty())
|
.filter(part -> !part.isEmpty())
|
||||||
.map(part -> part.substring(0, 1).toUpperCase(Locale.ROOT) + part.substring(1))
|
.map(part -> part.substring(0, 1).toUpperCase(Locale.ROOT) + part.substring(1))
|
||||||
.reduce((left, right) -> left + " " + right).orElse("Unknown") + " Biome";
|
.reduce((left, right) -> left + " " + right).orElse("Unknown") + " Biome";
|
||||||
|
return namespace.isEmpty() ? name : name + " (" + namespace + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package net.dnorberg.rivencraft.writing;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import net.dnorberg.rivencraft.book.LinkProperties;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.item.Items;
|
||||||
|
|
||||||
|
/** Built-in Legacy ink additives. Optional mod dusts will be mapped through tags separately. */
|
||||||
|
public final class InkModifierIngredients {
|
||||||
|
public record Effect(int flag, double chance) {}
|
||||||
|
public record Ingredient(ItemStack item, List<Effect> effects) {}
|
||||||
|
|
||||||
|
private static final List<Ingredient> BUILT_IN = List.of(
|
||||||
|
new Ingredient(new ItemStack(Items.GUNPOWDER), List.of(new Effect(LinkProperties.DISARM, 0.20))),
|
||||||
|
new Ingredient(new ItemStack(Items.MUSHROOM_STEW), List.of(new Effect(LinkProperties.DISARM, 0.05))),
|
||||||
|
new Ingredient(new ItemStack(Items.EXPERIENCE_BOTTLE), List.of(new Effect(LinkProperties.INTRA_LINKING, 0.15))),
|
||||||
|
new Ingredient(new ItemStack(Items.ENDER_PEARL), List.of(
|
||||||
|
new Effect(LinkProperties.INTRA_LINKING, 0.15),
|
||||||
|
new Effect(LinkProperties.DISARM, 0.15))),
|
||||||
|
new Ingredient(new ItemStack(Items.FEATHER), List.of(new Effect(LinkProperties.MAINTAIN_MOMENTUM, 0.15))),
|
||||||
|
new Ingredient(new ItemStack(Items.FIRE_CHARGE), List.of(new Effect(LinkProperties.DISARM, 0.25)))
|
||||||
|
);
|
||||||
|
|
||||||
|
private InkModifierIngredients() {}
|
||||||
|
|
||||||
|
public static List<Ingredient> builtIn() {
|
||||||
|
return BUILT_IN;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Ingredient find(ItemStack stack) {
|
||||||
|
return BUILT_IN.stream().filter(ingredient -> stack.is(ingredient.item().getItem())).findFirst().orElse(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package net.dnorberg.rivencraft.writing;
|
package net.dnorberg.rivencraft.writing;
|
||||||
|
|
||||||
import net.dnorberg.rivencraft.item.PageItem;
|
import net.dnorberg.rivencraft.item.PageItem;
|
||||||
|
import net.dnorberg.rivencraft.registry.ModDataComponents;
|
||||||
import net.dnorberg.rivencraft.registry.ModItems;
|
import net.dnorberg.rivencraft.registry.ModItems;
|
||||||
import net.dnorberg.rivencraft.registry.ModRecipeSerializers;
|
import net.dnorberg.rivencraft.registry.ModRecipeSerializers;
|
||||||
import net.minecraft.core.HolderLookup;
|
import net.minecraft.core.HolderLookup;
|
||||||
@@ -50,11 +51,13 @@ public final class LinkingBookRecipe extends CustomRecipe {
|
|||||||
ItemStack panel = findPanel(input);
|
ItemStack panel = findPanel(input);
|
||||||
if (panel.isEmpty()) return ItemStack.EMPTY;
|
if (panel.isEmpty()) return ItemStack.EMPTY;
|
||||||
ItemStack book = new ItemStack(ModItems.LINKING_BOOK.get());
|
ItemStack book = new ItemStack(ModItems.LINKING_BOOK.get());
|
||||||
// Legacy copied the panel's data. Only its custom name is meaningful to a
|
// Copy book-relevant panel data, never the Page identity component.
|
||||||
// 1.21.1 Linking Book today; page-only components must not reach the book.
|
|
||||||
if (panel.has(DataComponents.CUSTOM_NAME)) {
|
if (panel.has(DataComponents.CUSTOM_NAME)) {
|
||||||
book.set(DataComponents.CUSTOM_NAME, panel.get(DataComponents.CUSTOM_NAME));
|
book.set(DataComponents.CUSTOM_NAME, panel.get(DataComponents.CUSTOM_NAME));
|
||||||
}
|
}
|
||||||
|
if (panel.has(ModDataComponents.LINK_PROPERTIES.get())) {
|
||||||
|
book.set(ModDataComponents.LINK_PROPERTIES.get(), panel.get(ModDataComponents.LINK_PROPERTIES.get()));
|
||||||
|
}
|
||||||
return book;
|
return book;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,6 @@ public final class SymbolCatalog {
|
|||||||
});
|
});
|
||||||
registries.lookupOrThrow(Registries.BIOME).listElements()
|
registries.lookupOrThrow(Registries.BIOME).listElements()
|
||||||
.map(holder -> holder.key().location())
|
.map(holder -> holder.key().location())
|
||||||
.filter(id -> id.getNamespace().equals("minecraft"))
|
|
||||||
.forEach(id -> loaded.putIfAbsent(BiomeSymbolPages.symbolId(id),
|
.forEach(id -> loaded.putIfAbsent(BiomeSymbolPages.symbolId(id),
|
||||||
BiomeSymbolPages.definition(id)));
|
BiomeSymbolPages.definition(id)));
|
||||||
BlockSymbolPages.availableBlocks().forEach(id -> loaded.putIfAbsent(
|
BlockSymbolPages.availableBlocks().forEach(id -> loaded.putIfAbsent(
|
||||||
|
|||||||
@@ -80,6 +80,8 @@ public record SymbolSemantics(Role role, Value value) {
|
|||||||
SKY("sky", Kind.CHOICE, "overworld", "nether", "end"),
|
SKY("sky", Kind.CHOICE, "overworld", "nether", "end"),
|
||||||
WEATHER("weather", Kind.CHOICE,
|
WEATHER("weather", Kind.CHOICE,
|
||||||
"normal", "fast", "slow", "off", "always", "cloudy", "rain", "snow", "storm"),
|
"normal", "fast", "slow", "off", "always", "cloudy", "rain", "snow", "storm"),
|
||||||
|
SEASON("season", Kind.CHOICE,
|
||||||
|
"no_seasons", "seasons", "eternal_winter", "eternal_summer", "eternal_fall", "eternal_spring"),
|
||||||
CELESTIAL("celestial", Kind.CHOICE, "normal_time"),
|
CELESTIAL("celestial", Kind.CHOICE, "normal_time"),
|
||||||
PERIOD_MODIFIER("period_modifier", Kind.NUMBER),
|
PERIOD_MODIFIER("period_modifier", Kind.NUMBER),
|
||||||
ANGLE_MODIFIER("angle_modifier", Kind.NUMBER),
|
ANGLE_MODIFIER("angle_modifier", Kind.NUMBER),
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ public final class WritingGrammar {
|
|||||||
|
|
||||||
private static boolean singular(Role role) {
|
private static boolean singular(Role role) {
|
||||||
return switch (role) {
|
return switch (role) {
|
||||||
case TERRAIN, BIOME_CONTROLLER, WEATHER, LIGHTING, SKY, CELESTIAL -> true;
|
case TERRAIN, BIOME_CONTROLLER, WEATHER, SEASON, LIGHTING, SKY, CELESTIAL -> true;
|
||||||
default -> false;
|
default -> false;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -167,11 +167,12 @@ public final class WritingGrammar {
|
|||||||
case BIOME -> 1;
|
case BIOME -> 1;
|
||||||
case BIOME_CONTROLLER -> 2;
|
case BIOME_CONTROLLER -> 2;
|
||||||
case WEATHER -> 3;
|
case WEATHER -> 3;
|
||||||
case LIGHTING -> 4;
|
case SEASON -> 4;
|
||||||
case SKY -> 5;
|
case LIGHTING -> 5;
|
||||||
case PERIOD_MODIFIER, ANGLE_MODIFIER, PHASE_MODIFIER -> 6;
|
case SKY -> 6;
|
||||||
case CELESTIAL -> 7;
|
case PERIOD_MODIFIER, ANGLE_MODIFIER, PHASE_MODIFIER -> 7;
|
||||||
case BLOCK, FEATURE -> 8;
|
case CELESTIAL -> 8;
|
||||||
|
case BLOCK, FEATURE -> 9;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,10 @@
|
|||||||
"item.rivencraft.page.blank": "Blank Page",
|
"item.rivencraft.page.blank": "Blank Page",
|
||||||
"item.rivencraft.page.blank.description": "Ready for writing at a Writing Desk.",
|
"item.rivencraft.page.blank.description": "Ready for writing at a Writing Desk.",
|
||||||
"item.rivencraft.page.link_panel": "Link Panel Page",
|
"item.rivencraft.page.link_panel": "Link Panel Page",
|
||||||
"item.rivencraft.page.link_panel.description": "The baseline panel required to assemble a Descriptive Book.",
|
"item.rivencraft.page.link_panel.description": "A Link Panel for assembling books.",
|
||||||
|
"item.rivencraft.link_property.disarm": "Disarm",
|
||||||
|
"item.rivencraft.link_property.maintain_momentum": "Maintain Momentum",
|
||||||
|
"item.rivencraft.link_property.intra_linking": "Intra Linking",
|
||||||
"item.rivencraft.page.unresolved": "Unresolved Symbol Page",
|
"item.rivencraft.page.unresolved": "Unresolved Symbol Page",
|
||||||
"item.rivencraft.notebook": "Notebook",
|
"item.rivencraft.notebook": "Notebook",
|
||||||
"item.rivencraft.notebook.pages": "Pages: %s/%s",
|
"item.rivencraft.notebook.pages": "Pages: %s/%s",
|
||||||
@@ -23,6 +26,8 @@
|
|||||||
"block.rivencraft.ink_mixer": "Ink Mixer",
|
"block.rivencraft.ink_mixer": "Ink Mixer",
|
||||||
"container.rivencraft.ink_mixer": "Ink Mixer",
|
"container.rivencraft.ink_mixer": "Ink Mixer",
|
||||||
"screen.rivencraft.ink_mixer.ink": "Ink: %s/%s",
|
"screen.rivencraft.ink_mixer.ink": "Ink: %s/%s",
|
||||||
|
"screen.rivencraft.ink_mixer.additive_hint": "Click the basin with an additive; right-click adds one.",
|
||||||
|
"screen.rivencraft.ink_mixer.chance": "%s: %s%%",
|
||||||
"screen.rivencraft.book_binder.title": "Book title",
|
"screen.rivencraft.book_binder.title": "Book title",
|
||||||
"screen.rivencraft.book_binder.title_hint": "Name the book",
|
"screen.rivencraft.book_binder.title_hint": "Name the book",
|
||||||
"screen.rivencraft.book_binder.missing_panel": "Link Panel required as the first page",
|
"screen.rivencraft.book_binder.missing_panel": "Link Panel required as the first page",
|
||||||
@@ -67,6 +72,7 @@
|
|||||||
"message.rivencraft.linking_book.linked": "Linked",
|
"message.rivencraft.linking_book.linked": "Linked",
|
||||||
"message.rivencraft.linking_book.missing_dimension": "That dimension is unavailable",
|
"message.rivencraft.linking_book.missing_dimension": "That dimension is unavailable",
|
||||||
"message.rivencraft.linking_book.unsafe": "No safe destination was found near the link",
|
"message.rivencraft.linking_book.unsafe": "No safe destination was found near the link",
|
||||||
|
"message.rivencraft.linking_book.intra_required": "This book needs an Intra Linking panel for same-dimension travel",
|
||||||
"message.rivencraft.descriptive_book.unwritten": "This Descriptive Book is unwritten",
|
"message.rivencraft.descriptive_book.unwritten": "This Descriptive Book is unwritten",
|
||||||
"message.rivencraft.descriptive_book.created": "Created Age: %s",
|
"message.rivencraft.descriptive_book.created": "Created Age: %s",
|
||||||
"message.rivencraft.descriptive_book.unavailable": "That Age is unavailable",
|
"message.rivencraft.descriptive_book.unavailable": "That Age is unavailable",
|
||||||
@@ -189,6 +195,18 @@
|
|||||||
"symbol.rivencraft.weather.always.description": "Keep the Age rainy.",
|
"symbol.rivencraft.weather.always.description": "Keep the Age rainy.",
|
||||||
"symbol.rivencraft.weather.storm": "Storm Weather",
|
"symbol.rivencraft.weather.storm": "Storm Weather",
|
||||||
"symbol.rivencraft.weather.storm.description": "Keep the Age rainy and thundering.",
|
"symbol.rivencraft.weather.storm.description": "Keep the Age rainy and thundering.",
|
||||||
|
"symbol.rivencraft.season.no_seasons": "No Seasons",
|
||||||
|
"symbol.rivencraft.season.no_seasons.description": "Keep seasonal changes out of this Age.",
|
||||||
|
"symbol.rivencraft.season.seasons": "Seasons",
|
||||||
|
"symbol.rivencraft.season.seasons.description": "Let this Age follow its own season cycle.",
|
||||||
|
"symbol.rivencraft.season.eternal_winter": "Eternal Winter",
|
||||||
|
"symbol.rivencraft.season.eternal_winter.description": "Hold this Age in midwinter where the biome allows winter effects.",
|
||||||
|
"symbol.rivencraft.season.eternal_summer": "Eternal Summer",
|
||||||
|
"symbol.rivencraft.season.eternal_summer.description": "Hold this Age in midsummer.",
|
||||||
|
"symbol.rivencraft.season.eternal_fall": "Eternal Fall",
|
||||||
|
"symbol.rivencraft.season.eternal_fall.description": "Hold this Age in midautumn.",
|
||||||
|
"symbol.rivencraft.season.eternal_spring": "Eternal Spring",
|
||||||
|
"symbol.rivencraft.season.eternal_spring.description": "Hold this Age in midspring.",
|
||||||
"symbol.rivencraft.celestial.normal_time": "Normal Time",
|
"symbol.rivencraft.celestial.normal_time": "Normal Time",
|
||||||
"symbol.rivencraft.celestial.normal_time.description": "Use a normal-length celestial cycle.",
|
"symbol.rivencraft.celestial.normal_time.description": "Use a normal-length celestial cycle.",
|
||||||
"symbol.rivencraft.period.zero": "Zero Length",
|
"symbol.rivencraft.period.zero": "Zero Length",
|
||||||
@@ -243,6 +261,8 @@
|
|||||||
"jei.rivencraft.writing.link_panel_hand": "Hold paper and an Ink Vial in opposite hands; use the vial to make a Link Panel.",
|
"jei.rivencraft.writing.link_panel_hand": "Hold paper and an Ink Vial in opposite hands; use the vial to make a Link Panel.",
|
||||||
"jei.rivencraft.ink_mixer": "Ink Mixer",
|
"jei.rivencraft.ink_mixer": "Ink Mixer",
|
||||||
"jei.rivencraft.ink_mixer.usage": "Paper + ink makes a Link Panel. One vial fills 16 ink; each panel uses the configured ink cost. The empty vial returns as a glass bottle.",
|
"jei.rivencraft.ink_mixer.usage": "Paper + ink makes a Link Panel. One vial fills 16 ink; each panel uses the configured ink cost. The empty vial returns as a glass bottle.",
|
||||||
|
"jei.rivencraft.ink_mixer.additive": "Click this additive into the ink basin: %s. Effects roll when the panel is taken.",
|
||||||
|
"jei.rivencraft.ink_mixer.effect": "%s %s%%",
|
||||||
"jei.rivencraft.writing.copy": "At a Writing Desk, select a stored Page, add paper and ink, then take the copy. The source Page stays.",
|
"jei.rivencraft.writing.copy": "At a Writing Desk, select a stored Page, add paper and ink, then take the copy. The source Page stays.",
|
||||||
"jei.rivencraft.writing.bind": "At a Book Binder, name the Age and add a cover plus Link Panel. Optional symbol Pages follow the panel.",
|
"jei.rivencraft.writing.bind": "At a Book Binder, name the Age and add a cover plus Link Panel. Optional symbol Pages follow the panel.",
|
||||||
"jei.rivencraft.writing.linking_book": "Craft one Link Panel Page with leather to make an unwritten Linking Book. Open it to name and bind it.",
|
"jei.rivencraft.writing.linking_book": "Craft one Link Panel Page with leather to make an unwritten Linking Book. Open it to name and bind it.",
|
||||||
@@ -250,8 +270,10 @@
|
|||||||
"itemGroup.rivencraft.pages.link": "Rivencraft Link Pages",
|
"itemGroup.rivencraft.pages.link": "Rivencraft Link Pages",
|
||||||
"itemGroup.rivencraft.pages.terrain": "Rivencraft Terrain Pages",
|
"itemGroup.rivencraft.pages.terrain": "Rivencraft Terrain Pages",
|
||||||
"itemGroup.rivencraft.pages.biome": "Rivencraft Biome Pages",
|
"itemGroup.rivencraft.pages.biome": "Rivencraft Biome Pages",
|
||||||
|
"itemGroup.rivencraft.pages.cave_biome": "Rivencraft Cave Biome Pages",
|
||||||
"itemGroup.rivencraft.pages.biome_generation": "Rivencraft Biome Generation Pages",
|
"itemGroup.rivencraft.pages.biome_generation": "Rivencraft Biome Generation Pages",
|
||||||
"itemGroup.rivencraft.pages.weather": "Rivencraft Weather Pages",
|
"itemGroup.rivencraft.pages.weather": "Rivencraft Weather Pages",
|
||||||
|
"itemGroup.rivencraft.pages.season": "Rivencraft Season Pages",
|
||||||
"itemGroup.rivencraft.pages.lighting": "Rivencraft Lighting Pages",
|
"itemGroup.rivencraft.pages.lighting": "Rivencraft Lighting Pages",
|
||||||
"itemGroup.rivencraft.pages.sky": "Rivencraft Sky Pages",
|
"itemGroup.rivencraft.pages.sky": "Rivencraft Sky Pages",
|
||||||
"itemGroup.rivencraft.pages.celestial": "Rivencraft Celestial Pages",
|
"itemGroup.rivencraft.pages.celestial": "Rivencraft Celestial Pages",
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"schema_version": 2,
|
||||||
|
"name": "symbol.rivencraft.season.eternal_fall",
|
||||||
|
"description": "symbol.rivencraft.season.eternal_fall.description",
|
||||||
|
"category": "rivencraft:season",
|
||||||
|
"semantics": { "role": "season", "value": "eternal_fall" }
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"schema_version": 2,
|
||||||
|
"name": "symbol.rivencraft.season.eternal_spring",
|
||||||
|
"description": "symbol.rivencraft.season.eternal_spring.description",
|
||||||
|
"category": "rivencraft:season",
|
||||||
|
"semantics": { "role": "season", "value": "eternal_spring" }
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"schema_version": 2,
|
||||||
|
"name": "symbol.rivencraft.season.eternal_summer",
|
||||||
|
"description": "symbol.rivencraft.season.eternal_summer.description",
|
||||||
|
"category": "rivencraft:season",
|
||||||
|
"semantics": { "role": "season", "value": "eternal_summer" }
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"schema_version": 2,
|
||||||
|
"name": "symbol.rivencraft.season.eternal_winter",
|
||||||
|
"description": "symbol.rivencraft.season.eternal_winter.description",
|
||||||
|
"category": "rivencraft:season",
|
||||||
|
"semantics": { "role": "season", "value": "eternal_winter" }
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"schema_version": 2,
|
||||||
|
"name": "symbol.rivencraft.season.no_seasons",
|
||||||
|
"description": "symbol.rivencraft.season.no_seasons.description",
|
||||||
|
"category": "rivencraft:season",
|
||||||
|
"semantics": { "role": "season", "value": "no_seasons" }
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"schema_version": 2,
|
||||||
|
"name": "symbol.rivencraft.season.seasons",
|
||||||
|
"description": "symbol.rivencraft.season.seasons.description",
|
||||||
|
"category": "rivencraft:season",
|
||||||
|
"semantics": { "role": "season", "value": "seasons" }
|
||||||
|
}
|
||||||
Reference in new issue
Block a user