Search in sources :

Example 1 with ClientPlayerRotationPacket

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);
    }
}
Also used : ClientPlayerPositionPacket(com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerPositionPacket) ClientPlayerRotationPacket(com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerRotationPacket) ClientPlayerPositionRotationPacket(com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerPositionRotationPacket)

Aggregations

ClientPlayerPositionPacket (com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerPositionPacket)1 ClientPlayerPositionRotationPacket (com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerPositionRotationPacket)1 ClientPlayerRotationPacket (com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerRotationPacket)1