mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-01-29 19:41:50 +01:00
Send movement updates more often
This commit is contained in:
parent
9980fa7c05
commit
7235b6afee
@ -21,6 +21,7 @@ import net.citizensnpcs.util.Messages;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_6_R3.EntityLiving;
|
||||
import net.minecraft.server.v1_6_R3.Packet34EntityTeleport;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
@ -38,6 +39,7 @@ import com.google.common.base.Throwables;
|
||||
public class CitizensNPC extends AbstractNPC {
|
||||
private EntityController entityController;
|
||||
private final CitizensNavigator navigator = new CitizensNavigator(this);
|
||||
private int packetUpdateCount;
|
||||
|
||||
public CitizensNPC(int id, String name, EntityController entityController, NPCRegistry registry) {
|
||||
super(id, name, registry);
|
||||
@ -228,6 +230,13 @@ public class CitizensNPC extends AbstractNPC {
|
||||
if (isSpawned()) {
|
||||
NMS.trySwim(getBukkitEntity());
|
||||
navigator.run();
|
||||
if (++packetUpdateCount > 30) {
|
||||
if (!getNavigator().isNavigating()) {
|
||||
NMS.sendPacketNearby(getStoredLocation(),
|
||||
new Packet34EntityTeleport(NMS.getHandle(getBukkitEntity())));
|
||||
}
|
||||
packetUpdateCount = 0;
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
Throwable error = Throwables.getRootCause(ex);
|
||||
|
@ -30,7 +30,6 @@ import net.minecraft.server.v1_6_R3.Navigation;
|
||||
import net.minecraft.server.v1_6_R3.NetworkManager;
|
||||
import net.minecraft.server.v1_6_R3.Packet;
|
||||
import net.minecraft.server.v1_6_R3.Packet201PlayerInfo;
|
||||
import net.minecraft.server.v1_6_R3.Packet34EntityTeleport;
|
||||
import net.minecraft.server.v1_6_R3.Packet35EntityHeadRotation;
|
||||
import net.minecraft.server.v1_6_R3.Packet5EntityEquipment;
|
||||
import net.minecraft.server.v1_6_R3.PlayerInteractManager;
|
||||
@ -240,11 +239,10 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
|
||||
private void updatePackets(boolean navigating) {
|
||||
if (++packetUpdateCount >= 30) {
|
||||
Location current = getBukkitEntity().getLocation(packetLocationCache);
|
||||
Packet[] packets = new Packet[navigating ? 6 : 8];
|
||||
Packet[] packets = new Packet[navigating ? 6 : 7];
|
||||
if (!navigating) {
|
||||
packets[6] = new Packet35EntityHeadRotation(id,
|
||||
(byte) MathHelper.d(NMS.getHeadYaw(this) * 256.0F / 360.0F));
|
||||
packets[7] = new Packet34EntityTeleport(this);
|
||||
}
|
||||
for (int i = 0; i < 5; i++) {
|
||||
packets[i] = new Packet5EntityEquipment(id, i, getEquipment(i));
|
||||
|
Loading…
Reference in New Issue
Block a user