Class VehicleComponent<T extends LivingEntity & ClientVehicle>

java.lang.Object
org.geysermc.geyser.entity.vehicle.VehicleComponent<T>
Direct Known Subclasses:
BoostableVehicleComponent, CamelVehicleComponent

public class VehicleComponent<T extends LivingEntity & ClientVehicle> extends Object
  • Field Details

    • vehicle

      protected final T extends LivingEntity & ClientVehicle vehicle
    • boundingBox

      protected final BoundingBox boundingBox
    • stepHeight

      protected float stepHeight
    • moveSpeed

      protected float moveSpeed
    • gravity

      protected double gravity
    • effectLevitation

      protected int effectLevitation
    • effectSlowFalling

      protected boolean effectSlowFalling
    • effectWeaving

      protected boolean effectWeaving
  • Constructor Details

    • VehicleComponent

      public VehicleComponent(T vehicle, float stepHeight)
  • Method Details

    • setWidth

      public void setWidth(float width)
    • setHeight

      public void setHeight(float height)
    • moveAbsolute

      public void moveAbsolute(double x, double y, double z)
    • moveAbsolute

      public void moveAbsolute(org.cloudburstmc.math.vector.Vector3d vec)
    • moveRelative

      public void moveRelative(double x, double y, double z)
    • moveRelative

      public void moveRelative(org.cloudburstmc.math.vector.Vector3d vec)
    • getBoundingBox

      public BoundingBox getBoundingBox()
    • setEffect

      public void setEffect(org.geysermc.mcprotocollib.protocol.data.game.entity.Effect effect, int effectAmplifier)
    • removeEffect

      public void removeEffect(org.geysermc.mcprotocollib.protocol.data.game.entity.Effect effect)
    • setMoveSpeed

      public void setMoveSpeed(float moveSpeed)
    • getMoveSpeed

      public float getMoveSpeed()
    • setStepHeight

      public void setStepHeight(float stepHeight)
    • setGravity

      public void setGravity(double gravity)
    • correctMovement

      public org.cloudburstmc.math.vector.Vector3d correctMovement(org.cloudburstmc.math.vector.Vector3d movement)
    • onMount

      public void onMount()
    • onDismount

      public void onDismount()
    • tickVehicle

      public void tickVehicle()
      Called every session tick while the player is mounted on the vehicle.
    • updateFluidMovement

      protected it.unimi.dsi.fastutil.objects.ObjectDoublePair<Fluid> updateFluidMovement(VehicleComponent<T>.VehicleContext ctx)
      Adds velocity of all colliding fluids to the vehicle, and returns the height of the fluid to use for movement.
      Parameters:
      ctx - context
      Returns:
      type and height of fluid to use for movement
    • getFluidHeightAndApplyMovement

      protected double getFluidHeightAndApplyMovement(VehicleComponent<T>.VehicleContext ctx, org.geysermc.erosion.util.BlockPositionIterator iter, Fluid fluid, double speed, double minY)
      Calculates how deep the vehicle is in a fluid, and applies its velocity.
      Parameters:
      ctx - context
      iter - iterator of colliding blocks
      fluid - type of fluid
      speed - multiplier for fluid motion
      minY - minY of the bounding box used to check for fluid collision; not exactly the same as the vehicle's bounding box
      Returns:
      height of fluid compared to minY
    • javaNormalize

      protected org.cloudburstmc.math.vector.Vector3d javaNormalize(org.cloudburstmc.math.vector.Vector3d vec)
      Java edition returns the zero vector if the length of the input vector is less than 0.0001
    • getWorldFluidHeight

      protected float getWorldFluidHeight(Fluid fluidType, int blockId)
    • getLogicalFluidHeight

      protected float getLogicalFluidHeight(Fluid fluidType, int blockId)
    • isFlowBlocked

      protected boolean isFlowBlocked(Fluid fluid, int adjacentBlockId)
    • waterMovement

      protected void waterMovement(VehicleComponent<T>.VehicleContext ctx)
    • lavaMovement

      protected void lavaMovement(VehicleComponent<T>.VehicleContext ctx, double lavaHeight)
    • landMovement

      protected void landMovement(VehicleComponent<T>.VehicleContext ctx)
    • shouldApplyFluidJumpBoost

      protected boolean shouldApplyFluidJumpBoost(VehicleComponent<T>.VehicleContext ctx, double originalY)
    • getFluidGravity

      protected org.cloudburstmc.math.vector.Vector3f getFluidGravity(double gravity, boolean falling)
    • getBlockMovementMultiplier

      protected @Nullable org.cloudburstmc.math.vector.Vector3f getBlockMovementMultiplier(VehicleComponent<T>.VehicleContext ctx)
      Check if any blocks the vehicle is colliding with should multiply movement. (Cobweb, powder snow, berry bush)

      This is different from the speed factor of a block the vehicle is standing on, such as soul sand.

      Parameters:
      ctx - context
      Returns:
      the multiplier
    • applyBlockCollisionEffects

      protected void applyBlockCollisionEffects(VehicleComponent<T>.VehicleContext ctx)
    • onHoneyBlockCollision

      protected void onHoneyBlockCollision()
    • onBubbleColumnCollision

      protected void onBubbleColumnCollision(boolean drag)
    • travel

      protected boolean travel(VehicleComponent<T>.VehicleContext ctx, float speed)
      Calculates the next position of the vehicle while checking for collision and adjusting velocity.
      Returns:
      true if there was a horizontal collision
    • isClimbing

      protected boolean isClimbing(VehicleComponent<T>.VehicleContext ctx)
    • getInputVelocity

      protected org.cloudburstmc.math.vector.Vector3f getInputVelocity(VehicleComponent<T>.VehicleContext ctx, float speed)
      Translates the player's input into velocity.
      Parameters:
      ctx - context
      speed - multiplier for input
      Returns:
      velocity
    • normalizeInput

      protected org.cloudburstmc.math.vector.Vector2f normalizeInput(org.cloudburstmc.math.vector.Vector2f input)
    • getVehicleRotation

      protected org.cloudburstmc.math.vector.Vector2f getVehicleRotation()
      Gets the rotation to use for the vehicle. This is based on the player's head rotation.
    • moveVehicle

      protected void moveVehicle(org.cloudburstmc.math.vector.Vector3d javaPos)
      Sets the new position for the vehicle and sends packets to both the java server and bedrock client.

      This also updates the session's last vehicle move timestamp.

      Parameters:
      javaPos - the new java position of the vehicle
    • getGravity

      protected double getGravity()
    • getBlockUnderSupport

      protected BlockState getBlockUnderSupport(VehicleComponent<T>.VehicleContext ctx, float dist)
      Returns the block that is x amount of blocks under the main supporting block.
    • getLandingBlock

      protected BlockState getLandingBlock(VehicleComponent<T>.VehicleContext ctx)
      The block to use when determining if the vehicle should bounce after landing. Currently just slime and bed blocks.
    • getVelocityBlock

      protected BlockState getVelocityBlock(VehicleComponent<T>.VehicleContext ctx)
      The block to use when calculating slipperiness and speed. If on a slab, this will be the block under the slab.
    • getVelocityMultiplier

      protected float getVelocityMultiplier(VehicleComponent<T>.VehicleContext ctx)
    • getJumpVelocityMultiplier

      protected float getJumpVelocityMultiplier(VehicleComponent<T>.VehicleContext ctx)