From 30d40f8eeb6a800a044cc8a6bcbfb53598460657 Mon Sep 17 00:00:00 2001 From: Robotgiggle Date: Tue, 18 Nov 2025 15:52:07 -0500 Subject: [PATCH 1/6] Make MishapInvalidPattern display the offending pattern --- .../hexcasting/api/casting/iota/PatternIota.java | 2 +- .../api/casting/mishaps/MishapInvalidPattern.kt | 11 ++++++++--- .../assets/hexcasting/lang/en_us.flatten.json5 | 3 ++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Common/src/main/java/at/petrak/hexcasting/api/casting/iota/PatternIota.java b/Common/src/main/java/at/petrak/hexcasting/api/casting/iota/PatternIota.java index b86e8541ce..74db0a95fb 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/casting/iota/PatternIota.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/iota/PatternIota.java @@ -98,7 +98,7 @@ public boolean toleratesOther(Iota that) { castedName = special.handler::getName; action = special.handler.act(); } else if (lookup instanceof PatternShapeMatch.Nothing) { - throw new MishapInvalidPattern(); + throw new MishapInvalidPattern(this.getPattern()); } else throw new IllegalStateException(); // do the actual calculation!! diff --git a/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapInvalidPattern.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapInvalidPattern.kt index 20fbd31fb5..129ef4a513 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapInvalidPattern.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapInvalidPattern.kt @@ -4,10 +4,13 @@ import at.petrak.hexcasting.api.casting.eval.CastingEnvironment import at.petrak.hexcasting.api.casting.eval.ResolvedPatternType import at.petrak.hexcasting.api.casting.iota.GarbageIota import at.petrak.hexcasting.api.casting.iota.Iota +import at.petrak.hexcasting.api.casting.iota.PatternIota +import at.petrak.hexcasting.api.casting.math.HexPattern import at.petrak.hexcasting.api.pigment.FrozenPigment +import net.minecraft.network.chat.Component import net.minecraft.world.item.DyeColor -class MishapInvalidPattern : Mishap() { +class MishapInvalidPattern(val pattern: HexPattern? = null) : Mishap() { override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenPigment = dyeColor(DyeColor.YELLOW) @@ -17,6 +20,8 @@ class MishapInvalidPattern : Mishap() { stack.add(GarbageIota()) } - override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) = - error("invalid_pattern") + override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context): Component? { + if (pattern == null) return error("invalid_pattern_generic") + else return error("invalid_pattern", PatternIota.display(pattern)) + } } 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 e6d6b6e21c..b44aae80b3 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 @@ -984,7 +984,8 @@ mishap: { "": "%s: %s", - invalid_pattern: "That pattern isn't associated with any action", + invalid_pattern: "The pattern %s isn't associated with any action", + invalid_pattern_generic: "That pattern isn't associated with any action", unescaped: "Expected to evaluate a pattern, but evaluated %s instead", not_enough_args: "expected %s or more arguments but the stack was only %s tall", From 3f61f24e51ac1a969c0359d62694237a23478a73 Mon Sep 17 00:00:00 2001 From: Robotgiggle Date: Tue, 18 Nov 2025 15:52:56 -0500 Subject: [PATCH 2/6] Make MishapInvalidIota display the type of the offending iota --- .../api/casting/mishaps/MishapInvalidIota.kt | 13 ++++-- .../hexcasting/lang/en_us.flatten.json5 | 46 +++++++++++++++---- 2 files changed, 47 insertions(+), 12 deletions(-) diff --git a/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapInvalidIota.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapInvalidIota.kt index 17e71d6044..2741b1df4d 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapInvalidIota.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapInvalidIota.kt @@ -5,6 +5,7 @@ import at.petrak.hexcasting.api.casting.iota.GarbageIota import at.petrak.hexcasting.api.casting.iota.Iota import at.petrak.hexcasting.api.pigment.FrozenPigment import at.petrak.hexcasting.api.utils.asTranslatedComponent +import at.petrak.hexcasting.common.lib.hex.HexIotaTypes import net.minecraft.network.chat.Component import net.minecraft.world.item.DyeColor @@ -23,11 +24,17 @@ class MishapInvalidIota( stack[stack.size - 1 - reverseIdx] = GarbageIota(); } - override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) = - error( + override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context): Component? { + val perpKey = HexIotaTypes.REGISTRY.getKey(perpetrator.getType()) + val perpDesc = Component.translatableWithFallback( + "hexcasting.iota.${perpKey}.desc", + "hexcasting.mishap.invalid_value.class.${perpKey?.getPath()}" + ) + return error( "invalid_value", expected, reverseIdx, - perpetrator.display() + perpDesc, perpetrator.display() ) + } companion object { @JvmStatic 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 b44aae80b3..dc4870b56a 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 @@ -971,14 +971,42 @@ }, "iota.hexcasting:": { - "null": "Null", - double: "Number", - boolean: "Boolean", - entity: "Entity", - list: "List", - pattern: "Pattern", - garbage: "Garbage", - vec3: "Vector", + null: { + "": "Null", + desc: "a null value", + }, + double: { + "": "Number", + desc: "a number", + }, + boolean: { + "": "Boolean", + desc: "a boolean", + }, + entity: { + "": "Entity", + desc: "an entity", + }, + list: { + "": "List", + desc: "a list", + }, + pattern: { + "": "Pattern", + desc: "a pattern", + }, + garbage: { + "": "Garbage", + desc: "garbage", + }, + vec3: { + "": "Vector", + desc: "a vector", + }, + continution: { + "": "Continuation", + desc: "a jump iota", + }, }, mishap: { @@ -1035,7 +1063,7 @@ bad_caster: "Tried to execute a pattern that requires a greater mind", invalid_value: { - "": "expected %s at index %s of the stack, but got %s", + "": "expected %s at index %s of the stack, but got %s: %s", class: { double: "a number", From c332450ced2f5b237fc70374b0b054cfe706aeab Mon Sep 17 00:00:00 2001 From: Robotgiggle Date: Tue, 18 Nov 2025 15:53:20 -0500 Subject: [PATCH 3/6] Allow MishapInvalidIota to refer to null, garbage, and jump iotas --- .../resources/assets/hexcasting/lang/en_us.flatten.json5 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 dc4870b56a..97c25c27c1 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 @@ -969,7 +969,7 @@ escape: "Consideration", undo: "Evanition", }, - + "iota.hexcasting:": { null: { "": "Null", @@ -1070,8 +1070,10 @@ boolean: "a boolean", vector: "a vector", list: "a list", - widget: "an influence", pattern: "a pattern", + continuation: "a jump iota", + garbage: "garbage", + null: "null", entity: { "": "an entity", From f22cffed82d807105c23fd42e541efa6b810d553 Mon Sep 17 00:00:00 2001 From: Robotgiggle Date: Tue, 18 Nov 2025 16:58:34 -0500 Subject: [PATCH 4/6] Add mishap verbosity changes to changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 42e07d067d..b253c2976a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). - Re-added the slate limit for spell circles, by Stickia in [#909](https://github.com/FallingColors/HexMod/pull/909). - Renamed Inverse Tangent Purification II to Inverse Tangent Distillation, by Robotgiggle in [#921](https://github.com/FallingColors/HexMod/pull/921). - Massively improved ru_ru translations, by JustS-js and LedinecMing in [#832](https://github.com/FallingColors/HexMod/pull/832). +- Changed the invalid-pattern mishap to display the offending pattern, by Robotgiggle in [#951](https://github.com/FallingColors/HexMod/pull/951) +- Changed the invalid-iota mishap to display the type of the offending iota along with the iota itself, by Robotgiggle in [#951](https://github.com/FallingColors/HexMod/pull/951) ### Fixed From 936b42e4142907c65b0dfeae2646e487a75333a2 Mon Sep 17 00:00:00 2001 From: "[object Object]" Date: Tue, 18 Nov 2025 21:47:34 -0500 Subject: [PATCH 5/6] Update CHANGELOG.md --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b253c2976a..c9a858745b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,8 +37,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). - Re-added the slate limit for spell circles, by Stickia in [#909](https://github.com/FallingColors/HexMod/pull/909). - Renamed Inverse Tangent Purification II to Inverse Tangent Distillation, by Robotgiggle in [#921](https://github.com/FallingColors/HexMod/pull/921). - Massively improved ru_ru translations, by JustS-js and LedinecMing in [#832](https://github.com/FallingColors/HexMod/pull/832). -- Changed the invalid-pattern mishap to display the offending pattern, by Robotgiggle in [#951](https://github.com/FallingColors/HexMod/pull/951) -- Changed the invalid-iota mishap to display the type of the offending iota along with the iota itself, by Robotgiggle in [#951](https://github.com/FallingColors/HexMod/pull/951) +- Changed the invalid-pattern mishap to display the offending pattern, by Robotgiggle in [#951](https://github.com/FallingColors/HexMod/pull/951). +- Changed the invalid-iota mishap to display the type of the offending iota along with the iota itself, by Robotgiggle in [#951](https://github.com/FallingColors/HexMod/pull/951). ### Fixed From e25f5004af22b5b46f4f0297af6257bbe8d239a5 Mon Sep 17 00:00:00 2001 From: Robotgiggle Date: Tue, 18 Nov 2025 22:28:45 -0500 Subject: [PATCH 6/6] Code cleanup --- .../hexcasting/api/casting/mishaps/MishapInvalidPattern.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapInvalidPattern.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapInvalidPattern.kt index 129ef4a513..4e9f9a18df 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapInvalidPattern.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapInvalidPattern.kt @@ -10,7 +10,10 @@ import at.petrak.hexcasting.api.pigment.FrozenPigment import net.minecraft.network.chat.Component import net.minecraft.world.item.DyeColor -class MishapInvalidPattern(val pattern: HexPattern? = null) : Mishap() { +class MishapInvalidPattern(val pattern: HexPattern?) : Mishap() { + @Deprecated("Provide the pattern that caused the mishap as an argument") + constructor() : this(null) {} + override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenPigment = dyeColor(DyeColor.YELLOW) @@ -22,6 +25,6 @@ class MishapInvalidPattern(val pattern: HexPattern? = null) : Mishap() { override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context): Component? { if (pattern == null) return error("invalid_pattern_generic") - else return error("invalid_pattern", PatternIota.display(pattern)) + return error("invalid_pattern", PatternIota.display(pattern)) } }