From 4d0f83a3a2ff0394ddaadd53abb9a3e2730e3279 Mon Sep 17 00:00:00 2001 From: Alwinfy <20421383+Alwinfy@users.noreply.github.com> Date: Sun, 8 May 2022 19:24:36 -0400 Subject: [PATCH] moar bugfix --- src/main/java/at/petrak/hexcasting/api/spell/SpellList.kt | 2 +- .../hexcasting/common/casting/operators/eval/OpEval.kt | 3 ++- .../hexcasting/common/casting/operators/eval/OpForEach.kt | 5 +++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/at/petrak/hexcasting/api/spell/SpellList.kt b/src/main/java/at/petrak/hexcasting/api/spell/SpellList.kt index 5a1d1553..a2bbce33 100644 --- a/src/main/java/at/petrak/hexcasting/api/spell/SpellList.kt +++ b/src/main/java/at/petrak/hexcasting/api/spell/SpellList.kt @@ -48,7 +48,7 @@ sealed class SpellList: Iterable> { return this } while (idx > 0) { - if (ptr.hasNext()) { + if (!ptr.hasNext()) { return this } idx-- diff --git a/src/main/java/at/petrak/hexcasting/common/casting/operators/eval/OpEval.kt b/src/main/java/at/petrak/hexcasting/common/casting/operators/eval/OpEval.kt index f33acc1b..50bc7d3e 100644 --- a/src/main/java/at/petrak/hexcasting/common/casting/operators/eval/OpEval.kt +++ b/src/main/java/at/petrak/hexcasting/common/casting/operators/eval/OpEval.kt @@ -4,13 +4,14 @@ import at.petrak.hexcasting.api.spell.OperationResult import at.petrak.hexcasting.api.spell.Operator import at.petrak.hexcasting.api.spell.Operator.Companion.getChecked import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.SpellList import at.petrak.hexcasting.api.spell.casting.CastingContext import at.petrak.hexcasting.api.spell.casting.CastingHarness import at.petrak.hexcasting.api.spell.casting.OperatorSideEffect object OpEval : Operator { override fun operate(stack: MutableList>, local: SpellDatum<*>, ctx: CastingContext): OperationResult { - val instrs: List> = stack.getChecked(stack.lastIndex) + val instrs: SpellList = stack.getChecked(stack.lastIndex) stack.removeLastOrNull() ctx.incDepth() diff --git a/src/main/java/at/petrak/hexcasting/common/casting/operators/eval/OpForEach.kt b/src/main/java/at/petrak/hexcasting/common/casting/operators/eval/OpForEach.kt index 22504c6d..0470e560 100644 --- a/src/main/java/at/petrak/hexcasting/common/casting/operators/eval/OpForEach.kt +++ b/src/main/java/at/petrak/hexcasting/common/casting/operators/eval/OpForEach.kt @@ -4,6 +4,7 @@ import at.petrak.hexcasting.api.spell.OperationResult import at.petrak.hexcasting.api.spell.Operator import at.petrak.hexcasting.api.spell.Operator.Companion.getChecked import at.petrak.hexcasting.api.spell.SpellDatum +import at.petrak.hexcasting.api.spell.SpellList import at.petrak.hexcasting.api.spell.casting.CastingContext import at.petrak.hexcasting.api.spell.casting.CastingHarness import at.petrak.hexcasting.api.spell.casting.OperatorSideEffect @@ -14,8 +15,8 @@ object OpForEach : Operator { if (stack.size < 2) throw MishapNotEnoughArgs(2, stack.size) - val instrs: List> = stack.getChecked(stack.lastIndex - 1) - val datums: List> = stack.getChecked(stack.lastIndex) + val instrs: SpellList = stack.getChecked(stack.lastIndex - 1) + val datums: SpellList = stack.getChecked(stack.lastIndex) stack.removeLastOrNull() stack.removeLastOrNull()