mineflayer: Skins restorer plugin: bot.blockAt always returns null
- The FAQ doesn’t contain a resolution to my issue
Update
see this comment, the issue seems to be a problem with a plugin called SkinsRestorer (from what i’ve gathered from testing), im not sure what the internal problem is for this so i’ll have to leave this to the maintainers to debug as i really have no clue what goes on in any of the chunk handling code
Versions
- mineflayer: 948a27ee0c59b431725f1cde28ec29735042a9df
- server: paper 1.16.3
- node: 14.13.1
Detailed description of a problem
using bot.blockAt(new Vec3(x, y, z)) returns null rather than the block at those coordinates
edit: doesn’t need saying but there is most definetly a block at the provided coordinates
What did you try yet?
really not sure what the problem is internally so im not sure what to try
Your current code
// initalizing bot
// in an event handler, ran a few minutes after the bot successfully logs in
const { Vec3 } = require('vec3');
const block = bot.blockAt(new Vec3(x, y, z));
console.log(block); // null
Expected behavior
the function should return a Block
Additional context
edit: it seems the plugin is mis-handling chunk packets somewhere, i tried on 2 different servers, both paper 1.16.3, and only in one was i successfully able to get a block, the difference between these servers? just a few plugins, ill list them
AntiDisconnectSpam, AuthMe, ChatEx*, LuckPerms, PlaceholderAPI ProtocolLib, SkinsRestorer, TAB, Vault - these are the plugins on the server where blocks are not being returned, now i would imagine PlaceholderAPI or ProtocolLib would be one of the plugins causing this, as none of the other plugins interfear with the world itself, but idk
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 38 (38 by maintainers)
After looking through the source code, the bug is caused by the bot receiving a player info packet for itself that says player removed.
This can be fixed by checking if the player is equal to the bot in the player_info packet on action 4, and simply doing nothing if the target player is equal to the bot. A bot cannot receive a logout packet for itself in vanilla Minecraft, so this shouldn’t habe any adverse effects.
I’ll make a PR tomorrow.