Public Access
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
916755e810 |
No files matched your search
Binary file not shown.
|
After Width: | Height: | Size: 57 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 27 KiB |
@@ -0,0 +1,16 @@
|
|||||||
|
# Descriptive Book presentation (Milestone 5, issue #40)
|
||||||
|
|
||||||
|
The Legacy-style front spread has the Age name and author on the left and the destination panel on the right. The reference screenshots are `dev images/Pasted image.png` (front spread) and `dev images/Pasted image (2).png` (single-symbol spread). An authored book shows one full-size composed symbol on each turned right page, in the order stored in `BOOK_WRITING`; the former plain-text name and symbol ID are not shown for resolved pages. The last authored symbol is the last normal page, not a blank trailing page.
|
||||||
|
|
||||||
|
The Binder records the taking player's name on the finished book; direct Age binding also records the binding player. Older books without this component display `Unknown author` rather than attributing them to whoever happens to open them. Link-Panel-only and older page-free books retain their random-Age glyph details and destination preview. On authored books, hovering the front-page name exposes the existing trait summary without filling the left page with text.
|
||||||
|
|
||||||
|
The server resolves symbol display metadata from its current catalog and sends advisory grammar diagnostics with the book-opening payload. A missing data-pack symbol draws the unresolved page artwork and its original ID. An affected page displays a red `!` with the server's diagnostic on hover; separate writing-note pages show all diagnostics, including incomplete branches that the Age compiler filled. These UI notices do not alter or recompile the persisted Age plan. Symbol pages use the same bounded, runtime glyph composition as Page items and do not require Create, Ponder, or Immersive Portals.
|
||||||
|
|
||||||
|
## Manual visual and behavior checks
|
||||||
|
|
||||||
|
1. Bind a Descriptive Book with two distinct symbol pages. Open it: the front spread shows its Age name, your player name, and the link panel. Turn twice and confirm exactly one large symbol on each right page, in authored order, with no plain-text symbol description or blank trailing page.
|
||||||
|
2. Hover the front-page name to confirm the trait summary remains accessible. Click the link panel to confirm normal travel; repeat from a lectern to check the name, panel, and page-turn layout.
|
||||||
|
3. Open a Link-Panel-only book and confirm its existing random-Age details and destination preview still appear.
|
||||||
|
4. In a copy of a test world, remove a data pack that supplied one authored symbol. Reopen the book: its original symbol ID should remain readable beside the unresolved artwork, and the writing notes should explain the missing definition. Restore the pack and verify the page artwork returns without changing the saved Age.
|
||||||
|
|
||||||
|
`./gradlew build --offline` verifies compilation and jar assembly. The visual and data-pack-removal checks require an in-game client.
|
||||||
@@ -13,6 +13,7 @@ Serene Seasons 10.1.0.8 has no public dynamic-dimension registration hook, so th
|
|||||||
3. Without restarting or reconnecting, travel into the Age and check `/season get`; change its season with `/season set mid_winter` and check the Overworld and another Age separately.
|
3. Without restarting or reconnecting, travel into the Age and check `/season get`; change its season with `/season set mid_winter` and check the Overworld and another Age separately.
|
||||||
4. Reconnect another client and confirm it receives the same whitelist. Restart the server and confirm both the whitelist entry and the Age's season persisted.
|
4. Reconnect another client and confirm it receives the same whitelist. Restart the server and confirm both the whitelist entry and the Age's season persisted.
|
||||||
5. Build separate Ages with No Seasons, Seasons, and each Eternal page. Confirm No Seasons stays absent from Serene's whitelist, Seasons advances, and each Eternal Age remains in its named mid-season across several in-game days, a reconnect, and a server restart. Verify the Overworld still advances normally. The Eternal page should not stop the Age's sun or moon. With Serene removed, No Seasons should still bind, but the other five pages should refuse to bind with a clear message.
|
5. Build separate Ages with No Seasons, Seasons, and each Eternal page. Confirm No Seasons stays absent from Serene's whitelist, Seasons advances, and each Eternal Age remains in its named mid-season across several in-game days, a reconnect, and a server restart. Verify the Overworld still advances normally. The Eternal page should not stop the Age's sun or moon. With Serene removed, No Seasons should still bind, but the other five pages should refuse to bind with a clear message.
|
||||||
|
6. With Serene installed and `auto_whitelist_ages=true`, create several new Link-Panel-only Ages and Ages with symbols but no season page. `/rivencraft age list` shows each saved random `season:` choice. Check that No Seasons is absent from Serene's whitelist, Seasons advances, and each Eternal choice holds its season. Reopen the world and confirm the listed choices do not change. Without Serene, create another unpaged Age and confirm the list has no saved season choice for it.
|
||||||
|
|
||||||
For a local development run, `./gradlew runClient -PwithSereneSeasons=true` adds these two mods only to that run. The published Rivencraft jar does not include or require them.
|
For a local development run, `./gradlew runClient -PwithSereneSeasons=true` adds these two mods only to that run. The published Rivencraft jar does not include or require them.
|
||||||
|
|
||||||
@@ -31,7 +32,7 @@ An Age may specify one of six mutually exclusive seasonal modes:
|
|||||||
| Eternal Fall | Hold this Age in fall/autumn. |
|
| Eternal Fall | Hold this Age in fall/autumn. |
|
||||||
| Eternal Spring | Hold this Age in spring. |
|
| Eternal Spring | Hold this Age in spring. |
|
||||||
|
|
||||||
The six pages are available in the Season creative tab and the same page feed used by JEI. The writing grammar accepts at most one seasonal page, and its choice is saved in the Age plan. No Seasons removes that Age's ID from Serene's whitelist, even if it was previously enrolled; the other explicit pages enroll it regardless of the automatic-enrollment setting. An Age without a seasonal page follows the server's `auto_whitelist_ages` setting. If Serene Seasons is absent, No Seasons remains valid, but the other five pages reject **new** Age creation with a missing-dependency message rather than silently doing nothing. Existing Ages remain loadable with their saved pages, though their season effects are inactive until a supported season mod returns. The Ecliptic Seasons adapter is separate future work, and only one season mod is expected to be installed at a time.
|
The six pages are available in the Season creative tab and the same page feed used by JEI. The writing grammar accepts at most one seasonal page, and its choice is saved in the Age plan. No Seasons removes that Age's ID from Serene's whitelist, even if it was previously enrolled; the other explicit pages enroll it regardless of the automatic-enrollment setting. When a **new** Age has no season page and Serene Seasons is installed, Rivencraft chooses one of these six modes from the Age seed and saves that choice in the Age definition. A Link-Panel-only random Age is included. The choice does not change on reload or when the spawn moves. If Serene is absent at creation, no random seasonal modifier is assigned. Older Ages without a stored choice keep their previous normal-cycle behavior. The server's `auto_whitelist_ages=false` setting still prevents implicit (unpaged) modes other than No Seasons from enrolling the Age; explicit seasonal pages override it. If Serene Seasons is absent, No Seasons remains valid, but the other five pages reject **new** Age creation with a missing-dependency message rather than silently doing nothing. Existing Ages remain loadable with their saved pages, though their season effects are inactive until a supported season mod returns. Ecliptic Seasons integration was closed as unsupported for dynamic Ages in issue #39.
|
||||||
|
|
||||||
For an eternal mode, Rivencraft sets Serene's per-Age saved clock to the midpoint of the chosen season and resets it before it leaves that mid-season. Clients receive Serene's normal season sync. This does not freeze the Age's day/night cycle or change the Overworld's season. Eternal Winter does not guarantee snow in every biome.
|
For an eternal mode, Rivencraft sets Serene's per-Age saved clock to the midpoint of the chosen season and resets it before it leaves that mid-season. Clients receive Serene's normal season sync. This does not freeze the Age's day/night cycle or change the Overworld's season. Eternal Winter does not guarantee snow in every biome.
|
||||||
|
|
||||||
@@ -44,3 +45,5 @@ For an eternal mode, Rivencraft sets Serene's per-Age saved clock to the midpoin
|
|||||||
## Verification so far
|
## Verification so far
|
||||||
|
|
||||||
`./gradlew build` passed for candidate 0.4.9.2, and the baseline plus archived environment GameTests passed (35 required tests). The archive now covers seasonal page visibility, exclusivity, and saved-plan persistence without Serene installed. With Serene Seasons 10.1.0.8 and GlitchCore 2.1.0.2 in the optional local runtime, the GameTest server previously crashed when Serene Seasons sent `sereneseasons:sync_season_cycle` to a GameTest mock player that had not negotiated its client payload channel. The stack trace originates in Serene Seasons' `SeasonHandler.sendSeasonUpdate`, through GlitchCore's packet handler and NeoForge's packet check. This is a GameTest mock-network limitation, not a completed absent/present compatibility check. Do not keep rerunning that suite with Serene Seasons; use the real-client test path above instead.
|
`./gradlew build` passed for candidate 0.4.9.2, and the baseline plus archived environment GameTests passed (35 required tests). The archive now covers seasonal page visibility, exclusivity, and saved-plan persistence without Serene installed. With Serene Seasons 10.1.0.8 and GlitchCore 2.1.0.2 in the optional local runtime, the GameTest server previously crashed when Serene Seasons sent `sereneseasons:sync_season_cycle` to a GameTest mock player that had not negotiated its client payload channel. The stack trace originates in Serene Seasons' `SeasonHandler.sendSeasonUpdate`, through GlitchCore's packet handler and NeoForge's packet check. This is a GameTest mock-network limitation, not a completed absent/present compatibility check. Do not keep rerunning that suite with Serene Seasons; use the real-client test path above instead.
|
||||||
|
|
||||||
|
For candidate 0.4.10.1, `./gradlew build --offline` and the focused environment archive passed (36 required GameTests). The new regression check covers omitted-page selection, explicit-page precedence, no-Serene behavior, and save/reload. Actual Serene weather, whitelisting, and eternal-season visuals still require the real-client steps above.
|
||||||
+1
-1
@@ -36,7 +36,7 @@ mod_name=Rivencraft
|
|||||||
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
||||||
mod_license=LGPL-3.0-or-later
|
mod_license=LGPL-3.0-or-later
|
||||||
# The mod version. Rivencraft uses the x.y.z.b policy documented in README.md.
|
# The mod version. Rivencraft uses the x.y.z.b policy documented in README.md.
|
||||||
mod_version=0.4.9.2
|
mod_version=0.4.10.1
|
||||||
immersive_portals_version=6.0.7
|
immersive_portals_version=6.0.7
|
||||||
terrablender_version=4.1.0.8
|
terrablender_version=4.1.0.8
|
||||||
serene_seasons_version_id=B6nTjh4b
|
serene_seasons_version_id=B6nTjh4b
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import java.util.UUID;
|
|||||||
import net.dnorberg.rivencraft.Rivencraft;
|
import net.dnorberg.rivencraft.Rivencraft;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
/** Immutable, server-owned generation definition for one Age. */
|
/** Immutable, server-owned generation definition for one Age. */
|
||||||
public record AgeDefinition(
|
public record AgeDefinition(
|
||||||
@@ -17,7 +18,8 @@ public record AgeDefinition(
|
|||||||
ResourceLocation dimensionId,
|
ResourceLocation dimensionId,
|
||||||
BlockPos spawn,
|
BlockPos spawn,
|
||||||
AgeTraits traits,
|
AgeTraits traits,
|
||||||
AgeGenerationPlan plan
|
AgeGenerationPlan plan,
|
||||||
|
@Nullable AgeSeasonMode seasonMode
|
||||||
) {
|
) {
|
||||||
public static final ResourceLocation RANDOM_VANILLA_PROFILE = ResourceLocation.fromNamespaceAndPath(
|
public static final ResourceLocation RANDOM_VANILLA_PROFILE = ResourceLocation.fromNamespaceAndPath(
|
||||||
Rivencraft.MOD_ID, "random_vanilla"
|
Rivencraft.MOD_ID, "random_vanilla"
|
||||||
@@ -39,7 +41,14 @@ public record AgeDefinition(
|
|||||||
int generationVersion, long createdGameTime, ResourceLocation dimensionId,
|
int generationVersion, long createdGameTime, ResourceLocation dimensionId,
|
||||||
BlockPos spawn, AgeTraits traits) {
|
BlockPos spawn, AgeTraits traits) {
|
||||||
this(id, name, seed, generationProfile, generationVersion, createdGameTime,
|
this(id, name, seed, generationProfile, generationVersion, createdGameTime,
|
||||||
dimensionId, spawn, traits, null);
|
dimensionId, spawn, traits, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AgeDefinition(UUID id, String name, long seed, ResourceLocation generationProfile,
|
||||||
|
int generationVersion, long createdGameTime, ResourceLocation dimensionId,
|
||||||
|
BlockPos spawn, AgeTraits traits, AgeGenerationPlan plan) {
|
||||||
|
this(id, name, seed, generationProfile, generationVersion, createdGameTime,
|
||||||
|
dimensionId, spawn, traits, plan, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ResourceLocation dimensionId(UUID ageId) {
|
public static ResourceLocation dimensionId(UUID ageId) {
|
||||||
@@ -70,6 +79,6 @@ public record AgeDefinition(
|
|||||||
|
|
||||||
public AgeDefinition withSpawn(BlockPos spawn) {
|
public AgeDefinition withSpawn(BlockPos spawn) {
|
||||||
return new AgeDefinition(id, name, seed, generationProfile, generationVersion,
|
return new AgeDefinition(id, name, seed, generationProfile, generationVersion,
|
||||||
createdGameTime, dimensionId, spawn.immutable(), traits, plan);
|
createdGameTime, dimensionId, spawn.immutable(), traits, plan, seasonMode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -15,6 +15,7 @@ import net.minecraft.resources.ResourceLocation;
|
|||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.util.datafix.DataFixTypes;
|
import net.minecraft.util.datafix.DataFixTypes;
|
||||||
import net.minecraft.world.level.saveddata.SavedData;
|
import net.minecraft.world.level.saveddata.SavedData;
|
||||||
|
import net.neoforged.fml.ModList;
|
||||||
|
|
||||||
/** Server-wide persistent mapping from stable book UUIDs to immutable Age definitions. */
|
/** Server-wide persistent mapping from stable book UUIDs to immutable Age definitions. */
|
||||||
public final class AgeRegistrySavedData extends SavedData {
|
public final class AgeRegistrySavedData extends SavedData {
|
||||||
@@ -32,6 +33,7 @@ public final class AgeRegistrySavedData extends SavedData {
|
|||||||
private static final String SPAWN_Z_TAG = "SpawnZ";
|
private static final String SPAWN_Z_TAG = "SpawnZ";
|
||||||
private static final String TRAITS_TAG = "Traits";
|
private static final String TRAITS_TAG = "Traits";
|
||||||
private static final String PLAN_TAG = "GenerationPlan";
|
private static final String PLAN_TAG = "GenerationPlan";
|
||||||
|
private static final String SEASON_MODE_TAG = "SeasonMode";
|
||||||
private static final String BIOME_DISTRIBUTION_TAG = "BiomeDistribution";
|
private static final String BIOME_DISTRIBUTION_TAG = "BiomeDistribution";
|
||||||
private static final String LIGHTING_TAG = "Lighting";
|
private static final String LIGHTING_TAG = "Lighting";
|
||||||
private static final String WEATHER_TAG = "Weather";
|
private static final String WEATHER_TAG = "Weather";
|
||||||
@@ -130,7 +132,8 @@ public final class AgeRegistrySavedData extends SavedData {
|
|||||||
dimensionId,
|
dimensionId,
|
||||||
null,
|
null,
|
||||||
AgeEnvironmentCompiler.apply(plan, traits),
|
AgeEnvironmentCompiler.apply(plan, traits),
|
||||||
plan
|
plan,
|
||||||
|
AgeSeasonMode.select(plan, seed, ModList.get().isLoaded("sereneseasons"))
|
||||||
);
|
);
|
||||||
ages.put(created.id(), created);
|
ages.put(created.id(), created);
|
||||||
setDirty();
|
setDirty();
|
||||||
@@ -174,7 +177,9 @@ public final class AgeRegistrySavedData extends SavedData {
|
|||||||
spawn,
|
spawn,
|
||||||
readTraits(entry),
|
readTraits(entry),
|
||||||
entry.contains(PLAN_TAG, CompoundTag.TAG_COMPOUND)
|
entry.contains(PLAN_TAG, CompoundTag.TAG_COMPOUND)
|
||||||
? AgeGenerationPlan.load(entry.getCompound(PLAN_TAG)) : null
|
? AgeGenerationPlan.load(entry.getCompound(PLAN_TAG)) : null,
|
||||||
|
entry.contains(SEASON_MODE_TAG, CompoundTag.TAG_STRING)
|
||||||
|
? AgeSeasonMode.parseOrNull(entry.getString(SEASON_MODE_TAG)) : null
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
@@ -208,6 +213,7 @@ public final class AgeRegistrySavedData extends SavedData {
|
|||||||
traits.putFloat(CELESTIAL_PHASE_TAG, age.traits().celestialPhase());
|
traits.putFloat(CELESTIAL_PHASE_TAG, age.traits().celestialPhase());
|
||||||
entry.put(TRAITS_TAG, traits);
|
entry.put(TRAITS_TAG, traits);
|
||||||
if (age.plan() != null) entry.put(PLAN_TAG, age.plan().save());
|
if (age.plan() != null) entry.put(PLAN_TAG, age.plan().save());
|
||||||
|
if (age.seasonMode() != null) entry.putString(SEASON_MODE_TAG, age.seasonMode().name());
|
||||||
serializedAges.add(entry);
|
serializedAges.add(entry);
|
||||||
});
|
});
|
||||||
tag.put(AGES_TAG, serializedAges);
|
tag.put(AGES_TAG, serializedAges);
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
package net.dnorberg.rivencraft.book;
|
package net.dnorberg.rivencraft.book;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.Random;
|
||||||
import net.dnorberg.rivencraft.writing.SymbolSemantics;
|
import net.dnorberg.rivencraft.writing.SymbolSemantics;
|
||||||
import net.neoforged.fml.ModList;
|
import net.neoforged.fml.ModList;
|
||||||
|
|
||||||
/** One authored season policy per Age; unspecified Ages retain the normal cycle. */
|
/** One authored or seed-selected season policy per Age. */
|
||||||
public enum AgeSeasonMode {
|
public enum AgeSeasonMode {
|
||||||
NO_SEASONS,
|
NO_SEASONS,
|
||||||
SEASONS,
|
SEASONS,
|
||||||
@@ -13,6 +14,32 @@ public enum AgeSeasonMode {
|
|||||||
ETERNAL_FALL,
|
ETERNAL_FALL,
|
||||||
ETERNAL_SPRING;
|
ETERNAL_SPRING;
|
||||||
|
|
||||||
|
private static final long RANDOM_SALT = 0x5E45_0A5E_5EED_21L;
|
||||||
|
|
||||||
|
/** An omitted page is selected once when an Age is created with Serene installed. */
|
||||||
|
public static AgeSeasonMode select(AgeGenerationPlan plan, long ageSeed, boolean sereneInstalled) {
|
||||||
|
if (hasAuthoredPage(plan)) return from(plan);
|
||||||
|
return sereneInstalled ? values()[new Random(ageSeed ^ RANDOM_SALT).nextInt(values().length)] : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Existing Ages without a stored choice retain their old cycling behavior. */
|
||||||
|
public static AgeSeasonMode from(AgeDefinition age) {
|
||||||
|
return age.seasonMode() == null ? from(age.plan()) : age.seasonMode();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean hasAuthoredPage(AgeGenerationPlan plan) {
|
||||||
|
return plan != null && plan.symbols().stream()
|
||||||
|
.anyMatch(symbol -> symbol.semantics().role() == SymbolSemantics.Role.SEASON);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AgeSeasonMode parseOrNull(String value) {
|
||||||
|
try {
|
||||||
|
return valueOf(value);
|
||||||
|
} catch (IllegalArgumentException exception) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static AgeSeasonMode from(AgeGenerationPlan plan) {
|
public static AgeSeasonMode from(AgeGenerationPlan plan) {
|
||||||
if (plan == null) return SEASONS;
|
if (plan == null) return SEASONS;
|
||||||
return plan.symbols().stream()
|
return plan.symbols().stream()
|
||||||
@@ -24,9 +51,7 @@ public enum AgeSeasonMode {
|
|||||||
|
|
||||||
public static void validate(AgeGenerationPlan plan) {
|
public static void validate(AgeGenerationPlan plan) {
|
||||||
if (plan == null) return;
|
if (plan == null) return;
|
||||||
boolean authored = plan.symbols().stream()
|
if (hasAuthoredPage(plan) && from(plan) != NO_SEASONS
|
||||||
.anyMatch(symbol -> symbol.semantics().role() == SymbolSemantics.Role.SEASON);
|
|
||||||
if (authored && from(plan) != NO_SEASONS
|
|
||||||
&& !ModList.get().isLoaded("sereneseasons")) {
|
&& !ModList.get().isLoaded("sereneseasons")) {
|
||||||
throw new IllegalArgumentException("This seasonal page requires Serene Seasons to create the Age");
|
throw new IllegalArgumentException("This seasonal page requires Serene Seasons to create the Age");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ import net.dnorberg.rivencraft.writing.WritingEntry;
|
|||||||
import net.dnorberg.rivencraft.writing.WritingGrammar;
|
import net.dnorberg.rivencraft.writing.WritingGrammar;
|
||||||
import net.minecraft.gametest.framework.GameTest;
|
import net.minecraft.gametest.framework.GameTest;
|
||||||
import net.minecraft.gametest.framework.GameTestHelper;
|
import net.minecraft.gametest.framework.GameTestHelper;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.nbt.ListTag;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.level.dimension.BuiltinDimensionTypes;
|
import net.minecraft.world.level.dimension.BuiltinDimensionTypes;
|
||||||
import net.neoforged.neoforge.gametest.GameTestHolder;
|
import net.neoforged.neoforge.gametest.GameTestHolder;
|
||||||
@@ -93,6 +96,43 @@ public final class EnvironmentWritingGameTests {
|
|||||||
helper.succeed();
|
helper.succeed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GameTest(template = "empty")
|
||||||
|
public static void omittedSeasonPageSelectsOnlyWhenSereneIsPresent(GameTestHelper helper) {
|
||||||
|
helper.assertTrue(AgeSeasonMode.select(null, 42L, false) == null,
|
||||||
|
"An Age made without Serene must not receive a random seasonal modifier");
|
||||||
|
AgeSeasonMode selected = AgeSeasonMode.select(null, 42L, true);
|
||||||
|
helper.assertValueEqual(selected, AgeSeasonMode.select(null, 42L, true),
|
||||||
|
"The same Age seed must select the same seasonal modifier");
|
||||||
|
helper.assertTrue(selected != null, "Serene must select a mode when no season page is authored");
|
||||||
|
AgeDefinition age = new AgeDefinition(UUID.randomUUID(), "Season Test", 42L,
|
||||||
|
AgeGenerationProfiles.STANDARD, AgeDefinition.CURRENT_GENERATION_VERSION, 0L,
|
||||||
|
AgeDefinition.dimensionId(UUID.randomUUID()), null, AgeTraits.select(42L), null, selected);
|
||||||
|
helper.assertValueEqual(AgeSeasonMode.from(age.withSpawn(BlockPos.ZERO)), selected,
|
||||||
|
"Updating an Age spawn must preserve the chosen seasonal modifier");
|
||||||
|
OrderedWriting explicit = new OrderedWriting(List.of(WritingEntry.linkPanel(), page("season/no_seasons")));
|
||||||
|
AgeGenerationPlan plan = AgeGenerationPlan.compile(explicit, 42L, AgeGenerationProfiles.STANDARD,
|
||||||
|
AgeTraits.select(42L), helper.getLevel().registryAccess());
|
||||||
|
helper.assertValueEqual(AgeSeasonMode.select(plan, 42L, true), AgeSeasonMode.NO_SEASONS,
|
||||||
|
"An authored season page must override random selection");
|
||||||
|
AgeReference reference = new AgeReference(UUID.randomUUID(), "Season Persistence");
|
||||||
|
AgeRegistrySavedData data = AgeRegistrySavedData.get(helper.getLevel());
|
||||||
|
AgeRegistrySavedData.resolveOrCreate(helper.getLevel(), reference);
|
||||||
|
CompoundTag saved = data.save(new CompoundTag(), helper.getLevel().registryAccess());
|
||||||
|
ListTag entries = saved.getList("Ages", CompoundTag.TAG_COMPOUND);
|
||||||
|
for (int index = 0; index < entries.size(); index++) {
|
||||||
|
CompoundTag entry = entries.getCompound(index);
|
||||||
|
if (entry.getUUID("Id").equals(reference.id())) {
|
||||||
|
entry.putString("SeasonMode", selected.name());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AgeDefinition restored = AgeRegistrySavedData.load(saved, helper.getLevel().registryAccess())
|
||||||
|
.find(reference.id()).orElseThrow();
|
||||||
|
helper.assertValueEqual(restored.seasonMode(), selected,
|
||||||
|
"The selected seasonal modifier must survive Age data reload");
|
||||||
|
helper.succeed();
|
||||||
|
}
|
||||||
|
|
||||||
@GameTest(template = "empty")
|
@GameTest(template = "empty")
|
||||||
public static void writtenEnvironmentPersistsAndPageFreeAgesStaySeeded(GameTestHelper helper) {
|
public static void writtenEnvironmentPersistsAndPageFreeAgesStaySeeded(GameTestHelper helper) {
|
||||||
OrderedWriting writing = new OrderedWriting(List.of(
|
OrderedWriting writing = new OrderedWriting(List.of(
|
||||||
|
|||||||
@@ -92,8 +92,10 @@ public final class ClientBookInteractionHandler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
minecraft.setScreen(payload.fromStand()
|
minecraft.setScreen(payload.fromStand()
|
||||||
? new DescriptiveBookScreen(payload.source().pos(), payload.book(), payload.traits(), payload.writingSymbols())
|
? new DescriptiveBookScreen(payload.source().pos(), payload.book(), payload.traits(),
|
||||||
: new DescriptiveBookScreen(hand, payload.book(), payload.traits(), payload.writingSymbols()));
|
payload.writingSymbols(), payload.diagnostics())
|
||||||
|
: new DescriptiveBookScreen(hand, payload.book(), payload.traits(),
|
||||||
|
payload.writingSymbols(), payload.diagnostics()));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -69,6 +69,13 @@ public final class SymbolPageTextures {
|
|||||||
return forPage(stack, true);
|
return forPage(stack, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Book pages use the same server-resolved poem and glyph composition as Page items. */
|
||||||
|
public static ResourceLocation forDisplay(SymbolDisplayMetadata display) {
|
||||||
|
return display.resolved()
|
||||||
|
? forSymbol(display.id(), display.poem(), false)
|
||||||
|
: texture("item/page_unresolved");
|
||||||
|
}
|
||||||
|
|
||||||
private static ResourceLocation forPage(ItemStack stack, boolean item) {
|
private static ResourceLocation forPage(ItemStack stack, boolean item) {
|
||||||
PageContent content = PageItem.content(stack);
|
PageContent content = PageItem.content(stack);
|
||||||
if (content.kind() == PageContent.Kind.UNRESOLVED_SYMBOL) return texture("item/page_unresolved");
|
if (content.kind() == PageContent.Kind.UNRESOLVED_SYMBOL) return texture("item/page_unresolved");
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import net.dnorberg.rivencraft.registry.ModDataComponents;
|
|||||||
import net.dnorberg.rivencraft.writing.OrderedWriting;
|
import net.dnorberg.rivencraft.writing.OrderedWriting;
|
||||||
import net.dnorberg.rivencraft.writing.SymbolDisplayMetadata;
|
import net.dnorberg.rivencraft.writing.SymbolDisplayMetadata;
|
||||||
import net.dnorberg.rivencraft.writing.WritingEntry;
|
import net.dnorberg.rivencraft.writing.WritingEntry;
|
||||||
|
import net.dnorberg.rivencraft.writing.WritingGrammar;
|
||||||
import net.dnorberg.rivencraft.client.preview.DestinationPreviewRenderer;
|
import net.dnorberg.rivencraft.client.preview.DestinationPreviewRenderer;
|
||||||
import net.dnorberg.rivencraft.client.preview.DestinationPreviewRenderers;
|
import net.dnorberg.rivencraft.client.preview.DestinationPreviewRenderers;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
@@ -44,6 +45,7 @@ public final class DescriptiveBookScreen extends Screen implements ExplorableBoo
|
|||||||
private static final int LINK_PANEL_Y = 20;
|
private static final int LINK_PANEL_Y = 20;
|
||||||
private static final int LINK_PANEL_WIDTH = 132;
|
private static final int LINK_PANEL_WIDTH = 132;
|
||||||
private static final int LINK_PANEL_HEIGHT = 83;
|
private static final int LINK_PANEL_HEIGHT = 83;
|
||||||
|
private static final int DIAGNOSTICS_PER_PAGE = 2;
|
||||||
private static final Component EXPLORE_ICON = Component.literal("👁");
|
private static final Component EXPLORE_ICON = Component.literal("👁");
|
||||||
|
|
||||||
private final AgeReference age;
|
private final AgeReference age;
|
||||||
@@ -51,7 +53,9 @@ public final class DescriptiveBookScreen extends Screen implements ExplorableBoo
|
|||||||
private final AgeTraits traits;
|
private final AgeTraits traits;
|
||||||
private final OrderedWriting writing;
|
private final OrderedWriting writing;
|
||||||
private final List<SymbolDisplayMetadata> writingSymbols;
|
private final List<SymbolDisplayMetadata> writingSymbols;
|
||||||
|
private final List<WritingGrammar.Diagnostic> diagnostics;
|
||||||
private final boolean pageFree;
|
private final boolean pageFree;
|
||||||
|
private final String author;
|
||||||
private final InteractionHand hand;
|
private final InteractionHand hand;
|
||||||
private final BlockPos bookStandPos;
|
private final BlockPos bookStandPos;
|
||||||
private DestinationPreviewRenderer preview;
|
private DestinationPreviewRenderer preview;
|
||||||
@@ -63,27 +67,33 @@ public final class DescriptiveBookScreen extends Screen implements ExplorableBoo
|
|||||||
private boolean movingToExploreOverlay;
|
private boolean movingToExploreOverlay;
|
||||||
|
|
||||||
public DescriptiveBookScreen(InteractionHand hand, ItemStack book, @Nullable AgeTraits traits,
|
public DescriptiveBookScreen(InteractionHand hand, ItemStack book, @Nullable AgeTraits traits,
|
||||||
List<SymbolDisplayMetadata> writingSymbols) {
|
List<SymbolDisplayMetadata> writingSymbols,
|
||||||
|
List<WritingGrammar.Diagnostic> diagnostics) {
|
||||||
super(book.getHoverName());
|
super(book.getHoverName());
|
||||||
age = book.get(ModDataComponents.AGE_REFERENCE.get());
|
age = book.get(ModDataComponents.AGE_REFERENCE.get());
|
||||||
generationProfile = book.get(ModDataComponents.AGE_GENERATION_PROFILE.get());
|
generationProfile = book.get(ModDataComponents.AGE_GENERATION_PROFILE.get());
|
||||||
this.traits = traits;
|
this.traits = traits;
|
||||||
writing = book.getOrDefault(ModDataComponents.BOOK_WRITING.get(), OrderedWriting.EMPTY);
|
writing = book.getOrDefault(ModDataComponents.BOOK_WRITING.get(), OrderedWriting.EMPTY);
|
||||||
this.writingSymbols = List.copyOf(writingSymbols);
|
this.writingSymbols = List.copyOf(writingSymbols);
|
||||||
|
this.diagnostics = List.copyOf(diagnostics);
|
||||||
pageFree = writing.entries().stream().noneMatch(entry -> entry.kind() == WritingEntry.Kind.SYMBOL);
|
pageFree = writing.entries().stream().noneMatch(entry -> entry.kind() == WritingEntry.Kind.SYMBOL);
|
||||||
|
author = book.get(ModDataComponents.BOOK_AUTHOR.get());
|
||||||
this.hand = hand;
|
this.hand = hand;
|
||||||
bookStandPos = null;
|
bookStandPos = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DescriptiveBookScreen(BlockPos bookStandPos, ItemStack book, @Nullable AgeTraits traits,
|
public DescriptiveBookScreen(BlockPos bookStandPos, ItemStack book, @Nullable AgeTraits traits,
|
||||||
List<SymbolDisplayMetadata> writingSymbols) {
|
List<SymbolDisplayMetadata> writingSymbols,
|
||||||
|
List<WritingGrammar.Diagnostic> diagnostics) {
|
||||||
super(book.getHoverName());
|
super(book.getHoverName());
|
||||||
age = book.get(ModDataComponents.AGE_REFERENCE.get());
|
age = book.get(ModDataComponents.AGE_REFERENCE.get());
|
||||||
generationProfile = book.get(ModDataComponents.AGE_GENERATION_PROFILE.get());
|
generationProfile = book.get(ModDataComponents.AGE_GENERATION_PROFILE.get());
|
||||||
this.traits = traits;
|
this.traits = traits;
|
||||||
writing = book.getOrDefault(ModDataComponents.BOOK_WRITING.get(), OrderedWriting.EMPTY);
|
writing = book.getOrDefault(ModDataComponents.BOOK_WRITING.get(), OrderedWriting.EMPTY);
|
||||||
this.writingSymbols = List.copyOf(writingSymbols);
|
this.writingSymbols = List.copyOf(writingSymbols);
|
||||||
|
this.diagnostics = List.copyOf(diagnostics);
|
||||||
pageFree = writing.entries().stream().noneMatch(entry -> entry.kind() == WritingEntry.Kind.SYMBOL);
|
pageFree = writing.entries().stream().noneMatch(entry -> entry.kind() == WritingEntry.Kind.SYMBOL);
|
||||||
|
author = book.get(ModDataComponents.BOOK_AUTHOR.get());
|
||||||
hand = InteractionHand.MAIN_HAND;
|
hand = InteractionHand.MAIN_HAND;
|
||||||
this.bookStandPos = bookStandPos.immutable();
|
this.bookStandPos = bookStandPos.immutable();
|
||||||
}
|
}
|
||||||
@@ -163,6 +173,33 @@ public final class DescriptiveBookScreen extends Screen implements ExplorableBoo
|
|||||||
else if (pageIndex < pageCount() && mouseX >= left + 293 && mouseX < left + 320)
|
else if (pageIndex < pageCount() && mouseX >= left + 293 && mouseX < left + 320)
|
||||||
graphics.renderTooltip(font, Component.translatable("screen.rivencraft.book.next_page"), mouseX, mouseY);
|
graphics.renderTooltip(font, Component.translatable("screen.rivencraft.book.next_page"), mouseX, mouseY);
|
||||||
}
|
}
|
||||||
|
if (pageIndex > 0 && pageIndex < writing.entries().size()
|
||||||
|
&& mouseX >= left + 285 && mouseX < left + 306
|
||||||
|
&& mouseY >= top + 149 && mouseY < top + 169) {
|
||||||
|
diagnostics.stream().filter(diagnostic -> diagnostic.index() == pageIndex)
|
||||||
|
.findFirst().ifPresent(diagnostic -> graphics.renderTooltip(font,
|
||||||
|
Component.literal(diagnostic.message()), mouseX, mouseY));
|
||||||
|
}
|
||||||
|
if (pageIndex == 0 && age != null && !pageFree && traits != null
|
||||||
|
&& mouseX >= left + 38 && mouseX < left + 154
|
||||||
|
&& mouseY >= top + 38 && mouseY < top + 67) {
|
||||||
|
graphics.renderComponentTooltip(font, List.of(
|
||||||
|
Component.translatable("screen.rivencraft.age.trait.biomes",
|
||||||
|
traitName("biome_distribution", traits.biomeDistribution())),
|
||||||
|
Component.translatable("screen.rivencraft.age.trait.lighting",
|
||||||
|
traitName("lighting", traits.lighting())),
|
||||||
|
Component.translatable("screen.rivencraft.age.trait.weather",
|
||||||
|
traitName("weather", traits.weather())),
|
||||||
|
Component.translatable("screen.rivencraft.age.trait.day_length",
|
||||||
|
traits.hasStoppedCelestialCycle()
|
||||||
|
? Component.translatable("trait.rivencraft.day_length.stopped")
|
||||||
|
: Component.literal(String.format(Locale.ROOT, "%.2fx", traits.celestialPeriod()))),
|
||||||
|
Component.translatable("screen.rivencraft.age.trait.celestial_angle",
|
||||||
|
Component.literal(String.format(Locale.ROOT, "%.0f°", traits.celestialAngle()))),
|
||||||
|
Component.translatable("screen.rivencraft.age.trait.celestial_phase",
|
||||||
|
Component.literal(String.format(Locale.ROOT, "%.0f%%", traits.celestialPhase() * 100.0F)))
|
||||||
|
), mouseX, mouseY);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void renderBook(GuiGraphics graphics, float partialTick) {
|
private void renderBook(GuiGraphics graphics, float partialTick) {
|
||||||
@@ -182,9 +219,12 @@ public final class DescriptiveBookScreen extends Screen implements ExplorableBoo
|
|||||||
graphics.enableScissor(left + 38, top + 38, left + 154, top + 174);
|
graphics.enableScissor(left + 38, top + 38, left + 154, top + 174);
|
||||||
renderFirstPageText(graphics, left, top);
|
renderFirstPageText(graphics, left, top);
|
||||||
graphics.disableScissor();
|
graphics.disableScissor();
|
||||||
} else if (pageIndex < pageCount()) {
|
} else if (pageIndex < writing.entries().size()) {
|
||||||
LegacyBookArtwork.drawFullPage(graphics, left, top);
|
LegacyBookArtwork.drawFullPage(graphics, left, top);
|
||||||
renderWrittenPage(graphics, left, top);
|
renderWrittenPage(graphics, left, top);
|
||||||
|
} else if (!diagnostics.isEmpty()) {
|
||||||
|
LegacyBookArtwork.drawFullPage(graphics, left, top);
|
||||||
|
renderDiagnosticsPage(graphics, left, top);
|
||||||
}
|
}
|
||||||
String counter = pageIndex + "/" + pageCount();
|
String counter = pageIndex + "/" + pageCount();
|
||||||
graphics.drawString(font, counter, left + 165 - font.width(counter) / 2,
|
graphics.drawString(font, counter, left + 165 - font.width(counter) / 2,
|
||||||
@@ -193,20 +233,27 @@ public final class DescriptiveBookScreen extends Screen implements ExplorableBoo
|
|||||||
|
|
||||||
private int pageCount() {
|
private int pageCount() {
|
||||||
// Older page-free Descriptive Books do not have a BOOK_WRITING component.
|
// Older page-free Descriptive Books do not have a BOOK_WRITING component.
|
||||||
return Math.max(1, writing.entries().size());
|
int authoredPages = Math.max(1, writing.entries().size() - 1);
|
||||||
|
return authoredPages + (diagnostics.isEmpty() ? 0
|
||||||
|
: (diagnostics.size() + DIAGNOSTICS_PER_PAGE - 1) / DIAGNOSTICS_PER_PAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void renderFirstPageText(GuiGraphics graphics, int left, int top) {
|
private void renderFirstPageText(GuiGraphics graphics, int left, int top) {
|
||||||
int x = left + 40;
|
int x = left + 40;
|
||||||
drawWrappedWithoutShadow(graphics, Component.translatable("screen.rivencraft.age.title"),
|
|
||||||
x, top + 40, 110);
|
|
||||||
if (age == null) {
|
if (age == null) {
|
||||||
|
drawWrappedWithoutShadow(graphics, Component.translatable("screen.rivencraft.age.title"),
|
||||||
|
x, top + 40, 110);
|
||||||
drawWrappedWithoutShadow(graphics, Component.translatable("screen.rivencraft.age.name_prompt"),
|
drawWrappedWithoutShadow(graphics, Component.translatable("screen.rivencraft.age.name_prompt"),
|
||||||
x, top + 52, 110);
|
x, top + 52, 110);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int detailsY = drawWrappedWithoutShadow(graphics, Component.literal(age.name()),
|
int nameEnd = drawWrappedWithoutShadow(graphics, Component.literal(age.name()),
|
||||||
x + 10, top + 52, 100) + 10;
|
x, top + 40, 110);
|
||||||
|
int detailsY = drawWrappedWithoutShadow(graphics,
|
||||||
|
author == null || author.isBlank()
|
||||||
|
? Component.translatable("screen.rivencraft.age.unknown_author")
|
||||||
|
: Component.literal(author), x + 10, nameEnd + 2, 100) + 10;
|
||||||
|
if (!pageFree) return;
|
||||||
if (generationProfile != null) {
|
if (generationProfile != null) {
|
||||||
Component profileName = generationProfile.getNamespace().equals("rivencraft")
|
Component profileName = generationProfile.getNamespace().equals("rivencraft")
|
||||||
? Component.translatable("generator.rivencraft." + generationProfile.getPath())
|
? Component.translatable("generator.rivencraft." + generationProfile.getPath())
|
||||||
@@ -242,11 +289,37 @@ public final class DescriptiveBookScreen extends Screen implements ExplorableBoo
|
|||||||
.filter(candidate -> candidate.kind() == WritingEntry.Kind.SYMBOL).count() - 1;
|
.filter(candidate -> candidate.kind() == WritingEntry.Kind.SYMBOL).count() - 1;
|
||||||
SymbolDisplayMetadata display = symbolIndex < writingSymbols.size()
|
SymbolDisplayMetadata display = symbolIndex < writingSymbols.size()
|
||||||
? writingSymbols.get(symbolIndex) : SymbolDisplayMetadata.unresolved(entry.symbol().orElseThrow());
|
? writingSymbols.get(symbolIndex) : SymbolDisplayMetadata.unresolved(entry.symbol().orElseThrow());
|
||||||
int color = display.resolved() ? BOOK_TEXT_COLOR : UNRESOLVED_TEXT_COLOR;
|
graphics.enableScissor(left + 174, top + 26, left + 306, top + 172);
|
||||||
drawWrappedWithoutShadow(graphics, Component.translatable(display.nameTranslationKey()),
|
int textureSize = display.resolved() ? 128 : 16;
|
||||||
x, top + 39, 126, color);
|
graphics.blit(SymbolPageTextures.forDisplay(display), left + 177, top + 29,
|
||||||
drawWrappedWithoutShadow(graphics, Component.literal(display.id().toString()),
|
128, 128, 0, 0, textureSize, textureSize, textureSize, textureSize);
|
||||||
x, top + 64, 126, color);
|
if (!display.resolved()) {
|
||||||
|
drawWrappedWithoutShadow(graphics, Component.literal(display.id().toString()),
|
||||||
|
x, top + 151, 126, UNRESOLVED_TEXT_COLOR);
|
||||||
|
}
|
||||||
|
graphics.disableScissor();
|
||||||
|
if (diagnostics.stream().anyMatch(diagnostic -> diagnostic.index() == pageIndex)) {
|
||||||
|
graphics.drawString(font, "!", left + 293, top + 153, UNRESOLVED_TEXT_COLOR, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void renderDiagnosticsPage(GuiGraphics graphics, int left, int top) {
|
||||||
|
drawWrappedWithoutShadow(graphics, Component.translatable("screen.rivencraft.age.writing_notes"),
|
||||||
|
left + 176, top + 35, 126);
|
||||||
|
int start = (pageIndex - Math.max(1, writing.entries().size() - 1) - 1) * DIAGNOSTICS_PER_PAGE;
|
||||||
|
int y = top + 52;
|
||||||
|
graphics.enableScissor(left + 174, top + 50, left + 306, top + 173);
|
||||||
|
for (int index = start; index < Math.min(start + DIAGNOSTICS_PER_PAGE, diagnostics.size()); index++) {
|
||||||
|
WritingGrammar.Diagnostic diagnostic = diagnostics.get(index);
|
||||||
|
int color = diagnostic.error() ? UNRESOLVED_TEXT_COLOR : BOOK_TEXT_COLOR;
|
||||||
|
Component label = diagnostic.index() < 0
|
||||||
|
? Component.translatable("screen.rivencraft.age.writing_general")
|
||||||
|
: Component.translatable("screen.rivencraft.age.writing_page", diagnostic.index() + 1);
|
||||||
|
y = drawWrappedWithoutShadow(graphics, label, left + 176, y, 126, color) + 3;
|
||||||
|
y = drawWrappedWithoutShadow(graphics, Component.literal(diagnostic.message()),
|
||||||
|
left + 176, y, 126, color) + 10;
|
||||||
|
}
|
||||||
|
graphics.disableScissor();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void turnPage(int direction) {
|
private void turnPage(int direction) {
|
||||||
|
|||||||
@@ -43,6 +43,8 @@ public final class RivencraftCommands {
|
|||||||
source.sendSuccess(() -> Component.literal(
|
source.sendSuccess(() -> Component.literal(
|
||||||
(loaded ? "[loaded] " : "[unloaded] ")
|
(loaded ? "[loaded] " : "[unloaded] ")
|
||||||
+ age.name() + " — " + age.dimensionId()
|
+ age.name() + " — " + age.dimensionId()
|
||||||
|
+ (age.seasonMode() == null ? "" : " (season: "
|
||||||
|
+ age.seasonMode().name().toLowerCase(java.util.Locale.ROOT) + ")")
|
||||||
), false);
|
), false);
|
||||||
}
|
}
|
||||||
return ages.size();
|
return ages.size();
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import net.dnorberg.rivencraft.book.AgeRegistrySavedData;
|
|||||||
import net.dnorberg.rivencraft.book.AgeSeasonMode;
|
import net.dnorberg.rivencraft.book.AgeSeasonMode;
|
||||||
import net.dnorberg.rivencraft.config.RivencraftConfig;
|
import net.dnorberg.rivencraft.config.RivencraftConfig;
|
||||||
import net.dnorberg.rivencraft.network.SereneAgeWhitelistPayload;
|
import net.dnorberg.rivencraft.network.SereneAgeWhitelistPayload;
|
||||||
import net.dnorberg.rivencraft.writing.SymbolSemantics;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
@@ -24,9 +23,8 @@ public final class SereneSeasonsCompatibility {
|
|||||||
|
|
||||||
public static void registerAge(MinecraftServer server, AgeDefinition age) {
|
public static void registerAge(MinecraftServer server, AgeDefinition age) {
|
||||||
if (!available() || !isAge(age.dimensionId())) return;
|
if (!available() || !isAge(age.dimensionId())) return;
|
||||||
AgeSeasonMode mode = AgeSeasonMode.from(age.plan());
|
AgeSeasonMode mode = AgeSeasonMode.from(age);
|
||||||
boolean explicit = age.plan() != null && age.plan().symbols().stream()
|
boolean explicit = AgeSeasonMode.hasAuthoredPage(age.plan());
|
||||||
.anyMatch(symbol -> symbol.semantics().role() == SymbolSemantics.Role.SEASON);
|
|
||||||
if (mode != AgeSeasonMode.NO_SEASONS && !explicit && !RivencraftConfig.autoWhitelistSereneAges()) {
|
if (mode != AgeSeasonMode.NO_SEASONS && !explicit && !RivencraftConfig.autoWhitelistSereneAges()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -52,8 +50,9 @@ public final class SereneSeasonsCompatibility {
|
|||||||
AgeDefinition age = AgeRegistrySavedData.get(level)
|
AgeDefinition age = AgeRegistrySavedData.get(level)
|
||||||
.findByDimension(level.dimension().location()).orElse(null);
|
.findByDimension(level.dimension().location()).orElse(null);
|
||||||
if (age == null) return;
|
if (age == null) return;
|
||||||
AgeSeasonMode mode = AgeSeasonMode.from(age.plan());
|
AgeSeasonMode mode = AgeSeasonMode.from(age);
|
||||||
if (!mode.eternal()) return;
|
if (!mode.eternal() || !AgeSeasonMode.hasAuthoredPage(age.plan())
|
||||||
|
&& !RivencraftConfig.autoWhitelistSereneAges()) return;
|
||||||
try {
|
try {
|
||||||
SereneSeasonsAdapter.holdSeason(level, mode);
|
SereneSeasonsAdapter.holdSeason(level, mode);
|
||||||
} catch (RuntimeException exception) {
|
} catch (RuntimeException exception) {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package net.dnorberg.rivencraft.menu;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import net.dnorberg.rivencraft.block.entity.BookBinderBlockEntity;
|
import net.dnorberg.rivencraft.block.entity.BookBinderBlockEntity;
|
||||||
import net.dnorberg.rivencraft.item.PageItem;
|
import net.dnorberg.rivencraft.item.PageItem;
|
||||||
|
import net.dnorberg.rivencraft.registry.ModDataComponents;
|
||||||
import net.dnorberg.rivencraft.registry.ModItems;
|
import net.dnorberg.rivencraft.registry.ModItems;
|
||||||
import net.dnorberg.rivencraft.registry.ModMenus;
|
import net.dnorberg.rivencraft.registry.ModMenus;
|
||||||
import net.dnorberg.rivencraft.writing.PageContent;
|
import net.dnorberg.rivencraft.writing.PageContent;
|
||||||
@@ -33,6 +34,7 @@ public final class BookBinderMenu extends AbstractContainerMenu {
|
|||||||
private final Container inputs;
|
private final Container inputs;
|
||||||
private final SimpleContainer result = new SimpleContainer(1);
|
private final SimpleContainer result = new SimpleContainer(1);
|
||||||
private final boolean clientSide;
|
private final boolean clientSide;
|
||||||
|
private final Player bookAuthor;
|
||||||
private int selectedPage = -1;
|
private int selectedPage = -1;
|
||||||
private int grammarErrorCode = -1;
|
private int grammarErrorCode = -1;
|
||||||
private int grammarErrorStripIndex = -1;
|
private int grammarErrorStripIndex = -1;
|
||||||
@@ -47,6 +49,7 @@ public final class BookBinderMenu extends AbstractContainerMenu {
|
|||||||
this.binder = binder;
|
this.binder = binder;
|
||||||
inputs = binder == null ? new SimpleContainer(BookBinderBlockEntity.SIZE) : binder;
|
inputs = binder == null ? new SimpleContainer(BookBinderBlockEntity.SIZE) : binder;
|
||||||
clientSide = inventory.player.level().isClientSide;
|
clientSide = inventory.player.level().isClientSide;
|
||||||
|
bookAuthor = inventory.player;
|
||||||
addDataSlot(new DataSlot() {
|
addDataSlot(new DataSlot() {
|
||||||
@Override public int get() { return selectedPage; }
|
@Override public int get() { return selectedPage; }
|
||||||
@Override public void set(int value) { selectedPage = value; }
|
@Override public void set(int value) { selectedPage = value; }
|
||||||
@@ -167,6 +170,7 @@ public final class BookBinderMenu extends AbstractContainerMenu {
|
|||||||
refreshResult();
|
refreshResult();
|
||||||
if (!binder.canAssemble()) return ItemStack.EMPTY;
|
if (!binder.canAssemble()) return ItemStack.EMPTY;
|
||||||
ItemStack book = binder.previewBook();
|
ItemStack book = binder.previewBook();
|
||||||
|
book.set(ModDataComponents.BOOK_AUTHOR.get(), player.getGameProfile().getName());
|
||||||
ItemStack remainder = book.copy();
|
ItemStack remainder = book.copy();
|
||||||
if (!moveItemStackTo(remainder, PLAYER_START, slots.size(), true) || !remainder.isEmpty()) {
|
if (!moveItemStackTo(remainder, PLAYER_START, slots.size(), true) || !remainder.isEmpty()) {
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
@@ -221,6 +225,9 @@ public final class BookBinderMenu extends AbstractContainerMenu {
|
|||||||
private void refreshResult() {
|
private void refreshResult() {
|
||||||
if (clientSide) return;
|
if (clientSide) return;
|
||||||
ItemStack preview = binder == null ? ItemStack.EMPTY : binder.previewBook();
|
ItemStack preview = binder == null ? ItemStack.EMPTY : binder.previewBook();
|
||||||
|
if (!preview.isEmpty()) {
|
||||||
|
preview.set(ModDataComponents.BOOK_AUTHOR.get(), bookAuthor.getGameProfile().getName());
|
||||||
|
}
|
||||||
if (!ItemStack.matches(result.getItem(0), preview)) result.setItem(0, preview);
|
if (!ItemStack.matches(result.getItem(0), preview)) result.setItem(0, preview);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ public final class ModNetworking {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void register(RegisterPayloadHandlersEvent event) {
|
public static void register(RegisterPayloadHandlersEvent event) {
|
||||||
PayloadRegistrar registrar = event.registrar("13");
|
PayloadRegistrar registrar = event.registrar("14");
|
||||||
registrar.playToServer(RequestDescriptiveBookScreenPayload.TYPE, RequestDescriptiveBookScreenPayload.STREAM_CODEC,
|
registrar.playToServer(RequestDescriptiveBookScreenPayload.TYPE, RequestDescriptiveBookScreenPayload.STREAM_CODEC,
|
||||||
ModNetworking::requestDescriptiveBookScreen);
|
ModNetworking::requestDescriptiveBookScreen);
|
||||||
registrar.playToClient(OpenDescriptiveBookScreenPayload.TYPE, OpenDescriptiveBookScreenPayload.STREAM_CODEC,
|
registrar.playToClient(OpenDescriptiveBookScreenPayload.TYPE, OpenDescriptiveBookScreenPayload.STREAM_CODEC,
|
||||||
@@ -114,17 +114,21 @@ public final class ModNetworking {
|
|||||||
// Requests run on the same server thread as Age creation. A request queued
|
// Requests run on the same server thread as Age creation. A request queued
|
||||||
// during generation can only open the finished book, never a stale client copy.
|
// during generation can only open the finished book, never a stale client copy.
|
||||||
player.inventoryMenu.broadcastChanges();
|
player.inventoryMenu.broadcastChanges();
|
||||||
List<SymbolDisplayMetadata> writingSymbols = access.stack()
|
OrderedWriting writing = access.stack()
|
||||||
.getOrDefault(ModDataComponents.BOOK_WRITING.get(), OrderedWriting.EMPTY).entries().stream()
|
.getOrDefault(ModDataComponents.BOOK_WRITING.get(), OrderedWriting.EMPTY);
|
||||||
|
List<SymbolDisplayMetadata> writingSymbols = writing.entries().stream()
|
||||||
.filter(entry -> entry.kind() == WritingEntry.Kind.SYMBOL)
|
.filter(entry -> entry.kind() == WritingEntry.Kind.SYMBOL)
|
||||||
.map(entry -> SymbolCatalog.display(entry.symbol().orElseThrow()))
|
.map(entry -> SymbolCatalog.display(entry.symbol().orElseThrow()))
|
||||||
.toList();
|
.toList();
|
||||||
|
// Diagnostics are advisory display data from the authoritative server catalog.
|
||||||
|
// Opening a book never recompiles or changes its persisted Age plan.
|
||||||
|
var diagnostics = WritingGrammar.parse(writing).diagnostics();
|
||||||
PacketDistributor.sendToPlayer(player, new OpenDescriptiveBookScreenPayload(
|
PacketDistributor.sendToPlayer(player, new OpenDescriptiveBookScreenPayload(
|
||||||
payload.fromStand(), payload.offhand(),
|
payload.fromStand(), payload.offhand(),
|
||||||
GlobalPos.of(player.level().dimension(), payload.standPos()), access.stack().copy(),
|
GlobalPos.of(player.level().dimension(), payload.standPos()), access.stack().copy(),
|
||||||
definition == null ? null : definition.plan() != null && definition.plan().biomeSelection() != null
|
definition == null ? null : definition.plan() != null && definition.plan().biomeSelection() != null
|
||||||
? definition.traits().withBiomeDistribution(definition.plan().biomeSelection().distribution())
|
? definition.traits().withBiomeDistribution(definition.plan().biomeSelection().distribution())
|
||||||
: definition.traits(), writingSymbols));
|
: definition.traits(), writingSymbols, diagnostics));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void bindDescriptiveBook(BindDescriptiveBookPayload payload, IPayloadContext context) {
|
private static void bindDescriptiveBook(BindDescriptiveBookPayload payload, IPayloadContext context) {
|
||||||
@@ -168,6 +172,7 @@ public final class ModNetworking {
|
|||||||
}
|
}
|
||||||
|
|
||||||
access.stack().set(ModDataComponents.AGE_REFERENCE.get(), reference);
|
access.stack().set(ModDataComponents.AGE_REFERENCE.get(), reference);
|
||||||
|
access.stack().set(ModDataComponents.BOOK_AUTHOR.get(), player.getGameProfile().getName());
|
||||||
AgeRegistrySavedData.get(player.serverLevel()).find(reference.id()).ifPresent(definition ->
|
AgeRegistrySavedData.get(player.serverLevel()).find(reference.id()).ifPresent(definition ->
|
||||||
access.stack().set(ModDataComponents.AGE_GENERATION_PROFILE.get(), definition.generationProfile()));
|
access.stack().set(ModDataComponents.AGE_GENERATION_PROFILE.get(), definition.generationProfile()));
|
||||||
access.stack().set(DataComponents.CUSTOM_NAME, Component.literal(title));
|
access.stack().set(DataComponents.CUSTOM_NAME, Component.literal(title));
|
||||||
|
|||||||
+22
-2
@@ -6,6 +6,7 @@ import net.dnorberg.rivencraft.Rivencraft;
|
|||||||
import net.dnorberg.rivencraft.book.AgeTraits;
|
import net.dnorberg.rivencraft.book.AgeTraits;
|
||||||
import net.dnorberg.rivencraft.writing.OrderedWriting;
|
import net.dnorberg.rivencraft.writing.OrderedWriting;
|
||||||
import net.dnorberg.rivencraft.writing.SymbolDisplayMetadata;
|
import net.dnorberg.rivencraft.writing.SymbolDisplayMetadata;
|
||||||
|
import net.dnorberg.rivencraft.writing.WritingGrammar;
|
||||||
import net.minecraft.core.GlobalPos;
|
import net.minecraft.core.GlobalPos;
|
||||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||||
import net.minecraft.network.codec.StreamCodec;
|
import net.minecraft.network.codec.StreamCodec;
|
||||||
@@ -21,7 +22,8 @@ public record OpenDescriptiveBookScreenPayload(
|
|||||||
GlobalPos source,
|
GlobalPos source,
|
||||||
ItemStack book,
|
ItemStack book,
|
||||||
@Nullable AgeTraits traits,
|
@Nullable AgeTraits traits,
|
||||||
List<SymbolDisplayMetadata> writingSymbols
|
List<SymbolDisplayMetadata> writingSymbols,
|
||||||
|
List<WritingGrammar.Diagnostic> diagnostics
|
||||||
)
|
)
|
||||||
implements CustomPacketPayload {
|
implements CustomPacketPayload {
|
||||||
public static final Type<OpenDescriptiveBookScreenPayload> TYPE = new Type<>(
|
public static final Type<OpenDescriptiveBookScreenPayload> TYPE = new Type<>(
|
||||||
@@ -50,6 +52,15 @@ public record OpenDescriptiveBookScreenPayload(
|
|||||||
}
|
}
|
||||||
buffer.writeVarInt(payload.writingSymbols().size());
|
buffer.writeVarInt(payload.writingSymbols().size());
|
||||||
payload.writingSymbols().forEach(symbol -> SymbolDisplayMetadata.STREAM_CODEC.encode(buffer, symbol));
|
payload.writingSymbols().forEach(symbol -> SymbolDisplayMetadata.STREAM_CODEC.encode(buffer, symbol));
|
||||||
|
if (payload.diagnostics().size() > OrderedWriting.MAX_ENTRIES * 2) {
|
||||||
|
throw new IllegalArgumentException("Too many book grammar diagnostics");
|
||||||
|
}
|
||||||
|
buffer.writeVarInt(payload.diagnostics().size());
|
||||||
|
payload.diagnostics().forEach(diagnostic -> {
|
||||||
|
buffer.writeEnum(diagnostic.code());
|
||||||
|
buffer.writeVarInt(diagnostic.index());
|
||||||
|
buffer.writeUtf(diagnostic.message(), 1024);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static OpenDescriptiveBookScreenPayload decode(RegistryFriendlyByteBuf buffer) {
|
private static OpenDescriptiveBookScreenPayload decode(RegistryFriendlyByteBuf buffer) {
|
||||||
@@ -75,8 +86,17 @@ public record OpenDescriptiveBookScreenPayload(
|
|||||||
for (int index = 0; index < count; index++) {
|
for (int index = 0; index < count; index++) {
|
||||||
writingSymbols.add(SymbolDisplayMetadata.STREAM_CODEC.decode(buffer));
|
writingSymbols.add(SymbolDisplayMetadata.STREAM_CODEC.decode(buffer));
|
||||||
}
|
}
|
||||||
|
int diagnosticCount = buffer.readVarInt();
|
||||||
|
if (diagnosticCount < 0 || diagnosticCount > OrderedWriting.MAX_ENTRIES * 2) {
|
||||||
|
throw new IllegalArgumentException("Invalid book grammar diagnostic count " + diagnosticCount);
|
||||||
|
}
|
||||||
|
List<WritingGrammar.Diagnostic> diagnostics = new ArrayList<>(diagnosticCount);
|
||||||
|
for (int index = 0; index < diagnosticCount; index++) {
|
||||||
|
diagnostics.add(new WritingGrammar.Diagnostic(
|
||||||
|
buffer.readEnum(WritingGrammar.Code.class), buffer.readVarInt(), buffer.readUtf(1024)));
|
||||||
|
}
|
||||||
return new OpenDescriptiveBookScreenPayload(fromStand, offhand, source, book, traits,
|
return new OpenDescriptiveBookScreenPayload(fromStand, offhand, source, book, traits,
|
||||||
List.copyOf(writingSymbols));
|
List.copyOf(writingSymbols), List.copyOf(diagnostics));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -75,6 +75,12 @@ public final class ModDataComponents {
|
|||||||
.networkSynchronized(OrderedWriting.STREAM_CODEC)
|
.networkSynchronized(OrderedWriting.STREAM_CODEC)
|
||||||
.cacheEncoding()
|
.cacheEncoding()
|
||||||
.build());
|
.build());
|
||||||
|
public static final DeferredHolder<DataComponentType<?>, DataComponentType<String>> BOOK_AUTHOR =
|
||||||
|
DATA_COMPONENTS.register("book_author", () -> DataComponentType.<String>builder()
|
||||||
|
.persistent(Codec.STRING)
|
||||||
|
.networkSynchronized(ByteBufCodecs.STRING_UTF8)
|
||||||
|
.cacheEncoding()
|
||||||
|
.build());
|
||||||
public static final DeferredHolder<DataComponentType<?>, DataComponentType<Integer>> INK_REMAINING =
|
public static final DeferredHolder<DataComponentType<?>, DataComponentType<Integer>> INK_REMAINING =
|
||||||
DATA_COMPONENTS.register("ink_remaining", () -> DataComponentType.<Integer>builder()
|
DATA_COMPONENTS.register("ink_remaining", () -> DataComponentType.<Integer>builder()
|
||||||
.persistent(Codec.intRange(0, 16))
|
.persistent(Codec.intRange(0, 16))
|
||||||
|
|||||||
@@ -88,12 +88,16 @@
|
|||||||
"screen.rivencraft.book.unwritten": "This Descriptive Book is unwritten",
|
"screen.rivencraft.book.unwritten": "This Descriptive Book is unwritten",
|
||||||
"screen.rivencraft.age.title": "Age name",
|
"screen.rivencraft.age.title": "Age name",
|
||||||
"screen.rivencraft.age.title_hint": "Name this Age",
|
"screen.rivencraft.age.title_hint": "Name this Age",
|
||||||
|
"screen.rivencraft.age.unknown_author": "Unknown author",
|
||||||
"screen.rivencraft.age.name_prompt": "Name this Age before writing the Descriptive Book",
|
"screen.rivencraft.age.name_prompt": "Name this Age before writing the Descriptive Book",
|
||||||
"screen.rivencraft.age.create": "Create",
|
"screen.rivencraft.age.create": "Create",
|
||||||
"screen.rivencraft.age.generator": "Terrain: %s",
|
"screen.rivencraft.age.generator": "Terrain: %s",
|
||||||
"screen.rivencraft.age.pages": "Pages",
|
"screen.rivencraft.age.pages": "Pages",
|
||||||
"screen.rivencraft.age.details": "Details",
|
"screen.rivencraft.age.details": "Details",
|
||||||
"screen.rivencraft.age.pages_count": "Writing %s/%s",
|
"screen.rivencraft.age.pages_count": "Writing %s/%s",
|
||||||
|
"screen.rivencraft.age.writing_notes": "Writing notes",
|
||||||
|
"screen.rivencraft.age.writing_general": "Book",
|
||||||
|
"screen.rivencraft.age.writing_page": "Page %s",
|
||||||
"screen.rivencraft.age.trait.biomes": "Biomes: %s",
|
"screen.rivencraft.age.trait.biomes": "Biomes: %s",
|
||||||
"screen.rivencraft.age.trait.lighting": "Lighting: %s",
|
"screen.rivencraft.age.trait.lighting": "Lighting: %s",
|
||||||
"screen.rivencraft.age.trait.weather": "Weather: %s",
|
"screen.rivencraft.age.trait.weather": "Weather: %s",
|
||||||
|
|||||||
Reference in new issue
Block a user