PrismarineJS / mineflayer

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

Player Abilities #1587

Open ZenZon13 opened 3 years ago

ZenZon13 commented 3 years ago

Versions

Clear question

A clear question, with as much context as possible. What are you building? What problem are you trying to solve?

I want to make the Bot Fly Around (Not Creative with Allow Flying). For that I use currently use bot.creative.flyTo but I get kicked. This can be to do by vanilla or the spigot server. Maybe the Server does not know that we want to use the AllowFlying right. That can be solved by simply sending a Player Abilities Packet with the Flying bit. But I don't know if there is a function in the bot or how to send this (or any) packet manually.

Thanks for the Help in Advance

ArcticZeroo commented 3 years ago

If you get kicked by the server, then the server doesn't allow you to fly... if AllowFlight is true, flyTo won't get you kicked as far as I've tested in the past. Are you sure AllowFlight is enabled?

rom1504 commented 3 years ago

The player ability packet is sent by the server

On Wed, Jan 13, 2021, 01:29 Spencer notifications@github.com wrote:

If you get kicked by the server, then the server doesn't allow you to fly... if AllowFlight is true, flyTo won't get you kicked

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/PrismarineJS/mineflayer/issues/1587#issuecomment-759123003, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAR437S2OXPKVETDZHI2PETSZTSMXANCNFSM4V77MISQ .

ZenZon13 commented 3 years ago

To go a bit deeper: I wrote a Plugin witch tells me if the Players sends the player ability packet.

If you get kicked by the server, then the server doesn't allow you to fly... if AllowFlight is true, flyTo won't get you kicked as far as I've tested in the past. Are you sure AllowFlight is enabled?

On my spigot server I got not kicked, so I think it's like an anticheat that looks for if the player sends it. The player has definitely allowFlight because with a vanilla client I can fly there with a double jump.

[09:31:15 INFO]: UUID of player Weltherrschaft is 63aa4994-b190-47a3-abfe-a11dd70492ca
[09:31:15 INFO]: Weltherrschaft[/127.0.0.1:51174] logged in with entity id 854 at ([world]-217.5, 72.0, 66.5)
[09:31:20 INFO]: Flight: true
[09:31:25 INFO]: Flight: false
[09:31:26 INFO]: Flight: true
[09:31:26 INFO]: Flight: false
[09:31:29 INFO]: Weltherrschaft lost connection: Disconnected
[09:31:29 INFO]: Weltherrschaft left the game.
[09:35:06 INFO]: UUID of player Weltherrschaft is 63aa4994-b190-47a3-abfe-a11dd70492ca
[09:35:06 INFO]: Weltherrschaft[/192.168.178.86:50372] logged in with entity id 3326 at ([world]-296.57796718721846, 68.0, 37.507576563823996)

Above I am with a Vanilla Client flying and below the Bot. Bot code:

const mineflayer = require('mineflayer')
const mineflayerViewer = require('prismarine-viewer').mineflayer
const vec3 = require('vec3')

    botjson = {
        host: process.argv[2],
        port: parseInt(process.argv[3]),
        session
    }
    bot = mineflayer.createBot(botjson)
    bot.once('spawn', () => {
        mineflayerViewer(bot, {port: 3000})
        bot.creative.flyTo(new vec3(bot.entity.position.x, 1000, bot.entity.position.z))
    })

I check the fly over Prismarine viewer, and he is definitely flying: image

The plugin I wrote:

import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerToggleFlightEvent;
import org.bukkit.plugin.java.JavaPlugin;

public class FlyTestPlugin extends JavaPlugin implements Listener {

    @Override
    public void onEnable() {
        Bukkit.getPluginManager().registerEvents(this, this);
    }

    @EventHandler
    public void onPlayerToggleFly(PlayerToggleFlightEvent event) {
        Bukkit.getConsoleSender().sendMessage("Flight: "+event.isFlying());
    }

    @EventHandler
    public void onPlayerJoin(PlayerJoinEvent event) {
        event.getPlayer().setAllowFlight(true);
    }

}

The Event PlayerToggleFlightEvent is called when the player sends the PacketPlayInAbilities Packet where the Player is cahnging Flying.

ZenZon13 commented 3 years ago

The player ability packet is sent by the server On Wed, Jan 13, 2021, 01:29 Spencer @.***> wrote: If you get kicked by the server, then the server doesn't allow you to fly... if AllowFlight is true, flyTo won't get you kicked — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#1587 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAR437S2OXPKVETDZHI2PETSZTSMXANCNFSM4V77MISQ .

There are Two Packets one from the Server to the Client and from the Client to the Server.

rom1504 commented 3 years ago

Feel free to add what's needed in mineflayer

On Wed, Jan 13, 2021, 09:55 ZenZon13 notifications@github.com wrote:

The player ability packet is sent by the server … <#m265393229180209937> On Wed, Jan 13, 2021, 01:29 Spencer @.***> wrote: If you get kicked by the server, then the server doesn't allow you to fly... if AllowFlight is true, flyTo won't get you kicked — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#1587 (comment) https://github.com/PrismarineJS/mineflayer/issues/1587#issuecomment-759123003>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAR437S2OXPKVETDZHI2PETSZTSMXANCNFSM4V77MISQ .

There are Two Packets one from the Server to the Client and from the Client to the Server.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/PrismarineJS/mineflayer/issues/1587#issuecomment-759303956, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAR437WQEB7SQCB44AP7GZDSZVNYRANCNFSM4V77MISQ .