Skip to content
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 vehicle/passengers #3586

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Pix3lPirat3
Copy link
Contributor

Re-opening because I accidentally closed my last one, still need to figure out how to create a test for this.

So I found an issue where passengers were infinitely being added (unless I did that myself), an issue with passenger becoming undefined, and an issue with set_passengers running into the same issues. been working on this the last two nights and got it to a point of working (from my own testing) in 1.8.9 and 1.20.4, requires further testing. (Don't believe there are any built-in testing)

My test code was;

  setInterval(function() {
    let boat = bot.nearestEntity(ent => ent.name == 'Boat');
    if(!boat) return bot.chat('No boat');
    let player = bot.nearestEntity(ent => ent.type == 'player');
    if(!player) return bot.chat('No player.');
    let spider = bot.nearestEntity(ent => ent.name == 'Spider');
    if(!spider) return bot.chat('No spider.');

    bot.chat('Boat Passengers: ' + boat.passengers.length + ' Player Vehicle: ' + player.vehicle?.name + ' Spider Passengers: ' + spider.passengers?.length)
  }, 1000)

I don't believe the mount/unmount events work currently, was curious if that should still remain as bot.emit('mount/unmount') or added into the set_passenger/attach_entity events and emitted directly from the passenger/vehicle entities. However that's a separate thing.

const vehicle = entity.vehicle
delete entity.vehicle
bot.emit('entityDetach', entity, vehicle)
bot.emit('entityDetach', entity, entity.vehicle)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well this is not updating the state to detach anymore

} else {
entity.vehicle = fetchEntity(packet.vehicleId)
bot.emit('entityAttach', entity, entity.vehicle)
bot.emit('entityAttach', entity, fetchEntity(packet.vehicleId))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not updating the state to attach anymore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants