Which event for block destroyed because supporting block disappears?

Discussion in 'Plugin Development' started by Captain Chaos, Dec 23, 2012.

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

    Captain Chaos

    Which event should I listen to to detect blocks being destroyed (or dropping an item) because the block they are attached to disappears? Specifically, I am trying to detect when a torch is dropped because its supporting block disappears.

    Also, which event should I listen to to detect a torch being washed away by water?

    Basically, I need an event that is fired when a block disappears for any reason. I can't seem to find such an event, but perhaps I'm not looking right. BlockBreak only fires when the block is destroyed by a player. I've also tried BlockFade and BlockBurn, but they don't fire in this scenario. If it really doesn't exist then I'd like to request it as a feature.

    Cheers,
    Captain_Chaos
     
  2. try the blockpshygics event, I thought that was the event for it
     
  3. Offline

    Captain Chaos

    Thanks for the tip. It's not exactly what I wanted, but it does fire reliably before a torch disappears so I can use it, even though it's a bit kludgey...
     
  4. Offline

    desht

    BlockPhysicsEvent is in fact the exact (and only) event you need here. Maybe it seems kludgey, but it's the right approach. For attachable objects (torches, signs..), you can cast the MaterialData to Attachable and use getAttachedFace() in conjunction with getRelative() to see if the attachable block is still attached to a solid block. See this code here for an example: https://github.com/desht/ScrollingM...menusign/listeners/SMSBlockListener.java#L110
     
Thread Status:
Not open for further replies.

Share This Page