telepig works now, close #402

This commit is contained in:
petrak@ 2023-01-31 18:51:05 -06:00
parent ca36dfa484
commit f6cf4af59b
2 changed files with 16 additions and 29 deletions

View file

@ -1,8 +1,11 @@
package at.petrak.hexcasting.common.casting.operators.spells.great
import at.petrak.hexcasting.api.casting.*
import at.petrak.hexcasting.api.casting.ParticleSpray
import at.petrak.hexcasting.api.casting.RenderedSpell
import at.petrak.hexcasting.api.casting.castables.SpellAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getEntity
import at.petrak.hexcasting.api.casting.getVec3
import at.petrak.hexcasting.api.casting.iota.Iota
import at.petrak.hexcasting.api.casting.mishaps.MishapImmuneEntity
import at.petrak.hexcasting.api.casting.mishaps.MishapLocationTooFarAway
@ -102,25 +105,25 @@ object OpTeleport : SpellAction {
return
}
val base = teleportee.rootVehicle
val target = base.position().add(delta)
val playersToUpdate = mutableListOf<ServerPlayer>()
val indirect = base.indirectPassengers
val target = teleportee.position().add(delta)
val sticky = indirect.any { it.type.`is`(HexTags.Entities.STICKY_TELEPORTERS) }
val cannotSticky = indirect.none { it.type.`is`(HexTags.Entities.CANNOT_TELEPORT) }
if (sticky && cannotSticky)
val cannotTeleport = teleportee.passengers.any { it.type.`is`(HexTags.Entities.CANNOT_TELEPORT) }
if (cannotTeleport)
return
// A "sticky" entity teleports itself and its riders
val sticky = teleportee.type.`is`(HexTags.Entities.STICKY_TELEPORTERS)
// TODO: this probably does funky things with stacks of passengers. I doubt this will come up in practice
// though
if (sticky) {
teleportee.stopRiding()
teleportee.indirectPassengers.filterIsInstance<ServerPlayer>().forEach(playersToUpdate::add)
// this handles teleporting the passengers
base.teleportTo(target.x, target.y, target.z)
indirect
.filterIsInstance<ServerPlayer>()
.forEach(playersToUpdate::add)
teleportee.teleportTo(target.x, target.y, target.z)
} else {
// Break it into two stacks
// Snap everyone off the stacks
teleportee.stopRiding()
teleportee.passengers.forEach(Entity::stopRiding)
if (teleportee is ServerPlayer) {

View file

@ -1,22 +1,6 @@
{
"replace": false,
"values": [
{
"id": "create:contraption",
"required": false
},
{
"id": "create:stationary_contraption",
"required": false
},
{
"id": "create:gantry_contraption",
"required": false
},
{
"id": "create:carriage_contraption",
"required": false
},
"minecraft:pig",
"minecraft:strider",
"minecraft:horse",