Use teleportcause

This commit is contained in:
fullwall 2023-02-15 07:19:20 +08:00
parent 22e1821f24
commit a09a54d4da
3 changed files with 5 additions and 17 deletions

View File

@ -326,7 +326,7 @@ public class CitizensNPC extends AbstractNPC {
skinnable.getSkinTracker().onSpawnNPC();
}
getEntity().teleport(at);
teleport(at, TeleportCause.PLUGIN);
NMS.setHeadYaw(getEntity(), at.getYaw());
NMS.setBodyYaw(getEntity(), at.getYaw());
@ -468,8 +468,8 @@ public class CitizensNPC extends AbstractNPC {
if (navigator.isNavigating()) {
if (data().get(NPC.Metadata.SWIMMING, true)) {
getEntity().setVelocity(getEntity().getVelocity().multiply(data()
.get(NPC.Metadata.WATER_SPEED_MODIFIER, Setting.NPC_WATER_SPEED_MODIFIER.asFloat())));
getEntity().setVelocity(getEntity().getVelocity().multiply(
data().get(NPC.Metadata.WATER_SPEED_MODIFIER, Setting.NPC_WATER_SPEED_MODIFIER.asFloat())));
Location currentDest = navigator.getPathStrategy().getCurrentDestination();
if (currentDest == null || currentDest.getY() > getStoredLocation().getY()) {
NMS.trySwim(getEntity());

View File

@ -154,23 +154,11 @@ public class CitizensNPCRegistry implements NPCRegistry {
@Override
public NPC getByUniqueId(UUID uuid) {
if (uuid.version() == 2) {
long msb = uuid.getMostSignificantBits();
msb &= ~0x0000000000002000L;
msb |= 0x0000000000004000L;
uuid = new UUID(msb, uuid.getLeastSignificantBits());
}
return uniqueNPCs.get(uuid);
}
@Override
public NPC getByUniqueIdGlobal(UUID uuid) {
if (uuid.version() == 2) {
long msb = uuid.getMostSignificantBits();
msb &= ~0x0000000000002000L;
msb |= 0x0000000000004000L;
uuid = new UUID(msb, uuid.getLeastSignificantBits());
}
NPC npc = getByUniqueId(uuid);
if (npc != null)
return npc;

View File

@ -54,9 +54,9 @@ public class PacketNPC extends Trait {
public static interface EntityPacketTracker extends Runnable {
public void link(Player player);
public void unlinkAll(Consumer<Player> callback);
public void unlink(Player player);
public void unlinkAll(Consumer<Player> callback);
}
private class PacketController implements EntityController {