This commit is contained in:
gamma-delta 2022-07-27 11:55:59 -05:00
parent 4d95a57a17
commit e6767ae224
6 changed files with 76 additions and 16 deletions

View file

@ -225,7 +225,7 @@ class SpellDatum<T : Any> private constructor(val payload: T) {
TAG_PATTERN -> {
val pat = HexPattern.fromNBT(nbt.getCompound(TAG_PATTERN))
var angleDesc = pat.anglesSignature()
if (angleDesc.isNotBlank()) angleDesc = " $angleDesc";
if (angleDesc.isNotBlank()) angleDesc = " $angleDesc"
out += "HexPattern(".gold
out += "${pat.startDir}$angleDesc".white
out += ")".gold

View file

@ -5,9 +5,7 @@ import at.petrak.hexcasting.api.spell.*
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.mishaps.MishapImmuneEntity
import at.petrak.hexcasting.api.spell.mishaps.MishapLocationTooFarAway
import at.petrak.hexcasting.common.network.MsgBlinkAck
import at.petrak.hexcasting.xplat.IXplatAbstractions
import net.minecraft.server.level.ServerPlayer
import at.petrak.hexcasting.common.casting.operators.spells.great.OpTeleport
import net.minecraft.world.entity.Entity
import kotlin.math.max
import kotlin.math.roundToInt
@ -47,12 +45,8 @@ object OpBlink : SpellOperator {
private data class Spell(val target: Entity, val delta: Double) : RenderedSpell {
override fun cast(ctx: CastingContext) {
val dvec = target.lookAngle.scale(delta)
target.setPos(target.position().add(dvec))
if (target is ServerPlayer) {
target.connection.resetPosition()
IXplatAbstractions.INSTANCE.sendPacketToPlayer(target, MsgBlinkAck(dvec))
}
val delta = target.lookAngle.scale(delta)
OpTeleport.teleportRespectSticky(target, delta)
}
}
}

View file

@ -5,6 +5,7 @@ import at.petrak.hexcasting.api.spell.*
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.mishaps.MishapImmuneEntity
import at.petrak.hexcasting.api.spell.mishaps.MishapLocationTooFarAway
import at.petrak.hexcasting.common.lib.HexEntityTags
import at.petrak.hexcasting.common.network.MsgBlinkAck
import at.petrak.hexcasting.xplat.IXplatAbstractions
import net.minecraft.server.level.ServerPlayer
@ -43,12 +44,8 @@ object OpTeleport : SpellOperator {
private data class Spell(val teleportee: Entity, val delta: Vec3) : RenderedSpell {
override fun cast(ctx: CastingContext) {
val distance = delta.length()
if (distance < 32768.0) {
teleportee.setPos(teleportee.position().add(delta))
if (teleportee is ServerPlayer) {
IXplatAbstractions.INSTANCE.sendPacketToPlayer(teleportee, MsgBlinkAck(delta))
}
OpTeleport.teleportRespectSticky(teleportee, delta)
}
if (teleportee is ServerPlayer && teleportee == ctx.caster) {
@ -79,6 +76,36 @@ object OpTeleport : SpellOperator {
// we also don't drop the offhand just to be nice
}
}
}
fun teleportRespectSticky(teleportee: Entity, delta: Vec3) {
var stickyTeleport = false
// roll our own for loop
// this really would be more readable as a c-style for loop, waugh
var cursor = teleportee.vehicle
var base: Entity? = null
while (cursor != null) {
if (cursor.type.`is`(HexEntityTags.STICKY_TELEPORTERS))
stickyTeleport = true
base = cursor
cursor = cursor.vehicle
}
if (stickyTeleport) {
// this handles teleporting the passengers
val target = base!!.position().add(delta)
base.teleportTo(target.x, target.y, target.z)
} else {
// Break it into two stacks
teleportee.stopRiding()
teleportee.firstPassenger?.stopRiding()
teleportee.setPos(teleportee.position().add(delta))
}
teleportee.setPos(teleportee.position().add(delta))
if (teleportee is ServerPlayer) {
teleportee.connection.resetPosition()
IXplatAbstractions.INSTANCE.sendPacketToPlayer(teleportee, MsgBlinkAck(delta))
}
}
}

View file

@ -0,0 +1,15 @@
package at.petrak.hexcasting.common.lib;
import net.minecraft.core.Registry;
import net.minecraft.tags.TagKey;
import net.minecraft.world.entity.EntityType;
import static at.petrak.hexcasting.api.HexAPI.modLoc;
public class HexEntityTags {
public static final TagKey<EntityType<?>> STICKY_TELEPORTERS = create("sticky_teleporters");
public static TagKey<EntityType<?>> create(String name) {
return TagKey.create(Registry.ENTITY_TYPE_REGISTRY, modLoc(name));
}
}

View file

@ -964,7 +964,7 @@
"hexcasting.page.flight.2": "The entity (which must be a player) will be endowed with flight. The first number is the number of seconds they may fly for, and the second number is the radius of the zone they may fly in. If the recipient exits that zone, or their timer runs out while midair, the gravity that they spurned will get its revenge. Painfully.$(br2)It costs one quarter of an $(l:items/amethyst)$(item)Amethyst Dust/$, per meter of radius, per second in flight.",
"hexcasting.page.teleport.1": "Far more powerful than $(l:patterns/spells/basic#hexcasting:blink)$(action)Blink/$, this spell lets me teleport nearly anywhere in the entire world! There does seem to be a limit, but it is $(italic)much/$ greater than the normal radius of influence I am used to.",
"hexcasting.page.teleport.2": "The entity will be teleported by the given vector, which is an offset from its given position. No matter the distance, it always seems to cost about ten $(l:items/amethyst)$(item)Charged Amethyst/$.$(br2)The transference is not perfect, and it seems when teleporting something as complex as a player, their inventory doesn't $(italic)quite/$ stay attached, and tends to splatter everywhere at the destination.",
"hexcasting.page.teleport.2": "The entity will be teleported by the given vector, which is an offset from its given position. No matter the distance, it always seems to cost about ten $(l:items/amethyst)$(item)Charged Amethyst/$.$(br2)The transference is not perfect, and it seems when teleporting something as complex as a player, their inventory doesn't $(italic)quite/$ stay attached, and tends to splatter everywhere at the destination. In addition, the target will be forcibly removed from anything inanimate they are riding or sitting on ... but I've read scraps that suggest animals can come along for the ride, so to speak.",
"hexcasting.entry.zeniths": "Zeniths",
"hexcasting.page.zeniths.1": "This family of spells all impart a positive potion effect upon an entity, similar to the $(l:patterns/spells/nadirs)$(action)Nadirs/$. However, these have their _media costs increase with the $(italic)cube/$ of the potency.",

View file

@ -0,0 +1,24 @@
{
"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"
]
}