001 package org.bukkit.entity;
002
003 import org.bukkit.Location;
004 import org.bukkit.EntityEffect;
005 import org.bukkit.Server;
006 import org.bukkit.World;
007 import org.bukkit.event.entity.EntityDamageEvent;
008 import org.bukkit.metadata.Metadatable;
009 import org.bukkit.util.Vector;
010
011 import java.util.List;
012 import java.util.UUID;
013 import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
014
015 /**
016 * Represents a base entity in the world
017 */
018 public interface Entity extends Metadatable {
019
020 /**
021 * Gets the entity's current position
022 *
023 * @return a new copy of Location containing the position of this entity
024 */
025 public Location getLocation();
026
027 /**
028 * Stores the entity's current position in the provided Location object.
029 * <p>
030 * If the provided Location is null this method does nothing and returns
031 * null.
032 *
033 * @return The Location object provided or null
034 */
035 public Location getLocation(Location loc);
036
037 /**
038 * Sets this entity's velocity
039 *
040 * @param velocity New velocity to travel with
041 */
042 public void setVelocity(Vector velocity);
043
044 /**
045 * Gets this entity's current velocity
046 *
047 * @return Current travelling velocity of this entity
048 */
049 public Vector getVelocity();
050
051 /**
052 * Returns true if the entity is supported by a block. This value is a
053 * state updated by the server and is not recalculated unless the entity
054 * moves.
055 *
056 * @return True if entity is on ground.
057 */
058 public boolean isOnGround();
059
060 /**
061 * Gets the current world this entity resides in
062 *
063 * @return World
064 */
065 public World getWorld();
066
067 /**
068 * Teleports this entity to the given location. If this entity is riding a
069 * vehicle, it will be dismounted prior to teleportation.
070 *
071 * @param location New location to teleport this entity to
072 * @return <code>true</code> if the teleport was successful
073 */
074 public boolean teleport(Location location);
075
076 /**
077 * Teleports this entity to the given location. If this entity is riding a
078 * vehicle, it will be dismounted prior to teleportation.
079 *
080 * @param location New location to teleport this entity to
081 * @param cause The cause of this teleportation
082 * @return <code>true</code> if the teleport was successful
083 */
084 public boolean teleport(Location location, TeleportCause cause);
085
086 /**
087 * Teleports this entity to the target Entity. If this entity is riding a
088 * vehicle, it will be dismounted prior to teleportation.
089 *
090 * @param destination Entity to teleport this entity to
091 * @return <code>true</code> if the teleport was successful
092 */
093 public boolean teleport(Entity destination);
094
095 /**
096 * Teleports this entity to the target Entity. If this entity is riding a
097 * vehicle, it will be dismounted prior to teleportation.
098 *
099 * @param destination Entity to teleport this entity to
100 * @param cause The cause of this teleportation
101 * @return <code>true</code> if the teleport was successful
102 */
103 public boolean teleport(Entity destination, TeleportCause cause);
104
105 /**
106 * Returns a list of entities within a bounding box centered around this
107 * entity
108 *
109 * @param x 1/2 the size of the box along x axis
110 * @param y 1/2 the size of the box along y axis
111 * @param z 1/2 the size of the box along z axis
112 * @return List<Entity> List of entities nearby
113 */
114 public List<org.bukkit.entity.Entity> getNearbyEntities(double x, double y, double z);
115
116 /**
117 * Returns a unique id for this entity
118 *
119 * @return Entity id
120 */
121 public int getEntityId();
122
123 /**
124 * Returns the entity's current fire ticks (ticks before the entity stops
125 * being on fire).
126 *
127 * @return int fireTicks
128 */
129 public int getFireTicks();
130
131 /**
132 * Returns the entity's maximum fire ticks.
133 *
134 * @return int maxFireTicks
135 */
136 public int getMaxFireTicks();
137
138 /**
139 * Sets the entity's current fire ticks (ticks before the entity stops
140 * being on fire).
141 *
142 * @param ticks Current ticks remaining
143 */
144 public void setFireTicks(int ticks);
145
146 /**
147 * Mark the entity's removal.
148 */
149 public void remove();
150
151 /**
152 * Returns true if this entity has been marked for removal.
153 *
154 * @return True if it is dead.
155 */
156 public boolean isDead();
157
158 /**
159 * Returns false if the entity has died or been despawned for some other
160 * reason.
161 *
162 * @return True if valid.
163 */
164 public boolean isValid();
165
166 /**
167 * Gets the {@link Server} that contains this Entity
168 *
169 * @return Server instance running this Entity
170 */
171 public Server getServer();
172
173 /**
174 * Gets the primary passenger of a vehicle. For vehicles that could have
175 * multiple passengers, this will only return the primary passenger.
176 *
177 * @return an entity
178 */
179 public abstract Entity getPassenger();
180
181 /**
182 * Set the passenger of a vehicle.
183 *
184 * @param passenger The new passenger.
185 * @return false if it could not be done for whatever reason
186 */
187 public abstract boolean setPassenger(Entity passenger);
188
189 /**
190 * Check if a vehicle has passengers.
191 *
192 * @return True if the vehicle has no passengers.
193 */
194 public abstract boolean isEmpty();
195
196 /**
197 * Eject any passenger.
198 *
199 * @return True if there was a passenger.
200 */
201 public abstract boolean eject();
202
203 /**
204 * Returns the distance this entity has fallen
205 *
206 * @return The distance.
207 */
208 public float getFallDistance();
209
210 /**
211 * Sets the fall distance for this entity
212 *
213 * @param distance The new distance.
214 */
215 public void setFallDistance(float distance);
216
217 /**
218 * Record the last {@link EntityDamageEvent} inflicted on this entity
219 *
220 * @param event a {@link EntityDamageEvent}
221 */
222 public void setLastDamageCause(EntityDamageEvent event);
223
224 /**
225 * Retrieve the last {@link EntityDamageEvent} inflicted on this entity.
226 * This event may have been cancelled.
227 *
228 * @return the last known {@link EntityDamageEvent} or null if hitherto
229 * unharmed
230 */
231 public EntityDamageEvent getLastDamageCause();
232
233 /**
234 * Returns a unique and persistent id for this entity
235 *
236 * @return unique id
237 */
238 public UUID getUniqueId();
239
240 /**
241 * Gets the amount of ticks this entity has lived for.
242 * <p>
243 * This is the equivalent to "age" in entities.
244 *
245 * @return Age of entity
246 */
247 public int getTicksLived();
248
249 /**
250 * Sets the amount of ticks this entity has lived for.
251 * <p>
252 * This is the equivalent to "age" in entities. May not be less than one
253 * tick.
254 *
255 * @param value Age of entity
256 */
257 public void setTicksLived(int value);
258
259 /**
260 * Performs the specified {@link EntityEffect} for this entity.
261 * <p>
262 * This will be viewable to all players near the entity.
263 *
264 * @param type Effect to play.
265 */
266 public void playEffect(EntityEffect type);
267
268 /**
269 * Get the type of the entity.
270 *
271 * @return The entity type.
272 */
273 public EntityType getType();
274
275 /**
276 * Returns whether this entity is inside a vehicle.
277 *
278 * @return True if the entity is in a vehicle.
279 */
280 public boolean isInsideVehicle();
281
282 /**
283 * Leave the current vehicle. If the entity is currently in a vehicle (and
284 * is removed from it), true will be returned, otherwise false will be
285 * returned.
286 *
287 * @return True if the entity was in a vehicle.
288 */
289 public boolean leaveVehicle();
290
291 /**
292 * Get the vehicle that this player is inside. If there is no vehicle,
293 * null will be returned.
294 *
295 * @return The current vehicle.
296 */
297 public Entity getVehicle();
298 }