001/*
002 * Trident - A Multithreaded Server Alternative
003 * Copyright 2014 The TridentSDK Team
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 *    http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018package net.tridentsdk.entity;
019
020import net.tridentsdk.base.BoundingBox;
021import net.tridentsdk.base.Position;
022import net.tridentsdk.entity.traits.EntityProperties;
023import net.tridentsdk.entity.types.EntityType;
024import net.tridentsdk.util.Vector;
025import net.tridentsdk.world.World;
026
027import java.util.Set;
028import java.util.UUID;
029
030/**
031 * Represents the abstraction for a mob, player, animal, or other "object" that is not a block type
032 *
033 * @author The TridentSDK Team
034 * @since 0.3-alpha-DP
035 */
036public interface Entity {
037    /**
038     * Moves the entity to the specified position
039     *
040     * @param x the x coordinate of the position
041     * @param y the y coordinate of the position
042     * @param z the z coordinate of the position
043     */
044    void teleport(double x, double y, double z);
045
046    /**
047     * Moves the current entity to the provided entity's position
048     *
049     * @param entity the entity to move the current entity to
050     */
051    void teleport(Entity entity);
052
053    /**
054     * Moves the entity to the coordinates specified by the position object passed in
055     *
056     * @param position the position to move the entity to
057     */
058    void teleport(Position position);
059
060    /**
061     * The world which the entity resides in
062     *
063     * @return the world that contains the entity
064     */
065    World world();
066
067    /**
068     * The position of the entity with respect to the coordinate grid
069     *
070     * @return the entity's position
071     */
072    Position position();
073
074    /**
075     * The direction and movement magnitude of the entity
076     *
077     * @return the vector representing the entity's velocity
078     */
079    Vector velocity();
080
081    /**
082     * Sets the entity's movement direction and speed to the magnitude of the vector
083     *
084     * @param vector the vector to set the entity velocity to
085     */
086    void setVelocity(Vector vector);
087
088    /**
089     * Checks if the entity is currently on the ground, or at least touching the ground
090     *
091     * @return {@code true} if the entity touches the ground, {@code false} if it is in the air (such as if it was
092     * falling)
093     */
094    boolean onGround();
095
096    /**
097     * Gets the entities that are within proximity to this entity
098     *
099     * @param radius the spherical radius to look for entities around
100     * @return the collection of entities within the radius around the entity
101     */
102    Set<Entity> withinRange(double radius);
103
104    /**
105     * Gets the display name for the entity, used on inventories and deaths
106     *
107     * @return Display name
108     */
109    String displayName();
110
111    /**
112     * Sets the entity's display name, effects inventories (if applicable) and death messages
113     *
114     * @param name Entity name
115     */
116    void setDisplayName(String name);
117
118    /**
119     * Gets if the entity's display name visible
120     *
121     * @return if the entity's display name visible
122     */
123    boolean isNameVisible();
124
125    /**
126     * Gets if the entity is silent (sounds)
127     *
128     * @return if the entity is silent
129     */
130    boolean isSilent();
131
132    /**
133     * The identifier for this entity for runtime, see uniqueId for a set id of the entity
134     *
135     * @return the id to all entities on the server at runtime
136     * @see net.tridentsdk.entity.Entity#uniqueId()
137     */
138    int entityId();
139
140    /**
141     * The unique id for the entity to the server
142     *
143     * @return The unique id for the entity
144     */
145    UUID uniqueId();
146
147    /**
148     * Removes the entity from the world and destroys it, freeing all memory associated with it
149     */
150    void remove();
151
152    /**
153     * Gets the entity that is riding this entity, if there is any
154     *
155     * @return the entity that is riding, {@code null} if there are none
156     */
157    Entity passenger();
158
159    /**
160     * Mounts the specified entity on this entity
161     *
162     * @param entity the entity to set passenger to this entity
163     */
164    void setPassenger(Entity entity);
165
166    /**
167     * Removes the mounted entity, if there are any
168     */
169    void eject();
170
171    /**
172     * Gets the type of entity
173     *
174     * @return the entity type that is represented
175     */
176    EntityType type();
177
178    /**
179     * Sets the properties of this entity to the specified properties
180     *
181     * @param properties the properties to set
182     */
183    void applyProperties(EntityProperties properties);
184
185    /**
186     * Set the width and height of the entity
187     *
188     * @param width Width of entity
189     * @param height Height of entity
190     */
191    void setSize(float width, float height);
192
193    /**
194     * Returns the bounding box of the entity
195     *
196     * @return The bounding box of the entity
197     */
198    BoundingBox boundingBox();
199}