
org.bukkit.entity.Entity Maven / Gradle / Ivy
package org.bukkit.entity;
import net.md_5.bungee.api.chat.TextComponent;
import net.minecraft.server.AxisAlignedBB;
import net.minecraft.server.NBTTagCompound;
import org.bukkit.EntityEffect;
import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.metadata.Metadatable;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
import walkmc.Direction;
import walkmc.annotation.FromWalk;
import walkmc.interfaces.Localizable;
import walkmc.serializer.tag.impl.CompoundTag;
import java.util.List;
import java.util.UUID;
/**
* Represents a base entity in the world
*/
public interface Entity extends Metadatable, CommandSender, Comparable, Localizable {
@Override
@FromWalk
default int compareTo(@NotNull Entity o) {
return getUniqueId().compareTo(o.getUniqueId());
}
/**
* Pushs this entity in their coordinates with the given arguments.
*
* @param x the push strength for coordinate x
* @param y the push strength for coordinate y
* @param z the push strength for coordinate z
* @return the same entity for convenience
*/
Entity push(double x, double y, double z);
/**
* Pushs this entity in their direction with the given arguments.
*
* @param x the push strength for coordinate x
* @param y the push strength for coordinate y
* @param z the push strength for coordinate z
* @return the same entity for convenience
*/
Entity pushDirection(double x, double y, double z);
/**
* Pushs this entity to higher with the given strength.
*
* @param strength the push strength for coordinate y
* @return the same entity for convenience
*/
Entity pushHigh(double strength);
/**
* Returns if this entity has artificial intelligence.
*
* If this entity is not an insentient entity will returns false.
*/
boolean hasAI();
/**
* Sets if this entity has artificial intelligence.
*
* If this entity is not an insentient entity nothing will be changed.
*/
void setAI(boolean has);
/**
* Returns if this entity is persistent.
*
* If this entity is not an insentient entity will returns false.
*/
boolean isPersistent();
/**
* Sets if this entity as persistent.
*
* If this entity is not an insentient entity nothing will be changed.
*/
void setPersistent(boolean persistent);
/**
* Gets if this entity is silent.
*/
boolean isSilent();
/**
* Sets this entity silent.
*/
void setSilent(boolean silent);
/**
* Returns if this entity is in liquid.
*/
boolean isInLiquid();
/**
* Returns if this entity is in lava.
*/
boolean isInLava();
/**
* How high this entity can step up when running into a block to try to get over it
* (currently make note the entity will always step up this amount and not just the amount needed)
*
* @return the step height of this entity.
*/
float getStepHeight();
/**
* How high this entity can step up when running into a block to try to get over it
* (currently make note the entity will always step up this amount and not just the amount needed)
*/
void setStepHeight(float height);
/**
* Reduces the velocity applied by entity collisions by the specified percent.
*/
float getCollisionReduction();
/**
* Reduces the velocity applied by entity collisions by the specified percent.
*/
void setCollisionReduction(float reduction);
/**
* If this entity is invulnerable to any type of damage.
*/
boolean isInvulnerable();
/**
* Sets this entity invulnerable to any type of damage.
*/
void setInvulnerable(boolean invulnerable);
/**
* If this entity is immune to fire or lava
*/
boolean isFireProof();
/**
* If this entity is immune to fire or lava
*/
void setFireProof(boolean proof);
/**
* Gets the bounding box of this entity.
*/
AxisAlignedBB getBoundingBox();
/**
* Sets the bounding box of this entity.
*/
void setBoundingBox(AxisAlignedBB box);
/**
* If this entity is spawned from a spawner.
*/
boolean isFromSpawner();
/**
* Sets this entity as spawned from a spawner.
*/
void setFromSpawner(boolean fromSpawner);
/**
* The distance that has to be exceeded in order to triger
* a new step sound and an onEntityWalking event on a block
*/
int getNextStepDistance();
/**
* The distance that has to be exceeded in order to triger
* a new step sound and an onEntityWalking event on a block
*/
void setNextStepDistance(int distance);
/**
* Whether the entity is inside a Portal
*/
boolean isInPortal();
/**
* Gets the portal delay to teleport
*/
int getPortalDelay();
/**
* Sets the portal delay to teleport
*/
void setPortalDelay(int delay);
/**
* Gets the portal delay counter to teleport
*/
int getPortalCounter();
/**
* Sets the portal delay counter to teleport
*/
void setPortalCounter(int counter);
/**
* If this entity has their air borne.
*/
boolean isAirBorne();
/**
* Sets if this entity has their air borne.
*/
void setAirBorne(boolean borne);
/**
* Render entity even if it is outside the camera frustum. Only true in EntityFish for now.
* Used in RenderGlobal: render if ignoreFrustumCheck or in frustum.
*/
boolean getIgnoreFrustumCheck();
/**
* Render entity even if it is outside the camera frustum. Only true in EntityFish for now.
* Used in RenderGlobal: render if ignoreFrustumCheck or in frustum.
*/
void setIgnoreFrustumCheck(boolean ignore);
/**
* Gets the no damage ticks of this entity.
*/
int getNoDamageTicks();
/**
* Sets the no damage ticks of this entity.
*/
void setNoDamageTicks(int ticks);
/**
* True if after a move this entity has collided with something on X- or Z-axis
*/
boolean isCollidedHorizontally();
/**
* True if after a move this entity has collided with something on Y-axis
*/
boolean isCollidedVertically();
/**
* True if after a move this entity has collided with something either vertically or horizontally
*/
boolean isCollided();
/**
* Returns if this entity is in web.
*/
boolean isInWeb();
/**
* Gets the nbt tag of this entity.
*/
NBTTagCompound getTag();
/**
* Sets the new nbt tag of this entity.
*/
void setTag(NBTTagCompound tag);
/**
* Gets the persistent storage tag of this entity.
*/
CompoundTag getStorage();
/**
* Sets the new persistent storage tag of this entity.
*/
void setStorage(CompoundTag tag);
/**
* Gets the NMS entity handler of this entity.
*/
@FromWalk
net.minecraft.server.Entity getHandler();
/**
* Gets the direction that this entity is looking.
*/
@FromWalk
Direction getLookDirection();
/**
* Sets the custom name of this entity for only the specified player.
*
* @param player the only player that's will see the new custom name
* @param name the custom name to set
*/
@FromWalk
void setCustomNameTo(Player player, String name);
/**
* Sets the visibility of the custom name of this entity for only the specified player.
*
* @param player the only player that's will see the new visibility
* @param visible the visibility of the custom name
*/
@FromWalk
void setCustomNameVisibleTo(Player player, boolean visible);
/**
* Removes the custom name only visible for player.
*
* This will show the server-side custom name of the entity to the player.
*/
@FromWalk
void removeCustomNameTo(Player player);
/**
* Returns the current custom name only visible for player.
*/
@FromWalk
String getCustomNameTo(Player player);
/**
* Returns if this entity has a custom name only visible for the player.
*/
@FromWalk
boolean hasCustomNameTo(Player player);
/**
* Sets this entity invisible for the specified player.
*/
@FromWalk
void hideTo(Player player);
/**
* Sets this entity visible for the specified player.
*/
@FromWalk
void showTo(Player player);
/**
* Returns a text component with hover event displaying information of this entity.
*/
@FromWalk
TextComponent getTextComponent(String text);
/**
* Returns the clip state of this entity.
*
* Clip state is used to limit actions. Most commonly used in spectador and adventure game mode.
*/
@FromWalk
boolean getClip();
/**
* Sets the clip state of this entity.
*
* Clip state is used to limit actions. Most commonly used in spectador and adventure game mode.
*/
@FromWalk
void setClip(boolean clip);
/**
* Returns if this entity is on water.
*/
@FromWalk
boolean isInWater();
/**
* Sets this entity to look at the specified entity.
*/
@FromWalk
void lookAt(Entity entity);
/**
* Sets this entity to look at the specified location.
*/
@FromWalk
void lookAt(Location location);
/**
* Returns if this entity is colliding with another entity.
*/
@FromWalk
boolean isColliding(Entity other);
/**
* Gets the yaw value of this entity.
*/
@FromWalk
float getYaw();
/**
* Gets the pitch value of this entity.
*/
@FromWalk
float getPitch();
/**
* Sets the yaw value of this entity.
*/
@FromWalk
void setYaw(float yaw);
/**
* Sets the pitch value of this entity.
*/
@FromWalk
void setPitch(float pitch);
/**
* Gets the entity's current position
*
* @return a new copy of Location containing the position of this entity
*/
@NotNull
Location getLocation();
/**
* Stores the entity's current position in the provided Location object.
*
* If the provided Location is null this method does nothing and returns
* null.
*
* @param loc the location to copy into
* @return The Location object provided or null
*/
Location getLocation(Location loc);
/**
* Gets this entity's current velocity
*
* @return Current travelling velocity of this entity
*/
Vector getVelocity();
/**
* Sets this entity's velocity
*
* @param velocity New velocity to travel with
*/
void setVelocity(Vector velocity);
/**
* Returns true if the entity is supported by a block. This value is a
* state updated by the server and is not recalculated unless the entity
* moves.
*
* @return True if entity is on ground.
*/
boolean isOnGround();
/**
* Gets the current world this entity resides in
*
* @return World
*/
World getWorld();
/**
* Teleports this entity to the given location. If this entity is riding a
* vehicle, it will be dismounted prior to teleportation.
*
* @param location New location to teleport this entity to
* @return true
if the teleport was successful
*/
boolean teleport(Location location);
/**
* Teleports this entity to the given location. If this entity is riding a
* vehicle, it will be dismounted prior to teleportation.
*
* @param location New location to teleport this entity to
* @param cause The cause of this teleportation
* @return true
if the teleport was successful
*/
boolean teleport(Location location, TeleportCause cause);
/**
* Teleports this entity to the target Entity. If this entity is riding a
* vehicle, it will be dismounted prior to teleportation.
*
* @param destination Entity to teleport this entity to
* @return true
if the teleport was successful
*/
boolean teleport(Entity destination);
/**
* Teleports this entity to the target Entity. If this entity is riding a
* vehicle, it will be dismounted prior to teleportation.
*
* @param destination Entity to teleport this entity to
* @param cause The cause of this teleportation
* @return true
if the teleport was successful
*/
boolean teleport(Entity destination, TeleportCause cause);
/**
* Returns a list of entities within a bounding box centered around this
* entity
*
* @param x 1/2 the size of the box along x-axis
* @param y 1/2 the size of the box along y-axis
* @param z 1/2 the size of the box along z-axis
* @return {@code List} List of entities nearby
*/
List getNearbyEntities(double x, double y, double z);
/**
* Returns a unique id for this entity
*
* @return Entity id
*/
int getEntityId();
/**
* Returns the entity's current fire ticks (ticks before the entity stops
* being on fire).
*
* @return int fireTicks
*/
int getFireTicks();
/**
* Sets the entity's current fire ticks (ticks before the entity stops
* being on fire).
*
* @param ticks Current ticks remaining
*/
void setFireTicks(int ticks);
/**
* Returns the entity's maximum fire ticks.
*
* @return int maxFireTicks
*/
int getMaxFireTicks();
void setMaxFireTicks(int ticks);
/**
* Mark the entity's removal.
*/
void remove();
/**
* Returns true if this entity has been marked for removal.
*
* @return True if it is dead.
*/
boolean isDead();
/**
* Returns false if the entity has died or been despawned for some other
* reason.
*
* @return True if valid.
*/
boolean isValid();
/**
* Gets the {@link Server} that contains this Entity
*
* @return Server instance running this Entity
*/
Server getServer();
/**
* Gets the primary passenger of a vehicle. For vehicles that could have
* multiple passengers, this will only return the primary passenger.
*
* @return an entity
*/
Entity getPassenger();
/**
* Set the passenger of a vehicle.
*
* @param passenger The new passenger.
* @return false if it could not be done for whatever reason
*/
boolean setPassenger(Entity passenger);
/**
* Check if a vehicle has passengers.
*
* @return True if the vehicle has no passengers.
*/
boolean isEmpty();
/**
* Eject any passenger.
*
* @return True if there was a passenger.
*/
boolean eject();
/**
* Returns the distance this entity has fallen
*
* @return The distance.
*/
float getFallDistance();
/**
* Sets the fall distance for this entity
*
* @param distance The new distance.
*/
void setFallDistance(float distance);
/**
* Retrieve the last {@link EntityDamageEvent} inflicted on this entity.
* This event may have been cancelled.
*
* @return the last known {@link EntityDamageEvent} or null if hitherto
* unharmed
*/
EntityDamageEvent getLastDamageCause();
/**
* Record the last {@link EntityDamageEvent} inflicted on this entity
*
* @param event a {@link EntityDamageEvent}
*/
void setLastDamageCause(EntityDamageEvent event);
/**
* Returns a unique and persistent id for this entity
*
* @return unique id
*/
UUID getUniqueId();
/**
* Gets the amount of ticks this entity has lived for.
*
* This is the equivalent to "age" in entities.
*
* @return Age of entity
*/
int getTicksLived();
/**
* Sets the amount of ticks this entity has lived for.
*
* This is the equivalent to "age" in entities. May not be less than one
* tick.
*
* @param value Age of entity
*/
void setTicksLived(int value);
/**
* Performs the specified {@link EntityEffect} for this entity.
*
* This will be viewable to all players near the entity.
*
* @param type Effect to play.
*/
void playEffect(EntityEffect type);
/**
* Get the type of the entity.
*
* @return The entity type.
*/
EntityType getType();
/**
* Returns whether this entity is inside a vehicle.
*
* @return True if the entity is in a vehicle.
*/
boolean isInsideVehicle();
/**
* Leave the current vehicle. If the entity is currently in a vehicle (and
* is removed from it), true will be returned, otherwise false will be
* returned.
*
* @return True if the entity was in a vehicle.
*/
boolean leaveVehicle();
/**
* Get the vehicle that this player is inside. If there is no vehicle,
* null will be returned.
*
* @return The current vehicle.
*/
Entity getVehicle();
/**
* Gets the custom name on a mob. If there is no name this method will
* return null.
*
* This value has no effect on players, they will always use their real
* name.
*
* @return name of the mob or null
*/
String getCustomName();
/**
* Sets a custom name on a mob. This name will be used in death messages
* and can be sent to the client as a nameplate over the mob.
*
* Setting the name to null or an empty string will clear it.
*
* This value has no effect on players, they will always use their real
* name.
*
* @param name the name to set
*/
void setCustomName(String name);
/**
* Gets whether the mob's custom name is displayed client side.
*
* This value has no effect on players, they will always display their
* name.
*
* @return if the custom name is displayed
*/
boolean isCustomNameVisible();
/**
* Sets whether to display the mob's custom name client side. The
* name will be displayed above the mob similarly to a player.
*
* This value has no effect on players, they will always display their
* name.
*
* @param flag custom name or not
*/
void setCustomNameVisible(boolean flag);
Spigot spigot();
// Spigot Start
class Spigot {
/**
* Returns whether this entity is invulnerable.
*
* @return True if the entity is invulnerable.
*/
public boolean isInvulnerable() {
throw new UnsupportedOperationException("Not supported yet.");
}
}
// Spigot End
}