-
-
Notifications
You must be signed in to change notification settings - Fork 959
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
Fix potential null vehicle passengers array in entities plugin #3575
Conversation
- Remove unnecessary semicolons - Simplify dismount event emission - Ensure consistent null and array checks for vehicle and passenger entities
I didn't modify beds, but I can fix the error in beds if needed. Let me know! |
The more error you fix the better |
OK give me 30 mins |
Wait that test passed local |
- Remove commented initialization comment - Simplify comments for passenger entity checks - Maintain existing logic for removing passengers from vehicles
Ok cool their |
@@ -806,13 +806,21 @@ function inject (bot) { | |||
const passenger = fetchEntity(packet.entityId) | |||
const vehicle = packet.vehicleId === -1 ? null : fetchEntity(packet.vehicleId) | |||
|
|||
// Initialize passengers arrays if they don't exist | |||
if (!passenger.passengers) passenger.passengers = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this happen? if so why? can we initialize this when we create the entity?
@@ -806,13 +806,21 @@ function inject (bot) { | |||
const passenger = fetchEntity(packet.entityId) | |||
const vehicle = packet.vehicleId === -1 ? null : fetchEntity(packet.vehicleId) | |||
|
|||
// Initialize passengers arrays if they don't exist | |||
if (!passenger.passengers) passenger.passengers = [] | |||
if (vehicle && !vehicle.passengers) vehicle.passengers = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same question
const originalVehicle = passenger.vehicle | ||
if (originalVehicle !== null) { | ||
if (originalVehicle && originalVehicle.passengers && Array.isArray(originalVehicle.passengers)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this happen? is it a minecraft bug?
} | ||
passenger.vehicle = vehicle | ||
vehicle.passengers.push(passenger) | ||
if (vehicle && vehicle.passengers && Array.isArray(vehicle.passengers)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can vehicle.passengers not be an array?
@@ -830,14 +838,27 @@ function inject (bot) { | |||
const passengerEntities = passengers.map((passengerId) => fetchEntity(passengerId)) | |||
const vehicle = entityId === -1 ? null : bot.entities[entityId] | |||
|
|||
if (vehicle && !vehicle.passengers) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same q as above
return bot.entities[id] || (bot.entities[id] = new Entity(id)) | ||
if (!bot.entities[id]) { | ||
const entity = new Entity(id) | ||
entity.passengers = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not put this directly in prismarine entity ?
if we do that here why do we need to check passengers is an array above?
if (dimData) { | ||
bot.game.minY = dimData.minY | ||
bot.game.height = dimData.height | ||
if (bot.registry.dimensionsByName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this be empty? is it a bug in minecraft ?
sorry way to much effort GL tho love the project |
Fix crash caused by undefined vehicle entity in entities.js
This commit fixes a crash occurring when attempting to access
vehicle.passengers
on an undefined
vehicle
entity. The issue was triggered in:lib\plugins\entities.js:841