Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bot can't transition back into configuration state from play state properly. #3292

Open
1 task
wgaylord opened this issue Jan 26, 2024 · 7 comments
Open
1 task
Labels
bug Stage2 promising idea, but needs more thinking before implementation

Comments

@wgaylord
Copy link
Contributor

wgaylord commented Jan 26, 2024

  • The FAQ doesn't contain a resolution to my issue

Versions

  • mineflayer: 4.18.0
  • server: 1.20.2 paper I think. - Testing on play_pika-network_net.pika.host
  • node: v20.5.1

Detailed description of a problem

The bot will connect (enter a password since its an offline server) then after 30 seconds it will time out. While looking at the debug logs it appears as if it continues trying to do physics and stuff as if it was in the play state after transitioning back to the configuration to the configuration state

What did you try yet?

I haven't tried much since I just discovered the issue.

Your current code

const mineflayer = require('mineflayer');

var AutoAuth = require('mineflayer-auto-auth')

const bot = mineflayer.createBot({
host: 'play_pika-network_net.pika.host',
port: 25565,
username: '<username>',
auth: 'offline',
version: '1.20.2',
plugins: [AutoAuth],
  AutoAuth: {
    logging: true,
    password: '<a password you set on the server>',
    ignoreRepeat: true
  }
})

bot.on('messagestr', (msg) =>{
    console.log(msg);
})

bot.once('spawn', () => {console.log(`logged in as $(bot.username)`);bot.setControlState('forward',true);})

bot.on('serverAuth', function() {
 
});

bot.on('kick',(msg) => {console.log('kicked '+msg)})

Expected behavior

I expect the bot to join the server and stay connected. This was originally reported on the Discord and I continued investigating it.

Additional context

This is the debug log of joining the server. At the end you can notice it was told to enter the configuration state, then it starts trying to send packets that don't exist, showing that it clearly isn't transitioning properly.

log.txt

@wgaylord wgaylord added possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f labels Jan 26, 2024
@wgaylord
Copy link
Contributor Author

This is likely to be a bug both here (since it keeps doing position updates) and in node-minecraft-protocol.

@wgaylord
Copy link
Contributor Author

I have found a solution and will be submitting two PRs one to mineflayer and one to node-minecraft-protocol

@wgaylord
Copy link
Contributor Author

It appears as if only node-minecraft-protocol needed to be fixed. PrismarineJS/node-minecraft-protocol#1284 Close this when that is merged.

@wgaylord
Copy link
Contributor Author

wgaylord commented Feb 3, 2024

This is now fixed.

@wgaylord wgaylord closed this as completed Feb 3, 2024
@wgaylord
Copy link
Contributor Author

wgaylord commented Feb 5, 2024

Seems I closed this to early, noticed the bot continues trying to send position packets while in config state the second time. Should be a simple fix.

@wgaylord wgaylord reopened this Feb 5, 2024
@wgaylord
Copy link
Contributor Author

wgaylord commented Feb 6, 2024

Looks like the only reason its not fixed yet is that this fixed version of node-minecraft-protocol has not been pushed as a release to npm yet.

@extremeheat
Copy link
Member

extremeheat commented Feb 16, 2024

Fix was released, there could be issues between switching states even though we only stay in the config phase for a few milliseconds (ideally). So other code might not be aware of state change and continue sending play phase packets within that time. Fixing that is going to be hard, so I'd say let's see if it causes any problems before making lots of changes to everything

@rom1504 rom1504 added bug Stage2 promising idea, but needs more thinking before implementation and removed possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f labels Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Stage2 promising idea, but needs more thinking before implementation
Projects
None yet
Development

No branches or pull requests

3 participants