mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-10-02 09:08:02 +02:00
Use the root vehicle for NPC#teleport
This commit is contained in:
parent
59af96c467
commit
93495a9ab9
@ -215,7 +215,7 @@ public class CitizensNPC extends AbstractNPC {
|
||||
public void teleport(Location location, TeleportCause cause) {
|
||||
if (!this.isSpawned())
|
||||
return;
|
||||
teleport(getBukkitEntity(), location, false, 5);
|
||||
teleport(NMS.getRootVehicle(getBukkitEntity()), location, false, 5);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -156,6 +156,14 @@ public class NMS {
|
||||
: handle instanceof EntityHumanNPC ? ((EntityHumanNPC) handle).getNavigation() : null;
|
||||
}
|
||||
|
||||
public static org.bukkit.entity.Entity getRootVehicle(org.bukkit.entity.Entity entity) {
|
||||
Entity handle = NMS.getHandle(entity);
|
||||
while (handle.vehicle != null) {
|
||||
handle = handle.vehicle;
|
||||
}
|
||||
return handle.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static float getSpeedFor(NPC npc) {
|
||||
if (!npc.isSpawned())
|
||||
return DEFAULT_SPEED;
|
||||
|
Loading…
Reference in New Issue
Block a user