MCProtocolLib icon indicating copy to clipboard operation
MCProtocolLib copied to clipboard

MovePacket no working

Open Arbuzik-New opened this issue 6 months ago • 1 comments

I want to make the bot move.

bot.getClientSession().send(new ServerboundMovePlayerPosRotPacket(true, false, 0, 0, 0, 0f, 0f));

`

private final MinecraftProtocol minecraftProtocol;
private final SessionService sessionService;
private final ClientSession clientSession;

private int id;

private boolean lastSprinting;
private boolean lastOnGround;
private boolean lastHorizontalCollision;
private float yRotLast;
private float xRotLast;
private int positionReminder = 0;
private double lastX, lastY, lastZ;

public Bot(MinecraftProtocol minecraftProtocol, SessionService sessionService, ClientSession clientSession) {
    this.minecraftProtocol = minecraftProtocol;
    this.sessionService = sessionService;
    this.clientSession = clientSession;

    clientSession.addListener(new SessionAdapter() {

        @Override
        public void packetSent(Session session, Packet packet) {
            onPacketReceive(packet);
        }

        @Override
        public void packetReceived(Session session, Packet packet) {
            onPacketReceive(packet);
        }
    });
}

public void connect() {
    this.clientSession.connect();
}

public void disconnect(String reason) {
    this.clientSession.disconnect(reason);
}


public void onSend(Packet packet) {

}

public void onPacketReceive(Packet packet) {
    if (packet instanceof ClientboundLoginPacket loginPacket) this.id = loginPacket.getEntityId();
}

public void sendPacket(Packet packet) {clientSession.send(packet);}
public void sendMessage(String message) {sendPacket(new ServerboundChatPacket(message, 0, 0, null, 0, new BitSet()));}
public void sendCommand(String command) {sendPacket(new ServerboundChatCommandPacket(command));}

public String getName() {
    return this.minecraftProtocol.getProfile().getName();
}

public MinecraftProtocol getMinecraftProtocol() {return minecraftProtocol;}
public SessionService getSessionService() {return sessionService;}
public ClientSession getClientSession() {return clientSession;}

public int getId() {return id;}`

Arbuzik-New avatar Jun 29 '25 21:06 Arbuzik-New