mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-25 20:25:19 +01:00
Don't send per-player rotation packets as often
This commit is contained in:
parent
6ced30fa20
commit
f9def3fe6a
@ -71,10 +71,6 @@ public class ProtocolLibListener {
|
||||
});
|
||||
}
|
||||
|
||||
private static byte degToByte(float in) {
|
||||
return (byte) (in * 256.0F / 360.0F);
|
||||
}
|
||||
|
||||
private StructureModifier<Set<PlayerTeleportFlag>> getFlagsModifier(PacketContainer handle) {
|
||||
return handle.getSets(EnumWrappers.getGenericConverter(flagsClass, PlayerTeleportFlag.class));
|
||||
}
|
||||
@ -86,4 +82,8 @@ public class ProtocolLibListener {
|
||||
ZPITCH,
|
||||
ZYAW,
|
||||
}
|
||||
|
||||
private static byte degToByte(float in) {
|
||||
return (byte) (in * 256.0F / 360.0F);
|
||||
}
|
||||
}
|
||||
|
@ -181,13 +181,20 @@ public class CitizensNavigator implements Navigator, Runnable {
|
||||
if (!finished) {
|
||||
localParams.run();
|
||||
}
|
||||
localParams.lookAtFunction((n) -> {
|
||||
if (Bukkit.getServer().getPlayer("fullwall") == null) {
|
||||
return n.getTargetAsLocation();
|
||||
}
|
||||
return Bukkit.getServer().getPlayer("fullwall").getLocation();
|
||||
});
|
||||
if (localParams.lookAtFunction() != null) {
|
||||
if (session == null) {
|
||||
RotationTrait trait = npc.getOrAddTrait(RotationTrait.class);
|
||||
session = trait.createPacketSession(new RotationParams().filter((p) -> true).persist(true));
|
||||
session = trait.createPacketSession(new RotationParams().filter(p -> true).persist(true));
|
||||
}
|
||||
session.getSession().rotateToFace(localParams.lookAtFunction().apply(this));
|
||||
}
|
||||
|
||||
if (localParams.destinationTeleportMargin() > 0
|
||||
&& npcLoc.distance(targetLoc) <= localParams.destinationTeleportMargin()) {
|
||||
// TODO: easing?
|
||||
|
@ -74,10 +74,10 @@ public class RotationTrait extends Trait {
|
||||
|
||||
public PacketRotationSession getPacketSession(Player player) {
|
||||
PacketRotationSession lrs = packetSessionsByUUID.get(player.getUniqueId());
|
||||
if (lrs != null)
|
||||
if (lrs != null && lrs.triple != null)
|
||||
return lrs;
|
||||
for (PacketRotationSession session : packetSessions) {
|
||||
if (session.accepts(player)) {
|
||||
if (session.accepts(player) && session.triple != null) {
|
||||
return session;
|
||||
}
|
||||
}
|
||||
@ -198,10 +198,7 @@ public class RotationTrait extends Trait {
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
Location loc = entity.getLocation();
|
||||
loc.setPitch(pitch);
|
||||
loc.setYaw(headYaw);
|
||||
NMS.sendRotationNearby(entity, bodyYaw, headYaw, pitch);
|
||||
// NMS.sendRotationNearby(entity, bodyYaw, headYaw, pitch);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user