Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
LivingEntity.java
1 package org.bukkit.entity;
2 
3 import java.util.Collection;
4 import java.util.HashSet;
5 import java.util.List;
6 
7 import org.bukkit.Location;
8 import org.bukkit.block.Block;
13 
14 /**
15  * Represents a living entity, such as a monster or player
16  */
17 public interface LivingEntity extends Entity, Damageable, ProjectileSource {
18 
19  /**
20  * Gets the height of the living entity's eyes above its Location.
21  *
22  * @return height of the living entity's eyes above its location
23  */
24  public double getEyeHeight();
25 
26  /**
27  * Gets the height of the living entity's eyes above its Location.
28  *
29  * @param ignoreSneaking if set to true, the effects of sneaking will be
30  * ignored
31  * @return height of the living entity's eyes above its location
32  */
33  public double getEyeHeight(boolean ignoreSneaking);
34 
35  /**
36  * Get a Location detailing the current eye position of the living entity.
37  *
38  * @return a location at the eyes of the living entity
39  */
40  public Location getEyeLocation();
41 
42  /**
43  * Gets all blocks along the living entity's line of sight.
44  * <p>
45  * This list contains all blocks from the living entity's eye position to
46  * target inclusive.
47  *
48  * @param transparent HashSet containing all transparent block IDs (set to
49  * null for only air)
50  * @param maxDistance this is the maximum distance to scan (may be limited
51  * by server by at least 100 blocks, no less)
52  * @return list containing all blocks along the living entity's line of
53  * sight
54  * @deprecated Magic value
55  */
56  @Deprecated
57  public List<Block> getLineOfSight(HashSet<Byte> transparent, int maxDistance);
58 
59  /**
60  * Gets the block that the living entity has targeted.
61  *
62  * @param transparent HashSet containing all transparent block IDs (set to
63  * null for only air)
64  * @param maxDistance this is the maximum distance to scan (may be limited
65  * by server by at least 100 blocks, no less)
66  * @return block that the living entity has targeted
67  * @deprecated Magic value
68  */
69  @Deprecated
70  public Block getTargetBlock(HashSet<Byte> transparent, int maxDistance);
71 
72  /**
73  * Gets the last two blocks along the living entity's line of sight.
74  * <p>
75  * The target block will be the last block in the list.
76  *
77  * @param transparent HashSet containing all transparent block IDs (set to
78  * null for only air)
79  * @param maxDistance this is the maximum distance to scan. This may be
80  * further limited by the server, but never to less than 100 blocks
81  * @return list containing the last 2 blocks along the living entity's
82  * line of sight
83  * @deprecated Magic value
84  */
85  @Deprecated
86  public List<Block> getLastTwoTargetBlocks(HashSet<Byte> transparent, int maxDistance);
87 
88  /**
89  * Throws an egg from the living entity.
90  *
91  * @deprecated use launchProjectile(Egg.class) instead
92  * @return the egg thrown
93  */
94  @Deprecated
95  public Egg throwEgg();
96 
97  /**
98  * Throws a snowball from the living entity.
99  *
100  * @deprecated use launchProjectile(Snowball.class) instead
101  * @return the snowball thrown
102  */
103  @Deprecated
104  public Snowball throwSnowball();
105 
106  /**
107  * Shoots an arrow from the living entity.
108  *
109  * @deprecated use launchProjectile(Arrow.class) instead
110  * @return the arrow shot
111  */
112  @Deprecated
113  public Arrow shootArrow();
114 
115  /**
116  * Returns the amount of air that the living entity has remaining, in
117  * ticks.
118  *
119  * @return amount of air remaining
120  */
121  public int getRemainingAir();
122 
123  /**
124  * Sets the amount of air that the living entity has remaining, in ticks.
125  *
126  * @param ticks amount of air remaining
127  */
128  public void setRemainingAir(int ticks);
129 
130  /**
131  * Returns the maximum amount of air the living entity can have, in ticks.
132  *
133  * @return maximum amount of air
134  */
135  public int getMaximumAir();
136 
137  /**
138  * Sets the maximum amount of air the living entity can have, in ticks.
139  *
140  * @param ticks maximum amount of air
141  */
142  public void setMaximumAir(int ticks);
143 
144  /**
145  * Returns the living entity's current maximum no damage ticks.
146  * <p>
147  * This is the maximum duration in which the living entity will not take
148  * damage.
149  *
150  * @return maximum no damage ticks
151  */
152  public int getMaximumNoDamageTicks();
153 
154  /**
155  * Sets the living entity's current maximum no damage ticks.
156  *
157  * @param ticks maximum amount of no damage ticks
158  */
159  public void setMaximumNoDamageTicks(int ticks);
160 
161  /**
162  * Returns the living entity's last damage taken in the current no damage
163  * ticks time.
164  * <p>
165  * Only damage higher than this amount will further damage the living
166  * entity.
167  *
168  * @return damage taken since the last no damage ticks time period
169  */
170  public double getLastDamage();
171 
172  /**
173  * This method exists for legacy reasons to provide backwards
174  * compatibility. It will not exist at runtime and should not be used
175  * under any circumstances.
176  */
177  @Deprecated
178  public int _INVALID_getLastDamage();
179 
180  /**
181  * Sets the damage dealt within the current no damage ticks time period.
182  *
183  * @param damage amount of damage
184  */
185  public void setLastDamage(double damage);
186 
187  /**
188  * This method exists for legacy reasons to provide backwards
189  * compatibility. It will not exist at runtime and should not be used
190  * under any circumstances.
191  */
192  @Deprecated
193  public void _INVALID_setLastDamage(int damage);
194 
195  /**
196  * Returns the living entity's current no damage ticks.
197  *
198  * @return amount of no damage ticks
199  */
200  public int getNoDamageTicks();
201 
202  /**
203  * Sets the living entity's current no damage ticks.
204  *
205  * @param ticks amount of no damage ticks
206  */
207  public void setNoDamageTicks(int ticks);
208 
209  /**
210  * Gets the player identified as the killer of the living entity.
211  * <p>
212  * May be null.
213  *
214  * @return killer player, or null if none found
215  */
216  public Player getKiller();
217 
218  /**
219  * Adds the given {@link PotionEffect} to the living entity.
220  * <p>
221  * Only one potion effect can be present for a given {@link
222  * PotionEffectType}.
223  *
224  * @param effect PotionEffect to be added
225  * @return whether the effect could be added
226  */
227  public boolean addPotionEffect(PotionEffect effect);
228 
229  /**
230  * Adds the given {@link PotionEffect} to the living entity.
231  * <p>
232  * Only one potion effect can be present for a given {@link
233  * PotionEffectType}.
234  *
235  * @param effect PotionEffect to be added
236  * @param force whether conflicting effects should be removed
237  * @return whether the effect could be added
238  */
239  public boolean addPotionEffect(PotionEffect effect, boolean force);
240 
241  /**
242  * Attempts to add all of the given {@link PotionEffect} to the living
243  * entity.
244  *
245  * @param effects the effects to add
246  * @return whether all of the effects could be added
247  */
248  public boolean addPotionEffects(Collection<PotionEffect> effects);
249 
250  /**
251  * Returns whether the living entity already has an existing effect of
252  * the given {@link PotionEffectType} applied to it.
253  *
254  * @param type the potion type to check
255  * @return whether the living entity has this potion effect active on them
256  */
257  public boolean hasPotionEffect(PotionEffectType type);
258 
259  /**
260  * Removes any effects present of the given {@link PotionEffectType}.
261  *
262  * @param type the potion type to remove
263  */
264  public void removePotionEffect(PotionEffectType type);
265 
266  /**
267  * Returns all currently active {@link PotionEffect}s on the living
268  * entity.
269  *
270  * @return a collection of {@link PotionEffect}s
271  */
272  public Collection<PotionEffect> getActivePotionEffects();
273 
274  /**
275  * Checks whether the living entity has block line of sight to another.
276  * <p>
277  * This uses the same algorithm that hostile mobs use to find the closest
278  * player.
279  *
280  * @param other the entity to determine line of sight to
281  * @return true if there is a line of sight, false if not
282  */
283  public boolean hasLineOfSight(Entity other);
284 
285  /**
286  * Returns if the living entity despawns when away from players or not.
287  * <p>
288  * By default, animals are not removed while other mobs are.
289  *
290  * @return true if the living entity is removed when away from players
291  */
292  public boolean getRemoveWhenFarAway();
293 
294  /**
295  * Sets whether or not the living entity despawns when away from players
296  * or not.
297  *
298  * @param remove the removal status
299  */
300  public void setRemoveWhenFarAway(boolean remove);
301 
302  /**
303  * Gets the inventory with the equipment worn by the living entity.
304  *
305  * @return the living entity's inventory
306  */
307  public EntityEquipment getEquipment();
308 
309  /**
310  * Sets whether or not the living entity can pick up items.
311  *
312  * @param pickup whether or not the living entity can pick up items
313  */
314  public void setCanPickupItems(boolean pickup);
315 
316  /**
317  * Gets if the living entity can pick up items.
318  *
319  * @return whether or not the living entity can pick up items
320  */
321  public boolean getCanPickupItems();
322 
323  /**
324  * Sets a custom name on a mob. This name will be used in death messages
325  * and can be sent to the client as a nameplate over the mob.
326  * <p>
327  * Setting the name to null or an empty string will clear it.
328  * <p>
329  * This value has no effect on players, they will always use their real
330  * name.
331  *
332  * @param name the name to set
333  */
334  public void setCustomName(String name);
335 
336  /**
337  * Gets the custom name on a mob. If there is no name this method will
338  * return null.
339  * <p>
340  * This value has no effect on players, they will always use their real
341  * name.
342  *
343  * @return name of the mob or null
344  */
345  public String getCustomName();
346 
347  /**
348  * Sets whether or not to display the mob's custom name client side. The
349  * name will be displayed above the mob similarly to a player.
350  * <p>
351  * This value has no effect on players, they will always display their
352  * name.
353  *
354  * @param flag custom name or not
355  */
356  public void setCustomNameVisible(boolean flag);
357 
358  /**
359  * Gets whether or not the mob's custom name is displayed client side.
360  * <p>
361  * This value has no effect on players, they will always display their
362  * name.
363  *
364  * @return if the custom name is displayed
365  */
366  public boolean isCustomNameVisible();
367 
368  /**
369  * Returns whether the entity is currently leashed.
370  *
371  * @return whether the entity is leashed
372  */
373  public boolean isLeashed();
374 
375  /**
376  * Gets the entity that is currently leading this entity.
377  *
378  * @return the entity holding the leash
379  * @throws IllegalStateException if not currently leashed
380  */
381  public Entity getLeashHolder() throws IllegalStateException;
382 
383  /**
384  * Sets the leash on this entity to be held by the supplied entity.
385  * <p>
386  * This method has no effect on EnderDragons, Withers, Players, or Bats.
387  * Non-living entities excluding leashes will not persist as leash
388  * holders.
389  *
390  * @param holder the entity to leash this entity to
391  * @return whether the operation was successful
392  */
393  public boolean setLeashHolder(Entity holder);
394 }
boolean setLeashHolder(Entity holder)
void setCustomName(String name)
void removePotionEffect(PotionEffectType type)
void setCanPickupItems(boolean pickup)
void setMaximumNoDamageTicks(int ticks)
void setCustomNameVisible(boolean flag)
void _INVALID_setLastDamage(int damage)
List< Block > getLastTwoTargetBlocks(HashSet< Byte > transparent, int maxDistance)
boolean hasPotionEffect(PotionEffectType type)
EntityEquipment getEquipment()
List< Block > getLineOfSight(HashSet< Byte > transparent, int maxDistance)
Collection< PotionEffect > getActivePotionEffects()
void setRemoveWhenFarAway(boolean remove)
void setRemainingAir(int ticks)
void damage(double amount)
Block getTargetBlock(HashSet< Byte > transparent, int maxDistance)
boolean addPotionEffects(Collection< PotionEffect > effects)
boolean hasLineOfSight(Entity other)
void setLastDamage(double damage)
boolean addPotionEffect(PotionEffect effect)
void setNoDamageTicks(int ticks)