Commits
Shreyas Ayyengar authored and md_5 committed 4e006d28fca
26 26 | +import org.bukkit.event.entity.EntityRegainHealthEvent; |
27 27 | +import org.bukkit.event.entity.EntityRemoveEvent; |
28 28 | +import org.bukkit.event.entity.EntityResurrectEvent; |
29 29 | +import org.bukkit.event.entity.EntityTeleportEvent; |
30 30 | +import org.bukkit.event.player.PlayerItemConsumeEvent; |
31 31 | +// CraftBukkit end |
32 32 | + |
33 33 | public abstract class EntityLiving extends Entity implements Attackable { |
34 34 | |
35 35 | private static final Logger LOGGER = LogUtils.getLogger(); |
36 + | |
37 + | private static final double MAX_LINE_OF_SIGHT_TEST_RANGE = 128.0D; |
38 + | protected static final int LIVING_ENTITY_FLAG_IS_USING = 1; |
39 + | protected static final int LIVING_ENTITY_FLAG_OFF_HAND = 2; |
40 + | - protected static final int LIVING_ENTITY_FLAG_SPIN_ATTACK = 4; |
41 + | + public static final int LIVING_ENTITY_FLAG_SPIN_ATTACK = 4; |
42 + | protected static final DataWatcherObject<Byte> DATA_LIVING_ENTITY_FLAGS = DataWatcher.defineId(EntityLiving.class, DataWatcherRegistry.BYTE); |
43 + | public static final DataWatcherObject<Float> DATA_HEALTH_ID = DataWatcher.defineId(EntityLiving.class, DataWatcherRegistry.FLOAT); |
44 + | private static final DataWatcherObject<List<ParticleParam>> DATA_EFFECT_PARTICLES = DataWatcher.defineId(EntityLiving.class, DataWatcherRegistry.PARTICLES); |
36 45 | |
37 46 | protected boolean skipDropExperience; |
38 47 | private final Reference2ObjectMap<Enchantment, Set<EnchantmentLocationBasedEffect>> activeLocationDependentEnchantments; |
39 48 | protected float appliedScale; |
40 49 | + // CraftBukkit start |
41 50 | + public int expToDrop; |
42 51 | + public ArrayList<org.bukkit.inventory.ItemStack> drops = new ArrayList<org.bukkit.inventory.ItemStack>(); |
43 52 | + public final org.bukkit.craftbukkit.attribute.CraftAttributeMap craftAttributes; |
44 53 | + public boolean collides = true; |
45 54 | + public Set<UUID> collidableExemptions = new HashSet<>(); |
1001 1010 | |
1002 1011 | if (map != null) { |
1003 1012 | |
1004 1013 | } |
1005 1014 | |
1006 1015 | if (!this.level().isClientSide) { |
1007 1016 | + if (flag != this.getSharedFlag(7) && !CraftEventFactory.callToggleGlideEvent(this, flag).isCancelled()) // CraftBukkit |
1008 1017 | this.setSharedFlag(7, flag); |
1009 1018 | } |
1010 1019 | |
1011 - | |
1020 + | |
1012 1021 | |
1013 1022 | @Override |
1014 1023 | public boolean isPickable() { |
1015 1024 | - return !this.isRemoved(); |
1016 1025 | + return !this.isRemoved() && this.collides; // CraftBukkit |
1017 1026 | } |
1018 1027 | |
1019 1028 | @Override |
1020 1029 | public boolean isPushable() { |
1021 1030 | - return this.isAlive() && !this.isSpectator() && !this.onClimbable(); |
1022 1031 | + return this.isAlive() && !this.isSpectator() && !this.onClimbable() && this.collides; // CraftBukkit |
1023 - | } |
1024 - | |
1032 + | + } |
1033 + | + |
1025 1034 | + // CraftBukkit start - collidable API |
1026 1035 | + @Override |
1027 1036 | + public boolean canCollideWithBukkit(Entity entity) { |
1028 1037 | + return isPushable() && this.collides != this.collidableExemptions.contains(entity.getUUID()); |
1029 - | + } |
1038 + | } |
1030 1039 | + // CraftBukkit end |
1031 - | + |
1040 + | |
1032 1041 | @Override |
1033 1042 | public float getYHeadRot() { |
1034 - | return this.yHeadRot; |
1043 + | |
1044 + | |
1045 + | } |
1046 + | |
1047 + | - protected void setLivingEntityFlag(int i, boolean flag) { |
1048 + | + public void setLivingEntityFlag(int i, boolean flag) { |
1049 + | int j = (Byte) this.entityData.get(EntityLiving.DATA_LIVING_ENTITY_FLAGS); |
1050 + | |
1051 + | if (flag) { |
1035 1052 | |
1036 1053 | } else { |
1037 1054 | if (!this.useItem.isEmpty() && this.isUsingItem()) { |
1038 1055 | this.triggerItemUseEffects(this.useItem, 16); |
1039 1056 | - ItemStack itemstack = this.useItem.finishUsingItem(this.level(), this); |
1040 1057 | + // CraftBukkit start - fire PlayerItemConsumeEvent |
1041 1058 | + ItemStack itemstack; |
1042 1059 | + if (this instanceof EntityPlayer) { |
1043 1060 | + org.bukkit.inventory.ItemStack craftItem = CraftItemStack.asBukkitCopy(this.useItem); |
1044 1061 | + org.bukkit.inventory.EquipmentSlot hand = org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(enumhand); |