Skip to content

Commit d95f2e8

Browse files
committed
Cleaned up and generalized existing Spell Circle error messages
1 parent 837ab9e commit d95f2e8

File tree

5 files changed

+16
-14
lines changed

5 files changed

+16
-14
lines changed

Common/src/main/java/at/petrak/hexcasting/api/casting/circles/CircleExecutionState.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public class CircleExecutionState {
5656
public @Nullable UUID caster;
5757
public @Nullable FrozenPigment casterPigment;
5858
// This controls the speed of the current slate
59-
public Long reachedSlate;
59+
public long reachedSlate;
6060

6161
// Tracks the highest pos, and lowest pos of the AABB
6262
public BlockPos positivePos;
@@ -116,7 +116,6 @@ protected CircleExecutionState(BlockPos impetusPos, Direction impetusDir,
116116
BlockPos firstBlock = null;
117117
HashMap<ChunkPos, ChunkAccess> chunkMap = new HashMap<>();
118118
while (!todo.isEmpty()) {
119-
120119
var pair = todo.pop();
121120
var enterDir = pair.getFirst();
122121
var herePos = pair.getSecond();
@@ -294,7 +293,7 @@ public boolean tick(BlockEntityAbstractImpetus impetus) {
294293

295294
executorBlockState = executor.startEnergized(this.currentPos, executorBlockState, world);
296295
this.reachedPositions.add(this.currentPos);
297-
this.reachedSlate = this.reachedSlate +1;
296+
this.reachedSlate +=1;
298297

299298
// Do the execution!
300299
boolean halt = false;
@@ -321,7 +320,7 @@ public boolean tick(BlockEntityAbstractImpetus impetus) {
321320
Component.literal(this.currentPos.toShortString()).withStyle(ChatFormatting.RED)),
322321
new ItemStack(Items.COMPASS));
323322
ICircleComponent.sfx(this.currentPos, executorBlockState, world,
324-
Objects.requireNonNull(env.getImpetus()), false);
323+
Objects.requireNonNull(env.getImpetus()), false);
325324
halt = true;
326325
break;
327326
} else {
@@ -353,7 +352,7 @@ public boolean tick(BlockEntityAbstractImpetus impetus) {
353352
* How many ticks should pass between activations, given the number of blocks encountered so far.
354353
*/
355354
protected int getTickSpeed() {
356-
return Math.toIntExact(Math.max(2, 10 - (this.reachedSlate - 1) / 3));
355+
return (int) Math.max(2, 10 - (this.reachedSlate - 1) / 3);
357356
}
358357

359358
public void endExecution(BlockEntityAbstractImpetus impetus) {

Common/src/main/java/at/petrak/hexcasting/api/casting/circles/ICircleComponent.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
import at.petrak.hexcasting.common.lib.HexItems;
1212
import at.petrak.hexcasting.common.lib.HexSounds;
1313
import com.mojang.datafixers.util.Pair;
14+
import net.minecraft.ChatFormatting;
1415
import net.minecraft.Util;
1516
import net.minecraft.core.BlockPos;
1617
import net.minecraft.core.Direction;
17-
import net.minecraft.network.chat.Component;
1818
import net.minecraft.server.level.ServerLevel;
1919
import net.minecraft.sounds.SoundSource;
2020
import net.minecraft.util.Mth;
@@ -147,7 +147,7 @@ static void sfx(BlockPos pos, BlockState bs, Level world, BlockEntityAbstractImp
147147
*/
148148
default void fakeThrowMishap(BlockPos pos, BlockState bs, CastingImage image, CircleCastEnv env, Mishap mishap) {
149149
Mishap.Context errorCtx = new Mishap.Context(null,
150-
bs.getBlock().getName().append(" (").append(Component.literal(pos.toShortString())).append(")"));
150+
bs.getBlock().getName().withStyle(ChatFormatting.LIGHT_PURPLE));
151151
var sideEffect = new OperatorSideEffect.DoMishap(mishap, errorCtx);
152152
var vm = new CastingVM(image, env);
153153
sideEffect.performEffect(vm);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
44
import at.petrak.hexcasting.api.casting.iota.Iota
55
import at.petrak.hexcasting.api.casting.mishaps.Mishap
66
import at.petrak.hexcasting.api.pigment.FrozenPigment
7-
import at.petrak.hexcasting.api.utils.withStyle
87
import net.minecraft.ChatFormatting
98
import net.minecraft.core.BlockPos
109
import net.minecraft.network.chat.Component
@@ -22,5 +21,6 @@ class MishapBoolDirectrixEmptyStack(
2221
}
2322

2423
override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context): Component =
25-
error("circle.bool_directrix.empty_stack", pos.toShortString().withStyle(ChatFormatting.RED))
24+
error("circle.empty_stack", 1,
25+
Component.literal("(").append(pos.toShortString()).append(")").withStyle(ChatFormatting.RED))
2626
}

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
44
import at.petrak.hexcasting.api.casting.iota.Iota
55
import at.petrak.hexcasting.api.casting.mishaps.Mishap
66
import at.petrak.hexcasting.api.pigment.FrozenPigment
7+
import net.minecraft.ChatFormatting
78
import net.minecraft.core.BlockPos
89
import net.minecraft.network.chat.Component
910
import net.minecraft.world.item.DyeColor
@@ -21,5 +22,7 @@ class MishapBoolDirectrixNotBool(
2122
}
2223

2324
override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context): Component =
24-
error("circle.bool_directrix_no_bool", pos.toShortString(), perpetrator.display())
25+
error("circle.invalid_value", "boolean", 0,
26+
Component.literal("(").append(pos.toShortString()).append(")").withStyle(ChatFormatting.RED),
27+
perpetrator.display())
2528
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,10 +1105,10 @@
11051105
sapling: "a sapling",
11061106
replaceable: "somewhere to place a block",
11071107
},
1108-
1109-
"circle.bool_directrix": {
1110-
no_bool: "the iota encountered at %s was %s, not a bool",
1111-
empty_stack: "the stack was empty at %s",
1108+
1109+
circle: {
1110+
empty_stack: "expected %s or more arguments but the stack was empty at %s",
1111+
invalid_value: "expected %s at index %s of the stack at %s, but got %s"
11121112
},
11131113
},
11141114
// ^ mishap

0 commit comments

Comments
 (0)