Package noppes.npcs.api.entity
Interface IEntity<T extends net.minecraft.entity.Entity>
-
- Type Parameters:
T
- The underlying Minecraft entity type.
- All Known Subinterfaces:
IAnimal<T>
,ICustomNpc<T>
,IDBCPlayer
,IEntityItem<T>
,IEntityLiving<T>
,IEntityLivingBase<T>
,IMonster<T>
,IPixelmon<T>
,IPlayer<T>
,IVillager<T>
public interface IEntity<T extends net.minecraft.entity.Entity>
Represents a generic entity in the world. Provides methods to access or modify the entity's position, motion, temporary and persistent data, and to perform various actions (such as spawning particles, dropping items, or changing dimensions).
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
capturesDrops()
void
clearStoredData()
Clears all stored data.void
clearTempData()
Clears all temporary data.void
despawn()
Permanently despawns the entity.void
dropItem(IItemStack item)
Causes the entity to drop the given item.void
extinguish()
Extinguishes any fire on the entity.long
getAge()
INbt
getAllNbt()
Returns all NBT data for the entity.int
getBlockX()
int
getBlockY()
int
getBlockZ()
IEntity<?>[]
getCapturedDrops()
Returns the captured drops.int
getDimension()
int
getEntityId()
Returns the unique entity ID.double
getHeight()
T
getMCEntity()
Expert users only.IPos
getMotion()
Returns the entity's current motion as an IPos object.double
getMotionX()
double
getMotionY()
double
getMotionZ()
IEntity
getMount()
INbt
getNbt()
Returns the entity's NBT data.INbt
getNbtOptional()
Returns optional NBT data if available.float
getPitch()
Returns the entity's pitch.IPos
getPosition()
Returns the entity's current position as an IPos object.IEntity
getRider()
float
getRotation()
java.lang.Object
getStoredData(java.lang.String key)
Returns stored (persistent) data for the given key.java.lang.String[]
getStoredDataKeys()
Returns an array of keys for stored data.IEntity[]
getSurroundingEntities(int range)
Returns an array of entities within the specified range.IEntity[]
getSurroundingEntities(int range, int type)
Returns an array of entities of a specified type within the given range.java.lang.Object
getTempData(java.lang.String key)
Returns temporary data stored under the given key.java.lang.String[]
getTempDataKeys()
Returns an array of keys for temporary data.int
getType()
Returns the EntityType as defined in the scripting constants.java.lang.String
getTypeName()
java.lang.String
getUniqueID()
Returns the unique UUID string of the entity.double
getWidth()
IWorld
getWorld()
double
getX()
double
getY()
double
getYOffset()
Returns the vertical offset for rendering.double
getZ()
boolean
hasCollided()
boolean
hasCollidedHorizontally()
boolean
hasCollidedVertically()
boolean
hasStoredData(java.lang.String key)
Checks if stored data for the given key exists.boolean
hasTempData(java.lang.String key)
Checks if temporary data for the given key exists.boolean
inFire()
boolean
inLava()
boolean
inWater()
boolean
isAirborne()
boolean
isAlive()
boolean
isBurning()
boolean
isSneaking()
boolean
isSprinting()
void
knockback(double xpower, double ypower, double zpower, float direction)
Applies knockback using individual power components.void
knockback(int power, float direction)
Applies a knockback effect to the entity.void
knockback(IPos pos, float direction)
Applies knockback using a position vector.void
removeStoredData(java.lang.String key)
Removes the stored data for the given key.void
removeTempData(java.lang.String key)
Removes the temporary data for the given key.void
setBurning(int ticks)
Sets the entity on fire for the given number of ticks (20 ticks = 1 second).void
setCapturedDrops(IEntity<?>[] capturedDrops)
Sets the captured drops for this entity.void
setCapturesDrops(boolean capture)
Sets whether the entity captures drops.void
setDimension(int dimensionId)
Moves the entity to the specified dimension.void
setImmune(int ticks)
Sets the entity's immunity time (hurt resistance).void
setInvisible(boolean invisible)
Sets the entity's invisibility.void
setMotion(double x, double y, double z)
Convenience method to set the entity's motion in all three axes.void
setMotion(IPos pos)
Sets the entity's motion based on the given position.void
setMotionX(double x)
Sets the entity's x motion.void
setMotionY(double y)
Sets the entity's y motion.void
setMotionZ(double z)
Sets the entity's z motion.void
setMount(IEntity entity)
Sets the entity to be mounted by this entity.void
setNbt(INbt nbt)
Applies the given NBT data to the entity.void
setPitch(float pitch)
Sets the entity's pitch.void
setPosition(double x, double y, double z)
Sets the entity's position to the specified coordinates.void
setPosition(IPos pos)
Sets the entity's position using an IPos object.void
setRider(IEntity entity)
Sets the given entity as the rider of this entity.void
setRotation(float rotation)
Sets the entity's rotation (yaw) in degrees (0-360).void
setRotation(float rotationYaw, float rotationPitch)
Sets both the rotation (yaw) and pitch of the entity.void
setSneaking(boolean sneaking)
Sets whether the entity is sneaking.void
setSprinting(boolean sprinting)
Sets whether the entity is sprinting.void
setStoredData(java.lang.String key, java.lang.Object value)
Stores persistent data under the given key.void
setTempData(java.lang.String key, java.lang.Object value)
Stores temporary data that is cleared when the entity is unloaded.void
setX(double x)
Sets the entity's x position.void
setY(double y)
Sets the entity's y position.void
setZ(double z)
Sets the entity's z position.void
spawnParticle(IParticle entityParticle)
Spawns the given particle effect associated with this entity.void
storeAsClone(int tab, java.lang.String name)
Stores the entity as a clone with the given tab and name.boolean
typeOf(int type)
Checks whether the entity is of the specified EntityType.void
updateEntity()
Updates the entity's state.
-
-
-
Method Detail
-
spawnParticle
void spawnParticle(IParticle entityParticle)
Spawns the given particle effect associated with this entity.- Parameters:
entityParticle
- The particle effect to spawn.
-
getEntityId
int getEntityId()
Returns the unique entity ID.- Returns:
- the entity ID.
-
getUniqueID
java.lang.String getUniqueID()
Returns the unique UUID string of the entity.- Returns:
- the unique ID.
-
getYOffset
double getYOffset()
Returns the vertical offset for rendering.- Returns:
- the Y offset.
-
getWidth
double getWidth()
- Returns:
- The entity's width.
-
getHeight
double getHeight()
- Returns:
- The entity's height.
-
getX
double getX()
- Returns:
- The entity's x position.
-
setX
void setX(double x)
Sets the entity's x position.- Parameters:
x
- the new x position.
-
getY
double getY()
- Returns:
- The entity's y position.
-
setY
void setY(double y)
Sets the entity's y position.- Parameters:
y
- the new y position.
-
getZ
double getZ()
- Returns:
- The entity's z position.
-
setZ
void setZ(double z)
Sets the entity's z position.- Parameters:
z
- the new z position.
-
getMotionX
double getMotionX()
- Returns:
- The entity's x motion.
-
setMotionX
void setMotionX(double x)
Sets the entity's x motion.- Parameters:
x
- the new x motion.
-
getMotionY
double getMotionY()
- Returns:
- The entity's y motion.
-
setMotionY
void setMotionY(double y)
Sets the entity's y motion.- Parameters:
y
- the new y motion.
-
getMotionZ
double getMotionZ()
- Returns:
- The entity's z motion.
-
setMotionZ
void setMotionZ(double z)
Sets the entity's z motion.- Parameters:
z
- the new z motion.
-
setMotion
void setMotion(double x, double y, double z)
Convenience method to set the entity's motion in all three axes.- Parameters:
x
- the x motion.y
- the y motion.z
- the z motion.
-
setMotion
void setMotion(IPos pos)
Sets the entity's motion based on the given position.- Parameters:
pos
- the position containing motion components.
-
getMotion
IPos getMotion()
Returns the entity's current motion as an IPos object.- Returns:
- the motion vector.
-
isAirborne
boolean isAirborne()
- Returns:
- Whether the entity is airborne.
-
getBlockX
int getBlockX()
- Returns:
- The block (integer) x position.
-
getBlockY
int getBlockY()
- Returns:
- The block (integer) y position.
-
getBlockZ
int getBlockZ()
- Returns:
- The block (integer) z position.
-
setPosition
void setPosition(double x, double y, double z)
Sets the entity's position to the specified coordinates.- Parameters:
x
- the x coordinate.y
- the y coordinate.z
- the z coordinate.
-
setPosition
void setPosition(IPos pos)
Sets the entity's position using an IPos object.- Parameters:
pos
- the position object.
-
getPosition
IPos getPosition()
Returns the entity's current position as an IPos object.- Returns:
- the position.
-
getDimension
int getDimension()
- Returns:
- The dimension ID the entity is in.
-
setDimension
void setDimension(int dimensionId)
Moves the entity to the specified dimension.- Parameters:
dimensionId
- the dimension ID.
-
getSurroundingEntities
IEntity[] getSurroundingEntities(int range)
Returns an array of entities within the specified range.- Parameters:
range
- the search range.- Returns:
- an array of surrounding entities.
-
getSurroundingEntities
IEntity[] getSurroundingEntities(int range, int type)
Returns an array of entities of a specified type within the given range.- Parameters:
range
- the search range.type
- the EntityType to find.- Returns:
- an array of surrounding entities.
-
isAlive
boolean isAlive()
- Returns:
- Whether the entity is alive.
-
getTempData
java.lang.Object getTempData(java.lang.String key)
Returns temporary data stored under the given key.- Parameters:
key
- the key.- Returns:
- the temporary data.
-
setTempData
void setTempData(java.lang.String key, java.lang.Object value)
Stores temporary data that is cleared when the entity is unloaded.- Parameters:
key
- the key.value
- the value.
-
hasTempData
boolean hasTempData(java.lang.String key)
Checks if temporary data for the given key exists.- Parameters:
key
- the key.- Returns:
- true if it exists; false otherwise.
-
removeTempData
void removeTempData(java.lang.String key)
Removes the temporary data for the given key.- Parameters:
key
- the key.
-
clearTempData
void clearTempData()
Clears all temporary data.
-
getTempDataKeys
java.lang.String[] getTempDataKeys()
Returns an array of keys for temporary data.- Returns:
- the keys.
-
getStoredData
java.lang.Object getStoredData(java.lang.String key)
Returns stored (persistent) data for the given key.- Parameters:
key
- the key.- Returns:
- the stored data.
-
setStoredData
void setStoredData(java.lang.String key, java.lang.Object value)
Stores persistent data under the given key. Only Numbers and Strings are supported.- Parameters:
key
- the key.value
- the value.
-
hasStoredData
boolean hasStoredData(java.lang.String key)
Checks if stored data for the given key exists.- Parameters:
key
- the key.- Returns:
- true if it exists; false otherwise.
-
removeStoredData
void removeStoredData(java.lang.String key)
Removes the stored data for the given key.- Parameters:
key
- the key.
-
clearStoredData
void clearStoredData()
Clears all stored data.
-
getStoredDataKeys
java.lang.String[] getStoredDataKeys()
Returns an array of keys for stored data.- Returns:
- the keys.
-
getAge
long getAge()
- Returns:
- The age of the entity in ticks.
-
despawn
void despawn()
Permanently despawns the entity.
-
inWater
boolean inWater()
- Returns:
- Whether the entity is standing in water.
-
inLava
boolean inLava()
- Returns:
- Whether the entity is standing in lava.
-
inFire
boolean inFire()
- Returns:
- Whether the entity is standing in fire.
-
isBurning
boolean isBurning()
- Returns:
- Whether the entity is on fire.
-
setBurning
void setBurning(int ticks)
Sets the entity on fire for the given number of ticks (20 ticks = 1 second).- Parameters:
ticks
- the burn duration.
-
extinguish
void extinguish()
Extinguishes any fire on the entity.
-
getTypeName
java.lang.String getTypeName()
- Returns:
- The entity type name as registered in Minecraft.
-
dropItem
void dropItem(IItemStack item)
Causes the entity to drop the given item.- Parameters:
item
- the item to drop.
-
getRider
IEntity getRider()
- Returns:
- The entity riding this entity.
-
setRider
void setRider(IEntity entity)
Sets the given entity as the rider of this entity.- Parameters:
entity
- the rider.
-
getMount
IEntity getMount()
- Returns:
- The entity this entity is riding.
-
setMount
void setMount(IEntity entity)
Sets the entity to be mounted by this entity.- Parameters:
entity
- the mount.
-
getType
int getType()
Returns the EntityType as defined in the scripting constants.- Returns:
- the EntityType.
-
typeOf
boolean typeOf(int type)
Checks whether the entity is of the specified EntityType.- Parameters:
type
- the type to check.- Returns:
- true if the entity is of that type; false otherwise.
-
setRotation
void setRotation(float rotation)
Sets the entity's rotation (yaw) in degrees (0-360).- Parameters:
rotation
- the rotation angle.
-
setRotation
void setRotation(float rotationYaw, float rotationPitch)
Sets both the rotation (yaw) and pitch of the entity.- Parameters:
rotationYaw
- the yaw angle.rotationPitch
- the pitch angle.
-
getRotation
float getRotation()
- Returns:
- The current rotation (yaw) of the entity.
-
setPitch
void setPitch(float pitch)
Sets the entity's pitch.- Parameters:
pitch
- the pitch angle.
-
getPitch
float getPitch()
Returns the entity's pitch.- Returns:
- the pitch angle.
-
knockback
void knockback(int power, float direction)
Applies a knockback effect to the entity.- Parameters:
power
- the strength of the knockback.direction
- the direction in degrees (usually based on getRotation()).
-
knockback
void knockback(double xpower, double ypower, double zpower, float direction)
Applies knockback using individual power components.- Parameters:
xpower
- the x-axis power.ypower
- the y-axis power.zpower
- the z-axis power.direction
- the direction in degrees.
-
knockback
void knockback(IPos pos, float direction)
Applies knockback using a position vector.- Parameters:
pos
- the position vector.direction
- the direction in degrees.
-
setImmune
void setImmune(int ticks)
Sets the entity's immunity time (hurt resistance).- Parameters:
ticks
- the number of ticks.
-
setInvisible
void setInvisible(boolean invisible)
Sets the entity's invisibility.- Parameters:
invisible
- true to make invisible.
-
setSneaking
void setSneaking(boolean sneaking)
Sets whether the entity is sneaking.- Parameters:
sneaking
- true to enable sneaking.
-
setSprinting
void setSprinting(boolean sprinting)
Sets whether the entity is sprinting.- Parameters:
sprinting
- true to enable sprinting.
-
hasCollided
boolean hasCollided()
- Returns:
- Whether the entity has collided with something.
-
hasCollidedVertically
boolean hasCollidedVertically()
- Returns:
- Whether the entity has collided vertically.
-
hasCollidedHorizontally
boolean hasCollidedHorizontally()
- Returns:
- Whether the entity has collided horizontally.
-
capturesDrops
boolean capturesDrops()
- Returns:
- Whether the entity is capturing drops.
-
setCapturesDrops
void setCapturesDrops(boolean capture)
Sets whether the entity captures drops.- Parameters:
capture
- true to capture drops.
-
setCapturedDrops
void setCapturedDrops(IEntity<?>[] capturedDrops)
Sets the captured drops for this entity.- Parameters:
capturedDrops
- an array of captured drops.
-
getCapturedDrops
IEntity<?>[] getCapturedDrops()
Returns the captured drops.- Returns:
- an array of captured drops.
-
isSneaking
boolean isSneaking()
- Returns:
- Whether the entity is sneaking.
- Since:
- 1.7.10c
-
isSprinting
boolean isSprinting()
- Returns:
- Whether the entity is sprinting.
- Since:
- 1.7.10c
-
getMCEntity
T getMCEntity()
Expert users only.- Returns:
- The underlying Minecraft entity.
-
getNbt
INbt getNbt()
Returns the entity's NBT data.- Returns:
- the NBT data.
-
getAllNbt
INbt getAllNbt()
Returns all NBT data for the entity.- Returns:
- the complete NBT data.
-
setNbt
void setNbt(INbt nbt)
Applies the given NBT data to the entity.- Parameters:
nbt
- the NBT data.
-
getNbtOptional
INbt getNbtOptional()
Returns optional NBT data if available.- Returns:
- the optional NBT data, or null if none.
-
storeAsClone
void storeAsClone(int tab, java.lang.String name)
Stores the entity as a clone with the given tab and name.- Parameters:
tab
- the tab index.name
- the name for the clone.
-
getWorld
IWorld getWorld()
- Returns:
- The world this entity exists in.
-
updateEntity
void updateEntity()
Updates the entity's state.
-
-