diff --git a/CHANGELOG.md b/CHANGELOG.md index ffece28434..524e0c552a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). - 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 disallowed-action mishap to properly display the offending action, by Robotgiggle in [#970](https://github.com/FallingColors/HexMod/pull/970). ### Fixed diff --git a/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/CastingEnvironment.java b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/CastingEnvironment.java index d465c877fa..2345eb4267 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/CastingEnvironment.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/CastingEnvironment.java @@ -189,7 +189,7 @@ public void precheckAction(PatternShapeMatch match) throws Mishap { ResourceLocation key = actionKey(match); if (!HexConfig.server().isActionAllowed(key)) { - throw new MishapDisallowedSpell(); + throw new MishapDisallowedSpell("disallowed", key); } } diff --git a/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/env/CircleCastEnv.java b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/env/CircleCastEnv.java index 1fb6698bf7..333deaa813 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/env/CircleCastEnv.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/env/CircleCastEnv.java @@ -72,7 +72,7 @@ public void precheckAction(PatternShapeMatch match) throws Mishap { ResourceLocation key = actionKey(match); if (!HexConfig.server().isActionAllowedInCircles(key)) { - throw new MishapDisallowedSpell("disallowed_circle"); + throw new MishapDisallowedSpell("disallowed_circle", key); } } diff --git a/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapDisallowedSpell.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapDisallowedSpell.kt index d3118e5590..c55772107e 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapDisallowedSpell.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapDisallowedSpell.kt @@ -4,9 +4,15 @@ import at.petrak.hexcasting.api.casting.eval.CastingEnvironment import at.petrak.hexcasting.api.casting.eval.ResolvedPatternType import at.petrak.hexcasting.api.casting.iota.Iota import at.petrak.hexcasting.api.pigment.FrozenPigment +import at.petrak.hexcasting.api.utils.asTranslatedComponent +import net.minecraft.resources.ResourceLocation; +import net.minecraft.network.chat.Component import net.minecraft.world.item.DyeColor -class MishapDisallowedSpell(val type: String = "disallowed") : Mishap() { +class MishapDisallowedSpell(val type: String, val actionKey: ResourceLocation?) : Mishap() { + @Deprecated("Provide the type (disallowed or disallowed_circle) and the action key that caused the mishap") + constructor(type: String = "disallowed") : this(type, null) {} + override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenPigment = dyeColor(DyeColor.BLACK) @@ -16,6 +22,8 @@ class MishapDisallowedSpell(val type: String = "disallowed") : Mishap() { // NO-OP } - override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) = - error(type) + override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context): Component? { + if (actionKey == null) return error(type + "_generic") + return error(type, "hexcasting.action.$actionKey".asTranslatedComponent) + } } 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 7935f10419..37e8a218fa 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 @@ -1055,8 +1055,10 @@ }, no_akashic_record: "No Akashic Record at %s", - disallowed: "has been disallowed by the server admins", - disallowed_circle: "has been disallowed in spell circles by the server admins", + disallowed: "%s has been disallowed by the server admins", + disallowed_generic: "That pattern has been disallowed by the server admins", + disallowed_circle: "%s has been disallowed in spell circles by the server admins", + disallowed_circle_generic: "That pattern has been disallowed in spell circles by the server admins", invalid_spell_datum_type: "Tried to use a value of invalid type as a SpellDatum: %s (class %s). This is a bug in the mod.", unknown: "threw an exception (%s). This is a bug in the mod.", stack_size: "Exceeded the size limit of the stack",