What event is triggered by breaking a Mob Spawner? - Solved

Discussion in 'CommandHelper' started by retrontology, Apr 30, 2017.

  1. retrontology

    retrontology New Member

    I can't seem to figure out which event is triggered whenever a mob spawner is broken.

    I'm trying to write a script that will drop a copy of a mob spawner whenever it's broken with a Silk Touch II pick. I thought that it would be handled by block_break, but it wasn't triggering when it should have. I did some debugging and wrote the @event['block'] to console at the very beginning of the code so it would spit out all the blocks broken. I mined some stone before and after I broke the spawner. The stone showed up every time, but the spawner never did. I tried breaking a whole bunch at that point, but none of them were triggering it. I also tried the event entity_death as a bit of a long shot, but it wasn't triggered either.

    I'm curious if there is another event that would be triggered by a spawner being broken, perhaps there's some conflict with another plugin, or maybe a config issue? I'm kind of at a loss atm and any help would be appreciated. I'm running v3.3.2-SNAPSHOT.3184 if that helps. Thanks for your time.
  2. PseudoKnight

    PseudoKnight Well-Known Member

    A plugin may be interfering here, setting the block to air. This is not very common because CH usually gets the event first. Another less likely scenario is another block_break script consuming the event. I confirmed block_break fires fine on my server for block type 52 (spawner).
  3. sat

    sat Member

    I use something like:
    (But with other control inside for other blocks)

    bind(block_break, null, null, @event,
    if(@event['block']['type'] == 52) {
    cancel()
    }
    )

    With control its must give a trick like this
    bind(block_break, null, array('bloc':array('type':'52')), @event,
    cancel()
    )
  4. PseudoKnight

    PseudoKnight Well-Known Member

    The prefilter is completely wrong in the second one, but they both should fire.

    Here's a proper prefilter for that:
    PHP:
    bind(block_break, null, array('type': 52), @event) {
  5. retrontology

    retrontology New Member

    Alright, so I'm kinda dumb and forgot to check the prefilter (I was editing this code from a previous dev on the server) and it was set to array('type': 1). No wonder I was seeing nothing but stone pop up :oops:

    I made a new event bind with the proper prefilter:
    and it works like a charm now.

    Thanks for the help guys! You saved me quite a bit more time banging my head against the wall. I thought it might be related to an oversight on my part, which is why I posted here instead of a bug report, and you pointed it out pretty fast lol.
  6. PseudoKnight

    PseudoKnight Well-Known Member

    I think we can all relate to that. Heh.
    retrontology likes this.