Extra null check in sit trait

This commit is contained in:
fullwall 2024-09-27 23:06:33 +08:00
parent 0f701a3c40
commit e78499f6ca
2 changed files with 4 additions and 11 deletions

View File

@ -41,8 +41,9 @@ public class MountTrait extends Trait {
@Override
public void onDespawn() {
if (NMS.getVehicle(npc.getEntity()) != null) {
if (currentMount != null) {
npc.getEntity().leaveVehicle();
currentMount = null;
}
}
@ -51,11 +52,6 @@ public class MountTrait extends Trait {
onDespawn();
}
@Override
public void onSpawn() {
checkMounted();
}
@Override
public void run() {
if (!npc.isSpawned())
@ -79,10 +75,7 @@ public class MountTrait extends Trait {
public void unmount() {
if (currentMount == null)
return;
if (NMS.getVehicle(npc.getEntity()) != null) {
npc.getEntity().leaveVehicle();
}
onDespawn();
uuid = null;
currentMount = null;
}
}

View File

@ -26,7 +26,7 @@ public class SitTrait extends Trait {
}
public boolean isSitting() {
return sittingAt != null;
return sittingAt != null && sittingAt.getWorld() != null;
}
@Override