Class VehicleMovement

java.lang.Object
nl.mtvehicles.core.movement.VehicleMovement
Direct Known Subclasses:
VehicleMovement1_12

public class VehicleMovement extends Object
Class concerning the movement of vehicles
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected 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 blades
    protected org.bukkit.entity.ArmorStand
    Vehicle's armor stand with its texture
    protected VehicleType
    The type of vehicle.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected 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 layer
    protected org.bukkit.Location
    Get location of the block in front of the vehicle
    protected 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
    Check the movement and teleport the main seat
    protected void
    Check the movement of the vehicle
    protected 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 friction
    protected 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 yaw
    protected void
    Check the rotation of the vehicle
    protected void
    Rotate and move the rotors accordingly.
    protected void
    spawnParticles​(org.bukkit.entity.ArmorStand stand, org.bukkit.Location loc)
    Spawn tank's shooting particles
    protected float
    Get steering packet's rotation
    protected 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 the TankShootEvent.
    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 location
    protected 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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • packet

      protected Object packet
      Given steering packet, checked.
      See Also:
      PacketHandler.isObjectPacket(Object)
    • player

      protected org.bukkit.entity.Player player
      Player who is steering the vehicle.
    • vehicleType

      protected VehicleType vehicleType
      The type of vehicle. Uses an enum (not a String as it used to be).
      See Also:
      VehicleType
    • license

      protected String license
      The vehicle's license plate.
    • standMain

      protected org.bukkit.entity.ArmorStand standMain
      Vehicle's main armor stand (moved)
    • standSkin

      protected org.bukkit.entity.ArmorStand standSkin
      Vehicle's armor stand with its texture
    • standMainSeat

      protected org.bukkit.entity.ArmorStand standMainSeat
      Vehicle's armor stand for the main seat (where the driver is seated)
    • standRotors

      @Nullable protected @Nullable org.bukkit.entity.ArmorStand standRotors
      Vehicle's armor stand for helicopter blades
    • isFalling

      protected boolean isFalling
      True if a flying vehicle is falling from the air.
    • extremeFalling

      protected boolean extremeFalling
      True 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

      public void vehicleMovement(org.bukkit.entity.Player player, Object packet)
      Main method for vehicles' movement
      Parameters:
      player - Player who is steering the vehicle
      packet - 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 seat
      loc - Location where the seat will be teleported to
    • getTeleportMethod

      protected static String getTeleportMethod()
      Get the String name of the method for teleporting an ArmorStand. Changes between versions.
      Returns:
      Teleport method's name as String.
    • teleportSeat

      protected void teleportSeat(Object seat, double x, double y, double z, float yaw, float pitch)
      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 Entity
      x - X-coordinate of the locatoin
      y - Y-coordinate of the locatoin
      z - Z-coordinate of the locatoin
      yaw - Yaw of the locatoin
      pitch - 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 ArmorStand
      loc - 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 the TankShootEvent.
      Parameters:
      stand - The tank's main ArmorStand
      loc - Location of where the TNT should be spawned
    • boatPassable

      public boolean boatPassable(String blockName)