001    package org.bukkit.entity;
002    
003    import java.util.Collection;
004    import java.util.HashSet;
005    import java.util.List;
006    
007    import org.bukkit.Location;
008    import org.bukkit.block.Block;
009    import org.bukkit.inventory.EntityEquipment;
010    import org.bukkit.potion.PotionEffect;
011    import org.bukkit.potion.PotionEffectType;
012    
013    /**
014     * Represents a living entity, such as a monster or player
015     */
016    public interface LivingEntity extends Entity, Damageable {
017        /**
018         * Gets the height of the entity's head above its Location
019         *
020         * @return Height of the entity's eyes above its Location
021         */
022        public double getEyeHeight();
023    
024        /**
025         * Gets the height of the entity's head above its Location
026         *
027         * @param ignoreSneaking If set to true, the effects of sneaking will be ignored
028         * @return Height of the entity's eyes above its Location
029         */
030        public double getEyeHeight(boolean ignoreSneaking);
031    
032        /**
033         * Get a Location detailing the current eye position of the LivingEntity.
034         *
035         * @return a Location at the eyes of the LivingEntity.
036         */
037        public Location getEyeLocation();
038    
039        /**
040         * Gets all blocks along the player's line of sight
041         * List iterates from player's position to target inclusive
042         *
043         * @param transparent HashSet containing all transparent block IDs. If set to null only air is considered transparent.
044         * @param maxDistance This is the maximum distance to scan. This may be further limited by the server, but never to less than 100 blocks.
045         * @return List containing all blocks along the player's line of sight
046         */
047        public List<Block> getLineOfSight(HashSet<Byte> transparent, int maxDistance);
048    
049        /**
050         * Gets the block that the player has targeted
051         *
052         * @param transparent HashSet containing all transparent block IDs. If set to null only air is considered transparent.
053         * @param maxDistance This is the maximum distance to scan. This may be further limited by the server, but never to less than 100 blocks.
054         * @return Block that the player has targeted
055         */
056        public Block getTargetBlock(HashSet<Byte> transparent, int maxDistance);
057    
058        /**
059         * Gets the last two blocks along the player's line of sight.
060         * The target block will be the last block in the list.
061         *
062         * @param transparent HashSet containing all transparent block IDs. If set to null only air is considered transparent.
063         * @param maxDistance This is the maximum distance to scan. This may be further limited by the server, but never to less than 100 blocks
064         * @return List containing the last 2 blocks along the player's line of sight
065         */
066        public List<Block> getLastTwoTargetBlocks(HashSet<Byte> transparent, int maxDistance);
067    
068        /**
069         * Throws an egg from the entity.
070         *
071         * @deprecated Use launchProjectile(Egg.class) instead
072         * @return The egg thrown.
073         */
074        @Deprecated
075        public Egg throwEgg();
076    
077        /**
078         * Throws a snowball from the entity.
079         *
080         * @deprecated Use launchProjectile(Snowball.class) instead
081         * @return The snowball thrown.
082         */
083        @Deprecated
084        public Snowball throwSnowball();
085    
086        /**
087         * Shoots an arrow from the entity.
088         *
089         * @deprecated Use launchProjectile(Arrow.class) instead
090         * @return The arrow shot.
091         */
092        @Deprecated
093        public Arrow shootArrow();
094    
095        /**
096         * Launches a {@link Projectile} from the entity.
097         *
098         * @param projectile Class of the projectile to launch
099         *
100         * @return The launched projectile.
101         */
102        public <T extends Projectile> T launchProjectile(Class<? extends T> projectile);
103    
104        /**
105         * Returns the amount of air that this entity has remaining, in ticks
106         *
107         * @return Amount of air remaining
108         */
109        public int getRemainingAir();
110    
111        /**
112         * Sets the amount of air that this entity has remaining, in ticks
113         *
114         * @param ticks Amount of air remaining
115         */
116        public void setRemainingAir(int ticks);
117    
118        /**
119         * Returns the maximum amount of air this entity can have, in ticks
120         *
121         * @return Maximum amount of air
122         */
123        public int getMaximumAir();
124    
125        /**
126         * Sets the maximum amount of air this entity can have, in ticks
127         *
128         * @param ticks Maximum amount of air
129         */
130        public void setMaximumAir(int ticks);
131    
132        /**
133         * Returns the entities current maximum noDamageTicks
134         * This is the time in ticks the entity will become unable to take
135         * equal or less damage than the lastDamage
136         *
137         * @return noDamageTicks
138         */
139        public int getMaximumNoDamageTicks();
140    
141        /**
142         * Sets the entities current maximum noDamageTicks
143         *
144         * @param ticks maximumNoDamageTicks
145         */
146        public void setMaximumNoDamageTicks(int ticks);
147    
148        /**
149         * Returns the entities lastDamage taken in the current noDamageTicks time.
150         * Only damage higher than this amount will further damage the entity.
151         *
152         * @return lastDamage
153         */
154        public int getLastDamage();
155    
156        /**
157         * Sets the entities current maximum noDamageTicks
158         *
159         * @param damage last damage
160         */
161        public void setLastDamage(int damage);
162    
163        /**
164         * Returns the entities current noDamageTicks
165         *
166         * @return noDamageTicks
167         */
168        public int getNoDamageTicks();
169    
170        /**
171         * Sets the entities current noDamageTicks
172         *
173         * @param ticks NoDamageTicks
174         */
175        public void setNoDamageTicks(int ticks);
176    
177        /**
178         * Gets the player identified as the killer of this entity.
179         * <p />
180         * May be null.
181         *
182         * @return Killer player, or null if none found.
183         */
184        public Player getKiller();
185    
186        /**
187         * Adds the given {@link PotionEffect} to this entity.
188         * Only one potion effect can be present for a given {@link PotionEffectType}.
189         *
190         * @param effect PotionEffect to be added
191         * @return Whether the effect could be added
192         */
193        public boolean addPotionEffect(PotionEffect effect);
194    
195        /**
196         * Adds the given {@link PotionEffect} to this entity.
197         * Only one potion effect can be present for a given {@link PotionEffectType}.
198         *
199         * @param effect PotionEffect to be added
200         * @param force Whether conflicting effects should be removed
201         * @return Whether the effect could be added
202         */
203        public boolean addPotionEffect(PotionEffect effect, boolean force);
204    
205        /**
206         * Attempts to add all of the given {@link PotionEffect} to this entity.
207         *
208         * @param effects The effects to add
209         * @return Whether all of the effects could be added
210         */
211        public boolean addPotionEffects(Collection<PotionEffect> effects);
212    
213        /**
214         * Returns whether the entity already has an existing
215         * effect of the given {@link PotionEffectType} applied to it.
216         *
217         * @param type The potion type to check
218         * @return Whether the player has this potion effect active on them.
219         */
220        public boolean hasPotionEffect(PotionEffectType type);
221    
222        /**
223         * Removes any effects present of the given {@link PotionEffectType}.
224         *
225         * @param type The potion type to remove
226         */
227        public void removePotionEffect(PotionEffectType type);
228    
229        /**
230         * Returns all currently active {@link PotionEffect}s on this entity.
231         *
232         * @return A collection of {@link PotionEffect}s
233         */
234        public Collection<PotionEffect> getActivePotionEffects();
235    
236        /**
237         * Checks whether the entity has block line of sight to another.<br />
238         * This uses the same algorithm that hostile mobs use to find the closest player.
239         *
240         * @param other The entity to determine line of sight to.
241         * @return true if there is a line of sight, false if not.
242         */
243        public boolean hasLineOfSight(Entity other);
244    
245        /**
246         * Returns if the entity despawns when away from players or not.<br />
247         * By default animals are not removed while other mobs are.
248         *
249         * @return true if the entity is removed when away from players
250         */
251        public boolean getRemoveWhenFarAway();
252    
253        /**
254         * Sets whether or not the entity despawns when away from players or not.
255         *
256         * @param remove The remove status
257         */
258        public void setRemoveWhenFarAway(boolean remove);
259    
260        /**
261         *  Gets the inventory with the equipment worn by this entity.
262         *
263         *  @return the entities inventory.
264         */
265        public EntityEquipment getEquipment();
266    
267        /**
268         * Sets whether or not the entity can pick up items
269         *
270         * @param pickup Whether or not the entity can pick up items
271         */
272        public void setCanPickupItems(boolean pickup);
273    
274        /**
275         * Gets if the entity can pick up items
276         *
277         * @return whether or not the entity can pick up items
278         */
279        public boolean getCanPickupItems();
280    }