Package net.risingworld.api.events.npc
Class NpcSpawnEvent
java.lang.Object
net.risingworld.api.events.Event
net.risingworld.api.events.npc.NpcSpawnEvent
- All Implemented Interfaces:
Cancellable
Called when an npc is about to spawn. Cancelling this event prevents the
npc from spawning.
-
Nested Class Summary
Nested Classes -
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionlongGets the global ID that will be assigned to the npc once it spawns.getNpc()Gets the npc that is about to spawn.Gets the origin of this npc spawn, i.e the reason why this npc spawns (e.g natural spawn, or spawned via command etc).Returns the related player.shortGets the type ID of the npc.intbooleanDetermines if the event is cancelled.voidsetCancelled(boolean cancel) Cancels this event.voidsetPosition(float x, float y, float z) voidsetPosition(Vector3f position) voidsetRotation(float x, float y, float z, float w) voidsetRotation(Quaternion rotation) voidsetTypeID(short newTypeID) voidsetVariation(int newVariation)
-
Method Details
-
getNpc
Gets the npc that is about to spawn.- Returns:
- the npc that is about to spawn (unless the event is cancelled).
-
getGlobalID
public long getGlobalID()Gets the global ID that will be assigned to the npc once it spawns.- Returns:
- the unique global ID of the npc.
-
getTypeID
public short getTypeID()Gets the type ID of the npc.- Returns:
- the type ID of the npc (i.e the internal ID of the npc in the definitions table. For example, pigs have ID 1, cows have ID 2 etc).
-
setTypeID
public void setTypeID(short newTypeID) -
getVariation
public int getVariation() -
setVariation
public void setVariation(int newVariation) -
getPosition
-
setPosition
-
setPosition
public void setPosition(float x, float y, float z) -
getRotation
-
setRotation
-
setRotation
public void setRotation(float x, float y, float z, float w) -
getOrigin
Gets the origin of this npc spawn, i.e the reason why this npc spawns (e.g natural spawn, or spawned via command etc).- Returns:
- the npc spawn origin.
-
getRelatedPlayer
Returns the related player. This only works if the npc was spawned via command (then the player who executed the command will be returned), otherwise null will be returned.- Returns:
- the player who spawned this npc, or null if this npc spawned naturally.
-
isCancelled
public boolean isCancelled()Description copied from interface:CancellableDetermines if the event is cancelled. If an event is cancelled, it will no longer be executed, but other plugins will still receive the event.
Please note: If the event is threaded, cancellation has no effect, i.e the event will still be executed.- Specified by:
isCancelledin interfaceCancellable- Returns:
- true if the event is cancelled, or false if not.
-
setCancelled
public void setCancelled(boolean cancel) Description copied from interface:CancellableCancels this event. This means it will no longer be executed, but other plugins will still receive the event.- Specified by:
setCancelledin interfaceCancellable- Parameters:
cancel- set to true if you want to cancel this event.- Example: Cancel "PlayerEnterAreaEvent", i.e prevent player from entering an area
-