mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-01 20:50:41 +01:00
Allow teleportation of entities on vehicles. Fixes BUKKIT-4210
Up until Minecraft version 1.5 it was not possible to teleport entities within vehicles. With the 1.5 update came the change in the Minecraft teleportation logic to dismount before teleporting the entity, if applicable. This commit ammends the existing CraftBukkit logic for rejecting teleportation for entities in vehicles to permit the action. Due to this change, CraftBukkit is now in-line with Minecraft 1.5 teleportation logic.
This commit is contained in:
parent
80e8f2ab87
commit
a4805dbd77
2 changed files with 8 additions and 2 deletions
|
@ -201,10 +201,13 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
|||
}
|
||||
|
||||
public boolean teleport(Location location, TeleportCause cause) {
|
||||
if (entity.vehicle != null || entity.passenger != null || entity.dead) {
|
||||
if (entity.passenger != null || entity.dead) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If this entity is riding another entity, we must dismount before teleporting.
|
||||
entity.mount(null);
|
||||
|
||||
entity.world = ((CraftWorld) location.getWorld()).getHandle();
|
||||
entity.setLocation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
|
||||
// entity.setLocation() throws no event, and so cannot be cancelled
|
||||
|
|
|
@ -458,7 +458,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (entity.vehicle != null || entity.passenger != null) {
|
||||
if (entity.passenger != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -475,6 +475,9 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
return false;
|
||||
}
|
||||
|
||||
// If this player is riding another entity, we must dismount before teleporting.
|
||||
entity.mount(null);
|
||||
|
||||
// Update the From Location
|
||||
from = event.getFrom();
|
||||
// Grab the new To Location dependent on whether the event was cancelled.
|
||||
|
|
Loading…
Reference in a new issue