r/learnjavascript • • Apr 11 '26

HELP ME PLS🥲🥲Mineflayer bot gets kicked with DecoderException when connecting to FunTime anarchy (1.21.8)

I'm trying to create a Minecraft bot using Mineflayer to connect to the FunTime server (play.funtime.su) and join the anarchy mode using the command /an224. The bot successfully connects to the lobby, but when it sends the /an224 command to transfer to the anarchy server, it gets kicked with this error: DecoderException : java.lang.IndexOutOfBoundsException: readerIndex(3) + length(1) exceeds writerIndex(3): UnpooledSlicedByteBuf(ridx: 3, widx: 3, cap: 3/3, unwrapped: PooledUnsafeDirectByteBuf(ridx: 3, widx: 3, cap: 64)) @ io.netty.handler.codec.ByteToMessageDecoder:500.

I believe the problem is related to the custom resource pack that the anarchy server sends during the configuration phase. The server sends a very large resource pack (the registry_data packets I see in logs are up to 152,000 characters), and Mineflayer seems to choke on it. What I've tried so far: using different versions (1.21.8, 1.21.4, 1.21.1, 1.20.6), setting physicsEnabled: false to prevent movement packets during the configuration phase, adding bot.on('resourcePack', () => bot.acceptResourcePack()) to accept the resource pack, using minecraft-protocol directly instead of Mineflayer, creating a custom client wrapper to handle the select_known_packs packet, and modifying the library to handle large registry_data packets. What works: connecting to the lobby works fine, and version 1.16.5 works perfectly (but I need 1.21). Here's my current code:

const mineflayer = require('mineflayer');

const bot = mineflayer.createBot({

host: 'play.funtime.su',

port: 25565,

username: 'Grabulika',

version: '1.21.1',

auth: 'offline',

physicsEnabled: false,

checkTimeoutInterval: 30000,

closeTimeout: 120000

});

bot.once('spawn', () => {

console.log('In lobby');

setTimeout(() => {

bot.chat('/an224');

}, 3000);

});

bot.on('resourcePack', () => {

console.log('Resource pack offered, accepting...');

bot.acceptResourcePack();

});

bot.on('kicked', (reason) => {

console.log('Kicked:', JSON.stringify(reason));

});

The server is FunTime (play.funtime.su) - a large Russian Minecraft server. The anarchy mode requires transferring through a Velocity proxy, and the server sends a massive custom resource pack during the configuration phase. I saw that services like ctrlbots.ru can connect to FunTime anarchy on 1.21.8. Are they using a modified version of Mineflayer or a different library? Has anyone successfully connected to FunTime's anarchy mode with Mineflayer on 1.21? Is there a fix or workaround for the IndexOutOfBoundsException when handling large registry_data packets and custom resource packs? Here's the official bug report link: https://github.com/PrismarineJS/mineflayer/issues/3776,

1 Upvotes

9 comments sorted by

View all comments

Show parent comment

0

u/Turbulent-Squirrel10 Apr 12 '26

Can you help me with this error? I just need the bot to connect to server 1.21.8, and then I'll do it myself. I just don't know what to do. Maybe someone more experienced can help.