Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
143da0a940 | ||
|
|
dc5157f973 | ||
|
|
956b91c462 | ||
|
|
c980366278 | ||
|
|
616e3d2af5 | ||
|
|
7d335f5952 | ||
|
|
211aa0733b | ||
|
|
8b418ce01c | ||
|
|
62693c2229 | ||
|
|
b8d23ee0c0 | ||
|
|
f276d412b9 | ||
|
|
954dd7097b | ||
|
|
1937a8c71d | ||
|
|
24b60706b0 | ||
|
|
109acc449a | ||
|
|
b06fbda461 | ||
|
|
c0bc91858e |
No files matched your search
@@ -0,0 +1,27 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Incorrect behavior or a regression in Rivencraft
|
||||
title: ""
|
||||
labels: type/bug
|
||||
assignees: ""
|
||||
---
|
||||
|
||||
## Observed behavior
|
||||
|
||||
Describe what happened, including the dimension, book type, preview mode, and
|
||||
installed optional mods when relevant.
|
||||
|
||||
## Expected behavior
|
||||
|
||||
Describe what should have happened.
|
||||
|
||||
## Reproduction
|
||||
|
||||
1. List the minimum steps needed to reproduce the problem.
|
||||
2. Include the Rivencraft, NeoForge, and optional-mod versions.
|
||||
3. Attach the relevant log or crash report.
|
||||
|
||||
## Acceptance criteria
|
||||
|
||||
- [ ] The reproduction no longer fails.
|
||||
- [ ] A focused regression check covers the corrected behavior when practical.
|
||||
@@ -0,0 +1,21 @@
|
||||
---
|
||||
name: Implementation task
|
||||
about: A scoped feature, refactor, compatibility, or documentation task
|
||||
title: ""
|
||||
labels: type/feature
|
||||
assignees: ""
|
||||
---
|
||||
|
||||
## Goal
|
||||
|
||||
Describe the behavior or outcome this task should deliver.
|
||||
|
||||
## Acceptance criteria
|
||||
|
||||
- [ ] Add observable acceptance criteria.
|
||||
- [ ] Cover persistence, migration, or compatibility when applicable.
|
||||
- [ ] Record the validation required before closing the issue.
|
||||
|
||||
## Context
|
||||
|
||||
Link related issues, upstream references, and relevant design constraints.
|
||||
@@ -4,10 +4,17 @@ Rivencraft is a clean, incremental port of the ideas and gameplay of
|
||||
[Mystcraft Legacy](https://github.com/Mystcraft/Mystcraft-Legacy) to Minecraft
|
||||
1.21.1 on NeoForge.
|
||||
|
||||
The bootstrap and books/linking milestones are complete. The project currently
|
||||
provides functional Linking Books and randomly seeded, persistent vanilla-like
|
||||
Ages created from page-free Descriptive Books. Symbols, instability, and the
|
||||
full writing mechanics have not been ported yet.
|
||||
The bootstrap, books/linking, and Ages milestones are complete. Milestone 4 is
|
||||
building the writing system on a data-pack symbol catalog and persistent
|
||||
ordered-writing model. The project currently provides functional Linking Books
|
||||
and randomly seeded, persistent vanilla-like Ages created from page-free
|
||||
Descriptive Books. Instability and full symbol-to-world grammar interpretation
|
||||
have not been ported yet.
|
||||
|
||||
Milestone 4 now includes stackable blank Pages plus server-created symbol,
|
||||
unresolved-symbol, and baseline link-panel states. Page visuals follow the
|
||||
legacy runtime-composition rules; written-page creation will become available
|
||||
through the Writing Desk work that follows.
|
||||
|
||||
## Linking Book
|
||||
|
||||
@@ -60,6 +67,10 @@ according to the configured Return Link policy.
|
||||
|
||||
Server owners can set `descriptive_books.return_link_mode` in Rivencraft's
|
||||
server config to `ON_CREATION` (default), `ALWAYS`, or `DISABLED`.
|
||||
Age creation, persistence, lifecycle commands, configuration, backups, and
|
||||
administrator recovery are documented in [docs/AGES.md](docs/AGES.md).
|
||||
Data-pack runtime profiles are documented in
|
||||
[docs/AGE_PROFILES.md](docs/AGE_PROFILES.md).
|
||||
|
||||
## Requirements
|
||||
|
||||
@@ -77,6 +88,9 @@ view. Without either integration, Rivencraft uses its built-in animated linking
|
||||
panel. Clients can set `book_preview.mode` in
|
||||
`rivencraft-client.toml` to `AUTO`, `IMMERSIVE_PORTALS`, `PONDER`, or `LEGACY`.
|
||||
Unavailable optional renderers safely fall back to `LEGACY`.
|
||||
The complete backend matrix, supported combinations, cleanup behavior, and
|
||||
known upstream limits are documented in
|
||||
[docs/PREVIEW_COMPATIBILITY.md](docs/PREVIEW_COMPATIBILITY.md).
|
||||
|
||||
## Build and run
|
||||
|
||||
@@ -107,8 +121,8 @@ Mystcraft Legacy targets Forge for Minecraft 1.12.2. Rivencraft therefore
|
||||
ports one subsystem at a time onto current registries, codecs, data packs, and
|
||||
NeoForge APIs instead of importing the legacy source tree wholesale.
|
||||
|
||||
See [docs/PORTING.md](docs/PORTING.md) for the initial roadmap and provenance
|
||||
rules.
|
||||
See [docs/PORTING.md](docs/PORTING.md) for the roadmap, live Gitea tracking
|
||||
links, architectural direction, and provenance rules.
|
||||
|
||||
## License
|
||||
|
||||
|
||||
|
After Width: | Height: | Size: 553 KiB |
@@ -0,0 +1,109 @@
|
||||
# Age creation and administration
|
||||
|
||||
## Creation
|
||||
|
||||
A page-free Descriptive Book creates an Age when the player assigns a name and
|
||||
presses **Create**. Rivencraft immediately assigns a UUID, derives a unique
|
||||
Minecraft-safe dimension identifier from the requested name, rolls a seed and
|
||||
traits, and persists that definition before asking Dynamic Dimensions to create
|
||||
the runtime world. Names that normalize to the same identifier receive stable
|
||||
suffixes such as `_2` and `_3`.
|
||||
|
||||
The selected terrain profile, biome distribution, lighting, weather, celestial
|
||||
period, celestial angle, and phase are deterministic and become part of the
|
||||
saved definition. A five-by-five cobblestone platform with clear headroom is
|
||||
prepared at a safe arrival point. The completed book and every copy carrying
|
||||
the same UUID resolve to that definition.
|
||||
|
||||
Creating an Age can take several ticks. The book cannot be reopened while its
|
||||
creation request is active. If creation is interrupted after the definition is
|
||||
saved, using the book again resumes from the same immutable definition instead
|
||||
of rolling a replacement.
|
||||
|
||||
## Persistence
|
||||
|
||||
Rivencraft owns each Age definition for the lifetime of a world. A definition
|
||||
contains the Age UUID, canonical name, seed, generation version, runtime
|
||||
dimension identifier, spawn, and deterministic traits. Definitions are stored
|
||||
in the Overworld saved data and are never rerolled during ordinary loading.
|
||||
Runtime terrain and entity data remain in the normal world dimension storage
|
||||
managed by Minecraft and Dynamic Dimensions. Back up the complete world folder
|
||||
while the server is stopped; copying only a dimension folder does not preserve
|
||||
the authoritative Age registry.
|
||||
|
||||
## Lifecycle
|
||||
|
||||
An Age definition is created before its runtime dimension. If dimension
|
||||
creation is interrupted, the saved definition remains authoritative and the
|
||||
same Age is reconstructed the next time its Descriptive Book is used.
|
||||
|
||||
Registered Ages load when the server starts. A book also loads its destination
|
||||
on demand when an administrator previously unloaded it. Unloading retains the
|
||||
definition and world folder, so existing books continue to reference the same
|
||||
Age and later reload the same terrain.
|
||||
|
||||
Rivencraft does not automatically delete Ages. Safe permanent deletion needs a
|
||||
complete reference index for books in inventories, containers, Book Stands,
|
||||
and unloaded chunks. Until that exists, retaining the definition prevents an
|
||||
administrator action from silently orphaning books.
|
||||
|
||||
Destination-preview chunk loaders are temporary. Rivencraft releases them when
|
||||
the book closes, the player travels, the player disconnects, the destination
|
||||
Age is unloaded, or the server stops.
|
||||
|
||||
## Commands
|
||||
|
||||
The commands require permission level 2.
|
||||
|
||||
- `/rivencraft age list` lists every registered Age and whether its runtime
|
||||
dimension is currently loaded.
|
||||
- `/rivencraft age unload <dimension>` safely unloads one Age. Players in that
|
||||
Age are handled by Dynamic Dimensions, and its definition and world data are
|
||||
retained. Use the command suggestions to select a registered dimension.
|
||||
|
||||
Opening a Descriptive Book for an unloaded Age loads it again from its saved
|
||||
definition.
|
||||
|
||||
## Configuration
|
||||
|
||||
Rivencraft writes gameplay settings to the world/server configuration managed
|
||||
by NeoForge. `descriptive_books.return_link_mode` accepts:
|
||||
|
||||
- `ON_CREATION` (default): create one Return Link the first time a player
|
||||
enters each Age.
|
||||
- `ALWAYS`: create a Return Link after every successful Descriptive Book trip.
|
||||
- `DISABLED`: never create Return Links automatically.
|
||||
|
||||
Each client has a separate `rivencraft-client.toml`. Its `book_preview.mode`
|
||||
setting accepts `AUTO`, `IMMERSIVE_PORTALS`, `PONDER`, or `LEGACY`. This changes
|
||||
only presentation and cannot change server-side Age generation or travel
|
||||
validation. See [PREVIEW_COMPATIBILITY.md](PREVIEW_COMPATIBILITY.md) for the
|
||||
selection matrix and integration limits.
|
||||
|
||||
Runtime generation profiles are server data-pack resources. Their schema,
|
||||
override rules, reload behavior, and deterministic fallback are documented in
|
||||
[AGE_PROFILES.md](AGE_PROFILES.md).
|
||||
|
||||
## Administrator recovery
|
||||
|
||||
Use this sequence when a book cannot load an existing Age:
|
||||
|
||||
1. Stop the server and make a copy of the complete world folder.
|
||||
2. Start the server and run `/rivencraft age list`. Confirm that the expected
|
||||
canonical name and dimension identifier remain registered.
|
||||
3. If the Age is listed as unloaded, open its Descriptive Book to reload it.
|
||||
This keeps the UUID, seed, profile, traits, and existing world folder.
|
||||
4. If a data-pack profile is missing or invalid, restore or repair that pack,
|
||||
run `/reload`, then unload and reopen the Age. A removed custom profile uses
|
||||
the deterministic `rivencraft:standard` fallback and logs the substitution.
|
||||
5. If the definition is missing, restore the complete world backup. Moving a
|
||||
dimension folder into another world cannot reconstruct its UUID or books.
|
||||
6. If the definition exists but its dimension data is damaged, restore the
|
||||
matching dimension data and authoritative world saved data from the same
|
||||
backup generation. Do not combine them from different backups.
|
||||
|
||||
There is intentionally no delete command in Milestone 3. Do not manually
|
||||
delete an Age definition or rename its dimension folder: books may exist in
|
||||
inventories, containers, Book Stands, or unloaded chunks, and would be
|
||||
orphaned. `/rivencraft age unload` is the supported reversible maintenance
|
||||
operation.
|
||||
@@ -0,0 +1,50 @@
|
||||
# Age runtime profiles
|
||||
|
||||
Rivencraft loads Age runtime profiles from server data packs at
|
||||
`data/<namespace>/rivencraft/age_profiles/<name>.json`. The resulting profile ID
|
||||
is `<namespace>:<name>`. Profiles select registered world-generation resources;
|
||||
they do not contain an Age's seed, name, spawn, or rolled traits.
|
||||
|
||||
## Schema version 1
|
||||
|
||||
```json
|
||||
{
|
||||
"schema_version": 1,
|
||||
"terrain": "noise",
|
||||
"noise_settings": "minecraft:overworld",
|
||||
"biome_preset": "minecraft:overworld",
|
||||
"dimension_type": "minecraft:overworld"
|
||||
}
|
||||
```
|
||||
|
||||
`terrain` is `noise`, `flat`, or `void`. Noise profiles require
|
||||
`noise_settings` and `biome_preset` references. Every profile requires a
|
||||
`dimension_type` reference. Omitted resource references use the Overworld
|
||||
entry. Rivencraft validates all referenced entries against the loaded dynamic
|
||||
registries during data-pack reload. An invalid profile is rejected.
|
||||
|
||||
The built-in profile IDs are `rivencraft:standard`, `amplified`, `island`,
|
||||
`cave`, `flat`, and `void`. Their JSON files are ordinary built-in data-pack
|
||||
resources and can be overridden by a higher-priority pack. The example under
|
||||
`docs/example-age-profile-pack` can be copied into a world's `datapacks`
|
||||
directory. Valid custom profiles join the stable, sorted pool used when a new
|
||||
Age rolls its base terrain; the selected ID is then persisted with that Age.
|
||||
|
||||
## Persistence and reload behavior
|
||||
|
||||
An Age permanently stores its selected profile ID, generation version, seed,
|
||||
and rolled traits. `/reload` replaces the profile definitions but does not
|
||||
reroll those immutable values. An unloaded Age resolves its stored profile
|
||||
again when it loads, so intentional profile overrides affect its runtime
|
||||
resources and newly generated chunks.
|
||||
|
||||
A profile removed after an Age was created resolves to `rivencraft:standard`.
|
||||
The legacy `rivencraft:random_vanilla` alias also resolves to `standard`.
|
||||
Rivencraft logs this fallback. Invalid built-in overrides do not replace the
|
||||
required built-in definitions; a reload fails if a required built-in profile
|
||||
is absent after resource resolution.
|
||||
|
||||
Only schema version 1 is accepted. A future schema change must add an explicit
|
||||
migration path before incrementing the version. The saved Age generation
|
||||
version remains independent of this data-pack schema and is never silently
|
||||
rewritten.
|
||||
@@ -0,0 +1,16 @@
|
||||
# Asset provenance
|
||||
|
||||
Rivencraft reuses selected assets from
|
||||
[Mystcraft Legacy](https://github.com/Mystcraft/Mystcraft-Legacy) under that
|
||||
project's GNU LGPL v3 license. Rivencraft itself uses the same license.
|
||||
|
||||
| Rivencraft asset | Upstream asset | Upstream revision | Changes |
|
||||
| --- | --- | --- | --- |
|
||||
| `assets/rivencraft/textures/item/page.png` | `assets/mystcraft/textures/items/page_background.png` | `9bc8ddc061845df0cd5ea47f4fdef773cff786ae` | Namespace/path rename only |
|
||||
| `assets/rivencraft/textures/item/linking_book_unwritten.png` | `assets/mystcraft/textures/items/unlinked.png` | `9bc8ddc061845df0cd5ea47f4fdef773cff786ae` | Namespace/path rename only |
|
||||
| `assets/rivencraft/textures/item/page_link_panel.png` | `page_background.png` and `PageBuilder.BasicPageSprite` | `9bc8ddc061845df0cd5ea47f4fdef773cff786ae` | Reproduces the legacy 160 px scale, black panel at `(25,30)`–`(135,75)`, and 128 px resample |
|
||||
| `assets/rivencraft/textures/item/page_symbol*.png` and `page_unresolved.png` | `page_background.png`, `textures/symbolcomponents.png`, `WordData`, `ModSymbols`, and `PageBuilder.PageSprite` | `9bc8ddc061845df0cd5ea47f4fdef773cff786ae` | Static 1.21.1 renditions of the legacy runtime-composed four-word symbol pages; `normal_time` uses the legacy Full Length poem |
|
||||
|
||||
Mystcraft Legacy identifies XCompWiz as its project developer and includes the
|
||||
full LGPL v3 text in its root `LICENSE` file. Rivencraft's root `LICENSE`
|
||||
provides the same license terms.
|
||||
@@ -1,454 +1,86 @@
|
||||
# Porting plan
|
||||
# Porting roadmap
|
||||
|
||||
Mystcraft Legacy contains more than 700 Java source files and targets Minecraft
|
||||
1.12.2. The Minecraft world-generation, dimension, registry, networking, and
|
||||
rendering APIs have all changed substantially since that release. The port is
|
||||
split into independently testable milestones.
|
||||
Rivencraft ports Mystcraft Legacy from Minecraft 1.12.2 to NeoForge 1.21.1.
|
||||
The world-generation, dimension, registry, networking, and rendering APIs have
|
||||
changed substantially, so the work is divided into independently testable
|
||||
milestones.
|
||||
|
||||
## Project tracking
|
||||
|
||||
Gitea is the source of truth for project status:
|
||||
|
||||
- [Issues](https://gitea.tail180fb1.ts.net/dnorberg/rivencraft/issues) contain
|
||||
scoped implementation tasks, bugs, acceptance criteria, and technical
|
||||
discussion.
|
||||
- [Milestones](https://gitea.tail180fb1.ts.net/dnorberg/rivencraft/milestones)
|
||||
group issues into the porting phases below and show their live completion
|
||||
state.
|
||||
- [Releases](https://gitea.tail180fb1.ts.net/dnorberg/rivencraft/releases)
|
||||
contain user-facing changelogs for shipped versions.
|
||||
|
||||
New work should have an issue before implementation begins. Commits should
|
||||
reference the issue number when practical. A milestone closes only after its
|
||||
acceptance issue and all required implementation issues are complete.
|
||||
|
||||
## Milestones
|
||||
|
||||
1. **Bootstrap** — NeoForge 1.21.1 build, mod metadata, item registration, and
|
||||
CI. **Complete.**
|
||||
2. **Books and linking** — descriptive/linking book data components, lectern-like
|
||||
interaction, safe teleportation, and return links. **Complete.**
|
||||
3. **Ages** — dimension definitions backed by data packs, deterministic seeds,
|
||||
lifecycle management, and persistence. Make the legacy-style animated
|
||||
linking panel the built-in destination preview. Provide optional
|
||||
Create/Ponder and Immersive Portals integrations as alternative rotating-
|
||||
snapshot renderers. The configurable preview modes are `AUTO`,
|
||||
`IMMERSIVE_PORTALS`, `PONDER`, and `LEGACY`; `AUTO` prefers Immersive
|
||||
Portals when it is installed, then Create/Ponder, and finally the built-in
|
||||
legacy animation.
|
||||
2. **Books and linking** — Descriptive and Linking Book data, Book Stands,
|
||||
safe teleportation, return links, book screens, and destination previews.
|
||||
**Complete.**
|
||||
3. **Ages** — persistent generated dimensions, deterministic traits,
|
||||
lifecycle management, data-pack integration, and optional destination
|
||||
renderer compatibility. **Complete.** See
|
||||
[Milestone 3](https://gitea.tail180fb1.ts.net/dnorberg/rivencraft/milestone/8).
|
||||
4. **Writing system** — pages, symbols, notebooks, desks, and book assembly.
|
||||
**In progress.**
|
||||
5. **Age grammar** — translate symbol combinations into modern biome, noise,
|
||||
dimension-type, and worldgen configuration. Optional integrations with
|
||||
TerraBlender provide composable biome-region generation, while Serene
|
||||
Seasons and Ecliptic Seasons allow Age generation to participate in their
|
||||
respective seasonal systems. True Always Snow weather will be introduced
|
||||
with these season integrations; until then, its persisted trait uses
|
||||
biome-dependent precipitation. None of these integrations are required for
|
||||
Rivencraft's core world generation.
|
||||
6. **Instability** — deterministic validation and effects with server-safe
|
||||
behavior.
|
||||
dimension-type, and world-generation configuration. Optional integrations
|
||||
may add composable biome regions and seasonal behavior.
|
||||
6. **Instability** — deterministic validation and server-safe effects.
|
||||
7. **Structures and polish** — libraries, crystals, portals, recipes, models,
|
||||
sounds, advancements, compatibility, and migration tests.
|
||||
|
||||
## Architectural direction
|
||||
|
||||
Age references use UUIDs rather than dimension keys. The server-owned Age
|
||||
registry maps each stable identity to its immutable definition and runtime
|
||||
dimension, keeping saved books valid if an Age is migrated or regenerated.
|
||||
Operational lifecycle and unload behavior are documented in
|
||||
[AGES.md](AGES.md). The server data-pack schema for runtime generation is
|
||||
documented in [AGE_PROFILES.md](AGE_PROFILES.md).
|
||||
|
||||
The core mod must remain usable without Create, Ponder, or Immersive Portals.
|
||||
The built-in legacy animation is the dependency-free destination preview.
|
||||
Optional preview modes may use Create/Ponder snapshots or Immersive Portals
|
||||
live rendering when their dependencies are installed. The tested selection
|
||||
matrix and integration boundaries are documented in
|
||||
[PREVIEW_COMPATIBILITY.md](PREVIEW_COMPATIBILITY.md).
|
||||
|
||||
The writing system and Age grammar will build on the existing page-free Age
|
||||
path. Page-free books remain a useful deterministic fallback and test fixture
|
||||
after written symbol combinations become available.
|
||||
|
||||
Milestone 4 begins with a versioned, data-pack-defined symbol catalog and an
|
||||
immutable ordered-writing model. See [WRITING_DATA.md](WRITING_DATA.md). These
|
||||
contracts preserve unknown symbol identifiers and store author intent; they do
|
||||
not interpret symbols into Age generation, which remains Milestone 5 work.
|
||||
|
||||
## Provenance rules
|
||||
|
||||
- New code uses the `net.dnorberg.rivencraft` package.
|
||||
- Adapted Mystcraft code must retain its upstream copyright notice and be
|
||||
tracked in this document or a nearby source comment.
|
||||
- Do not copy generated, binary, or third-party dependency content from the
|
||||
- Reused legacy art is recorded in [ASSET_PROVENANCE.md](ASSET_PROVENANCE.md).
|
||||
- Adapted Mystcraft code retains its upstream copyright notice and is tracked
|
||||
in a nearby source comment or commit.
|
||||
- Generated, binary, and third-party dependency content is not copied from the
|
||||
legacy repository.
|
||||
- Preserve LGPL-3.0-or-later compatibility for the complete distributed mod.
|
||||
- The complete distributed mod remains compatible with LGPL-3.0-or-later.
|
||||
|
||||
## First vertical slice
|
||||
## Release policy
|
||||
|
||||
The first functional target is: create a Descriptive Book, bind it to one
|
||||
server-managed Age definition, travel to that Age, and use a Linking Book to
|
||||
return. This exercises persistence, networking, dimensions, and safety before
|
||||
the symbol grammar is introduced.
|
||||
|
||||
### Milestone 2 progress
|
||||
|
||||
- [x] Persistent, network-synchronized link-target data component.
|
||||
- [x] Linking Book binding with dimension, block position, yaw, and pitch.
|
||||
- [x] Server-authoritative cross-dimension travel with world-border, collision,
|
||||
and fluid checks.
|
||||
- [x] Nearby landing search and clear failure messages.
|
||||
- [x] Descriptive Book identity and Age reference components.
|
||||
- [x] Temporary vanilla-dimension Descriptive Book travel with return-link creation.
|
||||
- [x] Lectern-to-Book-Stand conversion, displayed book, activation, removal,
|
||||
persistence, and drops.
|
||||
- [x] Book-screen foundation with server-authoritative naming, binding, and
|
||||
explicit link activation.
|
||||
- [x] Ponder dependency and isolated destination-preview level boundary.
|
||||
- [x] Server-provided destination snapshots rendered as rotating Ponder scenes.
|
||||
- [x] Book Stand floating names synchronized from the stored book stack.
|
||||
- [x] Open the stored book screen from a Book Stand with server-validated linking.
|
||||
- [x] Automated in-game tests for binding, persistence, and travel.
|
||||
|
||||
The temporary shapeless Linking Book recipe makes the linking subsystem easy
|
||||
to test. It can move into the writing/bookbinder progression when that system
|
||||
is implemented.
|
||||
|
||||
Age references use UUIDs rather than dimension keys. Milestone 3 will own the
|
||||
mapping from that stable identity to server data and a runtime dimension. This
|
||||
keeps saved books valid if an Age is migrated or regenerated.
|
||||
|
||||
Vanilla lecterns accept extensible item tags when inserting books, but their
|
||||
block entity still validates only vanilla writable and written books. To avoid
|
||||
an invalid lectern state, inserting a Rivencraft book converts the lectern into
|
||||
a visually compatible Rivencraft Book Stand. Removing the book converts it
|
||||
back.
|
||||
|
||||
Mystcraft Legacy did not impose an item cooldown when linking. Rivencraft's
|
||||
initial cooldown used Minecraft's item-type cooldown system, which delayed all
|
||||
Linking Book stacks at once. Version 0.1.3 removes that cooldown to match the
|
||||
legacy behavior.
|
||||
|
||||
Version 0.1.4 moves Linking Book binding and travel behind a book screen. The
|
||||
client requests an action, while the server revalidates the held book and owns
|
||||
all changes to its destination and custom name. Descriptive Book Age references
|
||||
now carry a display name alongside their stable UUID, with backward-compatible
|
||||
decoding for existing UUID-only data.
|
||||
|
||||
Version 0.1.5 ensures the book interaction listener opens screens only for the
|
||||
logical-client event. This avoids calling the render system from the integrated
|
||||
server thread when a book is used in singleplayer.
|
||||
|
||||
Version 0.1.6 gives the Linking Book screen an open-book layout inspired by the
|
||||
legacy interface. The destination preview occupies the left page, the book name
|
||||
and destination details occupy the right page, and the preview itself is the
|
||||
link action; the separate Link and Done buttons have been removed.
|
||||
|
||||
Version 0.1.7 suppresses Minecraft's default full-screen menu blur for the
|
||||
Linking Book screen. The open-book texture supplies the GUI background while
|
||||
the world remains sharp behind it.
|
||||
|
||||
Version 0.1.8 renders all Linking Book destination details in the same dark ink
|
||||
color as the book name for consistent contrast against the parchment.
|
||||
|
||||
Version 0.1.9 synchronizes the Book Stand's stored stack to clients and renders
|
||||
its display name as a camera-facing label above the book.
|
||||
|
||||
Version 0.1.10 corrects the nameplate transform and matches Minecraft's normal
|
||||
plus see-through text passes so angled stand geometry cannot hide the label.
|
||||
|
||||
Version 0.1.11 opens the stored book interface when a Book Stand is used with
|
||||
an empty hand. Linking Books travel through the preview panel, and the server
|
||||
revalidates the stand position, interaction distance, stored item, and target.
|
||||
|
||||
Version 0.1.12 replaces the Linking Book screen's convenience text draws with
|
||||
explicit no-shadow rendering for clearer dark ink on the parchment texture.
|
||||
|
||||
Version 0.1.13 requests a bounded, server-validated 9-by-7-by-9 block snapshot
|
||||
from the held book or nearby Book Stand and renders it as a clipped, rotating
|
||||
Ponder world section on the Linking Book's left page.
|
||||
|
||||
Version 0.1.14 expands the destination snapshot to 9-by-7-by-17 blocks along
|
||||
the Z axis, rescales the rotating scene to expose that depth, and colors the
|
||||
panel background with the destination biome's sky color.
|
||||
|
||||
Version 0.1.15 adds three dedicated-server GameTests covering Linking Book
|
||||
component serialization, successful safe travel with restored orientation, and
|
||||
rejection of fully blocked destinations. The test suite uses a minimal bundled
|
||||
structure template and runs with `./gradlew runGameTestServer`.
|
||||
|
||||
Version 0.1.16 makes destination previews sample a centered 17-by-7-by-17
|
||||
volume. The Ponder scene uses a scale that keeps its full horizontal diagonal
|
||||
inside the panel, so the complete snapshot remains available during its orbit.
|
||||
|
||||
Version 0.1.17 changes destination previews to a 9-by-128-by-9 volume: a
|
||||
square horizontal footprint with a vertical slice spanning 64 blocks below and
|
||||
63 blocks above the recorded linking location.
|
||||
|
||||
Version 0.1.18 changes the preview cache to 9-by-64-by-9, spanning 32 blocks
|
||||
below and 31 above the link point. Its camera is centered on a 9-by-7-by-9
|
||||
window around the link point so the book retains a readable close-up.
|
||||
|
||||
Version 0.1.19 renders the complete 9-by-64-by-9 snapshot in that Ponder
|
||||
scene while retaining the target-centered camera framing.
|
||||
|
||||
Version 0.1.20 uses a cubic 18-by-18-by-18 snapshot. The renderer remaps the
|
||||
link point within that cube so its existing target-centered camera framing is
|
||||
unchanged.
|
||||
|
||||
Version 0.1.21 treats air and leaf blocks as passable linking destinations;
|
||||
links no longer require a solid floor beneath the player.
|
||||
|
||||
Version 0.2.0 completes Milestone 2. Until Milestone 3 provides generated Age
|
||||
dimensions, Descriptive Book UUIDs deterministically resolve to vanilla
|
||||
dimensions and create a bound Return Link to the source on successful travel.
|
||||
|
||||
Version 0.2.1 gives Descriptive Books the same open-parchment layout and
|
||||
left-page link interaction as Linking Books.
|
||||
|
||||
Version 0.2.2 adds the same server-provided Ponder destination preview to
|
||||
Descriptive Books. If no snapshot is available, the left page shows an
|
||||
animated linking-panel fallback.
|
||||
|
||||
Version 0.2.3 requires Descriptive Book destinations to have a sturdy floor,
|
||||
while Linking Books continue to permit passable floorless destinations.
|
||||
|
||||
Version 0.2.4 expands Descriptive Book arrival validation with an outward,
|
||||
terrain-aware search for an alternate grounded location near an unsafe target.
|
||||
|
||||
Version 0.2.5 uses dimension-appropriate preview skies for vanilla Nether and
|
||||
End destinations instead of their inherited Overworld biome sky tint.
|
||||
|
||||
Version 0.2.6 expands destination snapshots to a 32-by-32-by-32 cube while
|
||||
keeping the existing target-centered Ponder camera position.
|
||||
|
||||
Version 0.2.7 persists each Age's first successful visit and creates its
|
||||
Return Link only for that initial arrival.
|
||||
|
||||
Version 0.2.8 makes Return Link creation a server setting: `ON_CREATION`
|
||||
(default), `ALWAYS`, or `DISABLED`.
|
||||
|
||||
Version 0.2.9.0 begins Milestone 3 with a server-owned, world-persistent Age
|
||||
registry. Each Age UUID resolves exactly once to an immutable random seed,
|
||||
generation profile, generation-version marker, canonical name, and creation
|
||||
time. The temporary vanilla-dimension adapter remains in place until runtime
|
||||
Age dimensions are introduced by a later release slice.
|
||||
|
||||
Version 0.2.10.0 makes page-free Descriptive Books playable. Naming an
|
||||
unwritten book creates a dedicated, persistent vanilla-like Age through the
|
||||
Dynamic Dimensions API. Each Age reloads with its server, retains its terrain,
|
||||
and receives a five-by-five cobblestone platform with cleared arrival headroom.
|
||||
|
||||
Version 0.2.10.1 improves Age arrival placement. Non-Nether Ages select the
|
||||
highest sturdy surface near the origin and fall back to a platform at Y=63 when
|
||||
no suitable natural footing exists.
|
||||
|
||||
Version 0.2.10.2 allows leaf blocks to count as proper natural footing when
|
||||
selecting the highest arrival surface.
|
||||
|
||||
Version 0.2.10.3 scans each candidate column downward from the dimension's top
|
||||
before choosing footing, preventing cave floors from being selected as the Age
|
||||
arrival surface. Columns covered by fluid remain ineligible.
|
||||
|
||||
Version 0.2.10.4 restores Mystcraft Legacy's standard linking sound for both
|
||||
Linking and Descriptive Books. Successful travel plays the sound at its source
|
||||
and destination with the legacy volume and pitch variation.
|
||||
|
||||
Version 0.2.10.5 derives each new Age's saved dimension folder from its
|
||||
player-assigned name. Names are converted to safe lowercase resource paths,
|
||||
and folder conflicts receive `_2`, `_3`, and later numeric suffixes. Existing
|
||||
UUID-based dimension folders remain unchanged for save compatibility.
|
||||
|
||||
Version 0.2.10.6 prevents a Descriptive Book from reopening while its Age is
|
||||
being generated. Screen opening now waits for the server's current copy of the
|
||||
held or displayed book, so a delayed interaction opens only the completed Age.
|
||||
|
||||
Version 0.2.11.0 adds a dependency-free, legacy-style portal bloom as the
|
||||
fallback destination preview for Linking and Descriptive Books. Clients with
|
||||
Create installed retain the rotating Ponder snapshot; clients without Create
|
||||
use the destination-tinted animation with the original effect's paired noisy
|
||||
spirals.
|
||||
|
||||
Version 0.2.11.1 makes Create genuinely optional. Ponder remains a compile-time
|
||||
API for the Create integration, while generated mod metadata no longer requires
|
||||
Ponder and marks Create as an optional client dependency.
|
||||
|
||||
Version 0.2.12.0 introduces the first legacy-inspired Age generator profiles.
|
||||
New page-free Ages deterministically select and persist Standard, Amplified,
|
||||
Island, Cave, Flat, or Void base terrain. Existing `random_vanilla` Ages remain
|
||||
mapped to their original Overworld generator for save compatibility. Terrain
|
||||
alterations such as Skylands, Tendrils, Spheres, and Floating Islands remain
|
||||
future Age-grammar work layered above these base profiles.
|
||||
|
||||
Version 0.2.12.1 displays the persisted terrain generator on the description
|
||||
side of written Descriptive Books. Newly written books receive the synchronized
|
||||
profile immediately, while older books are backfilled from the server-owned Age
|
||||
registry when opened.
|
||||
|
||||
Version 0.2.13.0 constructs Standard, Amplified, Cave, and Island terrain from
|
||||
Minecraft's worldgen registries instead of borrowing generator instances from
|
||||
the vanilla levels. Noise settings and biome-source parameter lists therefore
|
||||
honor the server's loaded data packs. Automated coverage also verifies that a
|
||||
live Age's seed equals its immutable saved definition; Dynamic Dimensions
|
||||
derives both from the Overworld seed and the Age dimension identifier.
|
||||
|
||||
Version 0.2.16.13 gives Cave and Island/Skylands Ages Overworld biomes, sky,
|
||||
weather, lighting, and day/night behavior while retaining distinct terrain.
|
||||
Caves remain enclosed. Skylands use Minecraft's uniform floating-island noise
|
||||
and Overworld-like surfaces without the End's central dragon island.
|
||||
|
||||
Version 0.2.16.14 replaces the Explore text control with a compact eye symbol.
|
||||
Books opened from a Book Stand display the control disabled, preventing
|
||||
exploration while the book is mounted.
|
||||
|
||||
Version 0.2.16.15 restores Immersive Portals chunk loading for snapshots opened
|
||||
from Book Stands. Snapshot chunk loading is independent from whether the Explore
|
||||
control is enabled, so mounted books retain live terrain without allowing the
|
||||
player to enter Explore mode.
|
||||
|
||||
Version 0.2.17.0 begins persistent random Age traits. New page-free Ages select
|
||||
and save a legacy-inspired biome distribution, lighting mode, weather mode, and
|
||||
celestial period, angle, and phase. The celestial ranges follow Legacy's random
|
||||
symbol fallbacks: period 0.2–2.0, angle 0–360 degrees, and phase 0–1. Existing
|
||||
Ages load with normal Legacy defaults instead of being rerolled. This immutable
|
||||
trait layer is the foundation for applying each choice to modern worldgen.
|
||||
|
||||
Version 0.2.18.0 applies each Age's persisted lighting trait to its runtime
|
||||
dimension. Normal Lighting retains Overworld skylight and ambient brightness;
|
||||
Bright Lighting uses Legacy's 0.25 ambient-light floor; Dark Lighting disables
|
||||
dimension skylight while retaining local block light. The latter is the closest
|
||||
server-safe modern equivalent to Legacy's removed per-dimension light-table
|
||||
scaling hook.
|
||||
|
||||
Version 0.2.18.1 prevents Cave Ages from choosing a spawn on their upper roof.
|
||||
Their grounded arrival search now begins with the floor below player Y=64 and
|
||||
works downward. If it finds no suitable footing, the existing floor-Y=63
|
||||
platform fallback places the player at Y=64.
|
||||
|
||||
Version 0.2.19.0 applies persisted weather traits to loaded Ages. Normal uses
|
||||
Minecraft's normal weather cycle. Fast and Slow use Legacy's original duration
|
||||
and cooldown ranges at half and double normal speed for Minecraft's combined
|
||||
rain/thunder weather timer. Off keeps an Age clear;
|
||||
Always, Cloudy, Rain, and Snow maintain non-thundering precipitation; Storm
|
||||
maintains rain and thunder. Minecraft still chooses rain versus snow from biome
|
||||
temperature, so dedicated Snow/Rain biome overrides remain future work.
|
||||
|
||||
Version 0.2.20.0 applies persisted celestial timing to each Age. The saved
|
||||
period controls NeoForge's per-dimension clock rate, with a period of 1 matching
|
||||
a vanilla 20-minute day, 0.2 running five times faster, and 2 running at half
|
||||
speed. The saved phase sets the clock only during first-spawn initialization;
|
||||
later loads continue from saved world time. Celestial angle remains persisted
|
||||
for a future custom sky renderer because vanilla dimension data cannot rotate
|
||||
the sun's render plane.
|
||||
|
||||
Version 0.2.20.1 restores Legacy's Zero Length celestial modifier as a rarer
|
||||
random outcome using its effective one-in-seven grammar weight. Zero Length
|
||||
freezes an Age at its generated phase without changing the global daylight
|
||||
cycle, while nonzero Ages retain their independently scaled clocks.
|
||||
|
||||
Version 0.2.20.2 gives Zero Length Ages a stationary per-dimension clock rate
|
||||
instead of advancing and correcting their time once per tick. This keeps the
|
||||
integer day time fixed while preventing the client skybox from visually
|
||||
bouncing between adjacent celestial positions.
|
||||
|
||||
Version 0.2.21.0 begins applying persisted biome-distribution traits. Native
|
||||
Distribution retains Minecraft's data-pack-aware Overworld climate source.
|
||||
Single Biome Distribution deterministically selects one registered biome from
|
||||
the Age seed and uses it throughout compatible noise-based terrain. Flat and
|
||||
Void profiles retain their profile-specific biome sources. Legacy's scaled,
|
||||
tiled, and grid layouts require dedicated modern biome sources and remain the
|
||||
next distribution work.
|
||||
|
||||
Version 0.2.21.1 changes Cave Ages from Nether noise settings to Minecraft's
|
||||
cave noise settings. Caves remain enclosed, but use stone, water, and
|
||||
Overworld-like surfaces together with the persisted Native or Single biome
|
||||
distribution. This prevents Nether terrain generation from leaking into newly
|
||||
generated Cave Age chunks.
|
||||
|
||||
Version 0.2.22.0 applies Tiled Biome Distribution using two deterministic
|
||||
Age-seeded biomes in the legacy diagonal-checkerboard layout. Each square is
|
||||
16 chunks (256 blocks) wide, matching Mystcraft Legacy's coordinate shift, and
|
||||
uses Minecraft's serializable checkerboard biome source so the layout remains
|
||||
stable across server reloads.
|
||||
|
||||
Version 0.2.22.1 includes the server-owned Age traits in the validated
|
||||
Descriptive Book screen response and displays the terrain, biome distribution,
|
||||
lighting, weather, day length, celestial angle, and celestial phase on the
|
||||
book's right-hand description page. This works for held books and Book Stands
|
||||
without copying mutable Age-generation data onto the item.
|
||||
|
||||
Version 0.2.23.0 applies Grid Biome Distribution using two deterministic
|
||||
Age-seeded biomes in Legacy's diagonal checkerboard layout. Each cell is one
|
||||
16-by-16-block chunk, and the built-in serializable biome source reconstructs
|
||||
the same layout whenever the Age reloads.
|
||||
|
||||
Version 0.2.24.0 applies Tiny Biome Distribution using three deterministic
|
||||
Age-seeded biomes and softly bounded seeded regions. Tiny begins at Legacy's
|
||||
smallest 16-block nominal scale; the serializable biome source retains its
|
||||
seed, selected biomes, and scale across Age reloads.
|
||||
|
||||
Version 0.2.25.0 completes the scaled biome distributions. Small, Medium,
|
||||
Large, and Huge reuse Tiny's seeded, softly bounded regions at nominal widths
|
||||
of 32, 64, 128, and 256 blocks. Every size selects three deterministic biomes
|
||||
and serializes the selection, Age seed, and scale with the runtime dimension.
|
||||
|
||||
Version 0.2.25.1 applies biome-specific material rules without replacing an
|
||||
Age's selected terrain profile. End biome columns generate from End stone;
|
||||
Nether biome columns use Minecraft's Nether surface rules for netherrack,
|
||||
soul sand, basalt, and nylium instead of inheriting Overworld blocks.
|
||||
|
||||
Version 0.2.26.0 applies each Age's persisted celestial angle to the client
|
||||
sky. The sun, moon, and stars follow a plane rotated by the saved Legacy-style
|
||||
angle in normal gameplay and Immersive Portals previews, while vanilla
|
||||
dimensions retain their standard celestial path.
|
||||
|
||||
Version 0.2.26.1 rotates the celestial path around the world's vertical axis,
|
||||
allowing the saved angle to change each Age's sunrise and sunset compass
|
||||
direction instead of merely tilting the rendered path.
|
||||
|
||||
Version 0.2.14.0 restores the legacy Linking and Descriptive Book artwork for
|
||||
inventory items and gives each book its matching open-book texture when placed
|
||||
on a Book Stand. Return Linking Books created inside another Age also retain and
|
||||
display that Age's saved name instead of exposing its dimension identifier.
|
||||
|
||||
Version 0.2.14.1 gives every newly bound Linking Book a friendly destination
|
||||
label. Standard books and Return Links use saved Age names inside Rivencraft
|
||||
Ages and the familiar Overworld, The Nether, and The End names in vanilla
|
||||
dimensions. Existing vanilla links receive the same presentation at display
|
||||
time without requiring item migration.
|
||||
|
||||
Version 0.2.15.0 adds the client-side book-preview mode configuration and the
|
||||
selection policy for `AUTO`, `IMMERSIVE_PORTALS`, `PONDER`, and `LEGACY`.
|
||||
`AUTO` uses Ponder when Create is present and otherwise uses the built-in
|
||||
legacy animation. Explicit optional modes fall back to `LEGACY` when their
|
||||
renderer is unavailable.
|
||||
|
||||
Version 0.2.16.0 implements the optional Immersive Portals GUI renderer. Its
|
||||
default view orbits the live destination like the Ponder snapshot. The Explore
|
||||
control switches to a movable remote camera using movement keys and mouse drag;
|
||||
right-click resets the camera and restores the passive book GUI. A validated
|
||||
per-player chunk loader exists only while the screen is open and is released
|
||||
on close. `AUTO` now prefers Immersive Portals, then Ponder, then `LEGACY`.
|
||||
|
||||
Version 0.2.16.1 corrects Immersive Portals detection to use its NeoForge mod
|
||||
ID, `immersive_portals_core`. Rivencraft now also refreshes Immersive Portals'
|
||||
integer dimension map whenever saved or newly created Ages are loaded, before
|
||||
their chunks can be synchronized to a player.
|
||||
|
||||
Version 0.2.16.2 routes book travel through Immersive Portals' seamless
|
||||
teleport API when that mod is installed, preserving its client-world registry
|
||||
during links between Ages and vanilla dimensions. The Explore control is also
|
||||
positioned fully below the live snapshot window on both book screens.
|
||||
|
||||
Version 0.2.16.3 restores the full window viewport immediately after drawing
|
||||
an Immersive Portals snapshot. Book titles, destination details, and controls
|
||||
therefore render in their normal page positions instead of being compressed
|
||||
inside the snapshot rectangle.
|
||||
|
||||
Version 0.2.16.4 clears the Immersive Portals GUI framebuffer between remote
|
||||
world renders, preventing moving camera frames from accumulating into a sky
|
||||
smear. The framebuffer now follows Immersive Portals' shared-target lifecycle
|
||||
so a queued end-of-frame render cannot target a texture destroyed on GUI close.
|
||||
|
||||
Version 0.2.16.5 expands live-preview chunk loading to Immersive Portals'
|
||||
reference eight-chunk radius. Rivencraft prepares the central 3x3 destination
|
||||
chunks and requests an immediate tracking update when the GUI opens, providing
|
||||
terrain for the first useful snapshot while the remaining chunks stream in.
|
||||
|
||||
Version 0.2.16.6 makes Linking and Descriptive Book screens non-pausing. The
|
||||
integrated server now continues ticking in single-player while a book is open,
|
||||
allowing live preview chunks to generate and stream into the snapshot.
|
||||
|
||||
Version 0.2.16.7 handles configured movement bindings directly in both book
|
||||
screens while Explore mode is active. Movement, jump, and sneak now move the
|
||||
remote camera even though Minecraft suspends normal gameplay key states while
|
||||
a GUI is open.
|
||||
|
||||
Version 0.2.16.8 links Explore mode to real player movement in the current
|
||||
dimension. Entering Explore anchors the source player and destination camera;
|
||||
walking, jumping, falling, or being moved shifts the snapshot camera by the
|
||||
same displacement while the book remains open and normal collision still
|
||||
applies.
|
||||
|
||||
The preview code is separated behind a renderer interface and uses an isolated
|
||||
Ponder level populated from server-authoritative destination snapshots.
|
||||
|
||||
## Version policy
|
||||
|
||||
Versions follow `x.y.z.b`:
|
||||
|
||||
- `x`: major release point.
|
||||
- `y`: number of completed milestones.
|
||||
- `z`: release slice within the active milestone.
|
||||
- `b`: bug-fix and additional-work iteration within that release slice.
|
||||
|
||||
Starting a release slice increments `z` and resets `b` to zero. Completing a
|
||||
milestone increments `y` and resets both `z` and `b` to zero. The first
|
||||
milestone-2 slice is therefore `0.1.1.0`; a fix on that slice is `0.1.1.1`;
|
||||
and milestone 2 completion is `0.2.0.0`.
|
||||
|
||||
## Milestone 1 acceptance record
|
||||
|
||||
- The project builds on a Java 21 JDK with `./gradlew build`.
|
||||
- Mod identity and dependencies are declared in generated NeoForge metadata.
|
||||
- Registrations are isolated by registry type and use deferred registration.
|
||||
- The Descriptive Book loads with a model, name, tooltip, and creative tab.
|
||||
- CI builds every pushed commit and pull request.
|
||||
The version scheme is documented in the project README. Every published
|
||||
version receives a Gitea release containing its changelog, built mod JAR, and
|
||||
SHA-256 checksum. Release notes describe user-visible behavior, compatibility
|
||||
changes, migrations, and validation performed for that version; ongoing task
|
||||
notes stay in issues.
|
||||
@@ -0,0 +1,78 @@
|
||||
# Destination preview compatibility
|
||||
|
||||
Rivencraft has three destination preview backends. The selected backend is a
|
||||
client presentation detail; the server validates travel and Age generation is
|
||||
independent of every preview integration.
|
||||
|
||||
## Selection matrix
|
||||
|
||||
Set `book_preview.mode` in `rivencraft-client.toml`.
|
||||
|
||||
| Configured mode | Immersive Portals installed | Create/Ponder installed | Selected backend |
|
||||
| --- | --- | --- | --- |
|
||||
| `AUTO` | yes | either | Immersive Portals |
|
||||
| `AUTO` | no | yes | Ponder snapshot |
|
||||
| `AUTO` | no | no | built-in legacy animation |
|
||||
| `IMMERSIVE_PORTALS` | yes | either | Immersive Portals |
|
||||
| `IMMERSIVE_PORTALS` | no | either | built-in legacy animation |
|
||||
| `PONDER` | either | yes | Ponder snapshot |
|
||||
| `PONDER` | either | no | built-in legacy animation |
|
||||
| `LEGACY` | either | either | built-in legacy animation |
|
||||
|
||||
Explicit optional modes fall back directly to `LEGACY`. They do not silently
|
||||
select the other optional integration. GameTests exercise every row and every
|
||||
dependency-presence permutation.
|
||||
|
||||
## Book behavior
|
||||
|
||||
Held Linking and Descriptive Books render the selected backend in the preview
|
||||
panel. Immersive Portals additionally exposes **Explore**: the player remains
|
||||
at the opening position, mouse look controls the remote camera, and
|
||||
right-click returns to the standard book view.
|
||||
|
||||
Books on a Book Stand use the same preview panel, but Explore is disabled so
|
||||
the player cannot move away and leave a remote preview session owned by the
|
||||
stand screen. Closing either screen releases its server chunk loader. Linking,
|
||||
disconnecting, unloading the destination Age, and stopping the server also
|
||||
release affected loaders.
|
||||
|
||||
The Immersive Portals backend force-loads the initial 3 by 3 destination area
|
||||
before registering its wider preview chunk loader. The Ponder backend clears
|
||||
the previous snapshot before applying replacement block data. The live backend
|
||||
clears its framebuffer on each render and restores the Minecraft viewport
|
||||
afterward. These rules prevent stale snapshot frames and book UI elements from
|
||||
being captured in the preview.
|
||||
|
||||
## Supported combinations and upstream limits
|
||||
|
||||
The compatibility baseline is Minecraft 1.21.1, NeoForge 21.1.251, Create
|
||||
6.0.10, and Immersive Portals 6.0.7. Core Age generation and the `LEGACY`
|
||||
backend run without Create or Immersive Portals; the headless GameTest server
|
||||
uses that dependency-free path.
|
||||
|
||||
Immersive Portals 6.0.7 is incompatible with Sodium 0.8.13 for Minecraft
|
||||
1.21.1: its Sodium compatibility mixin references the removed
|
||||
`OcclusionCuller.Visitor` class and crashes while entering a world. Sodium
|
||||
0.6.13 avoids that specific mixin failure. This compatibility boundary belongs
|
||||
to Immersive Portals and Sodium, before Rivencraft's preview code runs.
|
||||
|
||||
Immersive Portals reports that some Create contraptions can be invisible when
|
||||
the two mods are installed together. Rivencraft does not replace either mod's
|
||||
world or contraption renderer, so this remains an upstream rendering limit.
|
||||
The `PONDER` or `LEGACY` mode is the supported fallback when live rendering is
|
||||
unstable in a particular graphics or mod configuration.
|
||||
|
||||
## Release verification
|
||||
|
||||
For preview-related releases:
|
||||
|
||||
1. Run `./gradlew runGameTestServer` to verify the complete selection matrix,
|
||||
core Age creation, persistence, and travel without optional renderers.
|
||||
2. Open held Linking and Descriptive Books once with each available backend.
|
||||
3. Open both book types from a Book Stand and confirm Explore is disabled.
|
||||
4. With Immersive Portals, enter and leave Explore, travel between dimensions,
|
||||
close the screen, and disconnect; confirm destination chunks render and no
|
||||
preview loader remains active.
|
||||
5. With Ponder, reopen different destinations and confirm the previous
|
||||
snapshot does not bleed into the next one.
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
# Writing and symbol data
|
||||
|
||||
Milestone 4 stores what a player wrote without deciding what that writing does
|
||||
to an Age. Milestone 5 owns grammar validation, symbol interaction, instability,
|
||||
and translation into biome, noise, dimension-type, and other world-generation
|
||||
configuration.
|
||||
|
||||
## Symbol catalog
|
||||
|
||||
The authoritative server catalog loads JSON resources from
|
||||
`data/<namespace>/rivencraft/symbols/<path>.json`. The resource ID is the
|
||||
symbol ID. For example, `data/rivencraft/rivencraft/symbols/terrain/standard.json`
|
||||
defines `rivencraft:terrain/standard`.
|
||||
|
||||
Schema version 1 contains display metadata only:
|
||||
|
||||
```json
|
||||
{
|
||||
"schema_version": 1,
|
||||
"name": "symbol.rivencraft.terrain.standard",
|
||||
"description": "symbol.rivencraft.terrain.standard.description",
|
||||
"category": "rivencraft:terrain"
|
||||
}
|
||||
```
|
||||
|
||||
`name` and `description` are translation keys, not arbitrary formatted text or
|
||||
executable behavior. `category` is a namespaced organizational identifier.
|
||||
Invalid definitions are logged and excluded by the server. Menus and future
|
||||
page synchronization must obtain resolved display metadata from the server;
|
||||
clients never make a symbol valid by naming it.
|
||||
|
||||
Rivencraft ships a small catalog covering terrain, biomes, lighting, weather,
|
||||
celestial behavior, and features. It exists to exercise the complete writing
|
||||
workflow before Milestone 5 implements the full legacy grammar.
|
||||
|
||||
## Persistent writing
|
||||
|
||||
`SymbolReference` stores only a namespaced symbol ID. `WritingEntry` is either
|
||||
a symbol reference or a baseline link-panel marker. `OrderedWriting` retains up
|
||||
to 256 entries in exact player-authored order. All three contracts have both
|
||||
persistent codecs and bounded network codecs.
|
||||
|
||||
Removing a data pack never removes its IDs from saved writing. A missing ID is
|
||||
resolved as client-safe **Unresolved Symbol** display metadata while retaining
|
||||
the original namespaced ID for diagnostics and later restoration. This is
|
||||
deliberately different from treating an unknown symbol as valid grammar.
|
||||
|
||||
## Pages
|
||||
|
||||
The single stackable `rivencraft:page` item has a bounded, persistent
|
||||
`rivencraft:page_content` component. Its explicit states are blank, symbol,
|
||||
unresolved symbol, and baseline link panel. Symbol and unresolved-symbol pages
|
||||
retain their namespaced symbol reference; unresolved pages can be inspected and
|
||||
removed but are rejected as usable writing until their data pack returns.
|
||||
|
||||
Only server-side writing operations may turn a blank page into a known symbol
|
||||
page or link panel. The shared `PageItem` creation and validation gates reject
|
||||
new pages for identifiers absent from the server catalog. Later Writing Desk
|
||||
and Book Binder packets must call these gates rather than accepting page
|
||||
contents supplied by a client.
|
||||
|
||||
The item model uses server-assigned custom-model data derived from the symbol
|
||||
identifier. Built-in pages reproduce Mystcraft Legacy's four-word poem
|
||||
composition from its page background and symbol-component sheet. Data-pack
|
||||
symbols without a bundled resource-pack model use the legacy question-mark
|
||||
fallback while keeping their real identifier and display metadata.
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"schema_version": 1,
|
||||
"terrain": "noise",
|
||||
"noise_settings": "minecraft:amplified",
|
||||
"biome_preset": "minecraft:overworld",
|
||||
"dimension_type": "minecraft:overworld"
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"pack": {
|
||||
"pack_format": 48,
|
||||
"description": "Example Rivencraft Age runtime profile"
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,7 @@ mod_name=Rivencraft
|
||||
# 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
|
||||
# The mod version. Rivencraft uses the x.y.z.b policy documented in README.md.
|
||||
mod_version=0.2.26.1
|
||||
mod_version=0.3.3.4
|
||||
immersive_portals_version=6.0.7
|
||||
# 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.
|
||||
|
||||
@@ -4,17 +4,22 @@ import com.mojang.logging.LogUtils;
|
||||
import net.dnorberg.rivencraft.registry.ModCreativeTabs;
|
||||
import net.dnorberg.rivencraft.registry.ModDataComponents;
|
||||
import net.dnorberg.rivencraft.registry.ModItems;
|
||||
import net.dnorberg.rivencraft.registry.ModMenus;
|
||||
import net.dnorberg.rivencraft.registry.ModSounds;
|
||||
import net.dnorberg.rivencraft.registry.ModBlocks;
|
||||
import net.dnorberg.rivencraft.registry.ModBlockEntities;
|
||||
import net.dnorberg.rivencraft.registry.ModBiomeSources;
|
||||
import net.dnorberg.rivencraft.event.BookStandConversionHandler;
|
||||
import net.dnorberg.rivencraft.event.AgeCelestialAngleSync;
|
||||
import net.dnorberg.rivencraft.event.AgeLifecycleEvents;
|
||||
import net.dnorberg.rivencraft.command.RivencraftCommands;
|
||||
import net.dnorberg.rivencraft.network.ModNetworking;
|
||||
import net.dnorberg.rivencraft.config.RivencraftConfig;
|
||||
import net.dnorberg.rivencraft.config.RivencraftClientConfig;
|
||||
import net.dnorberg.rivencraft.book.AgeDimensionService;
|
||||
import net.dnorberg.rivencraft.book.AgeWeatherService;
|
||||
import net.dnorberg.rivencraft.book.AgeRuntimeProfiles;
|
||||
import net.dnorberg.rivencraft.writing.SymbolCatalog;
|
||||
import net.neoforged.bus.api.IEventBus;
|
||||
import net.neoforged.fml.ModContainer;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
@@ -37,12 +42,18 @@ public final class Rivencraft {
|
||||
ModBlocks.register(modEventBus);
|
||||
ModBlockEntities.register(modEventBus);
|
||||
ModItems.register(modEventBus);
|
||||
ModMenus.register(modEventBus);
|
||||
ModSounds.register(modEventBus);
|
||||
ModCreativeTabs.register(modEventBus);
|
||||
NeoForge.EVENT_BUS.addListener(BookStandConversionHandler::onRightClickBlock);
|
||||
NeoForge.EVENT_BUS.addListener(AgeWeatherService::onLevelTickPost);
|
||||
NeoForge.EVENT_BUS.addListener(AgeCelestialAngleSync::onPlayerLoggedIn);
|
||||
NeoForge.EVENT_BUS.addListener(AgeCelestialAngleSync::onPlayerChangedDimension);
|
||||
NeoForge.EVENT_BUS.addListener(AgeLifecycleEvents::onPlayerLoggedOut);
|
||||
NeoForge.EVENT_BUS.addListener(AgeLifecycleEvents::onServerStopping);
|
||||
NeoForge.EVENT_BUS.addListener(RivencraftCommands::register);
|
||||
NeoForge.EVENT_BUS.addListener(AgeRuntimeProfiles::register);
|
||||
NeoForge.EVENT_BUS.addListener(SymbolCatalog::register);
|
||||
LOGGER.info("Initializing Rivencraft");
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
package net.dnorberg.rivencraft.book;
|
||||
|
||||
import dev.galacticraft.dynamicdimensions.api.DynamicDimensionRegistry;
|
||||
import dev.galacticraft.dynamicdimensions.api.PlayerRemover;
|
||||
import dev.galacticraft.dynamicdimensions.api.event.DimensionRemovedCallback;
|
||||
import dev.galacticraft.dynamicdimensions.api.event.DynamicDimensionLoadCallback;
|
||||
import java.util.Optional;
|
||||
import java.util.OptionalLong;
|
||||
import java.util.List;
|
||||
import java.util.Comparator;
|
||||
import java.util.Collections;
|
||||
@@ -21,7 +22,6 @@ import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.util.valueproviders.UniformInt;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.biome.Biomes;
|
||||
@@ -30,7 +30,6 @@ import net.minecraft.world.level.biome.BiomeSource;
|
||||
import net.minecraft.world.level.biome.CheckerboardColumnBiomeSource;
|
||||
import net.minecraft.world.level.biome.FixedBiomeSource;
|
||||
import net.minecraft.world.level.biome.MultiNoiseBiomeSource;
|
||||
import net.minecraft.world.level.biome.MultiNoiseBiomeSourceParameterLists;
|
||||
import net.dnorberg.rivencraft.world.ScaledBiomeSource;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.dimension.BuiltinDimensionTypes;
|
||||
@@ -56,13 +55,14 @@ public final class AgeDimensionService {
|
||||
}
|
||||
|
||||
public static void register() {
|
||||
DimensionRemovedCallback.register((dimension, level) -> synchronizeImmersivePortals(level.getServer()));
|
||||
DynamicDimensionLoadCallback.register((server, loader) -> {
|
||||
ServerLevel overworld = server.overworld();
|
||||
for (AgeDefinition age : AgeRegistrySavedData.get(overworld).definitions()) {
|
||||
ServerLevel level = loader.loadDynamicDimension(
|
||||
age.dimensionId(),
|
||||
createGenerator(server, age),
|
||||
createDimensionType(age)
|
||||
createDimensionType(server, age)
|
||||
);
|
||||
if (level != null) {
|
||||
applyCelestialClock(level, age);
|
||||
@@ -104,7 +104,7 @@ public final class AgeDimensionService {
|
||||
ServerLevel loaded = DynamicDimensionRegistry.from(server).loadDynamicDimension(
|
||||
definition.dimensionId(),
|
||||
createGenerator(server, definition),
|
||||
createDimensionType(definition)
|
||||
createDimensionType(server, definition)
|
||||
);
|
||||
if (loaded == null) {
|
||||
Rivencraft.LOGGER.error("Failed to load Age {} as {}", definition.id(), definition.dimensionId());
|
||||
@@ -115,6 +115,27 @@ public final class AgeDimensionService {
|
||||
return loaded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unloads an Age while retaining its saved definition and dimension data.
|
||||
* A later book access reconstructs the same runtime level from that data.
|
||||
*/
|
||||
public static UnloadResult unload(MinecraftServer server, AgeDefinition definition) {
|
||||
ResourceKey<Level> key = dimensionKey(definition);
|
||||
if (server.getLevel(key) == null) {
|
||||
return UnloadResult.ALREADY_UNLOADED;
|
||||
}
|
||||
|
||||
if (ModList.get().isLoaded("immersive_portals_core")) {
|
||||
ImmersivePortalsChunkLoaders.closeForDimension(key);
|
||||
}
|
||||
boolean unloaded = DynamicDimensionRegistry.from(server)
|
||||
.unloadDynamicDimension(definition.dimensionId(), PlayerRemover.DEFAULT);
|
||||
if (!unloaded) {
|
||||
return UnloadResult.FAILED;
|
||||
}
|
||||
return UnloadResult.UNLOADED;
|
||||
}
|
||||
|
||||
private static void applyCelestialClock(ServerLevel level, AgeDefinition age) {
|
||||
if (age.traits().hasStoppedCelestialCycle()) {
|
||||
// NeoForge rejects an exact zero rate. The smallest positive float
|
||||
@@ -240,15 +261,15 @@ public final class AgeDimensionService {
|
||||
}
|
||||
|
||||
private static ChunkGenerator createGenerator(MinecraftServer server, AgeDefinition age) {
|
||||
ResourceLocation profile = age.generationProfile();
|
||||
if (profile.equals(AgeGenerationProfiles.FLAT)) {
|
||||
AgeRuntimeProfile profile = AgeRuntimeProfiles.resolve(age.generationProfile());
|
||||
if (profile.terrain() == AgeRuntimeProfile.Terrain.FLAT) {
|
||||
return new FlatLevelSource(FlatLevelGeneratorSettings.getDefault(
|
||||
server.registryAccess().lookupOrThrow(Registries.BIOME),
|
||||
server.registryAccess().lookupOrThrow(Registries.STRUCTURE_SET),
|
||||
server.registryAccess().lookupOrThrow(Registries.PLACED_FEATURE)
|
||||
));
|
||||
}
|
||||
if (profile.equals(AgeGenerationProfiles.VOID)) {
|
||||
if (profile.terrain() == AgeRuntimeProfile.Terrain.VOID) {
|
||||
FlatLevelGeneratorSettings settings = new FlatLevelGeneratorSettings(
|
||||
Optional.empty(),
|
||||
server.registryAccess().lookupOrThrow(Registries.BIOME).getOrThrow(Biomes.THE_VOID),
|
||||
@@ -261,22 +282,11 @@ public final class AgeDimensionService {
|
||||
var biomeParameters = server.registryAccess()
|
||||
.lookupOrThrow(Registries.MULTI_NOISE_BIOME_SOURCE_PARAMETER_LIST);
|
||||
var noiseSettings = server.registryAccess().lookupOrThrow(Registries.NOISE_SETTINGS);
|
||||
ResourceKey<NoiseGeneratorSettings> settingsKey;
|
||||
if (profile.equals(AgeGenerationProfiles.CAVE)) {
|
||||
settingsKey = NoiseGeneratorSettings.CAVES;
|
||||
} else if (profile.equals(AgeGenerationProfiles.ISLAND)) {
|
||||
settingsKey = NoiseGeneratorSettings.FLOATING_ISLANDS;
|
||||
} else if (profile.equals(AgeGenerationProfiles.AMPLIFIED)) {
|
||||
settingsKey = NoiseGeneratorSettings.AMPLIFIED;
|
||||
} else {
|
||||
settingsKey = NoiseGeneratorSettings.OVERWORLD;
|
||||
}
|
||||
// Cave uses Minecraft's enclosed cave density with stone, water, and
|
||||
// Overworld-like surfaces while retaining the Age's biome source.
|
||||
// Island/Skylands uses uniform floating-island density without the
|
||||
// End's central dragon island. Both use the Overworld environment.
|
||||
// random_vanilla is retained as a migration alias for existing Ages.
|
||||
BiomeSource biomeSource = createBiomeSource(server, age, biomeParameters);
|
||||
ResourceKey<NoiseGeneratorSettings> settingsKey = ResourceKey.create(
|
||||
Registries.NOISE_SETTINGS, profile.noiseSettings());
|
||||
ResourceKey<net.minecraft.world.level.biome.MultiNoiseBiomeSourceParameterList> biomePreset =
|
||||
ResourceKey.create(Registries.MULTI_NOISE_BIOME_SOURCE_PARAMETER_LIST, profile.biomePreset());
|
||||
BiomeSource biomeSource = createBiomeSource(server, age, biomeParameters, biomePreset);
|
||||
NoiseGeneratorSettings baseSettings = noiseSettings.getOrThrow(settingsKey).value();
|
||||
return new NoiseBasedChunkGenerator(biomeSource, Holder.direct(withBiomeMaterialRules(baseSettings)));
|
||||
}
|
||||
@@ -323,7 +333,8 @@ public final class AgeDimensionService {
|
||||
private static BiomeSource createBiomeSource(
|
||||
MinecraftServer server,
|
||||
AgeDefinition age,
|
||||
net.minecraft.core.HolderGetter<net.minecraft.world.level.biome.MultiNoiseBiomeSourceParameterList> biomeParameters
|
||||
net.minecraft.core.HolderGetter<net.minecraft.world.level.biome.MultiNoiseBiomeSourceParameterList> biomeParameters,
|
||||
ResourceKey<net.minecraft.world.level.biome.MultiNoiseBiomeSourceParameterList> biomePreset
|
||||
) {
|
||||
List<net.minecraft.core.Holder.Reference<Biome>> biomes = server.registryAccess()
|
||||
.lookupOrThrow(Registries.BIOME)
|
||||
@@ -370,30 +381,39 @@ public final class AgeDimensionService {
|
||||
);
|
||||
}
|
||||
return MultiNoiseBiomeSource.createFromPreset(
|
||||
biomeParameters.getOrThrow(MultiNoiseBiomeSourceParameterLists.OVERWORLD));
|
||||
biomeParameters.getOrThrow(biomePreset));
|
||||
}
|
||||
|
||||
private static DimensionType createDimensionType(AgeDefinition age) {
|
||||
private static DimensionType createDimensionType(MinecraftServer server, AgeDefinition age) {
|
||||
AgeRuntimeProfile profile = AgeRuntimeProfiles.resolve(age.generationProfile());
|
||||
DimensionType base = server.registryAccess().lookupOrThrow(Registries.DIMENSION_TYPE)
|
||||
.getOrThrow(ResourceKey.create(Registries.DIMENSION_TYPE, profile.dimensionType())).value();
|
||||
AgeTraits.Lighting lighting = age.traits().lighting();
|
||||
boolean hasSkyLight = lighting != AgeTraits.Lighting.DARK;
|
||||
float ambientLight = lighting == AgeTraits.Lighting.BRIGHT ? 0.25F : 0.0F;
|
||||
return new DimensionType(
|
||||
OptionalLong.empty(),
|
||||
base.fixedTime(),
|
||||
hasSkyLight,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
1.0D,
|
||||
false,
|
||||
false,
|
||||
-64,
|
||||
384,
|
||||
384,
|
||||
BlockTags.INFINIBURN_OVERWORLD,
|
||||
BuiltinDimensionTypes.OVERWORLD_EFFECTS,
|
||||
base.hasCeiling(),
|
||||
base.ultraWarm(),
|
||||
base.natural(),
|
||||
base.coordinateScale(),
|
||||
base.bedWorks(),
|
||||
base.respawnAnchorWorks(),
|
||||
base.minY(),
|
||||
base.height(),
|
||||
base.logicalHeight(),
|
||||
base.infiniburn(),
|
||||
base.effectsLocation(),
|
||||
ambientLight,
|
||||
new DimensionType.MonsterSettings(false, true, UniformInt.of(0, 7), 0)
|
||||
base.monsterSettings()
|
||||
);
|
||||
}
|
||||
|
||||
public enum UnloadResult {
|
||||
UNLOADED,
|
||||
ALREADY_UNLOADED,
|
||||
FAILED
|
||||
}
|
||||
|
||||
}
|
||||
@@ -33,6 +33,14 @@ public final class AgeGenerationProfiles {
|
||||
return RANDOM_PROFILES;
|
||||
}
|
||||
|
||||
/** Maps removed legacy aliases to a stable built-in profile. */
|
||||
public static ResourceLocation migrationFallback(ResourceLocation profile) {
|
||||
if (profile.equals(AgeDefinition.RANDOM_VANILLA_PROFILE)) {
|
||||
return STANDARD;
|
||||
}
|
||||
return isSupported(profile) ? profile : STANDARD;
|
||||
}
|
||||
|
||||
private static ResourceLocation id(String path) {
|
||||
return ResourceLocation.fromNamespaceAndPath(Rivencraft.MOD_ID, path);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
package net.dnorberg.rivencraft.book;
|
||||
|
||||
import java.util.UUID;
|
||||
import net.dnorberg.rivencraft.Rivencraft;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.gametest.framework.GameTest;
|
||||
import net.minecraft.gametest.framework.GameTestHelper;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.neoforged.neoforge.gametest.GameTestHolder;
|
||||
import net.neoforged.neoforge.gametest.PrefixGameTestTemplate;
|
||||
|
||||
/** Saved-data migration and round-trip acceptance coverage for persistent Ages. */
|
||||
@GameTestHolder(Rivencraft.MOD_ID)
|
||||
@PrefixGameTestTemplate(false)
|
||||
public final class AgePersistenceGameTests {
|
||||
private AgePersistenceGameTests() {
|
||||
}
|
||||
|
||||
@GameTest(template = "empty")
|
||||
public static void everyTraitCombinationRoundTripsWithoutRerolling(GameTestHelper helper) {
|
||||
ListTag entries = new ListTag();
|
||||
AgeTraits.BiomeDistribution[] distributions = AgeTraits.BiomeDistribution.values();
|
||||
AgeTraits.Lighting[] lightingValues = AgeTraits.Lighting.values();
|
||||
AgeTraits.Weather[] weatherValues = AgeTraits.Weather.values();
|
||||
|
||||
for (int index = 0; index < distributions.length; index++) {
|
||||
UUID id = new UUID(0x524956454E000000L + index, 0x4147450000000000L + index);
|
||||
AgeTraits traits = new AgeTraits(
|
||||
distributions[index],
|
||||
lightingValues[index % lightingValues.length],
|
||||
weatherValues[index % weatherValues.length],
|
||||
index == 0 ? AgeTraits.STOPPED_CELESTIAL_PERIOD : 0.25D + index * 0.15D,
|
||||
index * 37.5F,
|
||||
index * 0.1F
|
||||
);
|
||||
entries.add(entry(
|
||||
id,
|
||||
"Persistent " + distributions[index],
|
||||
9000L + index,
|
||||
AgeGenerationProfiles.all().get(index % AgeGenerationProfiles.all().size()),
|
||||
3 + index,
|
||||
1200L + index,
|
||||
ResourceLocation.fromNamespaceAndPath(Rivencraft.MOD_ID, "age/persistent_" + index),
|
||||
new BlockPos(index, 70 + index, -index),
|
||||
traits
|
||||
));
|
||||
}
|
||||
|
||||
CompoundTag root = new CompoundTag();
|
||||
root.put("Ages", entries);
|
||||
AgeRegistrySavedData first = AgeRegistrySavedData.load(root, helper.getLevel().registryAccess());
|
||||
CompoundTag serialized = first.save(new CompoundTag(), helper.getLevel().registryAccess());
|
||||
AgeRegistrySavedData restored = AgeRegistrySavedData.load(serialized, helper.getLevel().registryAccess());
|
||||
|
||||
for (int index = 0; index < distributions.length; index++) {
|
||||
UUID id = new UUID(0x524956454E000000L + index, 0x4147450000000000L + index);
|
||||
helper.assertValueEqual(restored.find(id).orElseThrow(), first.find(id).orElseThrow(),
|
||||
distributions[index] + " and its weather, lighting, celestial, and identity data must round-trip");
|
||||
}
|
||||
helper.succeed();
|
||||
}
|
||||
|
||||
@GameTest(template = "empty")
|
||||
public static void legacyDefinitionReceivesStableDefaults(GameTestHelper helper) {
|
||||
UUID id = UUID.fromString("4d797374-6372-6166-7400-000000000001");
|
||||
CompoundTag legacy = new CompoundTag();
|
||||
legacy.putUUID("Id", id);
|
||||
legacy.putString("Name", " Legacy Age ");
|
||||
legacy.putLong("Seed", 8675309L);
|
||||
legacy.putString("GenerationProfile", AgeDefinition.RANDOM_VANILLA_PROFILE.toString());
|
||||
legacy.putLong("CreatedGameTime", 42L);
|
||||
ListTag entries = new ListTag();
|
||||
entries.add(legacy);
|
||||
CompoundTag root = new CompoundTag();
|
||||
root.put("Ages", entries);
|
||||
|
||||
AgeRegistrySavedData migrated = AgeRegistrySavedData.load(root, helper.getLevel().registryAccess());
|
||||
AgeDefinition definition = migrated.find(id).orElseThrow();
|
||||
helper.assertValueEqual(definition.id(), id, "Migration must retain the Age UUID");
|
||||
helper.assertValueEqual(definition.name(), "Legacy Age", "Migration must normalize and retain the Age name");
|
||||
helper.assertValueEqual(definition.seed(), 8675309L, "Migration must retain the Age seed");
|
||||
helper.assertValueEqual(definition.generationProfile(), AgeDefinition.RANDOM_VANILLA_PROFILE,
|
||||
"Migration must retain the legacy generation profile for deterministic runtime fallback");
|
||||
helper.assertValueEqual(definition.generationVersion(), 1,
|
||||
"Definitions predating generation versions must receive version 1");
|
||||
helper.assertValueEqual(definition.dimensionId(), AgeDefinition.dimensionId(id),
|
||||
"Definitions predating named dimensions must retain the UUID-derived dimension");
|
||||
helper.assertValueEqual(definition.traits(), AgeTraits.LEGACY_DEFAULTS,
|
||||
"Definitions predating traits must receive stable legacy defaults");
|
||||
|
||||
CompoundTag serialized = migrated.save(new CompoundTag(), helper.getLevel().registryAccess());
|
||||
AgeDefinition reloaded = AgeRegistrySavedData.load(serialized, helper.getLevel().registryAccess())
|
||||
.find(id).orElseThrow();
|
||||
helper.assertValueEqual(reloaded, definition, "A migrated definition must not reroll on its next restart");
|
||||
helper.succeed();
|
||||
}
|
||||
|
||||
private static CompoundTag entry(
|
||||
UUID id,
|
||||
String name,
|
||||
long seed,
|
||||
ResourceLocation profile,
|
||||
int version,
|
||||
long createdTime,
|
||||
ResourceLocation dimension,
|
||||
BlockPos spawn,
|
||||
AgeTraits traits
|
||||
) {
|
||||
CompoundTag entry = new CompoundTag();
|
||||
entry.putUUID("Id", id);
|
||||
entry.putString("Name", name);
|
||||
entry.putLong("Seed", seed);
|
||||
entry.putString("GenerationProfile", profile.toString());
|
||||
entry.putInt("GenerationVersion", version);
|
||||
entry.putLong("CreatedGameTime", createdTime);
|
||||
entry.putString("Dimension", dimension.toString());
|
||||
entry.putInt("SpawnX", spawn.getX());
|
||||
entry.putInt("SpawnY", spawn.getY());
|
||||
entry.putInt("SpawnZ", spawn.getZ());
|
||||
CompoundTag serializedTraits = new CompoundTag();
|
||||
serializedTraits.putString("BiomeDistribution", traits.biomeDistribution().name());
|
||||
serializedTraits.putString("Lighting", traits.lighting().name());
|
||||
serializedTraits.putString("Weather", traits.weather().name());
|
||||
serializedTraits.putDouble("CelestialPeriod", traits.celestialPeriod());
|
||||
serializedTraits.putFloat("CelestialAngle", traits.celestialAngle());
|
||||
serializedTraits.putFloat("CelestialPhase", traits.celestialPhase());
|
||||
entry.put("Traits", serializedTraits);
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
@@ -91,7 +91,7 @@ public final class AgeRegistrySavedData extends SavedData {
|
||||
reference.id(),
|
||||
name,
|
||||
seed,
|
||||
AgeGenerationProfiles.select(seed),
|
||||
AgeRuntimeProfiles.select(seed),
|
||||
AgeDefinition.CURRENT_GENERATION_VERSION,
|
||||
createdGameTime,
|
||||
dimensionId,
|
||||
@@ -103,7 +103,7 @@ public final class AgeRegistrySavedData extends SavedData {
|
||||
return created;
|
||||
}
|
||||
|
||||
private static AgeRegistrySavedData load(CompoundTag tag, HolderLookup.Provider registries) {
|
||||
static AgeRegistrySavedData load(CompoundTag tag, HolderLookup.Provider registries) {
|
||||
AgeRegistrySavedData data = new AgeRegistrySavedData();
|
||||
ListTag serializedAges = tag.getList(AGES_TAG, CompoundTag.TAG_COMPOUND);
|
||||
for (int index = 0; index < serializedAges.size(); index++) {
|
||||
@@ -111,12 +111,18 @@ public final class AgeRegistrySavedData extends SavedData {
|
||||
if (!entry.hasUUID(ID_TAG)) {
|
||||
continue;
|
||||
}
|
||||
ResourceLocation profile = ResourceLocation.tryParse(entry.getString(PROFILE_TAG));
|
||||
ResourceLocation profile = entry.contains(PROFILE_TAG, CompoundTag.TAG_STRING)
|
||||
&& !entry.getString(PROFILE_TAG).isBlank()
|
||||
? ResourceLocation.tryParse(entry.getString(PROFILE_TAG))
|
||||
: null;
|
||||
if (profile == null) {
|
||||
profile = AgeDefinition.RANDOM_VANILLA_PROFILE;
|
||||
}
|
||||
UUID id = entry.getUUID(ID_TAG);
|
||||
ResourceLocation dimensionId = ResourceLocation.tryParse(entry.getString(DIMENSION_TAG));
|
||||
ResourceLocation dimensionId = entry.contains(DIMENSION_TAG, CompoundTag.TAG_STRING)
|
||||
&& !entry.getString(DIMENSION_TAG).isBlank()
|
||||
? ResourceLocation.tryParse(entry.getString(DIMENSION_TAG))
|
||||
: null;
|
||||
if (dimensionId == null) {
|
||||
dimensionId = AgeDefinition.dimensionId(id);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package net.dnorberg.rivencraft.book;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
/** Data-pack-defined resources used to construct an Age runtime dimension. */
|
||||
public record AgeRuntimeProfile(
|
||||
int schemaVersion,
|
||||
Terrain terrain,
|
||||
ResourceLocation noiseSettings,
|
||||
ResourceLocation biomePreset,
|
||||
ResourceLocation dimensionType
|
||||
) {
|
||||
public static final int CURRENT_SCHEMA_VERSION = 1;
|
||||
|
||||
public enum Terrain {
|
||||
NOISE,
|
||||
FLAT,
|
||||
VOID
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
package net.dnorberg.rivencraft.book;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import net.dnorberg.rivencraft.Rivencraft;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.server.packs.resources.SimpleJsonResourceReloadListener;
|
||||
import net.minecraft.util.profiling.ProfilerFiller;
|
||||
import net.minecraft.world.level.biome.MultiNoiseBiomeSourceParameterList;
|
||||
import net.minecraft.world.level.dimension.DimensionType;
|
||||
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
|
||||
import net.neoforged.neoforge.event.AddReloadListenerEvent;
|
||||
|
||||
/** Loads {@code data/<namespace>/rivencraft/age_profiles/*.json}. */
|
||||
public final class AgeRuntimeProfiles {
|
||||
private static final Gson GSON = new GsonBuilder().create();
|
||||
private static final String DIRECTORY = "rivencraft/age_profiles";
|
||||
private static final Map<ResourceLocation, AgeRuntimeProfile> PROFILES = new ConcurrentHashMap<>();
|
||||
|
||||
private AgeRuntimeProfiles() {
|
||||
}
|
||||
|
||||
public static void register(AddReloadListenerEvent event) {
|
||||
event.addListener(new Loader(event.getRegistryAccess()));
|
||||
}
|
||||
|
||||
public static AgeRuntimeProfile resolve(ResourceLocation id) {
|
||||
AgeRuntimeProfile profile = PROFILES.get(id);
|
||||
if (profile != null) {
|
||||
return profile;
|
||||
}
|
||||
ResourceLocation fallback = AgeGenerationProfiles.migrationFallback(id);
|
||||
profile = PROFILES.get(fallback);
|
||||
if (profile == null) {
|
||||
throw new IllegalStateException("Missing built-in Age runtime profile " + fallback);
|
||||
}
|
||||
Rivencraft.LOGGER.warn("Age runtime profile {} is unavailable; using deterministic fallback {}", id, fallback);
|
||||
return profile;
|
||||
}
|
||||
|
||||
public static Map<ResourceLocation, AgeRuntimeProfile> profiles() {
|
||||
return Map.copyOf(PROFILES);
|
||||
}
|
||||
|
||||
/** Selects from all valid loaded profiles in stable resource-ID order. */
|
||||
public static ResourceLocation select(long seed) {
|
||||
if (PROFILES.isEmpty()) {
|
||||
return AgeGenerationProfiles.select(seed);
|
||||
}
|
||||
java.util.List<ResourceLocation> ids = PROFILES.keySet().stream().sorted().toList();
|
||||
return ids.get(Math.floorMod(Long.hashCode(seed), ids.size()));
|
||||
}
|
||||
|
||||
static AgeRuntimeProfile parse(ResourceLocation id, JsonElement json, RegistryAccess registries) {
|
||||
JsonObject object = json.getAsJsonObject();
|
||||
int schemaVersion = object.has("schema_version") ? object.get("schema_version").getAsInt() : 1;
|
||||
if (schemaVersion != AgeRuntimeProfile.CURRENT_SCHEMA_VERSION) {
|
||||
throw new IllegalArgumentException("unsupported schema_version " + schemaVersion);
|
||||
}
|
||||
AgeRuntimeProfile.Terrain terrain = AgeRuntimeProfile.Terrain.valueOf(
|
||||
requiredString(object, "terrain").toUpperCase(java.util.Locale.ROOT));
|
||||
ResourceLocation noise = location(object, "noise_settings", "minecraft:overworld");
|
||||
ResourceLocation biome = location(object, "biome_preset", "minecraft:overworld");
|
||||
ResourceLocation dimension = location(object, "dimension_type", "minecraft:overworld");
|
||||
|
||||
if (terrain == AgeRuntimeProfile.Terrain.NOISE) {
|
||||
requireRegistryEntry(registries, Registries.NOISE_SETTINGS, noise, id, "noise_settings");
|
||||
requireRegistryEntry(registries, Registries.MULTI_NOISE_BIOME_SOURCE_PARAMETER_LIST,
|
||||
biome, id, "biome_preset");
|
||||
}
|
||||
requireRegistryEntry(registries, Registries.DIMENSION_TYPE, dimension, id, "dimension_type");
|
||||
return new AgeRuntimeProfile(schemaVersion, terrain, noise, biome, dimension);
|
||||
}
|
||||
|
||||
private static String requiredString(JsonObject object, String name) {
|
||||
if (!object.has(name)) {
|
||||
throw new IllegalArgumentException("missing " + name);
|
||||
}
|
||||
return object.get(name).getAsString();
|
||||
}
|
||||
|
||||
private static ResourceLocation location(JsonObject object, String name, String fallback) {
|
||||
ResourceLocation id = ResourceLocation.tryParse(object.has(name) ? object.get(name).getAsString() : fallback);
|
||||
if (id == null) {
|
||||
throw new IllegalArgumentException("invalid " + name);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
private static <T> void requireRegistryEntry(
|
||||
RegistryAccess registries,
|
||||
ResourceKey<? extends net.minecraft.core.Registry<T>> registry,
|
||||
ResourceLocation entry,
|
||||
ResourceLocation profile,
|
||||
String field
|
||||
) {
|
||||
if (registries.lookupOrThrow(registry).get(ResourceKey.create(registry, entry)).isEmpty()) {
|
||||
throw new IllegalArgumentException(profile + " references missing " + field + " " + entry);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class Loader extends SimpleJsonResourceReloadListener {
|
||||
private final RegistryAccess registries;
|
||||
|
||||
private Loader(RegistryAccess registries) {
|
||||
super(GSON, DIRECTORY);
|
||||
this.registries = registries;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void apply(Map<ResourceLocation, JsonElement> resources,
|
||||
ResourceManager resourceManager,
|
||||
ProfilerFiller profiler) {
|
||||
Map<ResourceLocation, AgeRuntimeProfile> loaded = new java.util.HashMap<>();
|
||||
resources.forEach((id, json) -> {
|
||||
try {
|
||||
loaded.put(id, parse(id, json, registries));
|
||||
} catch (RuntimeException exception) {
|
||||
Rivencraft.LOGGER.error("Ignoring invalid Age runtime profile {}: {}", id, exception.getMessage());
|
||||
}
|
||||
});
|
||||
for (ResourceLocation required : AgeGenerationProfiles.all()) {
|
||||
if (!loaded.containsKey(required)) {
|
||||
throw new IllegalStateException("Required built-in Age runtime profile is missing: " + required);
|
||||
}
|
||||
}
|
||||
PROFILES.clear();
|
||||
PROFILES.putAll(loaded);
|
||||
Rivencraft.LOGGER.info("Loaded {} Age runtime profiles", loaded.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -76,6 +76,7 @@ public final class LinkingService {
|
||||
LinkTarget target
|
||||
) {
|
||||
if (ModList.get().isLoaded("immersive_portals_core")) {
|
||||
ImmersivePortalsChunkLoaders.close(player);
|
||||
ImmersivePortalsChunkLoaders.teleport(
|
||||
player, destinationLevel, position, target.yaw(), target.pitch());
|
||||
} else {
|
||||
|
||||
@@ -2,12 +2,19 @@ package net.dnorberg.rivencraft.client;
|
||||
|
||||
import net.dnorberg.rivencraft.Rivencraft;
|
||||
import net.dnorberg.rivencraft.registry.ModBlockEntities;
|
||||
import net.dnorberg.rivencraft.registry.ModDataComponents;
|
||||
import net.dnorberg.rivencraft.registry.ModItems;
|
||||
import net.minecraft.client.renderer.item.ItemProperties;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.common.EventBusSubscriber;
|
||||
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.neoforged.neoforge.common.NeoForge;
|
||||
import net.neoforged.neoforge.client.event.EntityRenderersEvent;
|
||||
import net.neoforged.neoforge.client.event.RegisterMenuScreensEvent;
|
||||
import net.dnorberg.rivencraft.client.screen.NotebookScreen;
|
||||
import net.dnorberg.rivencraft.registry.ModMenus;
|
||||
|
||||
@EventBusSubscriber(modid = Rivencraft.MOD_ID, value = Dist.CLIENT)
|
||||
public final class ClientEvents {
|
||||
@@ -19,8 +26,18 @@ public final class ClientEvents {
|
||||
event.registerBlockEntityRenderer(ModBlockEntities.BOOK_STAND.get(), BookStandRenderer::new);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerScreens(RegisterMenuScreensEvent event) {
|
||||
event.register(ModMenus.NOTEBOOK.get(), NotebookScreen::new);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void clientSetup(FMLClientSetupEvent event) {
|
||||
event.enqueueWork(() -> ItemProperties.register(
|
||||
ModItems.LINKING_BOOK.get(),
|
||||
ResourceLocation.fromNamespaceAndPath(Rivencraft.MOD_ID, "bound"),
|
||||
(stack, level, entity, seed) -> stack.has(ModDataComponents.LINK_TARGET.get()) ? 1.0F : 0.0F
|
||||
));
|
||||
NeoForge.EVENT_BUS.addListener(ClientBookInteractionHandler::onRightClickItem);
|
||||
NeoForge.EVENT_BUS.addListener(ClientBookInteractionHandler::onRightClickBlock);
|
||||
NeoForge.EVENT_BUS.addListener(ClientBookExploreOverlay::onClientTickPre);
|
||||
|
||||
@@ -1,44 +1,22 @@
|
||||
package net.dnorberg.rivencraft.client.preview;
|
||||
|
||||
import net.dnorberg.rivencraft.config.RivencraftClientConfig;
|
||||
import net.dnorberg.rivencraft.compat.PreviewBackendSelector;
|
||||
import net.neoforged.fml.ModList;
|
||||
|
||||
/** Selects the configured destination preview while keeping optional integrations optional. */
|
||||
public final class DestinationPreviewRenderers {
|
||||
private enum Backend {
|
||||
IMMERSIVE_PORTALS,
|
||||
PONDER,
|
||||
LEGACY
|
||||
}
|
||||
|
||||
private DestinationPreviewRenderers() {
|
||||
}
|
||||
|
||||
public static DestinationPreviewRenderer create() {
|
||||
boolean ponderAvailable = ModList.get().isLoaded("create");
|
||||
// The mode and priority are established before the optional IP renderer
|
||||
// lands, so selecting it currently follows the documented safe fallback.
|
||||
boolean immersivePortalsAvailable = ModList.get().isLoaded("immersive_portals_core");
|
||||
return switch (selectBackend(
|
||||
return switch (PreviewBackendSelector.select(
|
||||
RivencraftClientConfig.previewMode(), immersivePortalsAvailable, ponderAvailable)) {
|
||||
case IMMERSIVE_PORTALS -> new ImmersivePortalsDestinationPreviewRenderer();
|
||||
case PONDER -> new PonderDestinationPreviewRenderer();
|
||||
case LEGACY -> new LegacyDestinationPreviewRenderer();
|
||||
};
|
||||
}
|
||||
|
||||
private static Backend selectBackend(
|
||||
RivencraftClientConfig.PreviewMode mode,
|
||||
boolean immersivePortalsAvailable,
|
||||
boolean ponderAvailable
|
||||
) {
|
||||
return switch (mode) {
|
||||
case AUTO -> immersivePortalsAvailable
|
||||
? Backend.IMMERSIVE_PORTALS
|
||||
: ponderAvailable ? Backend.PONDER : Backend.LEGACY;
|
||||
case IMMERSIVE_PORTALS -> immersivePortalsAvailable ? Backend.IMMERSIVE_PORTALS : Backend.LEGACY;
|
||||
case PONDER -> ponderAvailable ? Backend.PONDER : Backend.LEGACY;
|
||||
case LEGACY -> Backend.LEGACY;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -42,7 +42,11 @@ public final class ImmersivePortalsDestinationPreviewRenderer implements Destina
|
||||
|
||||
@Override
|
||||
public void accept(LinkPreviewPayload payload) {
|
||||
if (destination != null) {
|
||||
ImmersivePortalsPreviewAudioGuard.clear(destination.dimension());
|
||||
}
|
||||
destination = payload;
|
||||
ImmersivePortalsPreviewAudioGuard.mute(payload.dimension());
|
||||
resetView();
|
||||
}
|
||||
|
||||
@@ -118,6 +122,7 @@ public final class ImmersivePortalsDestinationPreviewRenderer implements Destina
|
||||
FRAMEBUFFER.clear(true);
|
||||
minecraft.getMainRenderTarget().bindWrite(true);
|
||||
MyRenderHelper.restoreViewPort();
|
||||
ImmersivePortalsPreviewAudioGuard.markCameraRestorePending();
|
||||
GuiPortalRendering.submitNextFrameRendering(info, FRAMEBUFFER);
|
||||
hasCompletedFrame = true;
|
||||
graphics.renderOutline(left, top, width, height, exploring ? 0xFFE0C36A : 0xFF7B6AA8);
|
||||
@@ -234,5 +239,8 @@ public final class ImmersivePortalsDestinationPreviewRenderer implements Destina
|
||||
public void close() {
|
||||
clearMovement();
|
||||
hasCompletedFrame = false;
|
||||
if (destination != null) {
|
||||
ImmersivePortalsPreviewAudioGuard.clear(destination.dimension());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package net.dnorberg.rivencraft.client.preview;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
/** Prevents an Immersive Portals preview world from contributing sounds to a book screen. */
|
||||
public final class ImmersivePortalsPreviewAudioGuard {
|
||||
private static ResourceKey<Level> mutedDimension;
|
||||
private static boolean cameraRestorePending;
|
||||
|
||||
private ImmersivePortalsPreviewAudioGuard() {
|
||||
}
|
||||
|
||||
public static void mute(ResourceKey<Level> dimension) {
|
||||
mutedDimension = dimension;
|
||||
}
|
||||
|
||||
public static void clear(ResourceKey<Level> dimension) {
|
||||
if (dimension.equals(mutedDimension)) {
|
||||
mutedDimension = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean shouldMute(ClientLevel level) {
|
||||
Minecraft minecraft = Minecraft.getInstance();
|
||||
return mutedDimension != null
|
||||
&& level.dimension().equals(mutedDimension)
|
||||
&& (minecraft.player == null || level != minecraft.player.level());
|
||||
}
|
||||
|
||||
public static void markCameraRestorePending() {
|
||||
cameraRestorePending = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Immersive Portals' GUI renderer leaves the shared main camera in the
|
||||
* remote world after its end-of-frame render. Restore it before the next
|
||||
* frame uses that camera for rain effects and the sound listener.
|
||||
*/
|
||||
public static void restorePlayerCamera() {
|
||||
Minecraft minecraft = Minecraft.getInstance();
|
||||
if (!cameraRestorePending) {
|
||||
return;
|
||||
}
|
||||
cameraRestorePending = false;
|
||||
if (minecraft.level == null || minecraft.getCameraEntity() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Camera camera = minecraft.gameRenderer.getMainCamera();
|
||||
camera.setup(
|
||||
minecraft.level,
|
||||
minecraft.getCameraEntity(),
|
||||
!minecraft.options.getCameraType().isFirstPerson(),
|
||||
minecraft.options.getCameraType().isMirrored(),
|
||||
camera.getPartialTickTime()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,338 @@
|
||||
package net.dnorberg.rivencraft.client.screen;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import net.dnorberg.rivencraft.menu.NotebookMenu;
|
||||
import net.dnorberg.rivencraft.network.RenameNotebookPagePayload;
|
||||
import net.dnorberg.rivencraft.registry.ModItems;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.gui.components.EditBox;
|
||||
import net.minecraft.client.gui.components.Tooltip;
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.inventory.ClickType;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.neoforged.neoforge.network.PacketDistributor;
|
||||
|
||||
/** A page surface modelled on Legacy's folder GUI, backed by the Notebook menu. */
|
||||
public final class NotebookScreen extends AbstractContainerScreen<NotebookMenu> {
|
||||
private static final int SURFACE_TOP = 20;
|
||||
private static final int SURFACE_BOTTOM = 132;
|
||||
private static final int SURFACE_RIGHT = 156;
|
||||
private static final int PAGE_WIDTH = 30;
|
||||
private static final int PAGE_HEIGHT = 40;
|
||||
private static final int PAGE_STEP_X = 31;
|
||||
private static final int PAGE_STEP_Y = 41;
|
||||
private static final int PAGE_COLUMNS = 5;
|
||||
private EditBox textInput;
|
||||
private boolean renaming;
|
||||
private boolean draggingScrollbar;
|
||||
private boolean surfaceClickPendingRelease;
|
||||
private int selectedSlot = -1;
|
||||
private int scroll;
|
||||
|
||||
public NotebookScreen(NotebookMenu menu, Inventory inventory, Component title) {
|
||||
super(menu, inventory, title);
|
||||
imageWidth = 176;
|
||||
imageHeight = 213;
|
||||
inventoryLabelY = 123;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
super.init();
|
||||
Button sortButton = Button.builder(Component.literal("AZ"), button -> {})
|
||||
.bounds(leftPos, topPos, 18, 18).build();
|
||||
Button allButton = Button.builder(Component.literal("ALL"), button -> {})
|
||||
.bounds(leftPos + 20, topPos, 26, 18).build();
|
||||
sortButton.active = false;
|
||||
allButton.active = false;
|
||||
addRenderableWidget(sortButton);
|
||||
addRenderableWidget(allButton);
|
||||
textInput = new EditBox(font, leftPos + 48, topPos, 86, 18,
|
||||
Component.translatable("screen.rivencraft.notebook.search"));
|
||||
textInput.setMaxLength(32);
|
||||
textInput.setHint(Component.translatable("screen.rivencraft.notebook.search"));
|
||||
textInput.setResponder(value -> {
|
||||
if (!renaming) scroll = 0;
|
||||
});
|
||||
addRenderableWidget(textInput);
|
||||
addRenderableWidget(Button.builder(Component.literal("R"), button -> toggleRename())
|
||||
.bounds(leftPos + 136, topPos, 18, 18)
|
||||
.tooltip(Tooltip.create(Component.translatable("screen.rivencraft.notebook.rename_toggle")))
|
||||
.build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTick) {
|
||||
super.render(graphics, mouseX, mouseY, partialTick);
|
||||
List<Integer> pages = visiblePages();
|
||||
scroll = Math.min(scroll, maxScroll(pages.size()));
|
||||
graphics.enableScissor(leftPos, topPos + SURFACE_TOP, leftPos + SURFACE_RIGHT,
|
||||
topPos + SURFACE_BOTTOM);
|
||||
for (int position = 0; position < pages.size(); position++) {
|
||||
int x = leftPos + (position % PAGE_COLUMNS) * PAGE_STEP_X;
|
||||
int y = topPos + SURFACE_TOP + (position / PAGE_COLUMNS) * PAGE_STEP_Y - scroll;
|
||||
if (y + PAGE_HEIGHT > topPos + SURFACE_TOP && y < topPos + SURFACE_BOTTOM) {
|
||||
drawPage(graphics, pages.get(position), x, y);
|
||||
}
|
||||
}
|
||||
graphics.disableScissor();
|
||||
drawScrollbar(graphics, pages.size());
|
||||
int hovered = pageAt(mouseX, mouseY, pages);
|
||||
if (!menu.getCarried().isEmpty() && inSurface(mouseX, mouseY)) {
|
||||
graphics.renderItem(menu.getCarried(), mouseX - 8, mouseY - 8);
|
||||
} else if (hovered >= 0) {
|
||||
ItemStack page = menu.getSlot(hovered).getItem();
|
||||
if (!page.isEmpty() && matchesSearch(page)) graphics.renderTooltip(font, page, mouseX, mouseY);
|
||||
} else {
|
||||
renderTooltip(graphics, mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderBg(GuiGraphics graphics, float partialTick, int mouseX, int mouseY) {
|
||||
graphics.fill(leftPos, topPos + SURFACE_TOP, leftPos + SURFACE_RIGHT,
|
||||
topPos + SURFACE_BOTTOM, 0xB0000000);
|
||||
drawBeveledPanel(graphics, leftPos, topPos + 132, imageWidth, 81);
|
||||
for (int row = 0; row < 3; row++) {
|
||||
for (int column = 0; column < 9; column++) drawSlot(graphics, 7 + column * 18, 134 + row * 18);
|
||||
}
|
||||
for (int column = 0; column < 9; column++) drawSlot(graphics, 7 + column * 18, 192);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderLabels(GuiGraphics graphics, int mouseX, int mouseY) {
|
||||
graphics.drawString(font, playerInventoryTitle, inventoryLabelX, inventoryLabelY, 0x404040, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||
if (inScrollbar(mouseX, mouseY) && button == 0) {
|
||||
draggingScrollbar = true;
|
||||
setScrollFromMouse(mouseY, visiblePages().size());
|
||||
return true;
|
||||
}
|
||||
int index = pageAt(mouseX, mouseY, visiblePages());
|
||||
if (index >= 0 && (button == 0 || button == 1)) {
|
||||
ItemStack page = menu.getSlot(index).getItem();
|
||||
if (!page.isEmpty() && !matchesSearch(page)) return true;
|
||||
if (renaming) finishRename();
|
||||
setFocused(null);
|
||||
textInput.setFocused(false);
|
||||
selectedSlot = index;
|
||||
slotClicked(menu.getSlot(index), index, button, ClickType.PICKUP);
|
||||
surfaceClickPendingRelease = true;
|
||||
return true;
|
||||
}
|
||||
return super.mouseClicked(mouseX, mouseY, button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseDragged(double mouseX, double mouseY, int button, double dragX, double dragY) {
|
||||
if (draggingScrollbar && button == 0) {
|
||||
setScrollFromMouse(mouseY, visiblePages().size());
|
||||
return true;
|
||||
}
|
||||
return super.mouseDragged(mouseX, mouseY, button, dragX, dragY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseReleased(double mouseX, double mouseY, int button) {
|
||||
if (draggingScrollbar || surfaceClickPendingRelease) {
|
||||
draggingScrollbar = false;
|
||||
surfaceClickPendingRelease = false;
|
||||
return true;
|
||||
}
|
||||
draggingScrollbar = false;
|
||||
return super.mouseReleased(mouseX, mouseY, button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseScrolled(double mouseX, double mouseY, double scrollX, double scrollY) {
|
||||
if (inSurface(mouseX, mouseY) || inScrollbar(mouseX, mouseY)) {
|
||||
scroll = Math.clamp(scroll - (int)Math.signum(scrollY) * 20,
|
||||
0, maxScroll(visiblePages().size()));
|
||||
return true;
|
||||
}
|
||||
return super.mouseScrolled(mouseX, mouseY, scrollX, scrollY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
|
||||
if (textInput.isFocused()) {
|
||||
if (renaming && (keyCode == 257 || keyCode == 335)) {
|
||||
finishRename();
|
||||
} else if (keyCode == 256) {
|
||||
if (renaming) finishRename();
|
||||
setFocused(null);
|
||||
textInput.setFocused(false);
|
||||
} else {
|
||||
textInput.keyPressed(keyCode, scanCode, modifiers);
|
||||
}
|
||||
// EditBox does not consume ordinary letter key presses; the matching charTyped
|
||||
// event handles text input. Do not pass them to the container's inventory keys.
|
||||
return true;
|
||||
}
|
||||
if (!textInput.isFocused() && keyCode == 82 && selectedSlot >= 0) {
|
||||
toggleRename();
|
||||
return true;
|
||||
}
|
||||
if (!textInput.isFocused() && selectedSlot >= 0 && (keyCode == 263 || keyCode == 262)) {
|
||||
moveSelected(keyCode == 262);
|
||||
return true;
|
||||
}
|
||||
return super.keyPressed(keyCode, scanCode, modifiers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClose() {
|
||||
commitRename();
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
private List<Integer> visiblePages() {
|
||||
List<Integer> pages = new ArrayList<>();
|
||||
int firstEmpty = -1;
|
||||
for (int index = 0; index < NotebookMenu.NOTEBOOK_SLOTS; index++) {
|
||||
ItemStack stack = menu.getSlot(index).getItem();
|
||||
if (stack.isEmpty()) {
|
||||
if (firstEmpty < 0) firstEmpty = index;
|
||||
} else {
|
||||
pages.add(index);
|
||||
}
|
||||
}
|
||||
if (firstEmpty >= 0 && menu.getCarried().is(ModItems.PAGE.get())) {
|
||||
pages.add(firstEmpty);
|
||||
}
|
||||
return pages;
|
||||
}
|
||||
|
||||
private boolean matchesSearch(ItemStack page) {
|
||||
return renaming || textInput.getValue().isBlank()
|
||||
|| page.getHoverName().getString().toLowerCase(Locale.ROOT)
|
||||
.contains(textInput.getValue().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
private int pageAt(double mouseX, double mouseY, List<Integer> pages) {
|
||||
if (!inSurface(mouseX, mouseY)) return -1;
|
||||
int localX = (int)mouseX - leftPos;
|
||||
int localY = (int)mouseY - topPos - SURFACE_TOP + scroll;
|
||||
int column = localX / PAGE_STEP_X;
|
||||
int position = (localY / PAGE_STEP_Y) * PAGE_COLUMNS + column;
|
||||
return column < PAGE_COLUMNS && localX % PAGE_STEP_X < PAGE_WIDTH
|
||||
&& localY % PAGE_STEP_Y < PAGE_HEIGHT && position < pages.size()
|
||||
? pages.get(position) : -1;
|
||||
}
|
||||
|
||||
private boolean inSurface(double mouseX, double mouseY) {
|
||||
return mouseX >= leftPos && mouseX < leftPos + SURFACE_RIGHT
|
||||
&& mouseY >= topPos + SURFACE_TOP && mouseY < topPos + SURFACE_BOTTOM;
|
||||
}
|
||||
|
||||
private boolean inScrollbar(double mouseX, double mouseY) {
|
||||
return mouseX >= leftPos + SURFACE_RIGHT && mouseX < leftPos + imageWidth
|
||||
&& mouseY >= topPos + SURFACE_TOP && mouseY < topPos + SURFACE_BOTTOM;
|
||||
}
|
||||
|
||||
private int maxScroll(int pageCount) {
|
||||
int rows = (pageCount + PAGE_COLUMNS - 1) / PAGE_COLUMNS;
|
||||
return Math.max(0, rows * PAGE_STEP_Y - (SURFACE_BOTTOM - SURFACE_TOP));
|
||||
}
|
||||
|
||||
private void setScrollFromMouse(double mouseY, int pageCount) {
|
||||
int maximum = maxScroll(pageCount);
|
||||
double fraction = (mouseY - topPos - SURFACE_TOP - 10.0)
|
||||
/ (SURFACE_BOTTOM - SURFACE_TOP - 20.0);
|
||||
scroll = Math.clamp((int)(Math.clamp(fraction, 0.0, 1.0) * maximum), 0, maximum);
|
||||
}
|
||||
|
||||
private void drawScrollbar(GuiGraphics graphics, int pageCount) {
|
||||
int x = leftPos + SURFACE_RIGHT;
|
||||
int y = topPos + SURFACE_TOP;
|
||||
int height = SURFACE_BOTTOM - SURFACE_TOP;
|
||||
graphics.fill(x, y, x + 20, y + height, 0xFF858585);
|
||||
graphics.renderOutline(x, y, 20, height, 0xFF262626);
|
||||
for (int line = y + 5; line < y + height - 4; line += 5) {
|
||||
graphics.fill(x + 4, line, x + 16, line + 1, 0xFFB7B7B7);
|
||||
}
|
||||
int maximum = maxScroll(pageCount);
|
||||
int thumbY = y + 4 + (maximum == 0 ? 0 : scroll * (height - 23) / maximum);
|
||||
graphics.fill(x + 4, thumbY, x + 16, thumbY + 15, 0xFFC9C9C9);
|
||||
graphics.renderOutline(x + 4, thumbY, 12, 15, 0xFF414141);
|
||||
}
|
||||
|
||||
private void drawPage(GuiGraphics graphics, int index, int x, int y) {
|
||||
ItemStack page = menu.getSlot(index).getItem();
|
||||
boolean visible = !page.isEmpty() && matchesSearch(page);
|
||||
graphics.fill(x, y, x + PAGE_WIDTH, y + PAGE_HEIGHT,
|
||||
visible ? 0xFFE5D4A7 : 0x704B4945);
|
||||
graphics.fill(x + 2, y + 2, x + PAGE_WIDTH - 2, y + PAGE_HEIGHT - 2,
|
||||
visible ? 0xFFF4E5C3 : 0x603B3934);
|
||||
graphics.renderOutline(x, y, PAGE_WIDTH, PAGE_HEIGHT,
|
||||
index == selectedSlot ? 0xFFFFD061 : 0xFF564A34);
|
||||
if (visible) {
|
||||
graphics.pose().pushPose();
|
||||
graphics.pose().translate(x + 3, y + 8, 0);
|
||||
graphics.pose().scale(1.5F, 1.5F, 1.0F);
|
||||
graphics.renderItem(page, 0, 0);
|
||||
graphics.pose().popPose();
|
||||
}
|
||||
}
|
||||
|
||||
private void toggleRename() {
|
||||
if (renaming) {
|
||||
finishRename();
|
||||
} else if (selectedSlot >= 0 && !menu.getSlot(selectedSlot).getItem().isEmpty()) {
|
||||
renaming = true;
|
||||
textInput.setValue(menu.getSlot(selectedSlot).getItem().getHoverName().getString());
|
||||
textInput.setHint(Component.translatable("screen.rivencraft.notebook.rename"));
|
||||
setFocused(textInput);
|
||||
textInput.setFocused(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void finishRename() {
|
||||
commitRename();
|
||||
renaming = false;
|
||||
textInput.setValue("");
|
||||
textInput.setHint(Component.translatable("screen.rivencraft.notebook.search"));
|
||||
}
|
||||
|
||||
private void commitRename() {
|
||||
if (renaming && selectedSlot >= 0 && !menu.getSlot(selectedSlot).getItem().isEmpty()) {
|
||||
PacketDistributor.sendToServer(new RenameNotebookPagePayload(
|
||||
menu.containerId, selectedSlot, textInput.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
private void moveSelected(boolean next) {
|
||||
int target = selectedSlot + (next ? 1 : -1);
|
||||
if (selectedSlot < 0 || target < 0 || target >= NotebookMenu.NOTEBOOK_SLOTS
|
||||
|| menu.getSlot(selectedSlot).getItem().isEmpty()) return;
|
||||
int buttonId = (next ? NotebookMenu.MOVE_NEXT_BASE : NotebookMenu.MOVE_PREVIOUS_BASE) + selectedSlot;
|
||||
if (menu.clickMenuButton(minecraft.player, buttonId)) {
|
||||
minecraft.gameMode.handleInventoryButtonClick(menu.containerId, buttonId);
|
||||
selectedSlot = target;
|
||||
}
|
||||
}
|
||||
|
||||
private static void drawBeveledPanel(GuiGraphics graphics, int x, int y, int width, int height) {
|
||||
graphics.fill(x, y, x + width, y + height, 0xFFC6C6C6);
|
||||
graphics.fill(x, y, x + width, y + 2, 0xFFFFFFFF);
|
||||
graphics.fill(x, y, x + 2, y + height, 0xFFFFFFFF);
|
||||
graphics.fill(x, y + height - 2, x + width, y + height, 0xFF555555);
|
||||
graphics.fill(x + width - 2, y, x + width, y + height, 0xFF555555);
|
||||
}
|
||||
|
||||
private void drawSlot(GuiGraphics graphics, int x, int y) {
|
||||
graphics.fill(leftPos + x, topPos + y, leftPos + x + 18, topPos + y + 18, 0xFF8B8B8B);
|
||||
graphics.fill(leftPos + x, topPos + y, leftPos + x + 18, topPos + y + 1, 0xFF373737);
|
||||
graphics.fill(leftPos + x, topPos + y, leftPos + x + 1, topPos + y + 18, 0xFF373737);
|
||||
graphics.fill(leftPos + x + 17, topPos + y, leftPos + x + 18, topPos + y + 18, 0xFFFFFFFF);
|
||||
graphics.fill(leftPos + x, topPos + y + 17, leftPos + x + 18, topPos + y + 18, 0xFFFFFFFF);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package net.dnorberg.rivencraft.command;
|
||||
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import net.dnorberg.rivencraft.book.AgeDefinition;
|
||||
import net.dnorberg.rivencraft.book.AgeDimensionService;
|
||||
import net.dnorberg.rivencraft.book.AgeRegistrySavedData;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.neoforged.neoforge.event.RegisterCommandsEvent;
|
||||
|
||||
/** Administrative commands for inspecting and safely unloading persistent Ages. */
|
||||
public final class RivencraftCommands {
|
||||
private RivencraftCommands() {
|
||||
}
|
||||
|
||||
public static void register(RegisterCommandsEvent event) {
|
||||
event.getDispatcher().register(Commands.literal("rivencraft")
|
||||
.requires(source -> source.hasPermission(2))
|
||||
.then(Commands.literal("age")
|
||||
.then(Commands.literal("list")
|
||||
.executes(context -> listAges(context.getSource())))
|
||||
.then(Commands.literal("unload")
|
||||
.then(Commands.argument("dimension", StringArgumentType.string())
|
||||
.suggests((context, builder) -> {
|
||||
AgeRegistrySavedData.get(context.getSource().getLevel()).definitions()
|
||||
.forEach(age -> builder.suggest(age.dimensionId().toString()));
|
||||
return builder.buildFuture();
|
||||
})
|
||||
.executes(context -> unloadAge(
|
||||
context.getSource(),
|
||||
StringArgumentType.getString(context, "dimension")
|
||||
))))));
|
||||
}
|
||||
|
||||
private static int listAges(net.minecraft.commands.CommandSourceStack source) {
|
||||
var ages = AgeRegistrySavedData.get(source.getLevel()).definitions().stream()
|
||||
.sorted(java.util.Comparator.comparing(AgeDefinition::name))
|
||||
.toList();
|
||||
source.sendSuccess(() -> Component.literal("Rivencraft Ages: " + ages.size()), false);
|
||||
for (AgeDefinition age : ages) {
|
||||
boolean loaded = source.getServer().getLevel(AgeDimensionService.dimensionKey(age)) != null;
|
||||
source.sendSuccess(() -> Component.literal(
|
||||
(loaded ? "[loaded] " : "[unloaded] ")
|
||||
+ age.name() + " — " + age.dimensionId()
|
||||
), false);
|
||||
}
|
||||
return ages.size();
|
||||
}
|
||||
|
||||
private static int unloadAge(net.minecraft.commands.CommandSourceStack source, String requestedDimension) {
|
||||
ResourceLocation dimension = ResourceLocation.tryParse(requestedDimension);
|
||||
if (dimension == null) {
|
||||
source.sendFailure(Component.literal("Invalid dimension id: " + requestedDimension));
|
||||
return 0;
|
||||
}
|
||||
AgeDefinition age = AgeRegistrySavedData.get(source.getLevel()).findByDimension(dimension).orElse(null);
|
||||
if (age == null) {
|
||||
source.sendFailure(Component.literal("Unknown Rivencraft Age: " + dimension));
|
||||
return 0;
|
||||
}
|
||||
|
||||
AgeDimensionService.UnloadResult result = AgeDimensionService.unload(source.getServer(), age);
|
||||
return switch (result) {
|
||||
case UNLOADED -> {
|
||||
source.sendSuccess(() -> Component.literal(
|
||||
"Unloaded " + age.name() + ". Its definition and world data were retained."
|
||||
), true);
|
||||
yield 1;
|
||||
}
|
||||
case ALREADY_UNLOADED -> {
|
||||
source.sendFailure(Component.literal(age.name() + " is already unloaded."));
|
||||
yield 0;
|
||||
}
|
||||
case FAILED -> {
|
||||
source.sendFailure(Component.literal("Dynamic Dimensions refused to unload " + age.name() + "."));
|
||||
yield 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,13 @@
|
||||
package net.dnorberg.rivencraft.compat;
|
||||
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import qouteall.imm_ptl.core.api.PortalAPI;
|
||||
import qouteall.imm_ptl.core.chunk_loading.ChunkLoader;
|
||||
@@ -14,12 +16,12 @@ import qouteall.q_misc_util.dimension.DimensionIntId;
|
||||
|
||||
/** Isolated server bridge; this class is loaded only when Immersive Portals is installed. */
|
||||
public final class ImmersivePortalsChunkLoaders {
|
||||
private static final Map<ServerPlayer, ChunkLoader> LOADERS = new WeakHashMap<>();
|
||||
private static final Map<ServerPlayer, ChunkLoader> LOADERS = new IdentityHashMap<>();
|
||||
|
||||
private ImmersivePortalsChunkLoaders() {
|
||||
}
|
||||
|
||||
public static void open(ServerPlayer player, ServerLevel level, BlockPos center) {
|
||||
public static synchronized void open(ServerPlayer player, ServerLevel level, BlockPos center) {
|
||||
close(player);
|
||||
int centerChunkX = center.getX() >> 4;
|
||||
int centerChunkZ = center.getZ() >> 4;
|
||||
@@ -37,13 +39,28 @@ public final class ImmersivePortalsChunkLoaders {
|
||||
ImmPtlChunkTracking.immediatelyUpdateForPlayer(player);
|
||||
}
|
||||
|
||||
public static void close(ServerPlayer player) {
|
||||
public static synchronized void close(ServerPlayer player) {
|
||||
ChunkLoader loader = LOADERS.remove(player);
|
||||
if (loader != null) {
|
||||
PortalAPI.removeChunkLoaderForPlayer(player, loader);
|
||||
}
|
||||
}
|
||||
|
||||
public static synchronized void closeForDimension(ResourceKey<Level> dimension) {
|
||||
LOADERS.entrySet().removeIf(entry -> {
|
||||
if (!entry.getValue().dimension().equals(dimension)) {
|
||||
return false;
|
||||
}
|
||||
PortalAPI.removeChunkLoaderForPlayer(entry.getKey(), entry.getValue());
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
public static synchronized void closeAll() {
|
||||
LOADERS.forEach(PortalAPI::removeChunkLoaderForPlayer);
|
||||
LOADERS.clear();
|
||||
}
|
||||
|
||||
/** Registers runtime dimensions and sends the revised ID map to connected clients. */
|
||||
public static void dimensionsChanged(MinecraftServer server) {
|
||||
DimensionIntId.onServerDimensionChanged(server);
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package net.dnorberg.rivencraft.compat;
|
||||
|
||||
import net.dnorberg.rivencraft.config.RivencraftClientConfig;
|
||||
|
||||
/** Pure selection policy for optional destination preview integrations. */
|
||||
public final class PreviewBackendSelector {
|
||||
public enum Backend {
|
||||
IMMERSIVE_PORTALS,
|
||||
PONDER,
|
||||
LEGACY
|
||||
}
|
||||
|
||||
private PreviewBackendSelector() {
|
||||
}
|
||||
|
||||
public static Backend select(
|
||||
RivencraftClientConfig.PreviewMode mode,
|
||||
boolean immersivePortalsAvailable,
|
||||
boolean ponderAvailable
|
||||
) {
|
||||
return switch (mode) {
|
||||
case AUTO -> immersivePortalsAvailable
|
||||
? Backend.IMMERSIVE_PORTALS
|
||||
: ponderAvailable ? Backend.PONDER : Backend.LEGACY;
|
||||
case IMMERSIVE_PORTALS -> immersivePortalsAvailable ? Backend.IMMERSIVE_PORTALS : Backend.LEGACY;
|
||||
case PONDER -> ponderAvailable ? Backend.PONDER : Backend.LEGACY;
|
||||
case LEGACY -> Backend.LEGACY;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package net.dnorberg.rivencraft.event;
|
||||
|
||||
import net.dnorberg.rivencraft.compat.ImmersivePortalsChunkLoaders;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.neoforged.fml.ModList;
|
||||
import net.neoforged.neoforge.event.entity.player.PlayerEvent;
|
||||
import net.neoforged.neoforge.event.server.ServerStoppingEvent;
|
||||
|
||||
/** Server-authoritative cleanup for resources that exist only while a preview is active. */
|
||||
public final class AgeLifecycleEvents {
|
||||
private AgeLifecycleEvents() {
|
||||
}
|
||||
|
||||
public static void onPlayerLoggedOut(PlayerEvent.PlayerLoggedOutEvent event) {
|
||||
if (event.getEntity() instanceof ServerPlayer player
|
||||
&& ModList.get().isLoaded("immersive_portals_core")) {
|
||||
ImmersivePortalsChunkLoaders.close(player);
|
||||
}
|
||||
}
|
||||
|
||||
public static void onServerStopping(ServerStoppingEvent event) {
|
||||
if (ModList.get().isLoaded("immersive_portals_core")) {
|
||||
ImmersivePortalsChunkLoaders.closeAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,10 +6,14 @@ import net.dnorberg.rivencraft.book.AgeDimensionService;
|
||||
import net.dnorberg.rivencraft.book.AgeGenerationProfiles;
|
||||
import net.dnorberg.rivencraft.book.AgeReference;
|
||||
import net.dnorberg.rivencraft.book.AgeRegistrySavedData;
|
||||
import net.dnorberg.rivencraft.book.AgeRuntimeProfile;
|
||||
import net.dnorberg.rivencraft.book.AgeRuntimeProfiles;
|
||||
import net.dnorberg.rivencraft.book.LinkTarget;
|
||||
import net.dnorberg.rivencraft.book.LinkingService;
|
||||
import net.dnorberg.rivencraft.book.AgeVisitSavedData;
|
||||
import net.dnorberg.rivencraft.book.AgeTraits;
|
||||
import net.dnorberg.rivencraft.compat.PreviewBackendSelector;
|
||||
import net.dnorberg.rivencraft.config.RivencraftClientConfig;
|
||||
import net.dnorberg.rivencraft.item.DescriptiveBookItem;
|
||||
import net.dnorberg.rivencraft.item.LinkingBookItem;
|
||||
import net.dnorberg.rivencraft.registry.ModDataComponents;
|
||||
@@ -38,6 +42,91 @@ public final class LinkingGameTests {
|
||||
private LinkingGameTests() {
|
||||
}
|
||||
|
||||
@GameTest(template = "empty")
|
||||
public static void previewBackendSelectionCoversOptionalDependencyMatrix(GameTestHelper helper) {
|
||||
assertPreviewBackend(helper, RivencraftClientConfig.PreviewMode.AUTO, true, true,
|
||||
PreviewBackendSelector.Backend.IMMERSIVE_PORTALS);
|
||||
assertPreviewBackend(helper, RivencraftClientConfig.PreviewMode.AUTO, true, false,
|
||||
PreviewBackendSelector.Backend.IMMERSIVE_PORTALS);
|
||||
assertPreviewBackend(helper, RivencraftClientConfig.PreviewMode.AUTO, false, true,
|
||||
PreviewBackendSelector.Backend.PONDER);
|
||||
assertPreviewBackend(helper, RivencraftClientConfig.PreviewMode.AUTO, false, false,
|
||||
PreviewBackendSelector.Backend.LEGACY);
|
||||
|
||||
for (boolean ponderAvailable : new boolean[] {false, true}) {
|
||||
assertPreviewBackend(helper, RivencraftClientConfig.PreviewMode.IMMERSIVE_PORTALS, true,
|
||||
ponderAvailable, PreviewBackendSelector.Backend.IMMERSIVE_PORTALS);
|
||||
assertPreviewBackend(helper, RivencraftClientConfig.PreviewMode.IMMERSIVE_PORTALS, false,
|
||||
ponderAvailable, PreviewBackendSelector.Backend.LEGACY);
|
||||
}
|
||||
for (boolean immersivePortalsAvailable : new boolean[] {false, true}) {
|
||||
assertPreviewBackend(helper, RivencraftClientConfig.PreviewMode.PONDER,
|
||||
immersivePortalsAvailable, true, PreviewBackendSelector.Backend.PONDER);
|
||||
assertPreviewBackend(helper, RivencraftClientConfig.PreviewMode.PONDER,
|
||||
immersivePortalsAvailable, false, PreviewBackendSelector.Backend.LEGACY);
|
||||
}
|
||||
for (boolean immersivePortalsAvailable : new boolean[] {false, true}) {
|
||||
for (boolean ponderAvailable : new boolean[] {false, true}) {
|
||||
assertPreviewBackend(helper, RivencraftClientConfig.PreviewMode.LEGACY,
|
||||
immersivePortalsAvailable, ponderAvailable, PreviewBackendSelector.Backend.LEGACY);
|
||||
}
|
||||
}
|
||||
helper.succeed();
|
||||
}
|
||||
|
||||
private static void assertPreviewBackend(
|
||||
GameTestHelper helper,
|
||||
RivencraftClientConfig.PreviewMode mode,
|
||||
boolean immersivePortalsAvailable,
|
||||
boolean ponderAvailable,
|
||||
PreviewBackendSelector.Backend expected
|
||||
) {
|
||||
helper.assertValueEqual(
|
||||
PreviewBackendSelector.select(mode, immersivePortalsAvailable, ponderAvailable),
|
||||
expected,
|
||||
mode + " selection with Immersive Portals=" + immersivePortalsAvailable
|
||||
+ " and Ponder=" + ponderAvailable
|
||||
);
|
||||
}
|
||||
|
||||
@GameTest(template = "empty")
|
||||
public static void dataPackAgeProfilesResolveRegisteredResources(GameTestHelper helper) {
|
||||
var registries = helper.getLevel().registryAccess();
|
||||
var profiles = AgeRuntimeProfiles.profiles();
|
||||
helper.assertTrue(profiles.keySet().containsAll(AgeGenerationProfiles.all()),
|
||||
"Every built-in Age runtime profile must survive data-pack validation");
|
||||
for (var entry : profiles.entrySet()) {
|
||||
AgeRuntimeProfile profile = entry.getValue();
|
||||
helper.assertValueEqual(profile.schemaVersion(), AgeRuntimeProfile.CURRENT_SCHEMA_VERSION,
|
||||
entry.getKey() + " must use the current runtime-profile schema");
|
||||
helper.assertTrue(registries.lookupOrThrow(net.minecraft.core.registries.Registries.DIMENSION_TYPE)
|
||||
.get(net.minecraft.resources.ResourceKey.create(
|
||||
net.minecraft.core.registries.Registries.DIMENSION_TYPE,
|
||||
profile.dimensionType())).isPresent(),
|
||||
entry.getKey() + " must reference a registered dimension type");
|
||||
if (profile.terrain() == AgeRuntimeProfile.Terrain.NOISE) {
|
||||
helper.assertTrue(registries.lookupOrThrow(net.minecraft.core.registries.Registries.NOISE_SETTINGS)
|
||||
.get(net.minecraft.resources.ResourceKey.create(
|
||||
net.minecraft.core.registries.Registries.NOISE_SETTINGS,
|
||||
profile.noiseSettings())).isPresent(),
|
||||
entry.getKey() + " must reference registered noise settings");
|
||||
helper.assertTrue(registries.lookupOrThrow(
|
||||
net.minecraft.core.registries.Registries.MULTI_NOISE_BIOME_SOURCE_PARAMETER_LIST)
|
||||
.get(net.minecraft.resources.ResourceKey.create(
|
||||
net.minecraft.core.registries.Registries.MULTI_NOISE_BIOME_SOURCE_PARAMETER_LIST,
|
||||
profile.biomePreset())).isPresent(),
|
||||
entry.getKey() + " must reference a registered biome preset");
|
||||
}
|
||||
}
|
||||
var missing = net.minecraft.resources.ResourceLocation.fromNamespaceAndPath("example", "removed_profile");
|
||||
helper.assertValueEqual(
|
||||
AgeRuntimeProfiles.resolve(missing),
|
||||
AgeRuntimeProfiles.resolve(AgeGenerationProfiles.STANDARD),
|
||||
"A removed custom profile must use the documented deterministic fallback"
|
||||
);
|
||||
helper.succeed();
|
||||
}
|
||||
|
||||
@GameTest(template = "empty")
|
||||
public static void linkTargetSurvivesItemSerialization(GameTestHelper helper) {
|
||||
LinkTarget expected = new LinkTarget(
|
||||
@@ -152,6 +241,114 @@ public final class LinkingGameTests {
|
||||
});
|
||||
}
|
||||
|
||||
@GameTest(template = "empty", timeoutTicks = 400)
|
||||
public static void everyTerrainProfileProvidesSafeArrivalAndReturnTravel(GameTestHelper helper) {
|
||||
ServerPlayer player = helper.makeMockServerPlayerInLevel();
|
||||
BlockPos returnPosition = player.blockPosition();
|
||||
helper.getLevel().setBlock(returnPosition.below(), Blocks.STONE.defaultBlockState(), 2);
|
||||
helper.getLevel().setBlock(returnPosition, Blocks.AIR.defaultBlockState(), 2);
|
||||
helper.getLevel().setBlock(returnPosition.above(), Blocks.AIR.defaultBlockState(), 2);
|
||||
LinkTarget returnTarget = new LinkTarget(
|
||||
GlobalPos.of(helper.getLevel().dimension(), returnPosition),
|
||||
player.getYRot(),
|
||||
player.getXRot()
|
||||
);
|
||||
long worldSeed = helper.getLevel().getServer().overworld().getSeed();
|
||||
runTerrainProfileTravel(helper, player, returnTarget, AgeGenerationProfiles.all(), 0, worldSeed);
|
||||
}
|
||||
|
||||
private static void runTerrainProfileTravel(
|
||||
GameTestHelper helper,
|
||||
ServerPlayer player,
|
||||
LinkTarget returnTarget,
|
||||
java.util.List<net.minecraft.resources.ResourceLocation> profiles,
|
||||
int index,
|
||||
long worldSeed
|
||||
) {
|
||||
if (index >= profiles.size()) {
|
||||
helper.succeed();
|
||||
return;
|
||||
}
|
||||
var profile = profiles.get(index);
|
||||
AgeReference reference = referenceSelectingProfile(profile, worldSeed);
|
||||
LinkTarget destination = AgeDimensionService.resolve(player, reference).orElse(null);
|
||||
helper.assertTrue(destination != null, profile + " must create a destination");
|
||||
if (destination == null) {
|
||||
return;
|
||||
}
|
||||
helper.runAfterDelay(1, () -> {
|
||||
AgeDefinition definition = AgeRegistrySavedData.get(helper.getLevel()).find(reference.id()).orElseThrow();
|
||||
helper.assertValueEqual(definition.generationProfile(), profile,
|
||||
"The acceptance fixture must select " + profile);
|
||||
var ageLevel = player.getServer().getLevel(destination.location().dimension());
|
||||
helper.assertTrue(ageLevel != null, profile + " must create a loaded runtime dimension");
|
||||
BlockPos spawn = destination.location().pos();
|
||||
helper.assertTrue(ageLevel != null && ageLevel.getBlockState(spawn.below()).is(Blocks.COBBLESTONE),
|
||||
profile + " must create a solid arrival platform");
|
||||
helper.assertTrue(ageLevel != null && ageLevel.getBlockState(spawn).isAir()
|
||||
&& ageLevel.getBlockState(spawn.above()).isAir(),
|
||||
profile + " must create clear arrival headroom");
|
||||
helper.assertValueEqual(LinkingService.travelWithFooting(player, destination),
|
||||
LinkingService.LinkResult.SUCCESS, profile + " must accept safe inbound travel");
|
||||
helper.assertValueEqual(LinkingService.travel(player, returnTarget),
|
||||
LinkingService.LinkResult.SUCCESS, profile + " must permit return travel");
|
||||
helper.runAfterDelay(1, () -> runTerrainProfileTravel(
|
||||
helper, player, returnTarget, profiles, index + 1, worldSeed));
|
||||
});
|
||||
}
|
||||
|
||||
private static AgeReference referenceSelectingProfile(
|
||||
net.minecraft.resources.ResourceLocation profile,
|
||||
long worldSeed
|
||||
) {
|
||||
UUID id = UUID.randomUUID();
|
||||
for (int candidate = 0; candidate < 100_000; candidate++) {
|
||||
String name = "Profile Acceptance " + profile.getPath() + " " + id + " " + candidate;
|
||||
var dimension = AgeDefinition.namedDimensionId(name);
|
||||
long seed = worldSeed + dimension.hashCode();
|
||||
if (AgeRuntimeProfiles.select(seed).equals(profile)) {
|
||||
return new AgeReference(id, name);
|
||||
}
|
||||
}
|
||||
throw new IllegalStateException("Could not select profile " + profile);
|
||||
}
|
||||
|
||||
@GameTest(template = "empty", timeoutTicks = 100)
|
||||
public static void unloadedAgeReloadsWithTheSameDefinition(GameTestHelper helper) {
|
||||
UUID id = UUID.randomUUID();
|
||||
AgeDefinition definition = AgeRegistrySavedData.resolveOrCreate(
|
||||
helper.getLevel(),
|
||||
new AgeReference(id, "Lifecycle Test Age " + id)
|
||||
);
|
||||
|
||||
var server = helper.getLevel().getServer();
|
||||
var first = AgeDimensionService.ensureLoaded(server, definition);
|
||||
helper.assertTrue(first != null, "The lifecycle test Age must load");
|
||||
helper.runAfterDelay(1, () -> {
|
||||
helper.assertValueEqual(
|
||||
AgeDimensionService.unload(server, definition),
|
||||
AgeDimensionService.UnloadResult.UNLOADED,
|
||||
"A loaded Age must unload without deleting its definition"
|
||||
);
|
||||
helper.runAfterDelay(1, () -> {
|
||||
helper.assertTrue(server.getLevel(AgeDimensionService.dimensionKey(definition)) == null,
|
||||
"An unloaded Age must leave the active server level map");
|
||||
|
||||
var reloaded = AgeDimensionService.ensureLoaded(server, definition);
|
||||
helper.assertTrue(reloaded != null, "A book must be able to reload an archived Age");
|
||||
helper.runAfterDelay(1, () -> {
|
||||
var registered = server.getLevel(AgeDimensionService.dimensionKey(definition));
|
||||
helper.assertTrue(registered != null, "The reloaded Age must rejoin the active server level map");
|
||||
helper.assertValueEqual(registered.getSeed(), definition.seed(),
|
||||
"Reloading an Age must preserve its immutable seed");
|
||||
helper.assertValueEqual(registered.dimension().location(), definition.dimensionId(),
|
||||
"Reloading an Age must preserve its dimension identifier");
|
||||
helper.succeed();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@GameTest(template = "empty", timeoutTicks = 200)
|
||||
public static void legacyBaseTerrainProfilesLoadRuntimeDimensions(GameTestHelper helper) {
|
||||
for (var profile : AgeGenerationProfiles.all()) {
|
||||
@@ -404,7 +601,9 @@ public final class LinkingGameTests {
|
||||
}
|
||||
helper.assertTrue(level.getChunkSource().getGenerator().getBiomeSource().possibleBiomes().stream().allMatch(holder -> holder.is(biome)),
|
||||
"The material test Age must select " + biome.location());
|
||||
// Sample away from the generated arrival platform around the Age spawn.
|
||||
// Sample away from the generated arrival platform. Vanilla surface rules
|
||||
// can place a shallow local patch such as gravel over the biome's base block.
|
||||
boolean foundExpectedSurface = false;
|
||||
int sampleX = 64;
|
||||
int sampleZ = 64;
|
||||
level.getChunk(sampleX >> 4, sampleZ >> 4);
|
||||
@@ -413,10 +612,15 @@ public final class LinkingGameTests {
|
||||
sampleX,
|
||||
sampleZ
|
||||
) - 1;
|
||||
var surfaceState = level.getBlockState(new BlockPos(sampleX, surfaceY, sampleZ));
|
||||
helper.assertTrue(surfaceState.is(expectedBlock),
|
||||
for (int depth = 0; depth <= 8; depth++) {
|
||||
if (level.getBlockState(new BlockPos(sampleX, surfaceY - depth, sampleZ)).is(expectedBlock)) {
|
||||
foundExpectedSurface = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
helper.assertTrue(foundExpectedSurface,
|
||||
biome.location() + " terrain must expose " + expectedBlock.getDescriptionId()
|
||||
+ " at the surface, found " + surfaceState);
|
||||
+ " across the sampled surface");
|
||||
}
|
||||
|
||||
@GameTest(template = "empty")
|
||||
|
||||
@@ -0,0 +1,206 @@
|
||||
package net.dnorberg.rivencraft.gametest;
|
||||
|
||||
import com.mojang.serialization.JsonOps;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import java.util.List;
|
||||
import net.dnorberg.rivencraft.Rivencraft;
|
||||
import net.dnorberg.rivencraft.writing.OrderedWriting;
|
||||
import net.dnorberg.rivencraft.writing.PageContent;
|
||||
import net.dnorberg.rivencraft.writing.SymbolCatalog;
|
||||
import net.dnorberg.rivencraft.writing.SymbolReference;
|
||||
import net.dnorberg.rivencraft.writing.WritingEntry;
|
||||
import net.dnorberg.rivencraft.writing.NotebookContents;
|
||||
import net.dnorberg.rivencraft.item.PageItem;
|
||||
import net.dnorberg.rivencraft.registry.ModDataComponents;
|
||||
import net.dnorberg.rivencraft.registry.ModItems;
|
||||
import net.dnorberg.rivencraft.menu.NotebookMenu;
|
||||
import net.minecraft.gametest.framework.GameTest;
|
||||
import net.minecraft.gametest.framework.GameTestHelper;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.inventory.ClickType;
|
||||
import net.neoforged.neoforge.gametest.GameTestHolder;
|
||||
import net.neoforged.neoforge.gametest.PrefixGameTestTemplate;
|
||||
|
||||
/** Acceptance coverage for Milestone 4's persistent writing contracts. */
|
||||
@GameTestHolder(Rivencraft.MOD_ID)
|
||||
@PrefixGameTestTemplate(false)
|
||||
public final class WritingDataGameTests {
|
||||
private WritingDataGameTests() {
|
||||
}
|
||||
|
||||
@GameTest(template = "empty")
|
||||
public static void orderedWritingPreservesKnownUnknownAndLinkPanelEntries(GameTestHelper helper) {
|
||||
SymbolReference known = reference("rivencraft:terrain/standard");
|
||||
SymbolReference unknown = reference("example:removed_symbol");
|
||||
OrderedWriting original = new OrderedWriting(List.of(
|
||||
WritingEntry.symbol(known),
|
||||
WritingEntry.symbol(unknown),
|
||||
WritingEntry.linkPanel()
|
||||
));
|
||||
|
||||
var json = OrderedWriting.CODEC.encodeStart(JsonOps.INSTANCE, original).result().orElseThrow();
|
||||
OrderedWriting persistentCopy = OrderedWriting.CODEC.parse(JsonOps.INSTANCE, json).result().orElseThrow();
|
||||
helper.assertValueEqual(persistentCopy, original,
|
||||
"Persistent writing codec must retain entry order and unknown symbol IDs");
|
||||
|
||||
FriendlyByteBuf buffer = new FriendlyByteBuf(Unpooled.buffer());
|
||||
OrderedWriting.STREAM_CODEC.encode(buffer, original);
|
||||
OrderedWriting networkCopy = OrderedWriting.STREAM_CODEC.decode(buffer);
|
||||
helper.assertValueEqual(networkCopy, original,
|
||||
"Network writing codec must retain entry order and unknown symbol IDs");
|
||||
helper.succeed();
|
||||
}
|
||||
|
||||
@GameTest(template = "empty")
|
||||
public static void serverCatalogResolvesBuiltinsAndKeepsUnknownReferencesReadable(GameTestHelper helper) {
|
||||
SymbolReference known = reference("rivencraft:terrain/standard");
|
||||
SymbolReference unknown = reference("example:removed_symbol");
|
||||
helper.assertTrue(SymbolCatalog.symbols().size() >= 6,
|
||||
"The built-in catalog must exercise every Milestone 4 writing workflow");
|
||||
helper.assertTrue(SymbolCatalog.isKnown(known),
|
||||
"The built-in Standard Terrain symbol must be server-authoritative");
|
||||
helper.assertFalse(SymbolCatalog.isKnown(unknown),
|
||||
"An absent data-pack symbol must remain unresolved");
|
||||
var unresolved = SymbolCatalog.display(unknown);
|
||||
helper.assertFalse(unresolved.resolved(),
|
||||
"Unknown symbol display metadata must be marked unresolved");
|
||||
helper.assertValueEqual(unresolved.id(), unknown.id(),
|
||||
"Unresolved display metadata must preserve the original namespaced ID");
|
||||
helper.succeed();
|
||||
}
|
||||
|
||||
@GameTest(template = "empty")
|
||||
public static void pageStatesPersistAndNetworkRoundTrip(GameTestHelper helper) {
|
||||
SymbolReference known = reference("rivencraft:terrain/standard");
|
||||
SymbolReference removed = reference("example:removed_symbol");
|
||||
List<PageContent> states = List.of(
|
||||
PageContent.BLANK,
|
||||
PageContent.symbol(known),
|
||||
PageContent.unresolved(removed),
|
||||
PageContent.LINK_PANEL
|
||||
);
|
||||
|
||||
for (PageContent state : states) {
|
||||
var json = PageContent.CODEC.encodeStart(JsonOps.INSTANCE, state).result().orElseThrow();
|
||||
PageContent persistentCopy = PageContent.CODEC.parse(JsonOps.INSTANCE, json).result().orElseThrow();
|
||||
helper.assertValueEqual(persistentCopy, state, "Page content must persist exactly");
|
||||
|
||||
FriendlyByteBuf buffer = new FriendlyByteBuf(Unpooled.buffer());
|
||||
PageContent.STREAM_CODEC.encode(buffer, state);
|
||||
helper.assertValueEqual(PageContent.STREAM_CODEC.decode(buffer), state,
|
||||
"Page content must network-sync exactly");
|
||||
}
|
||||
helper.succeed();
|
||||
}
|
||||
|
||||
@GameTest(template = "empty")
|
||||
public static void pageItemPreservesContentAndRejectsForgedUnknownSymbols(GameTestHelper helper) {
|
||||
SymbolReference known = reference("rivencraft:terrain/standard");
|
||||
SymbolReference unknown = reference("example:forged_symbol");
|
||||
ItemStack page = PageItem.createSymbolPage(known);
|
||||
CompoundTag serialized = (CompoundTag) page.saveOptional(helper.getLevel().registryAccess());
|
||||
ItemStack restored = ItemStack.parseOptional(helper.getLevel().registryAccess(), serialized);
|
||||
helper.assertValueEqual(restored.get(ModDataComponents.PAGE_CONTENT.get()), PageContent.symbol(known),
|
||||
"Symbol page content must survive an ItemStack save/load");
|
||||
helper.assertValueEqual(
|
||||
restored.get(ModDataComponents.PAGE_SYMBOL_DISPLAY.get()),
|
||||
SymbolCatalog.display(known),
|
||||
"Server-selected display metadata must survive for remote clients"
|
||||
);
|
||||
|
||||
ItemStack recovered = PageItem.createRecoveredPage(unknown);
|
||||
helper.assertFalse(PageItem.isUsableWriting(recovered),
|
||||
"An unresolved page must remain recoverable without becoming valid writing");
|
||||
try {
|
||||
PageItem.createSymbolPage(unknown);
|
||||
helper.fail("The server must reject new pages for unknown symbols");
|
||||
} catch (IllegalArgumentException expected) {
|
||||
helper.succeed();
|
||||
}
|
||||
}
|
||||
|
||||
@GameTest(template = "empty")
|
||||
public static void notebookContentsPreserveOrderGapsNamesAndUnknownPages(GameTestHelper helper) {
|
||||
ItemStack first = PageItem.createSymbolPage(reference("rivencraft:terrain/standard"));
|
||||
first.set(net.minecraft.core.component.DataComponents.CUSTOM_NAME,
|
||||
net.minecraft.network.chat.Component.literal("Foundation"));
|
||||
ItemStack unknown = PageItem.createRecoveredPage(reference("example:removed_symbol"));
|
||||
NotebookContents contents = new NotebookContents(List.of(first, ItemStack.EMPTY, unknown));
|
||||
ItemStack notebook = new ItemStack(ModItems.NOTEBOOK.get());
|
||||
notebook.set(ModDataComponents.NOTEBOOK_CONTENTS.get(), contents);
|
||||
|
||||
CompoundTag serialized = (CompoundTag)notebook.saveOptional(helper.getLevel().registryAccess());
|
||||
ItemStack restored = ItemStack.parseOptional(helper.getLevel().registryAccess(), serialized);
|
||||
NotebookContents restoredContents = restored.get(ModDataComponents.NOTEBOOK_CONTENTS.get());
|
||||
helper.assertTrue(restoredContents != null, "Notebook contents must survive ItemStack persistence");
|
||||
helper.assertValueEqual(restoredContents.pages().size(), 3,
|
||||
"Notebook persistence must retain ordered positions");
|
||||
helper.assertTrue(restoredContents.pages().get(1).isEmpty(),
|
||||
"Notebook persistence must retain empty positions between pages");
|
||||
helper.assertValueEqual(restoredContents.pages().get(0).getHoverName().getString(), "Foundation",
|
||||
"Renamed contained pages must retain their names");
|
||||
helper.assertValueEqual(PageItem.content(restoredContents.pages().get(2)).kind(),
|
||||
PageContent.Kind.UNRESOLVED_SYMBOL,
|
||||
"Unknown symbol pages must remain present and removable");
|
||||
helper.succeed();
|
||||
}
|
||||
|
||||
@GameTest(template = "empty")
|
||||
public static void notebookMenuValidatesInsertionAndPersistsReorderAndRename(GameTestHelper helper) {
|
||||
var player = helper.makeMockServerPlayerInLevel();
|
||||
ItemStack notebook = new ItemStack(ModItems.NOTEBOOK.get());
|
||||
player.setItemInHand(InteractionHand.MAIN_HAND, notebook);
|
||||
NotebookMenu menu = new NotebookMenu(7, player.getInventory(), InteractionHand.MAIN_HAND);
|
||||
ItemStack first = PageItem.createSymbolPage(reference("rivencraft:terrain/standard"));
|
||||
ItemStack second = PageItem.createRecoveredPage(reference("example:removed_symbol"));
|
||||
|
||||
helper.assertFalse(menu.getSlot(0).mayPlace(new ItemStack(Items.DIRT)),
|
||||
"Notebook slots must reject non-Page items");
|
||||
menu.getSlot(0).set(first);
|
||||
menu.getSlot(1).set(second);
|
||||
menu.renamePage(0, "Terrain Base");
|
||||
helper.assertTrue(menu.clickMenuButton(player, NotebookMenu.MOVE_NEXT_BASE),
|
||||
"The server menu must accept a valid adjacent reorder");
|
||||
|
||||
NotebookContents saved = notebook.get(ModDataComponents.NOTEBOOK_CONTENTS.get());
|
||||
helper.assertTrue(saved != null, "Menu changes must persist immediately to the Notebook item");
|
||||
helper.assertValueEqual(saved.pages().get(1).getHoverName().getString(), "Terrain Base",
|
||||
"Reordering must preserve the renamed Page stack");
|
||||
helper.assertValueEqual(PageItem.content(saved.pages().get(0)).kind(),
|
||||
PageContent.Kind.UNRESOLVED_SYMBOL,
|
||||
"Reordering must preserve unresolved pages");
|
||||
helper.succeed();
|
||||
}
|
||||
|
||||
@GameTest(template = "empty")
|
||||
public static void notebookMenuSurvivesInventoryStackReplacementAndClicks(GameTestHelper helper) {
|
||||
var player = helper.makeMockServerPlayerInLevel();
|
||||
player.setItemInHand(InteractionHand.MAIN_HAND, new ItemStack(ModItems.NOTEBOOK.get()));
|
||||
NotebookMenu menu = new NotebookMenu(8, player.getInventory(), InteractionHand.MAIN_HAND);
|
||||
|
||||
// Slot synchronization may replace the ItemStack object while the Notebook remains held.
|
||||
player.setItemInHand(InteractionHand.MAIN_HAND, player.getMainHandItem().copy());
|
||||
helper.assertTrue(menu.stillValid(player),
|
||||
"Replacing the held stack object must not close an open Notebook menu");
|
||||
menu.getSlot(0).set(PageItem.createSymbolPage(reference("rivencraft:terrain/standard")));
|
||||
helper.assertTrue(player.getMainHandItem().has(ModDataComponents.NOTEBOOK_CONTENTS.get()),
|
||||
"Page edits must persist to the current held Notebook stack");
|
||||
|
||||
player.getInventory().setItem(9, new ItemStack(Items.DIRT));
|
||||
menu.clicked(NotebookMenu.NOTEBOOK_SLOTS, 0, ClickType.PICKUP, player);
|
||||
helper.assertTrue(menu.getCarried().is(Items.DIRT),
|
||||
"Clicking a player inventory item must pick it up without closing the Notebook");
|
||||
helper.assertTrue(menu.stillValid(player),
|
||||
"Normal inventory clicks must leave the Notebook menu valid");
|
||||
helper.succeed();
|
||||
}
|
||||
|
||||
private static SymbolReference reference(String id) {
|
||||
return new SymbolReference(ResourceLocation.parse(id));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package net.dnorberg.rivencraft.item;
|
||||
|
||||
import java.util.List;
|
||||
import net.dnorberg.rivencraft.menu.NotebookMenu;
|
||||
import net.dnorberg.rivencraft.registry.ModDataComponents;
|
||||
import net.dnorberg.rivencraft.writing.NotebookContents;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResultHolder;
|
||||
import net.minecraft.world.SimpleMenuProvider;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.TooltipFlag;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
public final class NotebookItem extends Item {
|
||||
public NotebookItem(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand hand) {
|
||||
ItemStack notebook = player.getItemInHand(hand);
|
||||
if (!level.isClientSide && player instanceof ServerPlayer serverPlayer) {
|
||||
serverPlayer.openMenu(new SimpleMenuProvider(
|
||||
(containerId, inventory, ignored) -> new NotebookMenu(containerId, inventory, hand),
|
||||
notebook.getHoverName()),
|
||||
buffer -> buffer.writeBoolean(hand == InteractionHand.OFF_HAND));
|
||||
}
|
||||
return InteractionResultHolder.sidedSuccess(notebook, level.isClientSide);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendHoverText(ItemStack stack, TooltipContext context,
|
||||
List<Component> tooltip, TooltipFlag flag) {
|
||||
NotebookContents contents = stack.getOrDefault(
|
||||
ModDataComponents.NOTEBOOK_CONTENTS.get(), NotebookContents.EMPTY);
|
||||
tooltip.add(Component.translatable("item.rivencraft.notebook.pages",
|
||||
contents.pageCount(), NotebookContents.MAX_PAGES).withStyle(ChatFormatting.GRAY));
|
||||
if (contents.unresolvedCount() > 0) {
|
||||
tooltip.add(Component.translatable("item.rivencraft.notebook.unresolved",
|
||||
contents.unresolvedCount()).withStyle(ChatFormatting.RED));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
package net.dnorberg.rivencraft.item;
|
||||
|
||||
import java.util.List;
|
||||
import net.dnorberg.rivencraft.registry.ModDataComponents;
|
||||
import net.dnorberg.rivencraft.registry.ModItems;
|
||||
import net.dnorberg.rivencraft.writing.PageContent;
|
||||
import net.dnorberg.rivencraft.writing.SymbolCatalog;
|
||||
import net.dnorberg.rivencraft.writing.SymbolDisplayMetadata;
|
||||
import net.dnorberg.rivencraft.writing.SymbolReference;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.core.component.DataComponents;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.item.component.CustomModelData;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.TooltipFlag;
|
||||
|
||||
/** One stackable Page item whose server-owned component identifies its writing state. */
|
||||
public final class PageItem extends Item {
|
||||
public PageItem(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
public static ItemStack createSymbolPage(SymbolReference reference) {
|
||||
if (!SymbolCatalog.isKnown(reference)) {
|
||||
throw new IllegalArgumentException("Cannot create a page for unknown symbol " + reference.id());
|
||||
}
|
||||
return create(PageContent.symbol(reference));
|
||||
}
|
||||
|
||||
public static ItemStack createLinkPanelPage() {
|
||||
return create(PageContent.LINK_PANEL);
|
||||
}
|
||||
|
||||
/** Restores saved unknown references without granting them validity for new writing operations. */
|
||||
public static ItemStack createRecoveredPage(SymbolReference reference) {
|
||||
return create(PageContent.unresolved(reference));
|
||||
}
|
||||
|
||||
public static PageContent content(ItemStack stack) {
|
||||
PageContent content = stack.get(ModDataComponents.PAGE_CONTENT.get());
|
||||
return content == null ? PageContent.BLANK : content;
|
||||
}
|
||||
|
||||
/** Server-side gate for Desk and Binder inputs; unresolved pages remain removable but not usable. */
|
||||
public static boolean isUsableWriting(ItemStack stack) {
|
||||
if (!stack.is(ModItems.PAGE.get())) {
|
||||
return false;
|
||||
}
|
||||
PageContent resolved = content(stack).resolve();
|
||||
return resolved.kind() == PageContent.Kind.BLANK
|
||||
|| resolved.kind() == PageContent.Kind.LINK_PANEL
|
||||
|| resolved.isResolvedSymbol();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getName(ItemStack stack) {
|
||||
Component customName = stack.get(DataComponents.CUSTOM_NAME);
|
||||
if (customName != null) {
|
||||
return customName;
|
||||
}
|
||||
PageContent content = content(stack);
|
||||
return switch (content.kind()) {
|
||||
case BLANK -> Component.translatable("item.rivencraft.page.blank");
|
||||
case LINK_PANEL -> Component.translatable("item.rivencraft.page.link_panel");
|
||||
case UNRESOLVED_SYMBOL -> Component.translatable("item.rivencraft.page.unresolved");
|
||||
case SYMBOL -> symbolName(stack, content.symbol().orElseThrow());
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendHoverText(ItemStack stack, TooltipContext context,
|
||||
List<Component> tooltipComponents, TooltipFlag tooltipFlag) {
|
||||
PageContent content = content(stack);
|
||||
if (content.kind() == PageContent.Kind.BLANK) {
|
||||
tooltipComponents.add(Component.translatable("item.rivencraft.page.blank.description")
|
||||
.withStyle(ChatFormatting.GRAY));
|
||||
return;
|
||||
}
|
||||
if (content.kind() == PageContent.Kind.LINK_PANEL) {
|
||||
tooltipComponents.add(Component.translatable("item.rivencraft.page.link_panel.description")
|
||||
.withStyle(ChatFormatting.GRAY));
|
||||
return;
|
||||
}
|
||||
SymbolReference reference = content.symbol().orElseThrow();
|
||||
SymbolDisplayMetadata metadata = content.kind() == PageContent.Kind.SYMBOL
|
||||
? stack.getOrDefault(ModDataComponents.PAGE_SYMBOL_DISPLAY.get(), SymbolCatalog.display(reference))
|
||||
: SymbolDisplayMetadata.unresolved(reference);
|
||||
if (metadata.resolved()) {
|
||||
tooltipComponents.add(Component.translatable(metadata.descriptionTranslationKey())
|
||||
.withStyle(ChatFormatting.GRAY));
|
||||
} else {
|
||||
tooltipComponents.add(Component.translatable(
|
||||
"symbol.rivencraft.unresolved.description", reference.unresolvedName())
|
||||
.withStyle(ChatFormatting.RED));
|
||||
}
|
||||
tooltipComponents.add(Component.literal(reference.id().toString()).withStyle(ChatFormatting.DARK_GRAY));
|
||||
}
|
||||
|
||||
private static ItemStack create(PageContent content) {
|
||||
ItemStack stack = new ItemStack(ModItems.PAGE.get());
|
||||
stack.set(ModDataComponents.PAGE_CONTENT.get(), content);
|
||||
stack.set(DataComponents.CUSTOM_MODEL_DATA, new CustomModelData(modelIndex(content)));
|
||||
if (content.kind() == PageContent.Kind.SYMBOL) {
|
||||
stack.set(ModDataComponents.PAGE_SYMBOL_DISPLAY.get(),
|
||||
SymbolCatalog.display(content.symbol().orElseThrow()));
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
private static Component symbolName(ItemStack stack, SymbolReference reference) {
|
||||
SymbolDisplayMetadata metadata = stack.getOrDefault(
|
||||
ModDataComponents.PAGE_SYMBOL_DISPLAY.get(), SymbolCatalog.display(reference));
|
||||
return metadata.resolved()
|
||||
? Component.translatable(metadata.nameTranslationKey())
|
||||
: Component.translatable("item.rivencraft.page.unresolved");
|
||||
}
|
||||
|
||||
private static int modelIndex(PageContent content) {
|
||||
return switch (content.kind()) {
|
||||
case BLANK -> 0;
|
||||
case LINK_PANEL -> 1;
|
||||
case UNRESOLVED_SYMBOL -> 2;
|
||||
case SYMBOL -> switch (content.symbol().orElseThrow().id().toString()) {
|
||||
case "rivencraft:terrain/standard" -> 100;
|
||||
case "rivencraft:biome/native" -> 101;
|
||||
case "rivencraft:lighting/normal" -> 102;
|
||||
case "rivencraft:weather/normal" -> 103;
|
||||
case "rivencraft:celestial/normal_time" -> 104;
|
||||
case "rivencraft:feature/caves" -> 105;
|
||||
default -> 3;
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
package net.dnorberg.rivencraft.menu;
|
||||
|
||||
import java.util.List;
|
||||
import net.dnorberg.rivencraft.registry.ModDataComponents;
|
||||
import net.dnorberg.rivencraft.registry.ModItems;
|
||||
import net.dnorberg.rivencraft.registry.ModMenus;
|
||||
import net.dnorberg.rivencraft.writing.NotebookContents;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.core.component.DataComponents;
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.Container;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.SimpleContainer;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import net.minecraft.world.inventory.ClickType;
|
||||
import net.minecraft.world.inventory.Slot;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
public final class NotebookMenu extends AbstractContainerMenu {
|
||||
public static final int NOTEBOOK_SLOTS = NotebookContents.MAX_PAGES;
|
||||
public static final int MOVE_PREVIOUS_BASE = 0;
|
||||
public static final int MOVE_NEXT_BASE = NOTEBOOK_SLOTS;
|
||||
private static final int PLAYER_INVENTORY_START = NOTEBOOK_SLOTS;
|
||||
private final Inventory playerInventory;
|
||||
private final InteractionHand hand;
|
||||
private final int openedHotbarSlot;
|
||||
private final NotebookContainer contents;
|
||||
|
||||
public NotebookMenu(int containerId, Inventory inventory, RegistryFriendlyByteBuf data) {
|
||||
this(containerId, inventory, data.readBoolean() ? InteractionHand.OFF_HAND : InteractionHand.MAIN_HAND);
|
||||
}
|
||||
|
||||
public NotebookMenu(int containerId, Inventory inventory, InteractionHand hand) {
|
||||
super(ModMenus.NOTEBOOK.get(), containerId);
|
||||
this.playerInventory = inventory;
|
||||
this.hand = hand;
|
||||
this.openedHotbarSlot = inventory.selected;
|
||||
this.contents = new NotebookContainer(inventory, hand);
|
||||
|
||||
for (int row = 0; row < 3; row++) {
|
||||
for (int column = 0; column < 9; column++) {
|
||||
// The client draws these pages on a filtered, scrollable surface instead.
|
||||
addSlot(new PageSlot(contents, column + row * 9, -1000, -1000));
|
||||
}
|
||||
}
|
||||
for (int row = 0; row < 3; row++) {
|
||||
for (int column = 0; column < 9; column++) {
|
||||
int inventoryIndex = column + row * 9 + 9;
|
||||
addSlot(playerSlot(inventoryIndex, 8 + column * 18, 135 + row * 18));
|
||||
}
|
||||
}
|
||||
for (int column = 0; column < 9; column++) {
|
||||
addSlot(playerSlot(column, 8 + column * 18, 193));
|
||||
}
|
||||
}
|
||||
|
||||
private Slot playerSlot(int inventoryIndex, int x, int y) {
|
||||
boolean locked = hand == InteractionHand.MAIN_HAND && inventoryIndex == openedHotbarSlot;
|
||||
return locked ? new LockedSlot(playerInventory, inventoryIndex, x, y)
|
||||
: new Slot(playerInventory, inventoryIndex, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stillValid(Player player) {
|
||||
return player.isAlive()
|
||||
&& (hand == InteractionHand.OFF_HAND || player.getInventory().selected == openedHotbarSlot)
|
||||
&& player.getItemInHand(hand).is(ModItems.NOTEBOOK.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack quickMoveStack(Player player, int index) {
|
||||
Slot slot = slots.get(index);
|
||||
if (!slot.hasItem()) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
ItemStack source = slot.getItem();
|
||||
ItemStack original = source.copy();
|
||||
if (index < PLAYER_INVENTORY_START) {
|
||||
if (!moveItemStackTo(source, PLAYER_INVENTORY_START, slots.size(), true)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
} else {
|
||||
if (!source.is(ModItems.PAGE.get())
|
||||
|| !moveItemStackTo(source, 0, PLAYER_INVENTORY_START, false)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
if (source.isEmpty()) {
|
||||
slot.setByPlayer(ItemStack.EMPTY);
|
||||
} else {
|
||||
slot.setChanged();
|
||||
}
|
||||
return original;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean clickMenuButton(Player player, int id) {
|
||||
int source;
|
||||
int target;
|
||||
if (id >= MOVE_PREVIOUS_BASE && id < MOVE_NEXT_BASE) {
|
||||
source = id;
|
||||
target = source - 1;
|
||||
} else if (id >= MOVE_NEXT_BASE && id < MOVE_NEXT_BASE + NOTEBOOK_SLOTS) {
|
||||
source = id - MOVE_NEXT_BASE;
|
||||
target = source + 1;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
if (source < 0 || source >= NOTEBOOK_SLOTS || target < 0 || target >= NOTEBOOK_SLOTS
|
||||
|| contents.getItem(source).isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
contents.swap(source, target);
|
||||
broadcastChanges();
|
||||
return true;
|
||||
}
|
||||
|
||||
public void renamePage(int slot, String name) {
|
||||
if (slot < 0 || slot >= NOTEBOOK_SLOTS) {
|
||||
return;
|
||||
}
|
||||
ItemStack page = contents.getItem(slot);
|
||||
if (page.isEmpty() || !page.is(ModItems.PAGE.get())) {
|
||||
return;
|
||||
}
|
||||
if (name.isBlank()) {
|
||||
page.remove(DataComponents.CUSTOM_NAME);
|
||||
} else {
|
||||
page.set(DataComponents.CUSTOM_NAME, Component.literal(name));
|
||||
}
|
||||
contents.setChanged();
|
||||
broadcastChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clicked(int slotId, int button, ClickType clickType, Player player) {
|
||||
if (!stillValid(player)) {
|
||||
player.closeContainer();
|
||||
return;
|
||||
}
|
||||
if (clickType == ClickType.SWAP
|
||||
&& (button == openedHotbarSlot && hand == InteractionHand.MAIN_HAND
|
||||
|| button == 40 && hand == InteractionHand.OFF_HAND)) {
|
||||
return;
|
||||
}
|
||||
super.clicked(slotId, button, clickType, player);
|
||||
}
|
||||
|
||||
private static final class PageSlot extends Slot {
|
||||
private PageSlot(Container container, int slot, int x, int y) {
|
||||
super(container, slot, x, y);
|
||||
}
|
||||
|
||||
@Override public boolean mayPlace(ItemStack stack) { return stack.is(ModItems.PAGE.get()); }
|
||||
@Override public int getMaxStackSize() { return 1; }
|
||||
}
|
||||
|
||||
private static final class LockedSlot extends Slot {
|
||||
private LockedSlot(Container container, int slot, int x, int y) {
|
||||
super(container, slot, x, y);
|
||||
}
|
||||
|
||||
@Override public boolean mayPickup(Player player) { return false; }
|
||||
@Override public boolean mayPlace(ItemStack stack) { return false; }
|
||||
}
|
||||
|
||||
private static final class NotebookContainer extends SimpleContainer {
|
||||
private final Inventory inventory;
|
||||
private final InteractionHand hand;
|
||||
private boolean loading;
|
||||
|
||||
private NotebookContainer(Inventory inventory, InteractionHand hand) {
|
||||
super(NOTEBOOK_SLOTS);
|
||||
this.inventory = inventory;
|
||||
this.hand = hand;
|
||||
ItemStack notebook = inventory.player.getItemInHand(hand);
|
||||
loading = true;
|
||||
List<ItemStack> saved = notebook.getOrDefault(
|
||||
ModDataComponents.NOTEBOOK_CONTENTS.get(), NotebookContents.EMPTY).pages();
|
||||
for (int index = 0; index < saved.size(); index++) {
|
||||
super.setItem(index, saved.get(index).copy());
|
||||
}
|
||||
loading = false;
|
||||
}
|
||||
|
||||
private void swap(int first, int second) {
|
||||
loading = true;
|
||||
ItemStack held = getItem(first);
|
||||
setItem(first, getItem(second));
|
||||
setItem(second, held);
|
||||
loading = false;
|
||||
setChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChanged() {
|
||||
super.setChanged();
|
||||
ItemStack notebook = inventory.player.getItemInHand(hand);
|
||||
if (loading || !notebook.is(ModItems.NOTEBOOK.get())) {
|
||||
return;
|
||||
}
|
||||
NonNullList<ItemStack> saved = NonNullList.withSize(NOTEBOOK_SLOTS, ItemStack.EMPTY);
|
||||
for (int index = 0; index < NOTEBOOK_SLOTS; index++) {
|
||||
ItemStack page = getItem(index);
|
||||
saved.set(index, page.isEmpty() ? ItemStack.EMPTY : page.copyWithCount(1));
|
||||
}
|
||||
notebook.set(ModDataComponents.NOTEBOOK_CONTENTS.get(), new NotebookContents(saved));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package net.dnorberg.rivencraft.mixin.client;
|
||||
|
||||
import net.dnorberg.rivencraft.client.preview.ImmersivePortalsPreviewAudioGuard;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
/** Mutes only the remote client world displayed by a Rivencraft book preview. */
|
||||
@Mixin(value = ClientLevel.class, priority = 2000)
|
||||
public abstract class ClientLevelSoundMixin {
|
||||
@Inject(
|
||||
method = "playSound(DDDLnet/minecraft/sounds/SoundEvent;Lnet/minecraft/sounds/SoundSource;FFZJ)V",
|
||||
at = @At("HEAD"),
|
||||
cancellable = true
|
||||
)
|
||||
private void rivencraft$mutePreviewPositionSound(
|
||||
double x, double y, double z, SoundEvent sound, SoundSource source,
|
||||
float volume, float pitch, boolean distanceDelay, long seed, CallbackInfo callback
|
||||
) {
|
||||
rivencraft$cancelPreviewSound(callback);
|
||||
}
|
||||
|
||||
@Inject(
|
||||
method = "playLocalSound(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/sounds/SoundEvent;Lnet/minecraft/sounds/SoundSource;FF)V",
|
||||
at = @At("HEAD"),
|
||||
cancellable = true
|
||||
)
|
||||
private void rivencraft$mutePreviewLocalEntitySound(
|
||||
Entity entity, SoundEvent sound, SoundSource source, float volume, float pitch,
|
||||
CallbackInfo callback
|
||||
) {
|
||||
rivencraft$cancelPreviewSound(callback);
|
||||
}
|
||||
|
||||
@Inject(
|
||||
method = "playSeededSound(Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/entity/Entity;Lnet/minecraft/core/Holder;Lnet/minecraft/sounds/SoundSource;FFJ)V",
|
||||
at = @At("HEAD"),
|
||||
cancellable = true
|
||||
)
|
||||
private void rivencraft$mutePreviewSeededEntitySound(
|
||||
Player player, Entity entity, Holder<SoundEvent> sound, SoundSource source,
|
||||
float volume, float pitch, long seed, CallbackInfo callback
|
||||
) {
|
||||
rivencraft$cancelPreviewSound(callback);
|
||||
}
|
||||
|
||||
private void rivencraft$cancelPreviewSound(CallbackInfo callback) {
|
||||
if (ImmersivePortalsPreviewAudioGuard.shouldMute((ClientLevel)(Object)this)) {
|
||||
callback.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package net.dnorberg.rivencraft.mixin.client;
|
||||
|
||||
import net.dnorberg.rivencraft.client.preview.ImmersivePortalsPreviewAudioGuard;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Pseudo;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
/** Restores the player camera after Immersive Portals finishes GUI-world rendering. */
|
||||
@Pseudo
|
||||
@Mixin(targets = "qouteall.imm_ptl.core.render.GuiPortalRendering", remap = false)
|
||||
public abstract class ImmersivePortalsGuiRenderingMixin {
|
||||
@Inject(method = "_onGameRenderEnd", at = @At("RETURN"), remap = false)
|
||||
private static void rivencraft$restorePlayerCamera(CallbackInfo callback) {
|
||||
ImmersivePortalsPreviewAudioGuard.restorePlayerCamera();
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import net.dnorberg.rivencraft.client.ClientAgeCelestialAngles;
|
||||
import net.dnorberg.rivencraft.event.AgeCelestialAngleSync;
|
||||
import net.dnorberg.rivencraft.item.DescriptiveBookItem;
|
||||
import net.dnorberg.rivencraft.item.LinkingBookItem;
|
||||
import net.dnorberg.rivencraft.menu.NotebookMenu;
|
||||
import net.dnorberg.rivencraft.registry.ModDataComponents;
|
||||
import net.dnorberg.rivencraft.registry.ModItems;
|
||||
import net.minecraft.core.component.DataComponents;
|
||||
@@ -48,7 +49,9 @@ public final class ModNetworking {
|
||||
}
|
||||
|
||||
public static void register(RegisterPayloadHandlersEvent event) {
|
||||
PayloadRegistrar registrar = event.registrar("9");
|
||||
PayloadRegistrar registrar = event.registrar("10");
|
||||
registrar.playToServer(RenameNotebookPagePayload.TYPE, RenameNotebookPagePayload.STREAM_CODEC,
|
||||
ModNetworking::renameNotebookPage);
|
||||
registrar.playToServer(RequestDescriptiveBookScreenPayload.TYPE, RequestDescriptiveBookScreenPayload.STREAM_CODEC,
|
||||
ModNetworking::requestDescriptiveBookScreen);
|
||||
registrar.playToClient(OpenDescriptiveBookScreenPayload.TYPE, OpenDescriptiveBookScreenPayload.STREAM_CODEC,
|
||||
@@ -70,6 +73,16 @@ public final class ModNetworking {
|
||||
ClientAgeCelestialAngles::handle);
|
||||
}
|
||||
|
||||
private static void renameNotebookPage(RenameNotebookPagePayload payload, IPayloadContext context) {
|
||||
if (!(context.player() instanceof ServerPlayer player)
|
||||
|| !(player.containerMenu instanceof NotebookMenu menu)
|
||||
|| menu.containerId != payload.containerId()
|
||||
|| payload.name().length() > MAX_BOOK_TITLE_LENGTH) {
|
||||
return;
|
||||
}
|
||||
menu.renamePage(payload.slot(), normalizeTitle(payload.name()));
|
||||
}
|
||||
|
||||
private static void requestDescriptiveBookScreen(RequestDescriptiveBookScreenPayload payload, IPayloadContext context) {
|
||||
if (!(context.player() instanceof ServerPlayer player)) {
|
||||
return;
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package net.dnorberg.rivencraft.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.dnorberg.rivencraft.Rivencraft;
|
||||
import net.minecraft.network.codec.ByteBufCodecs;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public record RenameNotebookPagePayload(int containerId, int slot, String name) implements CustomPacketPayload {
|
||||
public static final Type<RenameNotebookPagePayload> TYPE = new Type<>(
|
||||
ResourceLocation.fromNamespaceAndPath(Rivencraft.MOD_ID, "rename_notebook_page"));
|
||||
public static final StreamCodec<ByteBuf, RenameNotebookPagePayload> STREAM_CODEC = StreamCodec.composite(
|
||||
ByteBufCodecs.VAR_INT, RenameNotebookPagePayload::containerId,
|
||||
ByteBufCodecs.VAR_INT, RenameNotebookPagePayload::slot,
|
||||
ByteBufCodecs.STRING_UTF8, RenameNotebookPagePayload::name,
|
||||
RenameNotebookPagePayload::new);
|
||||
|
||||
@Override public Type<? extends CustomPacketPayload> type() { return TYPE; }
|
||||
}
|
||||
@@ -19,6 +19,8 @@ public final class ModCreativeTabs {
|
||||
.displayItems((parameters, output) -> {
|
||||
output.accept(ModItems.DESCRIPTIVE_BOOK.get());
|
||||
output.accept(ModItems.LINKING_BOOK.get());
|
||||
output.accept(ModItems.PAGE.get());
|
||||
output.accept(ModItems.NOTEBOOK.get());
|
||||
})
|
||||
.build());
|
||||
|
||||
|
||||
@@ -3,6 +3,9 @@ package net.dnorberg.rivencraft.registry;
|
||||
import net.dnorberg.rivencraft.Rivencraft;
|
||||
import net.dnorberg.rivencraft.book.LinkTarget;
|
||||
import net.dnorberg.rivencraft.book.AgeReference;
|
||||
import net.dnorberg.rivencraft.writing.PageContent;
|
||||
import net.dnorberg.rivencraft.writing.NotebookContents;
|
||||
import net.dnorberg.rivencraft.writing.SymbolDisplayMetadata;
|
||||
import net.minecraft.core.component.DataComponentType;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
@@ -39,6 +42,24 @@ public final class ModDataComponents {
|
||||
.networkSynchronized(ByteBufCodecs.STRING_UTF8)
|
||||
.cacheEncoding()
|
||||
.build());
|
||||
public static final DeferredHolder<DataComponentType<?>, DataComponentType<PageContent>> PAGE_CONTENT =
|
||||
DATA_COMPONENTS.register("page_content", () -> DataComponentType.<PageContent>builder()
|
||||
.persistent(PageContent.CODEC)
|
||||
.networkSynchronized(PageContent.STREAM_CODEC)
|
||||
.cacheEncoding()
|
||||
.build());
|
||||
public static final DeferredHolder<DataComponentType<?>, DataComponentType<SymbolDisplayMetadata>> PAGE_SYMBOL_DISPLAY =
|
||||
DATA_COMPONENTS.register("page_symbol_display", () -> DataComponentType.<SymbolDisplayMetadata>builder()
|
||||
.persistent(SymbolDisplayMetadata.CODEC)
|
||||
.networkSynchronized(SymbolDisplayMetadata.STREAM_CODEC)
|
||||
.cacheEncoding()
|
||||
.build());
|
||||
public static final DeferredHolder<DataComponentType<?>, DataComponentType<NotebookContents>> NOTEBOOK_CONTENTS =
|
||||
DATA_COMPONENTS.register("notebook_contents", () -> DataComponentType.<NotebookContents>builder()
|
||||
.persistent(NotebookContents.CODEC)
|
||||
.networkSynchronized(NotebookContents.STREAM_CODEC)
|
||||
.cacheEncoding()
|
||||
.build());
|
||||
|
||||
private ModDataComponents() {
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package net.dnorberg.rivencraft.registry;
|
||||
import net.dnorberg.rivencraft.Rivencraft;
|
||||
import net.dnorberg.rivencraft.item.DescriptiveBookItem;
|
||||
import net.dnorberg.rivencraft.item.LinkingBookItem;
|
||||
import net.dnorberg.rivencraft.item.PageItem;
|
||||
import net.dnorberg.rivencraft.item.NotebookItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.neoforged.bus.api.IEventBus;
|
||||
import net.neoforged.neoforge.registries.DeferredItem;
|
||||
@@ -21,6 +23,16 @@ public final class ModItems {
|
||||
LinkingBookItem::new,
|
||||
new Item.Properties().stacksTo(1)
|
||||
);
|
||||
public static final DeferredItem<PageItem> PAGE = ITEMS.registerItem(
|
||||
"page",
|
||||
PageItem::new,
|
||||
new Item.Properties().stacksTo(64)
|
||||
);
|
||||
public static final DeferredItem<NotebookItem> NOTEBOOK = ITEMS.registerItem(
|
||||
"notebook",
|
||||
NotebookItem::new,
|
||||
new Item.Properties().stacksTo(1)
|
||||
);
|
||||
|
||||
private ModItems() {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package net.dnorberg.rivencraft.registry;
|
||||
|
||||
import net.dnorberg.rivencraft.Rivencraft;
|
||||
import net.dnorberg.rivencraft.menu.NotebookMenu;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.world.inventory.MenuType;
|
||||
import net.neoforged.bus.api.IEventBus;
|
||||
import net.neoforged.neoforge.common.extensions.IMenuTypeExtension;
|
||||
import net.neoforged.neoforge.registries.DeferredHolder;
|
||||
import net.neoforged.neoforge.registries.DeferredRegister;
|
||||
|
||||
public final class ModMenus {
|
||||
private static final DeferredRegister<MenuType<?>> MENUS =
|
||||
DeferredRegister.create(Registries.MENU, Rivencraft.MOD_ID);
|
||||
|
||||
public static final DeferredHolder<MenuType<?>, MenuType<NotebookMenu>> NOTEBOOK =
|
||||
MENUS.register("notebook", () -> IMenuTypeExtension.create(NotebookMenu::new));
|
||||
|
||||
private ModMenus() {
|
||||
}
|
||||
|
||||
public static void register(IEventBus modEventBus) {
|
||||
MENUS.register(modEventBus);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package net.dnorberg.rivencraft.writing;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.DataResult;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.dnorberg.rivencraft.item.PageItem;
|
||||
import net.dnorberg.rivencraft.registry.ModItems;
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.network.codec.ByteBufCodecs;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
/** A bounded, position-preserving collection of Page stacks stored on a Notebook item. */
|
||||
public record NotebookContents(List<ItemStack> pages) {
|
||||
public static final int MAX_PAGES = 27;
|
||||
public static final NotebookContents EMPTY = new NotebookContents(List.of());
|
||||
public static final Codec<NotebookContents> CODEC = ItemStack.OPTIONAL_CODEC.listOf()
|
||||
.validate(NotebookContents::validate)
|
||||
.xmap(NotebookContents::new, NotebookContents::pages);
|
||||
public static final StreamCodec<RegistryFriendlyByteBuf, NotebookContents> STREAM_CODEC = StreamCodec.of(
|
||||
NotebookContents::encode, NotebookContents::decode);
|
||||
|
||||
public NotebookContents {
|
||||
if (pages.size() > MAX_PAGES) {
|
||||
throw new IllegalArgumentException("Notebook exceeds " + MAX_PAGES + " page positions");
|
||||
}
|
||||
List<ItemStack> copies = new ArrayList<>(pages.size());
|
||||
for (ItemStack page : pages) {
|
||||
validatePage(page).getOrThrow();
|
||||
copies.add(page.copy());
|
||||
}
|
||||
pages = List.copyOf(copies);
|
||||
}
|
||||
|
||||
public int pageCount() {
|
||||
return (int)pages.stream().filter(page -> !page.isEmpty()).count();
|
||||
}
|
||||
|
||||
public int unresolvedCount() {
|
||||
return (int)pages.stream()
|
||||
.filter(page -> !page.isEmpty()
|
||||
&& PageContent.Kind.UNRESOLVED_SYMBOL == PageItem.content(page).kind())
|
||||
.count();
|
||||
}
|
||||
|
||||
private static DataResult<List<ItemStack>> validate(List<ItemStack> pages) {
|
||||
if (pages.size() > MAX_PAGES) {
|
||||
return DataResult.error(() -> "Notebook exceeds " + MAX_PAGES + " page positions");
|
||||
}
|
||||
for (ItemStack page : pages) {
|
||||
DataResult<ItemStack> result = validatePage(page);
|
||||
if (result.error().isPresent()) {
|
||||
return DataResult.error(() -> result.error().orElseThrow().message());
|
||||
}
|
||||
}
|
||||
return DataResult.success(pages);
|
||||
}
|
||||
|
||||
private static DataResult<ItemStack> validatePage(ItemStack page) {
|
||||
if (page.isEmpty()) {
|
||||
return DataResult.success(page);
|
||||
}
|
||||
if (!page.is(ModItems.PAGE.get())) {
|
||||
return DataResult.error(() -> "Notebook contains a non-Page item");
|
||||
}
|
||||
return page.getCount() == 1
|
||||
? DataResult.success(page)
|
||||
: DataResult.error(() -> "Notebook Page stacks must contain exactly one item");
|
||||
}
|
||||
|
||||
private static void encode(RegistryFriendlyByteBuf buffer, NotebookContents contents) {
|
||||
ByteBufCodecs.VAR_INT.encode(buffer, contents.pages.size());
|
||||
contents.pages.forEach(page -> ItemStack.OPTIONAL_STREAM_CODEC.encode(buffer, page));
|
||||
}
|
||||
|
||||
private static NotebookContents decode(RegistryFriendlyByteBuf buffer) {
|
||||
int size = ByteBufCodecs.VAR_INT.decode(buffer);
|
||||
if (size < 0 || size > MAX_PAGES) {
|
||||
throw new IllegalArgumentException("Invalid Notebook page count " + size);
|
||||
}
|
||||
List<ItemStack> pages = new ArrayList<>(size);
|
||||
for (int index = 0; index < size; index++) {
|
||||
pages.add(ItemStack.OPTIONAL_STREAM_CODEC.decode(buffer));
|
||||
}
|
||||
return new NotebookContents(pages);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package net.dnorberg.rivencraft.writing;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.DataResult;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import net.minecraft.network.codec.ByteBufCodecs;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
|
||||
/** Immutable ordered writing shared by pages, notebooks, desks, and books. */
|
||||
public record OrderedWriting(List<WritingEntry> entries) {
|
||||
public static final int MAX_ENTRIES = 256;
|
||||
public static final OrderedWriting EMPTY = new OrderedWriting(List.of());
|
||||
public static final Codec<OrderedWriting> CODEC = WritingEntry.CODEC.listOf()
|
||||
.validate(entries -> entries.size() <= MAX_ENTRIES
|
||||
? DataResult.success(entries)
|
||||
: DataResult.error(() -> "Writing exceeds " + MAX_ENTRIES + " entries"))
|
||||
.xmap(OrderedWriting::new, OrderedWriting::entries);
|
||||
public static final StreamCodec<ByteBuf, OrderedWriting> STREAM_CODEC = StreamCodec.of(
|
||||
OrderedWriting::encode, OrderedWriting::decode);
|
||||
|
||||
public OrderedWriting {
|
||||
entries = List.copyOf(Objects.requireNonNull(entries, "entries"));
|
||||
if (entries.size() > MAX_ENTRIES) {
|
||||
throw new IllegalArgumentException("Writing exceeds " + MAX_ENTRIES + " entries");
|
||||
}
|
||||
}
|
||||
|
||||
private static void encode(ByteBuf buffer, OrderedWriting writing) {
|
||||
ByteBufCodecs.VAR_INT.encode(buffer, writing.entries.size());
|
||||
writing.entries.forEach(entry -> WritingEntry.STREAM_CODEC.encode(buffer, entry));
|
||||
}
|
||||
|
||||
private static OrderedWriting decode(ByteBuf buffer) {
|
||||
int size = ByteBufCodecs.VAR_INT.decode(buffer);
|
||||
if (size < 0 || size > MAX_ENTRIES) {
|
||||
throw new IllegalArgumentException("Invalid writing entry count " + size);
|
||||
}
|
||||
List<WritingEntry> entries = new ArrayList<>(size);
|
||||
for (int index = 0; index < size; index++) {
|
||||
entries.add(WritingEntry.STREAM_CODEC.decode(buffer));
|
||||
}
|
||||
return new OrderedWriting(entries);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package net.dnorberg.rivencraft.writing;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.DataResult;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import net.minecraft.network.codec.ByteBufCodecs;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
|
||||
/** Persistent contents of a Page item. Unknown symbols remain explicit and recoverable. */
|
||||
public record PageContent(Kind kind, Optional<SymbolReference> symbol) {
|
||||
public static final PageContent BLANK = new PageContent(Kind.BLANK, Optional.empty());
|
||||
public static final PageContent LINK_PANEL = new PageContent(Kind.LINK_PANEL, Optional.empty());
|
||||
private static final Codec<Kind> KIND_CODEC = Codec.STRING.comapFlatMap(
|
||||
value -> {
|
||||
try {
|
||||
return DataResult.success(Kind.valueOf(value.toUpperCase(Locale.ROOT)));
|
||||
} catch (IllegalArgumentException exception) {
|
||||
return DataResult.error(() -> "Unknown page content kind: " + value);
|
||||
}
|
||||
},
|
||||
value -> value.name().toLowerCase(Locale.ROOT)
|
||||
);
|
||||
private static final Codec<PageContent> RECORD_CODEC = RecordCodecBuilder.create(instance -> instance.group(
|
||||
KIND_CODEC.fieldOf("kind").forGetter(PageContent::kind),
|
||||
SymbolReference.CODEC.optionalFieldOf("symbol").forGetter(PageContent::symbol)
|
||||
).apply(instance, PageContent::new));
|
||||
public static final Codec<PageContent> CODEC = RECORD_CODEC.flatXmap(PageContent::validate, PageContent::validate);
|
||||
public static final StreamCodec<ByteBuf, PageContent> STREAM_CODEC = StreamCodec.of(
|
||||
PageContent::encode, PageContent::decode);
|
||||
|
||||
public PageContent {
|
||||
Objects.requireNonNull(kind, "kind");
|
||||
symbol = Objects.requireNonNull(symbol, "symbol");
|
||||
boolean needsSymbol = kind == Kind.SYMBOL || kind == Kind.UNRESOLVED_SYMBOL;
|
||||
if (needsSymbol != symbol.isPresent()) {
|
||||
throw new IllegalArgumentException("Page contents do not match kind " + kind);
|
||||
}
|
||||
}
|
||||
|
||||
public static PageContent symbol(SymbolReference symbol) {
|
||||
return new PageContent(Kind.SYMBOL, Optional.of(symbol));
|
||||
}
|
||||
|
||||
public static PageContent unresolved(SymbolReference symbol) {
|
||||
return new PageContent(Kind.UNRESOLVED_SYMBOL, Optional.of(symbol));
|
||||
}
|
||||
|
||||
/** Re-resolves persisted data against the authoritative current server catalog. */
|
||||
public PageContent resolve() {
|
||||
if (kind != Kind.SYMBOL && kind != Kind.UNRESOLVED_SYMBOL) {
|
||||
return this;
|
||||
}
|
||||
SymbolReference reference = symbol.orElseThrow();
|
||||
return SymbolCatalog.isKnown(reference) ? symbol(reference) : unresolved(reference);
|
||||
}
|
||||
|
||||
public boolean isResolvedSymbol() {
|
||||
return kind == Kind.SYMBOL;
|
||||
}
|
||||
|
||||
private static DataResult<PageContent> validate(PageContent content) {
|
||||
boolean needsSymbol = content.kind == Kind.SYMBOL || content.kind == Kind.UNRESOLVED_SYMBOL;
|
||||
return needsSymbol == content.symbol.isPresent()
|
||||
? DataResult.success(content)
|
||||
: DataResult.error(() -> "Page contents do not match kind " + content.kind);
|
||||
}
|
||||
|
||||
private static void encode(ByteBuf buffer, PageContent content) {
|
||||
ByteBufCodecs.VAR_INT.encode(buffer, content.kind.ordinal());
|
||||
content.symbol.ifPresent(reference -> SymbolReference.STREAM_CODEC.encode(buffer, reference));
|
||||
}
|
||||
|
||||
private static PageContent decode(ByteBuf buffer) {
|
||||
int ordinal = ByteBufCodecs.VAR_INT.decode(buffer);
|
||||
if (ordinal < 0 || ordinal >= Kind.values().length) {
|
||||
throw new IllegalArgumentException("Unknown page content kind ordinal " + ordinal);
|
||||
}
|
||||
Kind kind = Kind.values()[ordinal];
|
||||
Optional<SymbolReference> symbol = kind == Kind.SYMBOL || kind == Kind.UNRESOLVED_SYMBOL
|
||||
? Optional.of(SymbolReference.STREAM_CODEC.decode(buffer))
|
||||
: Optional.empty();
|
||||
return new PageContent(kind, symbol);
|
||||
}
|
||||
|
||||
public enum Kind {
|
||||
BLANK,
|
||||
SYMBOL,
|
||||
UNRESOLVED_SYMBOL,
|
||||
LINK_PANEL
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package net.dnorberg.rivencraft.writing;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.mojang.serialization.JsonOps;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import net.dnorberg.rivencraft.Rivencraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.server.packs.resources.SimpleJsonResourceReloadListener;
|
||||
import net.minecraft.util.profiling.ProfilerFiller;
|
||||
import net.neoforged.neoforge.event.AddReloadListenerEvent;
|
||||
|
||||
/** Authoritative server catalog loaded from data/<namespace>/rivencraft/symbols. */
|
||||
public final class SymbolCatalog {
|
||||
private static final Gson GSON = new GsonBuilder().create();
|
||||
private static final String DIRECTORY = "rivencraft/symbols";
|
||||
private static volatile Map<ResourceLocation, SymbolDefinition> symbols = Map.of();
|
||||
|
||||
private SymbolCatalog() {
|
||||
}
|
||||
|
||||
public static void register(AddReloadListenerEvent event) {
|
||||
event.addListener(new Loader());
|
||||
}
|
||||
|
||||
public static Optional<SymbolDefinition> find(SymbolReference reference) {
|
||||
return Optional.ofNullable(symbols.get(reference.id()));
|
||||
}
|
||||
|
||||
public static boolean isKnown(SymbolReference reference) {
|
||||
return symbols.containsKey(reference.id());
|
||||
}
|
||||
|
||||
public static SymbolDisplayMetadata display(SymbolReference reference) {
|
||||
SymbolDefinition definition = symbols.get(reference.id());
|
||||
return definition == null
|
||||
? SymbolDisplayMetadata.unresolved(reference)
|
||||
: definition.display(reference.id());
|
||||
}
|
||||
|
||||
public static Map<ResourceLocation, SymbolDefinition> symbols() {
|
||||
return symbols;
|
||||
}
|
||||
|
||||
private static final class Loader extends SimpleJsonResourceReloadListener {
|
||||
private Loader() {
|
||||
super(GSON, DIRECTORY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void apply(Map<ResourceLocation, JsonElement> resources,
|
||||
ResourceManager resourceManager,
|
||||
ProfilerFiller profiler) {
|
||||
Map<ResourceLocation, SymbolDefinition> loaded = new HashMap<>();
|
||||
resources.forEach((id, json) -> SymbolDefinition.CODEC.parse(JsonOps.INSTANCE, json)
|
||||
.resultOrPartial(error -> Rivencraft.LOGGER.error(
|
||||
"Ignoring invalid writing symbol {}: {}", id, error))
|
||||
.ifPresent(definition -> loaded.put(id, definition)));
|
||||
symbols = Map.copyOf(loaded);
|
||||
Rivencraft.LOGGER.info("Loaded {} writing symbols", loaded.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package net.dnorberg.rivencraft.writing;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.DataResult;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import java.util.Objects;
|
||||
import java.util.regex.Pattern;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
/** Server-loaded, non-executable display metadata for a writing symbol. */
|
||||
public record SymbolDefinition(
|
||||
int schemaVersion,
|
||||
String nameTranslationKey,
|
||||
String descriptionTranslationKey,
|
||||
ResourceLocation category
|
||||
) {
|
||||
public static final int CURRENT_SCHEMA_VERSION = 1;
|
||||
private static final Pattern TRANSLATION_KEY = Pattern.compile("[a-z0-9_.-]+");
|
||||
private static final Codec<String> TRANSLATION_KEY_CODEC = Codec.STRING.comapFlatMap(
|
||||
value -> TRANSLATION_KEY.matcher(value).matches()
|
||||
? DataResult.success(value)
|
||||
: DataResult.error(() -> "Invalid translation key: " + value),
|
||||
value -> value
|
||||
);
|
||||
public static final Codec<SymbolDefinition> CODEC = RecordCodecBuilder.<SymbolDefinition>create(instance -> instance.group(
|
||||
Codec.INT.fieldOf("schema_version").forGetter(SymbolDefinition::schemaVersion),
|
||||
TRANSLATION_KEY_CODEC.fieldOf("name").forGetter(SymbolDefinition::nameTranslationKey),
|
||||
TRANSLATION_KEY_CODEC.fieldOf("description").forGetter(SymbolDefinition::descriptionTranslationKey),
|
||||
ResourceLocation.CODEC.fieldOf("category").forGetter(SymbolDefinition::category)
|
||||
).apply(instance, SymbolDefinition::new)).flatXmap(SymbolDefinition::validate, SymbolDefinition::validate);
|
||||
|
||||
public SymbolDefinition {
|
||||
Objects.requireNonNull(nameTranslationKey, "nameTranslationKey");
|
||||
Objects.requireNonNull(descriptionTranslationKey, "descriptionTranslationKey");
|
||||
Objects.requireNonNull(category, "category");
|
||||
}
|
||||
|
||||
public SymbolDisplayMetadata display(ResourceLocation id) {
|
||||
return new SymbolDisplayMetadata(id, nameTranslationKey, descriptionTranslationKey, category, true);
|
||||
}
|
||||
|
||||
private static DataResult<SymbolDefinition> validate(SymbolDefinition definition) {
|
||||
return definition.schemaVersion == CURRENT_SCHEMA_VERSION
|
||||
? DataResult.success(definition)
|
||||
: DataResult.error(() -> "Unsupported symbol schema_version " + definition.schemaVersion);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package net.dnorberg.rivencraft.writing;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.dnorberg.rivencraft.Rivencraft;
|
||||
import net.minecraft.network.codec.ByteBufCodecs;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
/** Client-safe symbol presentation selected by the authoritative server catalog. */
|
||||
public record SymbolDisplayMetadata(
|
||||
ResourceLocation id,
|
||||
String nameTranslationKey,
|
||||
String descriptionTranslationKey,
|
||||
ResourceLocation category,
|
||||
boolean resolved
|
||||
) {
|
||||
public static final Codec<SymbolDisplayMetadata> CODEC = RecordCodecBuilder.create(instance -> instance.group(
|
||||
ResourceLocation.CODEC.fieldOf("id").forGetter(SymbolDisplayMetadata::id),
|
||||
Codec.STRING.fieldOf("name").forGetter(SymbolDisplayMetadata::nameTranslationKey),
|
||||
Codec.STRING.fieldOf("description").forGetter(SymbolDisplayMetadata::descriptionTranslationKey),
|
||||
ResourceLocation.CODEC.fieldOf("category").forGetter(SymbolDisplayMetadata::category),
|
||||
Codec.BOOL.fieldOf("resolved").forGetter(SymbolDisplayMetadata::resolved)
|
||||
).apply(instance, SymbolDisplayMetadata::new));
|
||||
public static final StreamCodec<ByteBuf, SymbolDisplayMetadata> STREAM_CODEC = StreamCodec.composite(
|
||||
ResourceLocation.STREAM_CODEC, SymbolDisplayMetadata::id,
|
||||
ByteBufCodecs.STRING_UTF8, SymbolDisplayMetadata::nameTranslationKey,
|
||||
ByteBufCodecs.STRING_UTF8, SymbolDisplayMetadata::descriptionTranslationKey,
|
||||
ResourceLocation.STREAM_CODEC, SymbolDisplayMetadata::category,
|
||||
ByteBufCodecs.BOOL, SymbolDisplayMetadata::resolved,
|
||||
SymbolDisplayMetadata::new
|
||||
);
|
||||
|
||||
public static SymbolDisplayMetadata unresolved(SymbolReference reference) {
|
||||
return new SymbolDisplayMetadata(
|
||||
reference.id(),
|
||||
"symbol.rivencraft.unresolved",
|
||||
"symbol.rivencraft.unresolved.description",
|
||||
ResourceLocation.fromNamespaceAndPath(Rivencraft.MOD_ID, "unresolved"),
|
||||
false
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package net.dnorberg.rivencraft.writing;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.Objects;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
/** Stable namespaced identity for one writing symbol. */
|
||||
public record SymbolReference(ResourceLocation id) {
|
||||
public static final Codec<SymbolReference> CODEC = ResourceLocation.CODEC.xmap(
|
||||
SymbolReference::new, SymbolReference::id);
|
||||
public static final StreamCodec<ByteBuf, SymbolReference> STREAM_CODEC = ResourceLocation.STREAM_CODEC.map(
|
||||
SymbolReference::new, SymbolReference::id);
|
||||
|
||||
public SymbolReference {
|
||||
Objects.requireNonNull(id, "id");
|
||||
}
|
||||
|
||||
/** Remains useful when the defining data pack has been removed. */
|
||||
public String unresolvedName() {
|
||||
return id.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package net.dnorberg.rivencraft.writing;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.DataResult;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import net.minecraft.network.codec.ByteBufCodecs;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
|
||||
/** One ordered unit of book writing. Interpretation belongs to Milestone 5. */
|
||||
public record WritingEntry(Kind kind, Optional<SymbolReference> symbol) {
|
||||
private static final Codec<Kind> KIND_CODEC = Codec.STRING.comapFlatMap(
|
||||
value -> {
|
||||
try {
|
||||
return DataResult.success(Kind.valueOf(value.toUpperCase(Locale.ROOT)));
|
||||
} catch (IllegalArgumentException exception) {
|
||||
return DataResult.error(() -> "Unknown writing entry kind: " + value);
|
||||
}
|
||||
},
|
||||
value -> value.name().toLowerCase(Locale.ROOT)
|
||||
);
|
||||
private static final Codec<WritingEntry> RECORD_CODEC = RecordCodecBuilder.create(instance -> instance.group(
|
||||
KIND_CODEC.fieldOf("kind").forGetter(WritingEntry::kind),
|
||||
SymbolReference.CODEC.optionalFieldOf("symbol").forGetter(WritingEntry::symbol)
|
||||
).apply(instance, WritingEntry::new));
|
||||
public static final Codec<WritingEntry> CODEC = RECORD_CODEC.flatXmap(
|
||||
WritingEntry::validate, WritingEntry::validate);
|
||||
public static final StreamCodec<ByteBuf, WritingEntry> STREAM_CODEC = StreamCodec.of(
|
||||
WritingEntry::encode, WritingEntry::decode);
|
||||
|
||||
public WritingEntry {
|
||||
Objects.requireNonNull(kind, "kind");
|
||||
symbol = Objects.requireNonNull(symbol, "symbol");
|
||||
if (kind == Kind.SYMBOL && symbol.isEmpty()) {
|
||||
throw new IllegalArgumentException("Symbol writing entries require a symbol reference");
|
||||
}
|
||||
if (kind == Kind.LINK_PANEL && symbol.isPresent()) {
|
||||
throw new IllegalArgumentException("Link-panel writing entries cannot contain a symbol reference");
|
||||
}
|
||||
}
|
||||
|
||||
public static WritingEntry symbol(SymbolReference symbol) {
|
||||
return new WritingEntry(Kind.SYMBOL, Optional.of(symbol));
|
||||
}
|
||||
|
||||
public static WritingEntry linkPanel() {
|
||||
return new WritingEntry(Kind.LINK_PANEL, Optional.empty());
|
||||
}
|
||||
|
||||
private static DataResult<WritingEntry> validate(WritingEntry entry) {
|
||||
return entry.kind == Kind.SYMBOL && entry.symbol.isEmpty()
|
||||
|| entry.kind == Kind.LINK_PANEL && entry.symbol.isPresent()
|
||||
? DataResult.error(() -> "Writing entry contents do not match kind " + entry.kind)
|
||||
: DataResult.success(entry);
|
||||
}
|
||||
|
||||
private static void encode(ByteBuf buffer, WritingEntry entry) {
|
||||
ByteBufCodecs.VAR_INT.encode(buffer, entry.kind.ordinal());
|
||||
if (entry.kind == Kind.SYMBOL) {
|
||||
SymbolReference.STREAM_CODEC.encode(buffer, entry.symbol.orElseThrow());
|
||||
}
|
||||
}
|
||||
|
||||
private static WritingEntry decode(ByteBuf buffer) {
|
||||
int ordinal = ByteBufCodecs.VAR_INT.decode(buffer);
|
||||
if (ordinal < 0 || ordinal >= Kind.values().length) {
|
||||
throw new IllegalArgumentException("Unknown writing entry kind ordinal " + ordinal);
|
||||
}
|
||||
Kind kind = Kind.values()[ordinal];
|
||||
return kind == Kind.SYMBOL
|
||||
? symbol(SymbolReference.STREAM_CODEC.decode(buffer))
|
||||
: linkPanel();
|
||||
}
|
||||
|
||||
public enum Kind {
|
||||
SYMBOL,
|
||||
LINK_PANEL
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,20 @@
|
||||
"item.rivencraft.linking_book.unbound": "Unbound — sneak-use to bind",
|
||||
"item.rivencraft.linking_book.destination": "%s (%s, %s, %s)",
|
||||
"item.rivencraft.linking_book.return": "Return Link",
|
||||
"item.rivencraft.page": "Page",
|
||||
"item.rivencraft.page.blank": "Blank Page",
|
||||
"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.description": "The baseline panel required to assemble a Descriptive Book.",
|
||||
"item.rivencraft.page.unresolved": "Unresolved Symbol Page",
|
||||
"item.rivencraft.notebook": "Notebook",
|
||||
"item.rivencraft.notebook.pages": "Pages: %s/%s",
|
||||
"item.rivencraft.notebook.unresolved": "Unresolved pages: %s",
|
||||
"screen.rivencraft.notebook.rename": "Rename selected page",
|
||||
"screen.rivencraft.notebook.search": "Search pages",
|
||||
"screen.rivencraft.notebook.rename_toggle": "Rename selected page (R); use left/right arrows to reorder",
|
||||
"screen.rivencraft.notebook.move_previous": "Move selected page left",
|
||||
"screen.rivencraft.notebook.move_next": "Move selected page right",
|
||||
"message.rivencraft.linking_book.bind_hint": "Sneak-use to bind this book to your current location",
|
||||
"message.rivencraft.linking_book.unbound": "This Linking Book is unbound",
|
||||
"message.rivencraft.linking_book.bound": "Linking Book bound as %s",
|
||||
@@ -57,6 +71,20 @@
|
||||
"trait.rivencraft.weather.snow": "Snow",
|
||||
"trait.rivencraft.weather.storm": "Storm",
|
||||
"trait.rivencraft.day_length.stopped": "Stopped",
|
||||
"symbol.rivencraft.unresolved": "Unresolved Symbol",
|
||||
"symbol.rivencraft.unresolved.description": "Missing symbol: %s",
|
||||
"symbol.rivencraft.terrain.standard": "Standard Terrain",
|
||||
"symbol.rivencraft.terrain.standard.description": "A familiar continental terrain foundation.",
|
||||
"symbol.rivencraft.biome.native": "Native Biomes",
|
||||
"symbol.rivencraft.biome.native.description": "Use the terrain profile's native biome climate.",
|
||||
"symbol.rivencraft.lighting.normal": "Normal Lighting",
|
||||
"symbol.rivencraft.lighting.normal.description": "Use normal skylight and ambient brightness.",
|
||||
"symbol.rivencraft.weather.normal": "Normal Weather",
|
||||
"symbol.rivencraft.weather.normal.description": "Use the normal weather cycle.",
|
||||
"symbol.rivencraft.celestial.normal_time": "Normal Time",
|
||||
"symbol.rivencraft.celestial.normal_time.description": "Use a normal-length celestial cycle.",
|
||||
"symbol.rivencraft.feature.caves": "Caves",
|
||||
"symbol.rivencraft.feature.caves.description": "Describe underground cave features.",
|
||||
"generator.rivencraft.standard": "Standard",
|
||||
"generator.rivencraft.amplified": "Amplified",
|
||||
"generator.rivencraft.island": "Island",
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": {
|
||||
"layer0": "rivencraft:item/linking_book"
|
||||
}
|
||||
"layer0": "rivencraft:item/linking_book_unwritten"
|
||||
},
|
||||
"overrides": [
|
||||
{
|
||||
"predicate": {
|
||||
"rivencraft:bound": 1.0
|
||||
},
|
||||
"model": "rivencraft:item/linking_book_bound"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": {
|
||||
"layer0": "rivencraft:item/linking_book"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": {
|
||||
"layer0": "rivencraft:item/notebook"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": {
|
||||
"layer0": "rivencraft:item/page"
|
||||
},
|
||||
"overrides": [
|
||||
{ "predicate": { "custom_model_data": 1 }, "model": "rivencraft:item/page_link_panel" },
|
||||
{ "predicate": { "custom_model_data": 2 }, "model": "rivencraft:item/page_unresolved" },
|
||||
{ "predicate": { "custom_model_data": 3 }, "model": "rivencraft:item/page_symbol" },
|
||||
{ "predicate": { "custom_model_data": 100 }, "model": "rivencraft:item/page_symbol_terrain_standard" },
|
||||
{ "predicate": { "custom_model_data": 101 }, "model": "rivencraft:item/page_symbol_biome_native" },
|
||||
{ "predicate": { "custom_model_data": 102 }, "model": "rivencraft:item/page_symbol_lighting_normal" },
|
||||
{ "predicate": { "custom_model_data": 103 }, "model": "rivencraft:item/page_symbol_weather_normal" },
|
||||
{ "predicate": { "custom_model_data": 104 }, "model": "rivencraft:item/page_symbol_celestial_normal_time" },
|
||||
{ "predicate": { "custom_model_data": 105 }, "model": "rivencraft:item/page_symbol_feature_caves" }
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": {
|
||||
"layer0": "rivencraft:item/page_link_panel"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": {
|
||||
"layer0": "rivencraft:item/page_symbol"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": { "layer0": "rivencraft:item/page_symbol_biome_native" }
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": { "layer0": "rivencraft:item/page_symbol_celestial_normal_time" }
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": { "layer0": "rivencraft:item/page_symbol_feature_caves" }
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": { "layer0": "rivencraft:item/page_symbol_lighting_normal" }
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": { "layer0": "rivencraft:item/page_symbol_terrain_standard" }
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": { "layer0": "rivencraft:item/page_symbol_weather_normal" }
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": {
|
||||
"layer0": "rivencraft:item/page_unresolved"
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 546 B After Width: | Height: | Size: 441 B |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 489 B |
|
After Width: | Height: | Size: 405 B |
|
After Width: | Height: | Size: 303 B |
|
After Width: | Height: | Size: 297 B |
|
After Width: | Height: | Size: 941 B |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"category": "misc",
|
||||
"key": {
|
||||
"L": {
|
||||
"item": "minecraft:leather"
|
||||
},
|
||||
"S": {
|
||||
"item": "minecraft:string"
|
||||
}
|
||||
},
|
||||
"pattern": [
|
||||
" L ",
|
||||
"S ",
|
||||
" L "
|
||||
],
|
||||
"result": {
|
||||
"count": 1,
|
||||
"id": "rivencraft:notebook"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"type": "minecraft:crafting_shapeless",
|
||||
"category": "misc",
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "minecraft:paper"
|
||||
}
|
||||
],
|
||||
"result": {
|
||||
"count": 1,
|
||||
"id": "rivencraft:page"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"schema_version": 1,
|
||||
"terrain": "noise",
|
||||
"noise_settings": "minecraft:amplified",
|
||||
"biome_preset": "minecraft:overworld",
|
||||
"dimension_type": "minecraft:overworld"
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"schema_version": 1,
|
||||
"terrain": "noise",
|
||||
"noise_settings": "minecraft:caves",
|
||||
"biome_preset": "minecraft:overworld",
|
||||
"dimension_type": "minecraft:overworld"
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"schema_version": 1,
|
||||
"terrain": "flat",
|
||||
"dimension_type": "minecraft:overworld"
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"schema_version": 1,
|
||||
"terrain": "noise",
|
||||
"noise_settings": "minecraft:floating_islands",
|
||||
"biome_preset": "minecraft:overworld",
|
||||
"dimension_type": "minecraft:overworld"
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"schema_version": 1,
|
||||
"terrain": "noise",
|
||||
"noise_settings": "minecraft:overworld",
|
||||
"biome_preset": "minecraft:overworld",
|
||||
"dimension_type": "minecraft:overworld"
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"schema_version": 1,
|
||||
"terrain": "void",
|
||||
"dimension_type": "minecraft:overworld"
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"schema_version": 1,
|
||||
"name": "symbol.rivencraft.biome.native",
|
||||
"description": "symbol.rivencraft.biome.native.description",
|
||||
"category": "rivencraft:biome"
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"schema_version": 1,
|
||||
"name": "symbol.rivencraft.celestial.normal_time",
|
||||
"description": "symbol.rivencraft.celestial.normal_time.description",
|
||||
"category": "rivencraft:celestial"
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"schema_version": 1,
|
||||
"name": "symbol.rivencraft.feature.caves",
|
||||
"description": "symbol.rivencraft.feature.caves.description",
|
||||
"category": "rivencraft:feature"
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"schema_version": 1,
|
||||
"name": "symbol.rivencraft.lighting.normal",
|
||||
"description": "symbol.rivencraft.lighting.normal.description",
|
||||
"category": "rivencraft:lighting"
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"schema_version": 1,
|
||||
"name": "symbol.rivencraft.terrain.standard",
|
||||
"description": "symbol.rivencraft.terrain.standard.description",
|
||||
"category": "rivencraft:terrain"
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"schema_version": 1,
|
||||
"name": "symbol.rivencraft.weather.normal",
|
||||
"description": "symbol.rivencraft.weather.normal.description",
|
||||
"category": "rivencraft:weather"
|
||||
}
|
||||
@@ -4,6 +4,8 @@
|
||||
"package": "net.dnorberg.rivencraft.mixin",
|
||||
"compatibilityLevel": "JAVA_21",
|
||||
"client": [
|
||||
"client.ClientLevelSoundMixin",
|
||||
"client.ImmersivePortalsGuiRenderingMixin",
|
||||
"client.LevelRendererMixin"
|
||||
],
|
||||
"injectors": {
|
||||
|
||||