Fix teleporting

This commit is contained in:
Sollace 2024-10-05 00:04:05 +01:00
parent 3b6ad3d094
commit 9d108eb608
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
3 changed files with 15 additions and 16 deletions

View file

@ -179,7 +179,7 @@ public class UnicornTeleportAbility implements Ability<Pos> {
destination.z() + offset.getZ()
);
participant.setPosition(dest);
participant.requestTeleport(dest.x, dest.y, dest.z);
if (participant.getWorld().getBlockCollisions(participant, participant.getBoundingBox()).iterator().hasNext()) {
dest = destination.vec();
participant.requestTeleport(dest.x, participant.getY(), dest.z);

View file

@ -89,13 +89,22 @@ public class DisplacementSpell extends AbstractSpell implements HomingSpell, Pro
Vec3d sourcePos = originator.getOriginVector();
Vec3d sourceVel = originator.asEntity().getVelocity();
teleport(originator, target, sourcePos, sourceVel);
teleport(originator, originator.asEntity(), destinationPos, destinationVel);
Entity targetVehicle = teleport(originator, target, sourcePos, sourceVel);
Entity sourceVehicle = teleport(originator, originator.asEntity(), destinationPos, destinationVel);
if (targetVehicle != null) {
originator.asEntity().startRiding(targetVehicle);
}
if (sourceVehicle != null) {
target.startRiding(sourceVehicle);
}
originator.subtractEnergyCost(destinationPos.distanceTo(sourcePos) / 20F);
}
private void teleport(Caster<?> source, Entity entity, Vec3d pos, Vec3d vel) {
entity.setPosition(pos);
private Entity teleport(Caster<?> source, Entity entity, Vec3d pos, Vec3d vel) {
Entity oldVehicle = entity.getVehicle();
entity.requestTeleportAndDismount(pos.x, pos.y, pos.z);
entity.setVelocity(vel);
entity.setGlowing(false);
entity.playSound(USounds.SPELL_DISPLACEMENT_TELEPORT, 1, 1);
@ -104,6 +113,7 @@ public class DisplacementSpell extends AbstractSpell implements HomingSpell, Pro
if (damage > 0) {
entity.damage(source.damageOf(UDamageTypes.EXHAUSTION, source), damage);
}
return oldVehicle;
}
@Override

View file

@ -277,14 +277,3 @@ public class MindSwapSpell extends MimicSpell implements ProjectileDelegate.Enti
return clone;
}
}