Check if entity was spawned from mob spawner?

Discussion in 'Plugin Development' started by caseif, Dec 4, 2012.

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

    caseif

    I'm trying to do a check in my plugin to see if a killed mob was spawned in via a spawner, but I can't find anything pertaining to it, not in the Bukkit API, nor on the Internets. Is there a method for it, or will I need to use a "trick" of some sort?

    P.S. I'd be entirely fine with checking how much fall damage the mob sustained (as that's how mob farms work), but I can't seem to figure that out either.
     
  2. Offline

    Malikk

    I've done this in plugins of mine with metadata.

    Just listen to the spawn event and assign metadata for all mobs from spawners, then check whether or not the mob has your metadata.
     
  3. Offline

    caseif

    Ah, alright then. Would you by any chance know how to check how much fall damage the mob has sustained? I'd like to disable drops from those giant sky spawners (not sure if you know what I'm talking about) as well.
     
  4. Offline

    Malikk

    Probably listen to the EntityDamage event and check if it was by falling and then get the damage.
     
  5. Offline

    caseif

    Alright, thanks for the help!
     
  6. Offline

    bergerkiller

  7. Offline

    caseif

    Alright, I'm trying to add the metadata to the mobs, but I'm pretty confused as to how to set it. I'm supposed to use a String and a MetadataValue, but I have no idea how to create the latter.

    EDIT: Never mind, I found a thread that said to create a new FixedMetaDataValue, rather than a MetaDataValue.
     
  8. Offline

    Barinade

    I would personally use a hashmap for this, mostly because optimization is lame.
     
  9. Offline

    caseif

    Meh, let's just say HashMaps and I aren't the best of friends. I should really look into learning more about them...
     
  10. Offline

    Barinade

    I could help you with hashmaps if you have Skype: ira.sancti
     
  11. Offline

    Zarius

    I know this is an old thread but I'm trying to do exactly the same thing (keep track of what the entity spawn reason is - shame this isn't saved to the entity by default).

    Do you mean to say that keeping a local hashmap would be better for performance than stored it in the metadata? I'm partial to using the metadata as it just seems cleaner to keep the data with the entity but if there's a significant performance...
     
Thread Status:
Not open for further replies.

Share This Page