Package net.risingworld.api.objects
Class Vehicle
java.lang.Object
net.risingworld.api.objects.Vehicle
Represents a vehicle
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
destroy()
Destroys the vehicle.void
Ejects all passengers, i.e forces them to get out of the vehicle.int
getColor()
Gets the vehicle color.Gets the definition for this vehicle.long
Gets the unique global ID of the vehicle.getName()
Gets the optional custom name of the vehicle.getPassenger
(int seat) Gets the passenger on a particular seat.Player[]
Gets an array of all passengers, or more precisely, an array containing the occupant of each seat.Gets the world position of the vehicle.Gets the rotation of the vehicle.int
short
Gets the type ID of the vehicle.boolean
Gets whether or not the vehicle is destroyed/wrecked.void
setColor
(float r, float g, float b, float a) Sets the vehicle color.void
setColor
(int color) Sets the vehicle color.void
void
setPosition
(float x, float y, float z) Sets the world position of the vehicle.void
setPosition
(Vector3f position) Sets the world position of the vehicle.void
setRotation
(Quaternion rotation) Sets the rotation of the vehicle.void
setStrength
(int strength)
-
Constructor Details
-
Vehicle
protected Vehicle(long handle)
-
-
Method Details
-
getGlobalID
public long getGlobalID()Gets the unique global ID of the vehicle.- Returns:
- the unique ID of vehicle.
-
getDefinition
Gets the definition for this vehicle.- Returns:
- the vehicle definition.
- Example: Check if a particular vehicle is a boat
-
getTypeID
public short getTypeID()Gets the type ID of the vehicle.- Returns:
- the type ID
-
isDestroyed
public boolean isDestroyed()Gets whether or not the vehicle is destroyed/wrecked. If true, the vehicle still exists, but is usually only represented by a wreck model (and thus no longer usable).- Returns:
- true if the vehicle is wrecked/destroyed, false if not.
-
getName
Gets the optional custom name of the vehicle. By default vehicles don't have a custom name, unless it was set by a player.
Note: This is not to be confused this with the internal name of the vehicle type (e.g "rowboat", "rib" etc). If you want to get that name, use the vehicle definition instead, e.gString name = vehicle.getDefinition().name;
- Returns:
- the optional custom vehicle name, or null if no custom name was set for this vehicle.
-
setName
-
getPosition
Gets the world position of the vehicle.- Returns:
- the vehicle position.
-
setPosition
Sets the world position of the vehicle.- Parameters:
position
- the new position.
-
setPosition
public void setPosition(float x, float y, float z) Sets the world position of the vehicle.- Parameters:
x
- the new x position.y
- the new y position.z
- the new z position.
-
getRotation
Gets the rotation of the vehicle.- Returns:
- the vehicle rotation.
-
setRotation
Sets the rotation of the vehicle.- Parameters:
rotation
- the new rotation.
-
getStrength
public int getStrength() -
setStrength
public void setStrength(int strength) -
getColor
public int getColor()Gets the vehicle color.- Returns:
- the vehicle color as rgba int.
-
setColor
public void setColor(float r, float g, float b, float a) Sets the vehicle color.- Parameters:
r
- the red color component (0-1).g
- the green color component (0-1).b
- the blue color component (0-1).a
- the paint intensity/strength (0-1).
-
setColor
public void setColor(int color) Sets the vehicle color.- Parameters:
color
- the rgba color value as int.
-
getPassenger
Gets the passenger on a particular seat.- Parameters:
seat
- the vehicle seat.- Returns:
- the player which is sitting on the specified seat, or null if the seat is not occupied.
-
getPassengers
Gets an array of all passengers, or more precisely, an array containing the occupant of each seat. For example, if a vehicle has 5 seats and no passengers, an array with the length 5 containing null entries is returned. If a vehicle has 2 seats and one passenger on the first seat, an array with the length 2 containing the player and a null entry is returned etc.- Returns:
- an array containing all passengers.
-
ejectAllPassengers
public void ejectAllPassengers()Ejects all passengers, i.e forces them to get out of the vehicle. -
destroy
public void destroy()Destroys the vehicle.
-