Skip to content

Crash in physics.js when explosion occurs (Mineflayer 4.27.0, MC 1.21.4) #3635

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

Open
Hatadi-v opened this issue Apr 9, 2025 · 0 comments
Open
Labels
possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f

Comments

@Hatadi-v
Copy link

Hatadi-v commented Apr 9, 2025

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

Environment

  • Minecraft Version: 1.21.x (confirmed on 1.21.4)
  • Server Type: PaperMC, running on LAN (also tested on Vanilla & Spigot)
  • Mineflayer Version: 4.27.0
  • Node.js Version: v22.14.0
  • OS: Pop!_OS (Linux)

Problem

The bot crashes whenever an explosion happens nearby (e.g., TNT or Creeper).
It crashes inside mineflayer/lib/plugins/physics.js at line 299 whenever it tries to process explosion
I think it has something to do with insanely large vector in player knockback.

What did you try yet?

At first, I thought it was caused by my own bot code (~1000+ lines), but I reproduced the bug using a minimal Mineflayer bot that just connects and spawns.
I tested this on:

  • PaperMC, Vanilla, and Spigot servers
  • LAN setup
  • Fresh installs of Mineflayer and Node.js

All setups crash instantly on any explosion.

Minimal Reproduction code

import mineflayer from 'mineflayer';

const bot = mineflayer.createBot({
  host: 'localhost',   
  port: 25565,          
  username: 'TestBot',  
});

bot.on('spawn', () => {
  console.log('Bot spawned and ready');
});



Expected behavior

The bot shouldn't crash when an explosion occurs nearby.
Instead, it throws a TypeError trying to access property which is undefined ;-;

##Error

Chunk size is 53 but only 29 was read ; partial packet : {"name":"explosion","params":{"center":{"x":-2.5531342029571533,"y":1.4030810953376417e-36,"z":-3.218271255493164},"playerKnockback":{"x":-2.0000457763671875,"y":3.550067870195207e-28,"z":-1.3349637409800994e+30},"explosionParticle":{"type":"sweep_attack"},"soundId":16151}}; buffer :21c023668d03eeb8cdc04df828f5c00000c011e10325f186cc013f977eba590495aa3fc6db0ab35ed7abbfdd8c259c914fec15db04
/home/hatadi_v/Desktop/Ply/node_modules/vec3/index.js:82
    this.x += other.x
                    ^

TypeError: Cannot read properties of undefined (reading 'x')
    at Vec3.add (/home/hatadi_v/Desktop/Ply/node_modules/vec3/index.js:82:21)
    at Client.<anonymous> (/home/hatadi_v/Desktop/Ply/node_modules/mineflayer/lib/plugins/physics.js:299:29)
    at Client.emit (node:events:530:35)
    at emitPacket (/home/hatadi_v/Desktop/Ply/node_modules/minecraft-protocol/src/client.js:84:12)
    at FullPacketParser.<anonymous> (/home/hatadi_v/Desktop/Ply/node_modules/minecraft-protocol/src/client.js:113:9)
    at FullPacketParser.emit (node:events:518:28)
    at addChunk (/home/hatadi_v/Desktop/Ply/node_modules/readable-stream/lib/internal/streams/readable.js:323:12)
    at readableAddChunk (/home/hatadi_v/Desktop/Ply/node_modules/readable-stream/lib/internal/streams/readable.js:300:9)
    at Readable.push (/home/hatadi_v/Desktop/Ply/node_modules/readable-stream/lib/internal/streams/readable.js:246:10)
    at FullPacketParser._transform (/home/hatadi_v/Desktop/Ply/node_modules/protodef/src/serializer.js:89:10)

Node.js v22.14.0

Additional context

I am a beginner to both GitHub and JavaScript . Sorry if i misunderstood something. I tried to include every relevant information!

@Hatadi-v Hatadi-v 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 Apr 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f
Projects
None yet
Development

No branches or pull requests

1 participant