Package nl.mtvehicles.core.movement
Class VehicleMovement
java.lang.Object
nl.mtvehicles.core.movement.VehicleMovement
- Direct Known Subclasses:
VehicleMovement1_12
Class concerning the movement of vehicles
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
True if extreme falling is turned on in config.yml and 'isFalling' is true.protected boolean
True if a flying vehicle is falling from the air.protected String
The vehicle's license plate.protected Object
Given steering packet, checked.protected org.bukkit.entity.Player
Player who is steering the vehicle.protected org.bukkit.entity.ArmorStand
Vehicle's main armor stand (moved)protected org.bukkit.entity.ArmorStand
Vehicle's armor stand for the main seat (where the driver is seated)protected @Nullable org.bukkit.entity.ArmorStand
Vehicle's armor stand for helicopter bladesprotected org.bukkit.entity.ArmorStand
Vehicle's armor stand with its textureprotected VehicleType
The type of vehicle. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
Check the next block - carpets, slabs, snow - and do an appropriate action.boolean
boatPassable(String blockName)
protected double
getLayerHeight(int layers)
Get the Y height of a snow layerprotected org.bukkit.Location
Get location of the block in front of the vehicleprotected static String
Get the String name of the method for teleporting an ArmorStand.protected boolean
isPassable(org.bukkit.block.Block block)
Check whether a block is passable.protected void
mainSeat()
Check the movement and teleport the main seatprotected void
move()
Check the movement of the vehicleprotected void
pushVehicleDown(double minus)
Push vehicle down by a specified Y.protected void
pushVehicleUp(double plus)
Push vehicle up by a specified Y.protected void
Slow down the vehicle due to frictionprotected void
Remove fuel from vehicle (will use vehicle's fuel usage determined in VehicleData.yml)protected void
rotateVehicle(float yaw)
Rotate the vehicle to a specified yawprotected void
rotation()
Check the rotation of the vehicleprotected void
rotors()
Rotate and move the rotors accordingly.protected void
spawnParticles(org.bukkit.entity.ArmorStand stand, org.bukkit.Location loc)
Spawn tank's shooting particlesprotected float
Get steering packet's rotationprotected float
Get steering packet's movement (forwards × backwards)protected boolean
Checked whether a player is jumping (got from the steering packet)void
tankShoot(org.bukkit.entity.ArmorStand stand, org.bukkit.Location loc)
Spawn and shoot tank's TNT (must be enabled in config.yml), calls theTankShootEvent
.protected void
teleportSeat(Object seat, double x, double y, double z, float yaw, float pitch)
Teleport a seat to a desired location.protected void
teleportSeat(org.bukkit.entity.ArmorStand seat, org.bukkit.Location loc)
Teleport a seat to a specified locationprotected void
Teleport the armor stand to a correct location (based on speed, surroundings, fuel, etc...)void
vehicleMovement(org.bukkit.entity.Player player, Object packet)
Main method for vehicles' movement
-
Field Details
-
packet
Given steering packet, checked.- See Also:
PacketHandler.isObjectPacket(Object)
-
player
protected org.bukkit.entity.Player playerPlayer who is steering the vehicle. -
vehicleType
The type of vehicle. Uses an enum (not a String as it used to be).- See Also:
VehicleType
-
license
The vehicle's license plate. -
standMain
protected org.bukkit.entity.ArmorStand standMainVehicle's main armor stand (moved) -
standSkin
protected org.bukkit.entity.ArmorStand standSkinVehicle's armor stand with its texture -
standMainSeat
protected org.bukkit.entity.ArmorStand standMainSeatVehicle's armor stand for the main seat (where the driver is seated) -
standRotors
@Nullable protected @Nullable org.bukkit.entity.ArmorStand standRotorsVehicle's armor stand for helicopter blades -
isFalling
protected boolean isFallingTrue if a flying vehicle is falling from the air. -
extremeFalling
protected boolean extremeFallingTrue if extreme falling is turned on in config.yml and 'isFalling' is true. This makes falling faster, vehicles break when they land, etc...
-
-
Constructor Details
-
VehicleMovement
public VehicleMovement()
-
-
Method Details
-
vehicleMovement
Main method for vehicles' movement- Parameters:
player
- Player who is steering the vehiclepacket
- Packet used for steering (will be checked)- See Also:
PacketHandler.isObjectPacket(Object)
-
rotation
protected void rotation()Check the rotation of the vehicle -
rotateVehicle
protected void rotateVehicle(float yaw)Rotate the vehicle to a specified yaw -
move
protected void move()Check the movement of the vehicle -
putFrictionSpeed
protected void putFrictionSpeed()Slow down the vehicle due to friction -
blockCheck
protected boolean blockCheck()Check the next block - carpets, slabs, snow - and do an appropriate action.- Returns:
- True if the vehicle is moving upwards (in any way)
-
getLayerHeight
protected double getLayerHeight(int layers)Get the Y height of a snow layer- Parameters:
layers
- Number of layers- Returns:
- Height
-
mainSeat
protected void mainSeat()Check the movement and teleport the main seat -
teleportSeat
protected void teleportSeat(org.bukkit.entity.ArmorStand seat, org.bukkit.Location loc)Teleport a seat to a specified location- Parameters:
seat
- ArmorStand of the seatloc
- Location where the seat will be teleported to
-
getTeleportMethod
Get the String name of the method for teleporting an ArmorStand. Changes between versions.- Returns:
- Teleport method's name as String.
-
teleportSeat
Teleport a seat to a desired location. The seat must already be specified as a CraftBukkit Entity.- Parameters:
seat
- Seat's ArmorStand as a CraftBukkit Entityx
- X-coordinate of the locatoiny
- Y-coordinate of the locatoinz
- Z-coordinate of the locatoinyaw
- Yaw of the locatoinpitch
- Pitch of the locatoin
-
updateStand
protected void updateStand()Teleport the armor stand to a correct location (based on speed, surroundings, fuel, etc...) -
putFuelUsage
protected void putFuelUsage()Remove fuel from vehicle (will use vehicle's fuel usage determined in VehicleData.yml) -
isPassable
protected boolean isPassable(org.bukkit.block.Block block)Check whether a block is passable. Method used because 1.12 does not have this method natively.- Parameters:
block
- Checked block- Returns:
- True if the checked block is passable.
-
rotors
protected void rotors()Rotate and move the rotors accordingly. -
pushVehicleUp
protected void pushVehicleUp(double plus)Push vehicle up by a specified Y.- Parameters:
plus
- The height of which a vehicle is being pushed up.
-
pushVehicleDown
protected void pushVehicleDown(double minus)Push vehicle down by a specified Y.- Parameters:
minus
- The height of which a vehicle is being pushed down.
-
getLocationOfBlockAhead
protected org.bukkit.Location getLocationOfBlockAhead()Get location of the block in front of the vehicle -
steerIsJumping
protected boolean steerIsJumping()Checked whether a player is jumping (got from the steering packet)- Returns:
- True if player is jumping
-
steerGetXxa
protected float steerGetXxa()Get steering packet's rotation- Returns:
- Rotation from the packet
-
steerGetZza
protected float steerGetZza()Get steering packet's movement (forwards × backwards)- Returns:
- Movement from the packet
-
spawnParticles
protected void spawnParticles(org.bukkit.entity.ArmorStand stand, org.bukkit.Location loc)Spawn tank's shooting particles- Parameters:
stand
- The tank's main ArmorStandloc
- Location of where the particles should be spawned
-
tankShoot
public void tankShoot(org.bukkit.entity.ArmorStand stand, org.bukkit.Location loc)Spawn and shoot tank's TNT (must be enabled in config.yml), calls theTankShootEvent
.- Parameters:
stand
- The tank's main ArmorStandloc
- Location of where the TNT should be spawned
-
boatPassable
-