alwinfyyyyyyyy
This commit is contained in:
parent
cb8b4be953
commit
a3d915f90f
3 changed files with 13 additions and 8 deletions
|
@ -2,6 +2,7 @@ package at.petrak.hexcasting.api.spell.mishaps
|
|||
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.spell.SpellDatum
|
||||
import at.petrak.hexcasting.api.spell.SpellList
|
||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.world.effect.MobEffectInstance
|
||||
|
@ -26,7 +27,7 @@ class MishapOthersName(val other: Player) : Mishap() {
|
|||
fun getTrueNameFromDatum(datum: SpellDatum<*>, caster: Player): Player? {
|
||||
if (datum.payload is Player && datum.payload != caster)
|
||||
return datum.payload
|
||||
else if (datum.payload !is List<*>)
|
||||
else if (datum.payload !is SpellList)
|
||||
return null
|
||||
|
||||
val poolToSearch: MutableList<SpellDatum<*>> =
|
||||
|
@ -38,7 +39,7 @@ class MishapOthersName(val other: Player) : Mishap() {
|
|||
|
||||
if (datumToCheck.payload is Player && datumToCheck.payload != caster)
|
||||
return datumToCheck.payload
|
||||
else if (datumToCheck.payload is List<*>)
|
||||
else if (datumToCheck.payload is SpellList)
|
||||
poolToSearch.addAll(datumToCheck.payload.filterIsInstance<SpellDatum<*>>())
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package at.petrak.hexcasting.common.casting.operators.math
|
||||
|
||||
import at.petrak.hexcasting.api.spell.SpellDatum
|
||||
import at.petrak.hexcasting.api.spell.SpellList
|
||||
import at.petrak.hexcasting.api.spell.mishaps.MishapInvalidIota
|
||||
import com.mojang.datafixers.util.Either
|
||||
import net.minecraft.network.chat.TranslatableComponent
|
||||
|
@ -18,10 +19,10 @@ object MathOpUtils {
|
|||
)
|
||||
}
|
||||
|
||||
fun GetNumOrList(datum: SpellDatum<*>, reverseIdx: Int): Either<Double, List<SpellDatum<*>>> =
|
||||
fun GetNumOrList(datum: SpellDatum<*>, reverseIdx: Int): Either<Double, SpellList> =
|
||||
when (datum.payload) {
|
||||
is Double -> Either.left(datum.payload)
|
||||
is List<*> -> Either.right(datum.payload.filterIsInstance<SpellDatum<*>>())
|
||||
is SpellList -> Either.right(datum.payload)
|
||||
else -> throw MishapInvalidIota(
|
||||
datum,
|
||||
reverseIdx,
|
||||
|
|
|
@ -3,6 +3,7 @@ package at.petrak.hexcasting.common.casting.operators.math.logic
|
|||
import at.petrak.hexcasting.api.spell.ConstManaOperator
|
||||
import at.petrak.hexcasting.api.spell.Operator.Companion.spellListOf
|
||||
import at.petrak.hexcasting.api.spell.SpellDatum
|
||||
import at.petrak.hexcasting.api.spell.SpellList
|
||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||
import net.minecraft.world.phys.Vec3
|
||||
import kotlin.math.abs
|
||||
|
@ -21,11 +22,13 @@ class OpEquality(val invert: Boolean) : ConstManaOperator {
|
|||
return when {
|
||||
a is Double && b is Double -> abs(a - b) < 0.0001
|
||||
a is Vec3 && b is Vec3 -> a.subtract(b).lengthSqr() < 0.0000001
|
||||
a is List<*> && b is List<*> -> {
|
||||
if (a.size != b.size || recursionsLeft == 0)
|
||||
a is SpellList && b is SpellList -> {
|
||||
val castA = a.toList()
|
||||
val castB = b.toList()
|
||||
if (castA.size != castB.size || recursionsLeft == 0)
|
||||
return false
|
||||
for (i in a.indices)
|
||||
if (!checkEquals((a[i] as SpellDatum<*>).payload, (b[i] as SpellDatum<*>).payload, recursionsLeft - 1))
|
||||
for (i in castA.indices)
|
||||
if (!checkEquals(castA[i].payload, castB[i].payload, recursionsLeft - 1))
|
||||
return false
|
||||
true
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue