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