Magic

Magic

190k Downloads

Mount and unmount brooms with API

christophe6 opened this issue · 11 comments

commented

Hi

Is there a way with the magic api to let a player mount a broom that's not in their inventory? After unmounting they should not get the broom.

Any ideas? Thank you!

commented

Yes, basically make a new broom spell like

instabroom:
  inherit: broom
  parameters:
    mount_wand: false
    helmet_item: wood_hoe:11

Then cast that via the API.

commented

Thanks a lot (again 😂 )!!

commented

The PlayerMoveEvent does not seem to detect the movement of brooms? Is this possible? If so, do you have an alternative?

Thanks!

commented

Oh, thank you! I guess I should start a scheduled task when mounting the broom and stop it when the player is no longer on a broom. Is there an API method to check wether someone's flying a broom or not?

commented

Not really, you can call getActiveSpells and check for the broom spell being in there but that's about it.

commented

No, brooms work by applying velocity, PME is only for move packets sent from clients.

commented

I don’t think so, sorry- that’d be an event I’d have to fire every tick for every player on a broom.

What are you trying to do, exactly?

commented

I’m mounting players on a broom and they have to fly to the right flying key. When they reach it, they receive the key.

Thanks for your help!

commented

Few suggestions that seem like they’d work better:

  • set a scheduled task checking player locations each tick
  • use an entity for the key and detect collisions (I think there’s an event for that)
  • use a dropped item for the key and detect player pickup event
commented

Could you add a broommoveevent which is called upon multiplying velocity please?

commented

Thank you! Will be testing one of them soon.