Skip to content

Commit 3f61f24

Browse files
committed
Make MishapInvalidIota display the type of the offending iota
1 parent 30d40f8 commit 3f61f24

File tree

2 files changed

+47
-12
lines changed

2 files changed

+47
-12
lines changed

Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapInvalidIota.kt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import at.petrak.hexcasting.api.casting.iota.GarbageIota
55
import at.petrak.hexcasting.api.casting.iota.Iota
66
import at.petrak.hexcasting.api.pigment.FrozenPigment
77
import at.petrak.hexcasting.api.utils.asTranslatedComponent
8+
import at.petrak.hexcasting.common.lib.hex.HexIotaTypes
89
import net.minecraft.network.chat.Component
910
import net.minecraft.world.item.DyeColor
1011

@@ -23,11 +24,17 @@ class MishapInvalidIota(
2324
stack[stack.size - 1 - reverseIdx] = GarbageIota();
2425
}
2526

26-
override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) =
27-
error(
27+
override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context): Component? {
28+
val perpKey = HexIotaTypes.REGISTRY.getKey(perpetrator.getType())
29+
val perpDesc = Component.translatableWithFallback(
30+
"hexcasting.iota.${perpKey}.desc",
31+
"hexcasting.mishap.invalid_value.class.${perpKey?.getPath()}"
32+
)
33+
return error(
2834
"invalid_value", expected, reverseIdx,
29-
perpetrator.display()
35+
perpDesc, perpetrator.display()
3036
)
37+
}
3138

3239
companion object {
3340
@JvmStatic

Common/src/main/resources/assets/hexcasting/lang/en_us.flatten.json5

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -971,14 +971,42 @@
971971
},
972972

973973
"iota.hexcasting:": {
974-
"null": "Null",
975-
double: "Number",
976-
boolean: "Boolean",
977-
entity: "Entity",
978-
list: "List",
979-
pattern: "Pattern",
980-
garbage: "Garbage",
981-
vec3: "Vector",
974+
null: {
975+
"": "Null",
976+
desc: "a null value",
977+
},
978+
double: {
979+
"": "Number",
980+
desc: "a number",
981+
},
982+
boolean: {
983+
"": "Boolean",
984+
desc: "a boolean",
985+
},
986+
entity: {
987+
"": "Entity",
988+
desc: "an entity",
989+
},
990+
list: {
991+
"": "List",
992+
desc: "a list",
993+
},
994+
pattern: {
995+
"": "Pattern",
996+
desc: "a pattern",
997+
},
998+
garbage: {
999+
"": "Garbage",
1000+
desc: "garbage",
1001+
},
1002+
vec3: {
1003+
"": "Vector",
1004+
desc: "a vector",
1005+
},
1006+
continution: {
1007+
"": "Continuation",
1008+
desc: "a jump iota",
1009+
},
9821010
},
9831011

9841012
mishap: {
@@ -1035,7 +1063,7 @@
10351063
bad_caster: "Tried to execute a pattern that requires a greater mind",
10361064

10371065
invalid_value: {
1038-
"": "expected %s at index %s of the stack, but got %s",
1066+
"": "expected %s at index %s of the stack, but got %s: %s",
10391067

10401068
class: {
10411069
double: "a number",

0 commit comments

Comments
 (0)