use of net.minecraft.server.v1_13_R2.PacketPlayOutEntity.PacketPlayOutRelEntityMoveLook in project DragonsOnline by UniverseCraft.
the class PlayerNPC116R3 method updateLocationFor.
public void updateLocationFor(Player player, float pitch, float yaw) {
if (!lastSeenLocation.containsKey(player)) {
spawnFor(player);
return;
}
// resync
location = getEntity().getLocation();
location.setYaw(originalYaw);
byte byaw = getPacketRotation(yaw);
byte bpitch = getPacketRotation(pitch);
Vector move = getEntity().getLocation().subtract(lastSeenLocation.get(player)).toVector();
// since error in the dx/dy/dz's can accumulate or get desynced with the client.
if (move.lengthSquared() > 63.996 || System.currentTimeMillis() - lastForceRefresh.getOrDefault(player, 0L) > FORCE_REFRESH_LOCATION_INTERVAL_MS) {
PacketPlayOutEntityTeleport tp = new PacketPlayOutEntityTeleport();
setField(tp, "a", getEntityId());
setField(tp, "b", location.getX());
setField(tp, "c", location.getY());
setField(tp, "d", location.getZ());
setField(tp, "e", byaw);
setField(tp, "f", bpitch);
setField(tp, "g", handle.isOnGround());
sync(() -> sendPacket(tp, player));
lastForceRefresh.put(player, System.currentTimeMillis());
} else // But usually we can just send dx/dy/dz, resulting in smoother movement
// and smaller packets
{
int dx = (int) move.getX() * 4096;
int dy = (int) move.getY() * 4096;
int dz = (int) move.getZ() * 4096;
boolean onGround = handle.isOnGround();
PacketPlayOutRelEntityMoveLook packet = new PacketPlayOutRelEntityMoveLook(getEntityId(), (short) dx, (short) dy, (short) dz, byaw, bpitch, onGround);
sendPacket(packet, player);
}
sync(() -> sendPacket(new PacketPlayOutEntityHeadRotation(handle, byaw), player));
lastSeenLocation.put(player, location);
}
use of net.minecraft.server.v1_13_R2.PacketPlayOutEntity.PacketPlayOutRelEntityMoveLook in project MechanicsMain by WeaponMechanics.
the class FakeEntity_1_14_R1 method setPositionRotation.
@Override
public void setPositionRotation(short dx, short dy, short dz, byte yaw, byte pitch) {
PacketPlayOutRelEntityMoveLook packet = new PacketPlayOutRelEntityMoveLook(cache, dx, dy, dz, yaw, pitch, false);
PacketPlayOutEntityHeadRotation head = new PacketPlayOutEntityHeadRotation(entity, convertYaw(yaw));
sendPackets(packet, head);
}
use of net.minecraft.server.v1_13_R2.PacketPlayOutEntity.PacketPlayOutRelEntityMoveLook in project MechanicsMain by WeaponMechanics.
the class FakeEntity_1_9_R2 method setPositionRotation.
@Override
public void setPositionRotation(short dx, short dy, short dz, byte yaw, byte pitch) {
PacketPlayOutRelEntityMoveLook packet = new PacketPlayOutRelEntityMoveLook(cache, dx, dy, dz, yaw, pitch, false);
PacketPlayOutEntityHeadRotation head = new PacketPlayOutEntityHeadRotation(entity, convertYaw(yaw));
sendPackets(packet, head);
}
use of net.minecraft.server.v1_13_R2.PacketPlayOutEntity.PacketPlayOutRelEntityMoveLook in project MechanicsMain by WeaponMechanics.
the class FakeEntity_1_12_R1 method setPositionRotation.
@Override
public void setPositionRotation(short dx, short dy, short dz, byte yaw, byte pitch) {
PacketPlayOutRelEntityMoveLook packet = new PacketPlayOutRelEntityMoveLook(cache, dx, dy, dz, yaw, pitch, false);
PacketPlayOutEntityHeadRotation head = new PacketPlayOutEntityHeadRotation(entity, convertYaw(yaw));
sendPackets(packet, head);
}
Aggregations