PrismarineJS / mineflayer

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

Bot not taking knockback on online servers #2004

Closed 1tzkaos closed 3 years ago

1tzkaos commented 3 years ago

Versions

Detailed description of a problem

I am building a robot that can fight (not with the PVP plugin though as I need to configure it). One of the problems I have been facing is the bot does not take knockback on servers. I have checked the ping of the bot and it was around 30-60, so it isn't a connection-related problem.

What did you try yet?

Your current code

just join any server such as hypixel or mineplex or something and it wont take any knockback in pvp

Expected behavior

I expect the bot to take normal knockback. I originally tested the bot on a lan server and the bot showed normal behaviors such as knockback.

Additional context

I hope you have a great day or night :)

1tzkaos commented 3 years ago
const Discord = require('discord.js');
const mineflayer = require('mineflayer')
const pathfinder = require('mineflayer-pathfinder').pathfinder
const Movements = require('mineflayer-pathfinder').Movements
const { GoalNear } = require('mineflayer-pathfinder').goals
const armorManager = require('mineflayer-armor-manager')
const vec3 = require('vec3')

module.exports = {
    name: "duel",
    //aliases: ["h"],
    description: "Commands for the bot",
    execute(message, args) {
        const bot = mineflayer.createBot({
            host: 'hypixel.net', // minecraft server ip
            username: 'USERNAME', // minecraft username
            password: 'PASSWORD', // minecraft password, comment out if you want to log into online-mode=false servers
            port: args[1], // only set if you need a port that isn't 25565
            version: '1.8.9', // only set if you need a specific version or snapshot (ie: "1.8.9" or "1.16.5"), otherwise it's set automatically
            // auth: 'mojang'              // only set if you need microsoft auth, then set this to 'microsoft'
        })
        if (args[0] === "start") {
            bot.on('spawn', (username) => {
                message.channel.send("The bot has joined the server!")
                console.log('Joined Server (on login)')
                bot.chat("/duel PLAYERUSERNAME Sumo")
            })
        }
    }

}

I censored out the names of players as well as username and passwords, but this basic thing going into a duel, but won't take any knockback. I have also tested if the bot can move and the bot CAN move such as bot.setControlState('forward', true).

u9g commented 3 years ago

please put your code in codeblocks like so:

```js code() ```

to get:

code()
1tzkaos commented 3 years ago

There we go is that better

1tzkaos commented 3 years ago
const Discord = require('discord.js');
const mineflayer = require('mineflayer')
const pathfinder = require('mineflayer-pathfinder').pathfinder
const Movements = require('mineflayer-pathfinder').Movements
const { GoalNear } = require('mineflayer-pathfinder').goals
const armorManager = require('mineflayer-armor-manager')
const vec3 = require('vec3')

module.exports = {
    name: "duel",
    //aliases: ["h"],
    description: "Commands for the bot",
    execute(message, args) {
        const bot = mineflayer.createBot({
            host: 'hypixel.net', // minecraft server ip
            username: 'USERNAME', // minecraft username
            password: 'PASSWORD', // minecraft password, comment out if you want to log into online-mode=false servers
            port: args[1], // only set if you need a port that isn't 25565
            version: '1.8.9', // only set if you need a specific version or snapshot (ie: "1.8.9" or "1.16.5"), otherwise it's set automatically
            // auth: 'mojang'              // only set if you need microsoft auth, then set this to 'microsoft'
        })
        if (args[0] === "start") {
            bot.on('spawn', (username) => {
                message.channel.send("The bot has joined the server!")
                console.log('Joined Server (on login)')
                bot.chat("/duel PLAYERUSERNAME Sumo")
            })
        }
    }

}
u9g commented 3 years ago

At a certain mc version, kb is calculated server side, but on 1.8.9, it’s calculated client side, but not implemented in prismarine-physics yet, feel free to contribute it, but that’s why it doesn’t work now.

1tzkaos commented 3 years ago

should I change to a different mc version? Which mc version would cause kb to be calculated server-side?

1tzkaos commented 3 years ago

also is there a discord or something like that for mineflayer?

u9g commented 3 years ago

also is there a discord or something like that for mineflayer?

Yep, https://discord.gg/tWaPBNtkaq

u9g commented 3 years ago

should I change to a different mc version? Which mc version would cause kb to be calculated server-side?

I have no idea, you can either google around or try versions until it works, but I believe hypixel only supports 1.8.9 and 1.16.5, so you can try 1.16.5