diff --git a/CHANGELOG.md b/CHANGELOG.md index 42e07d067..c9a858745 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 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 b86e8541c..74db0a95f 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/MishapInvalidIota.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapInvalidIota.kt index 17e71d604..2741b1df4 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/java/at/petrak/hexcasting/api/casting/mishaps/MishapInvalidPattern.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapInvalidPattern.kt index 20fbd31fb..4e9f9a18d 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,16 @@ 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?) : 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) @@ -17,6 +23,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") + 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 e6d6b6e21..97c25c27c 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,22 +969,51 @@ escape: "Consideration", undo: "Evanition", }, - + "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: { "": "%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", @@ -1034,15 +1063,17 @@ 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", 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",