Remove dead var, add executeIota helper

This commit is contained in:
Alwinfy 2022-05-23 15:59:28 -04:00
parent fec005cb65
commit 9ad0a5cbe1
No known key found for this signature in database
GPG key ID: 2CCB99445F0C949E
3 changed files with 7 additions and 3 deletions

View file

@ -278,7 +278,6 @@ public abstract class BlockEntityAbstractImpetus extends HexBlockEntity implemen
new SpellCircleContext(this.getBlockPos(), bounds, this.activatorAlwaysInRange()));
var harness = new CastingHarness(ctx);
var castSpell = false;
var makeSound = false;
BlockPos erroredPos = null;
for (var tracked : this.trackedBlocks) {
@ -286,7 +285,7 @@ public abstract class BlockEntityAbstractImpetus extends HexBlockEntity implemen
if (bs.getBlock() instanceof BlockCircleComponent cc) {
var newPattern = cc.getPattern(tracked, bs, this.level);
if (newPattern != null) {
var info = harness.executeIotas(List.of(SpellDatum.make(newPattern)), splayer.getLevel());
var info = harness.executeIota(SpellDatum.make(newPattern), splayer.getLevel());
if (info.getMakesCastSound()) {
makeSound = true;
}

View file

@ -53,6 +53,11 @@ class CastingHarness private constructor(
prepackagedColorizer: FrozenColorizer? = null
) : this(mutableListOf(), SpellDatum.make(Widget.NULL), 0, mutableListOf(), false, ctx, prepackagedColorizer)
/**
* Execute a single iota.
*/
fun executeIota(iota: SpellDatum<*>, world: ServerLevel): ControllerInfo = executeIotas(listOf(iota), world)
/**
* Given a list of iotas, execute them in sequence.
*/

View file

@ -85,7 +85,7 @@ public record MsgNewSpellPatternSyn(InteractionHand handUsed, HexPattern pattern
clientInfo = new ControllerInfo(false, harness.getStack().isEmpty(), ResolvedPatternType.INVALID,
harness.generateDescs());
} else {
clientInfo = harness.executeIotas(List.of(SpellDatum.make(this.pattern)), sender.getLevel());
clientInfo = harness.executeIota(SpellDatum.make(this.pattern), sender.getLevel());
if (clientInfo.getMakesCastSound()) {
sender.level.playSound(null, sender.getX(), sender.getY(), sender.getZ(),