use of com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerRotationPacket in project CyanBot by XjCyan1de.
the class UpdatePositionHandler method onUpdate.
@Override
public void onUpdate() {
loc.add(speed);
// не отправляем, если чанк не прогружен
if (bot.getWorld().hasChunkAt(loc)) {
boolean pos = Double.compare(prev.getX(), loc.getX()) != 0 || Double.compare(prev.getY(), loc.getY()) != 0 || Double.compare(prev.getZ(), loc.getZ()) != 0;
boolean rot = Float.compare(prev.getPitch(), loc.getPitch()) != 0 || Float.compare(prev.getYaw(), loc.getYaw()) != 0;
if (pos && rot) {
bot.sendPacket(new ClientPlayerPositionRotationPacket(bot.isOnGround(), loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch()));
} else if (pos) {
bot.sendPacket(new ClientPlayerPositionPacket(bot.isOnGround(), loc.getX(), loc.getY(), loc.getZ()));
} else if (rot) {
bot.sendPacket(new ClientPlayerRotationPacket(bot.isOnGround(), loc.getYaw(), loc.getPitch()));
} else {
return;
}
prev.set(loc);
}
}
Aggregations