Solved [NOT POSSIBLE w/ LEFT CLICK] Get BlockBreakEvent to run before PlayerInteractEvent?

Discussion in 'Plugin Development' started by Blockhead7360, Sep 18, 2016.

Thread Status:
Not open for further replies.
  1. Offline

    Blockhead7360

    Hello! I have a problem.

    I am trying to get the BlockBreakEvent to run before the PlayerInteractEvent, so I can cancel the PlayerInteractEvent. Does that make sense?

    Basically, at some point, I need to cancel the PlayerInteractEvent. However, that causes the BlockBreakEvent not to run. I was wondering if there is any way to get it so if the block is broken, it runs the BlockBreakEvent and does not run the PlayerInteractEvent, and if the block isn't broken, it runs the PlayerInteractEvent.

    I need the LEFT_CLICK_BLOCK action still in the PlayerInteractEvent, but if there is absolutely no way to fix this issue, I'll just change it to RIGHT_CLICK_BLOCK and then it will work.

    Thanks!
     
  2. Offline

    RenditionsRule

    @Blockhead7360
    Unfortunately, I'm pretty sure that the interaction will always fire before the break event, since interact just means punching the block. It would fire even if the block didn't break.
     
    Blockhead7360 likes this.
  3. Offline

    Zombie_Striker

    @Blockhead7360
    PlayerInteractEvent will always trigger before block break event. You cannot change which events fire first without modifying the bukkit jar.

    I'm assuming you want to make sure blocks can't be broken (and do not want it to even register on the clients side). To get around this, cancel playerinteractevent if the player is leftclicking a block. Your events will still run, and the player will see the hand animation, the block just will not break.
     
    Blockhead7360 likes this.
  4. Offline

    Blockhead7360

Thread Status:
Not open for further replies.

Share This Page