2012-01-14 17:35:52 +00:00
|
|
|
package org.bukkit;
|
|
|
|
|
2012-01-29 11:10:40 +01:00
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
import com.google.common.collect.Maps;
|
2017-11-07 19:32:15 +11:00
|
|
|
import org.bukkit.entity.Ageable;
|
|
|
|
import org.bukkit.entity.ArmorStand;
|
|
|
|
import org.bukkit.entity.Entity;
|
|
|
|
import org.bukkit.entity.Firework;
|
|
|
|
import org.bukkit.entity.Guardian;
|
|
|
|
import org.bukkit.entity.IronGolem;
|
|
|
|
import org.bukkit.entity.LivingEntity;
|
|
|
|
import org.bukkit.entity.Rabbit;
|
|
|
|
import org.bukkit.entity.Squid;
|
|
|
|
import org.bukkit.entity.Tameable;
|
|
|
|
import org.bukkit.entity.TippedArrow;
|
|
|
|
import org.bukkit.entity.Villager;
|
|
|
|
import org.bukkit.entity.Witch;
|
|
|
|
import org.bukkit.entity.Wolf;
|
|
|
|
import org.bukkit.entity.ZombieVillager;
|
2012-01-29 11:10:40 +01:00
|
|
|
|
2012-01-14 17:35:52 +00:00
|
|
|
/**
|
|
|
|
* A list of all Effects that can happen to entities.
|
|
|
|
*/
|
|
|
|
public enum EntityEffect {
|
2012-01-15 14:37:30 +01:00
|
|
|
|
2017-11-07 19:32:15 +11:00
|
|
|
/**
|
|
|
|
* Colored particles from a tipped arrow.
|
|
|
|
*/
|
|
|
|
ARROW_PARTICLES(0, TippedArrow.class),
|
|
|
|
/**
|
|
|
|
* Rabbit jumping.
|
|
|
|
*/
|
|
|
|
RABBIT_JUMP(1, Rabbit.class),
|
2012-01-15 14:37:30 +01:00
|
|
|
/**
|
|
|
|
* When mobs get hurt.
|
|
|
|
*/
|
2017-11-07 19:32:15 +11:00
|
|
|
HURT(2, LivingEntity.class),
|
2012-01-15 14:37:30 +01:00
|
|
|
/**
|
|
|
|
* When a mob dies.
|
2013-04-02 00:11:22 -04:00
|
|
|
* <p>
|
2014-11-30 21:09:01 +00:00
|
|
|
* <b>This will cause client-glitches!</b>
|
2012-01-15 14:37:30 +01:00
|
|
|
*/
|
2017-11-07 19:32:15 +11:00
|
|
|
DEATH(3, LivingEntity.class),
|
|
|
|
/**
|
|
|
|
* Iron golem attacking.
|
|
|
|
*/
|
|
|
|
GOLEM_ATTACK(4, IronGolem.class),
|
|
|
|
// 5 - unused
|
2012-01-15 14:37:30 +01:00
|
|
|
/**
|
|
|
|
* The smoke when taming a wolf fails.
|
|
|
|
*/
|
2017-11-07 19:32:15 +11:00
|
|
|
WOLF_SMOKE(6, Tameable.class),
|
2012-01-15 14:37:30 +01:00
|
|
|
/**
|
|
|
|
* The hearts when taming a wolf succeeds.
|
|
|
|
*/
|
2017-11-07 19:32:15 +11:00
|
|
|
WOLF_HEARTS(7, Wolf.class),
|
2012-01-15 14:37:30 +01:00
|
|
|
/**
|
|
|
|
* When a wolf shakes (after being wet).
|
|
|
|
*/
|
2017-11-07 19:32:15 +11:00
|
|
|
WOLF_SHAKE(8, Wolf.class),
|
|
|
|
// 9 - unused
|
2012-01-29 11:10:40 +01:00
|
|
|
/**
|
2017-11-07 19:32:15 +11:00
|
|
|
* When an entity eats a LONG_GRASS block.
|
2012-01-29 11:10:40 +01:00
|
|
|
*/
|
2017-11-07 19:32:15 +11:00
|
|
|
SHEEP_EAT(10, LivingEntity.class),
|
2014-04-11 16:22:37 -06:00
|
|
|
/**
|
|
|
|
* When an Iron Golem gives a rose.
|
|
|
|
*/
|
2017-11-07 19:32:15 +11:00
|
|
|
IRON_GOLEM_ROSE(11, IronGolem.class),
|
2014-04-11 16:22:37 -06:00
|
|
|
/**
|
|
|
|
* Hearts from a villager.
|
|
|
|
*/
|
2017-11-07 19:32:15 +11:00
|
|
|
VILLAGER_HEART(12, Villager.class),
|
2014-04-11 16:22:37 -06:00
|
|
|
/**
|
|
|
|
* When a villager is angry.
|
|
|
|
*/
|
2017-11-07 19:32:15 +11:00
|
|
|
VILLAGER_ANGRY(13, Villager.class),
|
2014-04-11 16:22:37 -06:00
|
|
|
/**
|
|
|
|
* Happy particles from a villager.
|
|
|
|
*/
|
2017-11-07 19:32:15 +11:00
|
|
|
VILLAGER_HAPPY(14, Villager.class),
|
2014-04-11 16:22:37 -06:00
|
|
|
/**
|
|
|
|
* Magic particles from a witch.
|
|
|
|
*/
|
2017-11-07 19:32:15 +11:00
|
|
|
WITCH_MAGIC(15, Witch.class),
|
2014-04-11 16:22:37 -06:00
|
|
|
/**
|
|
|
|
* When a zombie transforms into a villager by shaking violently.
|
|
|
|
*/
|
2017-11-07 19:32:15 +11:00
|
|
|
ZOMBIE_TRANSFORM(16, ZombieVillager.class),
|
2014-04-11 16:22:37 -06:00
|
|
|
/**
|
|
|
|
* When a firework explodes.
|
|
|
|
*/
|
2017-11-07 19:32:15 +11:00
|
|
|
FIREWORK_EXPLODE(17, Firework.class),
|
|
|
|
/**
|
|
|
|
* Hearts from a breeding entity.
|
|
|
|
*/
|
|
|
|
LOVE_HEARTS(18, Ageable.class),
|
|
|
|
/**
|
|
|
|
* Resets squid rotation.
|
|
|
|
*/
|
|
|
|
SQUID_ROTATE(19, Squid.class),
|
|
|
|
/**
|
|
|
|
* Silverfish entering block, spawner spawning.
|
|
|
|
*/
|
|
|
|
ENTITY_POOF(20, LivingEntity.class),
|
|
|
|
/**
|
|
|
|
* Guardian sets laser target.
|
|
|
|
*/
|
|
|
|
GUARDIAN_TARGET(21, Guardian.class),
|
|
|
|
// 22-28 player internal flags
|
|
|
|
/**
|
|
|
|
* Shield blocks attack.
|
|
|
|
*/
|
|
|
|
SHIELD_BLOCK(29, LivingEntity.class),
|
|
|
|
/**
|
|
|
|
* Shield breaks.
|
|
|
|
*/
|
|
|
|
SHIELD_BREAK(30, LivingEntity.class),
|
|
|
|
// 31 - unused
|
|
|
|
/**
|
|
|
|
* Armor stand is hit.
|
|
|
|
*/
|
|
|
|
ARMOR_STAND_HIT(32, ArmorStand.class),
|
|
|
|
/**
|
|
|
|
* Entity hurt by thorns attack.
|
|
|
|
*/
|
|
|
|
THORNS_HURT(33, LivingEntity.class),
|
|
|
|
/**
|
|
|
|
* Iron golem puts away rose.
|
|
|
|
*/
|
|
|
|
IRON_GOLEM_SHEATH(34, IronGolem.class),
|
|
|
|
/**
|
|
|
|
* Totem prevents entity death.
|
|
|
|
*/
|
|
|
|
TOTEM_RESURRECT(35, LivingEntity.class),
|
|
|
|
/**
|
|
|
|
* Entity hurt due to drowning damage.
|
|
|
|
*/
|
|
|
|
HURT_DROWN(36, LivingEntity.class),
|
|
|
|
/**
|
|
|
|
* Entity hurt due to explosion damage.
|
|
|
|
*/
|
|
|
|
HURT_EXPLOSION(37, LivingEntity.class);
|
2012-01-15 14:37:30 +01:00
|
|
|
|
|
|
|
private final byte data;
|
2017-11-07 19:32:15 +11:00
|
|
|
private final Class<? extends Entity> applicable;
|
2012-01-29 11:10:40 +01:00
|
|
|
private final static Map<Byte, EntityEffect> BY_DATA = Maps.newHashMap();
|
2012-01-15 14:37:30 +01:00
|
|
|
|
2017-11-07 19:32:15 +11:00
|
|
|
EntityEffect(final int data, Class<? extends Entity> clazz) {
|
2012-01-29 11:10:40 +01:00
|
|
|
this.data = (byte) data;
|
2017-11-07 19:32:15 +11:00
|
|
|
this.applicable = clazz;
|
2012-01-15 14:37:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2012-02-26 10:35:17 -05:00
|
|
|
* Gets the data value of this EntityEffect
|
2012-01-29 11:10:40 +01:00
|
|
|
*
|
2012-02-26 10:35:17 -05:00
|
|
|
* @return The data value
|
2013-08-19 13:32:18 -05:00
|
|
|
* @deprecated Magic value
|
2012-01-15 14:37:30 +01:00
|
|
|
*/
|
2013-08-19 13:32:18 -05:00
|
|
|
@Deprecated
|
2012-01-15 14:37:30 +01:00
|
|
|
public byte getData() {
|
|
|
|
return data;
|
|
|
|
}
|
2012-01-29 11:10:40 +01:00
|
|
|
|
2017-11-07 19:32:15 +11:00
|
|
|
/**
|
|
|
|
* Gets entity superclass which this affect is applicable to.
|
|
|
|
*
|
|
|
|
* @return applicable class
|
|
|
|
*/
|
|
|
|
public Class<? extends Entity> getApplicable() {
|
|
|
|
return applicable;
|
|
|
|
}
|
|
|
|
|
2012-01-29 11:10:40 +01:00
|
|
|
/**
|
|
|
|
* Gets the EntityEffect with the given data value
|
|
|
|
*
|
|
|
|
* @param data Data value to fetch
|
2013-12-15 01:07:43 -05:00
|
|
|
* @return The {@link EntityEffect} representing the given value, or null
|
|
|
|
* if it doesn't exist
|
2013-08-19 13:32:18 -05:00
|
|
|
* @deprecated Magic value
|
2012-01-29 11:10:40 +01:00
|
|
|
*/
|
2013-08-19 13:32:18 -05:00
|
|
|
@Deprecated
|
2012-01-29 11:10:40 +01:00
|
|
|
public static EntityEffect getByData(final byte data) {
|
|
|
|
return BY_DATA.get(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static {
|
|
|
|
for (EntityEffect entityEffect : values()) {
|
|
|
|
BY_DATA.put(entityEffect.data, entityEffect);
|
|
|
|
}
|
|
|
|
}
|
2012-01-14 17:35:52 +00:00
|
|
|
}
|