Skip to content
New issue

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

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

Already on GitHub? # to your account

Uncaught TypeError TypeError: Cannot read properties of undefined (reading 'passengers') #3593

Open
1 task done
Meowphedrone opened this issue Feb 23, 2025 · 1 comment
Open
1 task done
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

@Meowphedrone
Copy link

Meowphedrone commented Feb 23, 2025

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

Versions

  • mineflayer: latest
  • server: local vanilla server, 1.21
  • node: 20.11.0

Detailed description of a problem

Uncaught TypeError TypeError: Cannot read properties of undefined (reading 'passengers')

crashes the bot when loading a chunk containing a mounted vehicle entity (striders with baby striders/zombie piglins in my case)

What did you try yet?

aint much, i just slapped additional checks to make sure vehicle isn't undefined and it worked. a band-aid solution but what do i care

Your current code

//BEFORE:
    for (const passengerEntity of passengerEntities) {
      const originalVehicle = passengerEntity.vehicle
      if (originalVehicle !== null) {
        const index = originalVehicle.passengers.indexOf(passengerEntity)
        originalVehicle.passengers = originalVehicle.passengers.splice(index, 1)
      }
      passengerEntity.vehicle = vehicle
      if (vehicle !== null) {
        vehicle.passengers.push(passengerEntity)
      }
    }
//AFTER:
    for (const passengerEntity of passengerEntities) {
      const originalVehicle = passengerEntity.vehicle
      if (vehicle && originalVehicle !== null) {
        const index = originalVehicle.passengers.indexOf(passengerEntity)
        originalVehicle.passengers = originalVehicle.passengers.splice(index, 1)
      }
      passengerEntity.vehicle = vehicle
      if (vehicle && vehicle != null) {
        vehicle.passengers.push(passengerEntity)
      }
    }

Expected behavior

uh. not crash

Additional context

meow

@Meowphedrone Meowphedrone 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 Feb 23, 2025
@Meowphedrone
Copy link
Author

the location of the code that causes this issue is at mineflayer\lib\plugins\entities.js:836:39 btw

azures04 added a commit to azures04/Mineflayer-Realm-AFK that referenced this issue Feb 25, 2025
Added patch-package module that allow me to patch an mineflayer issue, original issue : PrismarineJS/mineflayer#3593
# for free to join this conversation on GitHub. Already have an account? # 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