PrismarineJS / mineflayer

Create Minecraft bots with a powerful, stable, and high level JavaScript API.
https://prismarinejs.github.io/mineflayer/
MIT License
4.96k stars 904 forks source link

[ Bug ] Water leads to a bad movement package #2423

Closed std-microblock closed 2 years ago

std-microblock commented 2 years ago

Versions

Detailed description of a problem

When the bot gets onto the water, it sends a bad movement package immediately.

What did you try yet?

set physics.gravity to 0

Your current code


const mineflayer = require("mineflayer");
const mineflayerViewer = require("prismarine-viewer").mineflayer;
const { pathfinder, Movements } = require("mineflayer-pathfinder");
const { GoalNear } = require("mineflayer-pathfinder").goals;
const pvp = require('mineflayer-pvp').plugin

const bot = mineflayer.createBot({
  username: "TestBot",
  host: "sq.s1.vlssu.com",
  port: "42886",
});
bot.loadPlugin(pathfinder);
bot.loadPlugin(pvp);

function toArr(e){
    return [e.x,e.y,e.z]
}

bot.on("chat", async (username, message) => {
  if (message.startsWith("/register"))
    bot.chat(`/register xxxxx123 xxxxx123`);
  else if (message.startsWith("/login")){
    bot.chat(`/login xxxxx123`);
  }

  if(message.startsWith("BotTpa")){
    bot.chat(`/tpa ${username}`);
  }

});

bot.once("spawn", () => {
    bot.physics.gravity=0 
  mineflayerViewer(bot, { port: 3000 }); 
});
bot.on("move",console.log)
bot.on('kicked', console.log)
bot.on('error', console.log)

Expected behavior

Not to send the bad package

Additional context

Log:

Vec3 { x: -282.24961632730486, y: 59, z: 54.10260754988749 }
Vec3 { x: -282.24961632730486, y: 62, z: 54.10260754988749 }
Vec3 { x: -282.24961632730486, y: 62, z: 54.10260754988749 }
Vec3 { x: -282.24961632730486, y: NaN, z: 54.10260754988749 }
{"translate":"multiplayer.disconnect.invalid_player_movement"}
std-microblock commented 2 years ago

Temporary solution: change node_modules\prismarine-physics\index.js line 375 if(!entity.isInWater && !entity.isInLava){ into if(1){

nickelpro commented 2 years ago

Should be opened on pris-physics, not a Mineflayer proper bug.

dumbasPL commented 2 years ago

Seems like this is caused by missing proportionalLiquidGravity for 1.18 in features.json After adding 1.18 the list of versions water starts to work normally.

rom1504 commented 2 years ago

@dumbasPL can you npm update --depth 9999 and try again?

std-microblock commented 2 years ago

Fixed. Thanks!