Skip to content

Commit 720c027

Browse files
committed
Make MishapInvalidPattern display the offending pattern
1 parent f6c3b9f commit 720c027

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

Common/src/main/java/at/petrak/hexcasting/api/casting/iota/PatternIota.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public boolean toleratesOther(Iota that) {
9898
castedName = special.handler::getName;
9999
action = special.handler.act();
100100
} else if (lookup instanceof PatternShapeMatch.Nothing) {
101-
throw new MishapInvalidPattern();
101+
throw new MishapInvalidPattern(this.getPattern());
102102
} else throw new IllegalStateException();
103103

104104
// do the actual calculation!!

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
44
import at.petrak.hexcasting.api.casting.eval.ResolvedPatternType
55
import at.petrak.hexcasting.api.casting.iota.GarbageIota
66
import at.petrak.hexcasting.api.casting.iota.Iota
7+
import at.petrak.hexcasting.api.casting.iota.PatternIota
8+
import at.petrak.hexcasting.api.casting.math.HexPattern
79
import at.petrak.hexcasting.api.pigment.FrozenPigment
810
import net.minecraft.world.item.DyeColor
911

10-
class MishapInvalidPattern : Mishap() {
12+
class MishapInvalidPattern(val pattern: HexPattern) : Mishap() {
1113
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenPigment =
1214
dyeColor(DyeColor.YELLOW)
1315

@@ -18,5 +20,5 @@ class MishapInvalidPattern : Mishap() {
1820
}
1921

2022
override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) =
21-
error("invalid_pattern")
23+
error("invalid_pattern", PatternIota.display(pattern))
2224
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -975,7 +975,7 @@
975975
mishap: {
976976
"": "%s: %s",
977977

978-
invalid_pattern: "That pattern isn't associated with any action",
978+
invalid_pattern: "The pattern %s isn't associated with any action",
979979
unescaped: "Expected to evaluate a pattern, but evaluated %s instead",
980980

981981
not_enough_args: "expected %s or more arguments but the stack was only %s tall",

0 commit comments

Comments
 (0)