diff --git a/Common/src/main/java/at/petrak/hexcasting/api/casting/ActionUtils.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/ActionUtils.kt index c6dda37c9..a6943a4b6 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/casting/ActionUtils.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/ActionUtils.kt @@ -64,7 +64,7 @@ fun List.getVec3(idx: Int, argc: Int = 0): Vec3 { if (x is Vec3Iota) { return x.vec3 } else { - throw MishapInvalidIota.ofType(x, if (argc == 0) idx else argc - (idx + 1), "vector") + throw MishapInvalidIota.ofType(x, if (argc == 0) idx else argc - (idx + 1), "vec3") } } @@ -253,7 +253,7 @@ fun List.getBlockPos(idx: Int, argc: Int = 0): BlockPos { return BlockPos.containing(x.vec3) } - throw MishapInvalidIota.ofType(x, if (argc == 0) idx else argc - (idx + 1), "vector") + throw MishapInvalidIota.ofType(x, if (argc == 0) idx else argc - (idx + 1), "vec3") } fun List.getNumOrVec(idx: Int, argc: Int = 0): Either { 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..49414441c 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,14 @@ 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 typeStr = HexIotaTypes.REGISTRY.getKey(perpetrator.getType())?.getPath(); + val typeComp = Component.translatable("hexcasting.mishap.invalid_value.class.${typeStr}") + return error( "invalid_value", expected, reverseIdx, - perpetrator.display() + typeComp, 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..6bb9955fe 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,12 @@ 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.world.item.DyeColor -class MishapInvalidPattern : Mishap() { +class MishapInvalidPattern(val pattern: HexPattern) : Mishap() { override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenPigment = dyeColor(DyeColor.YELLOW) @@ -18,5 +20,5 @@ class MishapInvalidPattern : Mishap() { } override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) = - error("invalid_pattern") + 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 331a15840..995da7a06 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 @@ -975,7 +975,7 @@ mishap: { "": "%s: %s", - invalid_pattern: "That pattern isn't associated with any action", + invalid_pattern: "The pattern %s 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", @@ -1025,15 +1025,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", + vec3: "a vector", list: "a list", - widget: "an influence", pattern: "a pattern", + continuation: "a jump iota", + garbage: "garbage", + null: "null", entity: { "": "an entity",