Is there a way to detect mob type from onEntityDamagedByEntity event? As mob type i mean like Zombie, Creeper etc.
Based upon what I see in the javadocs you should be able to do something like: Code: // Is the entity a creeper?! if (entity instanceof Creeper) { runAway(entity); // Oh! It's just a piggeh! } else if (entity instanceof Pig) { oink(entity); } I have no idea if this works in the latest build -- I haven't yet needed to test this functionality.
entity <- Get entity object if (entity.getClass().getName() == [desired Entity class location]) { //action }
The caveat, of course, is that the desired class name will not be obvious. The class name for creepers, for example, seems to be "org.bukkit.craftbukkit.entity.CraftCreeper". I'm also not certain that reference equality will work across class loaders (it may or may not depending upon the JVM implementation). In spite of being not very object-oriented, I think the instanceof test is much simpler.
Wow, that was a great update to entities. Thanks! Also, what is the difference between for example org.bukkit.entity.Creeper and org.bukkit.craftbukkit.entity.CraftCreeper
Okay, I have a question. Cloth blocks change colors by changing the byte. Is the same thing possible with mob spawners? in a line of code how would you define each type of spawner individulally?
Also, onEntityDamagedByEntity seems to behave very weird. For example sometimes when i hit mob, event will trigger 3x. Any idea?