public interface Npc
Modifier and Type | Interface and Description |
---|---|
static class |
Npc.Type
Determines the npc type, i.e. if it's an animal, human etc.
|
Modifier and Type | Method and Description |
---|---|
void |
deleteAttribute(java.lang.String key)
Removes an attribute from this area.
|
int |
getAge()
Gets the "age" of the npc in seconds, i.e. how many seconds passed
since the npc was spawned.
|
java.lang.Object |
getAttribute(java.lang.String key)
Gets the value to which the specified key is mapped,
or null if no attribute is stored for that key.
|
Clothes |
getClothes()
Gets a
Clothes object which contains the clothes the npc
is currently wearing. |
Definitions.NpcDefinition |
getDefinition() |
int |
getGlobalID()
Gets the unique ID of the npc.
|
int |
getGroupID()
Gets the "group" ID of the npc.
|
int |
getHealth()
Gets the current health of the npc.
|
Player |
getHostilePlayer()
Gets the "hostile player".
|
int |
getHunger()
Gets the current hunger level of the npc. 100 means the npc is not
hungry, 0 means the npc is starving.
|
int |
getInfoID()
Gets the info ID of the npc.
|
java.lang.String |
getName()
Gets the name of the npc.
|
Player |
getNearestPlayer()
Gets the nearest player, or more precisely, the player which is considered as
the "nearest player" by the npc.
|
Vector3f |
getPosition()
Gets a Vector3f containing the current global x, y and z
coordinate of the npc.
|
java.lang.Object |
getRider()
Gets the rider of the npc, if present.
|
Quaternion |
getRotation() |
Skin |
getSkin()
Gets a
Skin object which represents the appearance of the npc,
i.e. gender, haircut, skin color, hair color etc. |
int |
getThirst()
Gets the current thirst level of the npc. 100 means the npc is not
thirsty, 0 means the npc is dying of dehydration.
|
Npc.Type |
getType()
Gets the type of this npc (i.e. the species/kind).
|
int |
getTypeID()
Gets the type ID of the npc.
|
int |
getVariation()
Gets the variation of the npc.
|
Vector3f |
getVectorToNearestPlayer()
Gets a normalized vector from the npc position to the position of the nearest player.
|
Vector3f |
getViewDirection()
Gets the current view direction of the npc as a normalized vector.
|
boolean |
hasAttribute(java.lang.String key)
Gets whether or not the provided attribute exists.
|
boolean |
isAlerted()
Gets whether or not the npc is currently alerted/alarmed.
|
boolean |
isDead()
Gets whether or not the npc is dead.
|
boolean |
isInLava()
Gets whether the npc is currently in lava or not.
|
boolean |
isInvincible()
Gets whether or not the npc is invincible, this means it cannot be killed
by any players or other npcs.
|
boolean |
isInWater()
Gets whether the npc is currently in water or not.
|
boolean |
isLocked()
Gets whether or not the npc is currently "locked".
|
boolean |
isSleeping()
Gets whether or not the npc is currently sleeping.
|
boolean |
isTransient()
Gets whether the npc is 'transient' or not.
|
boolean |
isUnderWater()
Gets whether the npc is currently under water or not.
|
void |
kill()
Kills the npc instantly.
|
void |
moveTo(float x,
float y,
float z)
Moves the npc to the provided position, i.e. the npc will walk to this position.
|
void |
moveTo(Vector3f position)
Moves the npc to the provided position, i.e. the npc will walk to this position.
|
void |
setAge(int age)
Sets the "age" of the npc.
|
void |
setAlerted(boolean set)
Changes the "alert" state of the npc.
|
void |
setAlerted(boolean set,
int duration)
Changes the "alert" state of the npc.
|
void |
setAttribute(java.lang.String key,
java.lang.Object value)
Stores an attribute for this area.
|
void |
setGroupID(int groupID)
Sets the "group" ID for the npc.
|
void |
setHealth(int health)
Sets the health of the npc.
|
void |
setHunger(int hunger)
Sets the hunger level of the npc. 100 means the npc is not hungry,
0 means the npc is starving.
|
void |
setInvincible(boolean set)
Enables/disables invincibility for this npc.
|
void |
setLocked(boolean set)
Locks or unlocks the npc.
|
void |
setName(java.lang.String name)
Sets the name of this npc.
|
void |
setPosition(float x,
float y,
float z)
Sets the global position of the npc (teleports the npc).
|
void |
setPosition(Vector3f position)
Sets the global position of the npc (teleports the npc).
|
void |
setRotation(float pitch,
float yaw,
float roll) |
void |
setRotation(Quaternion quaternion) |
void |
setThirst(int thirst)
Sets the thirst level of the npc. 100 means the npc is not thirsty,
0 means the npc is dying of dehydration.
|
void |
setViewDirection(float dirx,
float diry,
float dirz)
Sets the view direction of the npc.
|
void |
setViewDirection(Vector3f direction)
Sets the view direction of the npc.
|
void |
transform(int typeID,
int variation) |
Npc.Type getType()
getTypeID()
!int getGlobalID()
int getTypeID()
Npc.Type
!int getVariation()
int getGroupID()
void setGroupID(int groupID)
World.getNextNpcGroupID()
.groupID
- the group ID for the npc. Set -1 to set the group to "none"World.getNextNpcGroupID()
boolean isTransient()
java.lang.String getName()
void setName(java.lang.String name)
name
- the name you want to set for the npc.int getAge()
void setAge(int age)
age
- the new age, in seconds.int getInfoID()
Player getNearestPlayer()
Player getHostilePlayer()
boolean isLocked()
void setLocked(boolean set)
set
- true to lock the npc (so it will never move away), false to
unlock it (default behavior).boolean isInvincible()
void setInvincible(boolean set)
set
- true to make this npc invincible, false to set it back to default
behavior.java.lang.Object getRider()
npc.getType() == Type.Mount
. If there is no rider
(or if the npc cannot be used as mount), this function returns null.Player
, if present.Player.getMount()
void transform(int typeID, int variation)
Definitions.NpcDefinition getDefinition()
Vector3f getPosition()
void setPosition(Vector3f position)
position
- A Vector3f (float) containing the global target position.void setPosition(float x, float y, float z)
x
- global X coordinate to set (horizontally).y
- global Y coordinate to set (vertically).z
- global Z coordinate to set (horizontally).void moveTo(Vector3f position)
position
- the target position.void moveTo(float x, float y, float z)
x
- the target position X coordinate.y
- the target position Y coordinate.z
- the target position Z coordinate.Quaternion getRotation()
void setRotation(Quaternion quaternion)
void setRotation(float pitch, float yaw, float roll)
Vector3f getViewDirection()
void setViewDirection(Vector3f direction)
direction
- the new view direction as a Vector3f (float). Make sure to
use a unit/normalized vector.void setViewDirection(float dirx, float diry, float dirz)
dirx
- X component of the new view direction vector.diry
- Y component of the new view direction vector.dirz
- Z component of the new view direction vector.Vector3f getVectorToNearestPlayer()
boolean isInWater()
boolean isUnderWater()
boolean isInLava()
void setAlerted(boolean set)
moveTo(net.risingworld.api.utils.Vector3f)
method, this method can be used to force the npc to run.set
- true to set the npc alerted/alarmed, false to disable the alert
state.void setAlerted(boolean set, int duration)
set
- true to set the npc alerted/alarmed, false to disable the alert
state.duration
- the duration (in seconds) how long the npc will stay alerted.
Does nothing when setting the alert state to false.boolean isAlerted()
int getHealth()
void setHealth(int health)
health
- the new npc health.int getHunger()
void setHunger(int hunger)
hunger
- the new hunger level.int getThirst()
void setThirst(int thirst)
thirst
- the new thirst level.boolean isSleeping()
boolean isDead()
void kill()
Skin getSkin()
Skin
object which represents the appearance of the npc,
i.e. gender, haircut, skin color, hair color etc. Skin
object representing the visual appearance of
the npc. Returns null if this npc has no skin object.Clothes getClothes()
Clothes
object which contains the clothes the npc
is currently wearing. Clothes
object representing the clothes of the npc.
Returns null if this npc has no clothes (or if the npc cannot wear clothes).void setAttribute(java.lang.String key, java.lang.Object value)
key
- the name of the attribute.value
- the value/object you want to store.java.lang.Object getAttribute(java.lang.String key)
key
- the name of the attribute.boolean hasAttribute(java.lang.String key)
key
- the name of the attribute.void deleteAttribute(java.lang.String key)
key
- the name of the attribute you want to delete.