Make MountTrait more reliable by making the NPC leave its vehicle on despawn

This commit is contained in:
fullwall 2016-12-04 02:16:25 +08:00
parent 9329c66667
commit 2442e24255
2 changed files with 10 additions and 1 deletions

View File

@ -340,8 +340,9 @@ public class CitizensNavigator implements Navigator, Runnable {
if (!isNavigating())
return;
Entity vehicle = NMS.getVehicle(npc.getEntity());
if (!(vehicle instanceof NPCHolder))
if (!(vehicle instanceof NPCHolder)) {
return;
}
NPC mount = ((NPCHolder) vehicle).getNPC();
switch (getTargetType()) {
case ENTITY:

View File

@ -30,6 +30,14 @@ public class MountTrait extends Trait {
}
}
@Override
public void onDespawn() {
Entity e = NMS.getVehicle(npc.getEntity());
if (e != null) {
npc.getEntity().leaveVehicle();
}
}
@Override
public void onSpawn() {
checkMount(null);