Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
- SpellList has been removed ([#1032](https://github.com/FallingColors/HexMod/pull/1032)) @s5bug
- Casting Image and Casting Frames now store iotas in a TreeList ([#1033](https://github.com/FallingColors/HexMod/pull/1033)) @s5bug
- Changed resource registration to use the IXplatRegister system ([#1212](https://github.com/FallingColors/HexMod/pull/1212)) @Olfi01
- Operations and actions now accept the old stack and produce the new stack through a TreeList ([#1038](https://github.com/FallingColors/HexMod/pull/1038)) @s5bug

## `0.11.3` - 2025-11-22

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ object OpSplat : ConstMediaAction {
get() = 1

override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> =
args.getList(0, argc).toList()
args.getList(0, argc)
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class OpMakePackagedSpell(val isValid: Predicate<ItemStack>, val expectedTypeDes
env: CastingEnvironment
): SpellAction.Result {
val entity = args.getItemEntity(env.world, 0, argc)
val patterns = args.getList(1, argc).toList()
val patterns = args.getList(1, argc)

val (handStack) = env.getHeldItemToOperateOn {
val hexHolder = IXplatAbstractions.INSTANCE.findHexHolder(it)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ object ListArithmetic : Arithmetic {
UNAPPEND -> OperatorUnappend
ADD -> make2 { list0, list1 -> list0 + list1 }
ABS -> OperatorUnary(all(IotaPredicate.ofType(LIST.get()))) { iota: Iota -> DoubleIota(downcast(iota, LIST.get()).list.size.toDouble()) }
REV -> OperatorUnary(all(IotaPredicate.ofType(LIST.get()))) { iota: Iota -> ListIota(downcast(iota, LIST.get()).list.toList().asReversed()) }
REV -> OperatorUnary(all(IotaPredicate.ofType(LIST.get()))) { iota: Iota -> ListIota(downcast(iota, LIST.get()).list.reversed()) }
INDEX_OF -> OperatorIndexOf
REMOVE -> OperatorRemove
REPLACE -> OperatorReplace
Expand All @@ -58,6 +58,6 @@ object ListArithmetic : Arithmetic {

private fun make2(op: BinaryOperator<List<Iota>>): OperatorBinary = OperatorBinary(all(IotaPredicate.ofType(LIST.get())))
{ i: Iota, j: Iota -> ListIota(
op.apply(downcast(i, LIST.get()).list.toList(), downcast(j, LIST.get()).list.toList())
op.apply(downcast(i, LIST.get()).list, downcast(j, LIST.get()).list)
) }
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ object ListSetArithmetic : Arithmetic {

private fun make2(op: BinaryOperator<List<Iota>>): OperatorBinary = OperatorBinary(all(IotaPredicate.ofType(LIST.get())))
{ i: Iota, j: Iota -> ListIota(
op.apply(downcast(i, LIST.get()).list.toList(), downcast(j, LIST.get()).list.toList())
op.apply(downcast(i, LIST.get()).list, downcast(j, LIST.get()).list)
) }
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import at.petrak.hexcasting.common.lib.hex.HexIotaTypes.LIST
object OperatorAppend : OperatorBasic(2, IotaMultiPredicate.pair(IotaPredicate.ofType(LIST.get()), IotaPredicate.TRUE)) {
override fun apply(iotas: Iterable<Iota>, env: CastingEnvironment): Iterable<Iota> {
val it = iotas.iterator().withIndex()
val list = it.nextList(arity).toMutableList()
list.add(it.next().value)
return list.asActionResult
val list = it.nextList(arity)
return list.appended(it.next().value).asActionResult
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import kotlin.math.roundToInt
object OperatorIndex : OperatorBasic(2, IotaMultiPredicate.pair(IotaPredicate.ofType(LIST.get()), IotaPredicate.ofType(DOUBLE.get()))) {
override fun apply(iotas: Iterable<Iota>, env: CastingEnvironment): Iterable<Iota> {
val it = iotas.iterator()
val list = downcast(it.next(), LIST.get()).list.toMutableList()
val list = downcast(it.next(), LIST.get()).list
val index = downcast(it.next(), DOUBLE.get()).double
val x = list.getOrElse(index.roundToInt()) { NullIota() }
return listOf(x)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import at.petrak.hexcasting.common.lib.hex.HexIotaTypes.LIST
object OperatorIndexOf : OperatorBasic(2, IotaMultiPredicate.pair(IotaPredicate.ofType(LIST.get()), IotaPredicate.TRUE)) {
override fun apply(iotas: Iterable<Iota>, env: CastingEnvironment): Iterable<Iota> {
val it = iotas.iterator().withIndex()
val list = it.nextList(arity).toList()
val list = it.nextList(arity)
val toFind = it.next().value
return list.indexOfFirst { Iota.tolerates(toFind, it) }.asActionResult
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import at.petrak.hexcasting.common.lib.hex.HexIotaTypes.LIST
object OperatorRemove : OperatorBasic(2, IotaMultiPredicate.pair(IotaPredicate.ofType(LIST.get()), IotaPredicate.ofType(DOUBLE.get()))) {
override fun apply(iotas: Iterable<Iota>, env: CastingEnvironment): Iterable<Iota> {
val it = iotas.iterator().withIndex()
val list = it.nextList(arity).toMutableList()
val list = it.nextList(arity)
val index = it.nextInt(arity)
if (index < 0 || index >= list.size)
return list.asActionResult
list.removeAt(index)
return list.asActionResult

return list.take(index).appendedAll(list.drop(index + 1)).asActionResult
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ import kotlin.math.min
object OperatorSlice : OperatorBasic(3, IotaMultiPredicate.triple(IotaPredicate.ofType(LIST.get()), IotaPredicate.ofType(DOUBLE.get()), IotaPredicate.ofType(DOUBLE.get()))) {
override fun apply(iotas: Iterable<Iota>, env: CastingEnvironment): Iterable<Iota> {
val it = iotas.iterator().withIndex()
val list = it.nextList(arity).toList()
val list = it.nextList(arity)
val index0 = it.nextPositiveIntUnderInclusive(list.size, arity)
val index1 = it.nextPositiveIntUnderInclusive(list.size, arity)

if (index0 == index1)
return emptyList<Iota>().asActionResult
return list.subList(min(index0, index1), max(index0, index1)).asActionResult
return list.slice(min(index0, index1), max(index0, index1)).asActionResult
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ import at.petrak.hexcasting.common.lib.hex.HexIotaTypes.LIST
object OperatorUnappend : OperatorBasic(1, IotaMultiPredicate.all(IotaPredicate.ofType(LIST.get()))) {
override fun apply(iotas: Iterable<Iota>, env: CastingEnvironment): Iterable<Iota> {
val it = iotas.iterator().withIndex()
val list = it.nextList(arity).toMutableList()
val last = list.removeLastOrNull() ?: NullIota()
return listOf(ListIota(list), last)
val list = it.nextList(arity)
if (!list.isEmpty())
return listOf(ListIota(list.init()), list.last())
return listOf(ListIota(list), NullIota())
}
}
Loading