From f0251eb84b14aa6b591ec819ea6f59a553df2710 Mon Sep 17 00:00:00 2001 From: Robotgiggle <88736742+Robotgiggle@users.noreply.github.com> Date: Wed, 27 May 2026 16:28:21 -0400 Subject: [PATCH 1/2] Log error and safely handle missing pattern on loot scrolls --- .../common/loot/AddPerWorldPatternToScrollFunc.java | 10 +++++++++- .../assets/hexcasting/lang/en_us.flatten.json5 | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/loot/AddPerWorldPatternToScrollFunc.java b/Common/src/main/java/at/petrak/hexcasting/common/loot/AddPerWorldPatternToScrollFunc.java index 0d45634db..ade394173 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/loot/AddPerWorldPatternToScrollFunc.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/loot/AddPerWorldPatternToScrollFunc.java @@ -1,5 +1,6 @@ package at.petrak.hexcasting.common.loot; +import at.petrak.hexcasting.api.HexAPI; import at.petrak.hexcasting.api.casting.ActionRegistryEntry; import at.petrak.hexcasting.api.mod.HexTags; import at.petrak.hexcasting.api.utils.HexUtils; @@ -48,8 +49,15 @@ public static ItemStack doStatic(ItemStack stack, RandomSource rand, ServerLevel } } var patternKey = perWorldKeys.get(rand.nextInt(perWorldKeys.size())); + var patternID = patternKey.location().toString(); var pat = PatternRegistryManifest.getCanonicalStrokesPerWorld(patternKey, overworld); - NBTHelper.putString(stack, ItemScroll.TAG_OP_ID, patternKey.location().toString()); + if (pat == null) { + HexAPI.LOGGER.error("No per-world pattern found for action " + patternID + " while generating loot scroll! " + + "Try running '/hexcasting recalcPatterns' to generate the patterns for this world."); + NBTHelper.putString(stack, ItemScroll.TAG_RECALC_WARNING, patternID); + return stack; + } + NBTHelper.putString(stack, ItemScroll.TAG_OP_ID, patternID); NBTHelper.put(stack, ItemScroll.TAG_PATTERN, pat.serializeToNBT()); return stack; } diff --git a/Common/src/main/resources/assets/hexcasting/lang/en_us.flatten.json5 b/Common/src/main/resources/assets/hexcasting/lang/en_us.flatten.json5 index dd39d0e0c..44127f9e0 100644 --- a/Common/src/main/resources/assets/hexcasting/lang/en_us.flatten.json5 +++ b/Common/src/main/resources/assets/hexcasting/lang/en_us.flatten.json5 @@ -603,7 +603,7 @@ needs_purchase: "Purchase to show pattern", pattern_not_loaded: "Place in inventory to load pattern", "recalc_warning.line1": "The per-world pattern for %s has not been calculated yet!", - "recalc_warning.line2": "Please run /hexcasting recalcPatterns, then grab a new scroll.", + "recalc_warning.line2": "Please run /hexcasting recalcPatterns, then get a new scroll.", }, abacus: { From 9130e46d35d6ae0dca2490c2a21e11e2ee64429d Mon Sep 17 00:00:00 2001 From: Robotgiggle <88736742+Robotgiggle@users.noreply.github.com> Date: Wed, 27 May 2026 16:28:26 -0400 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6cd50c09c..c3aa3df74 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). ### Fixed - Fixed a crash loop when trying to generate a creative-mode ancient scroll for a Great Spell whose per-world pattern hasn't been calculated yet ([#992](https://github.com/FallingColors/HexMod/pull/992)) @Robotgiggle +- Fixed a crash when trying to generate a loot scroll for a Great Spell whose per-world pattern hasn't been calculated yet ([#1079](https://github.com/FallingColors/HexMod/pull/1079)) @Robotgiggle - Fixed Create Water and Create Lava causing the "position is forbidden to you" mishap when the position is actually just out of ambit ([#1029](https://github.com/FallingColors/HexMod/pull/1029)) @pythonmcpi - Fixed a broken translation key on the error message from a Shepherd Directrix ([#1013](https://github.com/FallingColors/HexMod/pull/1013)) @Teal-Wolf-25-v2 - Fixed the log spam caused by double pattern registration when joining a world ([#999](https://github.com/FallingColors/HexMod/pull/999)) @Real-Luxof