From c0675ce4dad31848cce240e73104ed924b912a1d Mon Sep 17 00:00:00 2001 From: Yaode_owo Date: Fri, 18 Oct 2024 14:56:40 -0400 Subject: [PATCH] Update position.js --- position.js | 95 +++++++++++++++++++++++++++-------------------------- 1 file changed, 48 insertions(+), 47 deletions(-) diff --git a/position.js b/position.js index 69da0fb..096f79b 100644 --- a/position.js +++ b/position.js @@ -1,48 +1,49 @@ -const mc = require('minecraft-protocol'); - -const bot = mc.createClient({ - //host: '95.216.192.50', // kaboom.pw - host: 'chipmunk.land', - port: 25565, - username: "Powitiow", - version: '1.20.4', -}); - -inject(bot); - -function inject(bot) { - - bot.position = { x: NaN, y: NaN, z: NaN, yaw: NaN, pitch: NaN, world: null }; - - bot.on('login', (packet) => { - bot.position.world = packet.worldName; - // setInterval(() => { console.log(bot.position) }, 500); - }); - - bot.on('respawn', (packet) => { bot.position.world = packet.worldName }); - - bot.on("position", (packet) => { // im dumb use 350 lines code - - const oldPosition = { ...bot.position }; - - const { x, y, z, yaw, pitch, flags, teleportId } = packet; - - bot.position.x = flags & 1 ? (bot.position.x + x) : x - bot.position.y = flags & 2 ? (bot.position.y + y) : y - bot.position.z = flags & 4 ? (bot.position.z + z) : z - bot.position.yaw = flags & 8 ? (bot.position.yaw + yaw) : yaw - bot.position.pitch = flags & 16 ? (bot.position.pitch + pitch) : pitch - - bot.write('teleport_confirm', { teleportId }) - - bot.emit('move', oldPosition) // idk why add "true", so i removed - }); - - bot.on("end", () => { - bot.position = { x: NaN, y: NaN, z: NaN, yaw: NaN, pitch: NaN, world: null }; - }); - - bot.on('move', oldPosition => { - console.log(oldPosition); // NaN value at join - }); +const mc = require('minecraft-protocol'); + +const bot = mc.createClient({ + //host: '95.216.192.50', // kaboom.pw + host: 'chipmunk.land', + port: 25565, + username: "Powitiow", + version: '1.20.4', +}); + +inject(bot); + +function inject(bot) { + + bot.position = { x: NaN, y: NaN, z: NaN, yaw: NaN, pitch: NaN, world: null }; + + bot.on('login', (packet) => { + bot.position.world = packet.worldName; + // setInterval(() => { console.log(bot.position) }, 500); + }); + + bot.on('respawn', (packet) => { bot.position.world = packet.worldName }); + + bot.on("position", (packet) => { // im dumb use 350 lines code + + const oldPosition = { ...bot.position }; + + const { x, y, z, yaw, pitch, flags, teleportId } = packet; + + bot.position.x = flags & 1 ? (bot.position.x + x) : x + bot.position.y = flags & 2 ? (bot.position.y + y) : y + bot.position.z = flags & 4 ? (bot.position.z + z) : z + bot.position.yaw = flags & 8 ? (bot.position.yaw + yaw) : yaw + bot.position.pitch = flags & 16 ? (bot.position.pitch + pitch) : pitch + + bot.write('teleport_confirm', { teleportId }) + + bot.emit('move', oldPosition, newPosition); + }); + + bot.on("end", () => { + bot.position = { x: NaN, y: NaN, z: NaN, yaw: NaN, pitch: NaN, world: null }; + }); + + bot.on('move', (oldPosition, newPosition) => { + console.log(oldPosition); // NaN value at join + console.log(newPosition); + }); } \ No newline at end of file