Class VehicleComponent<T extends LivingEntity & ClientVehicle>
java.lang.Object
org.geysermc.geyser.entity.vehicle.VehicleComponent<T>
- Direct Known Subclasses:
BoostableVehicleComponent,CamelVehicleComponent
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final BoundingBoxprotected intprotected booleanprotected booleanprotected doubleprotected floatprotected floatprotected final T -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidorg.cloudburstmc.math.vector.Vector3dcorrectMovement(org.cloudburstmc.math.vector.Vector3d movement) protected @Nullable org.cloudburstmc.math.vector.Vector3fCheck if any blocks the vehicle is colliding with should multiply movement.protected BlockStategetBlockUnderSupport(VehicleComponent<T>.VehicleContext ctx, float dist) Returns the block that is x amount of blocks under the main supporting block.protected org.cloudburstmc.math.vector.Vector3fgetFluidGravity(double gravity, boolean falling) protected doublegetFluidHeightAndApplyMovement(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.protected doubleprotected org.cloudburstmc.math.vector.Vector3fgetInputVelocity(VehicleComponent<T>.VehicleContext ctx, float speed) Translates the player's input into velocity.protected floatprotected BlockStateThe block to use when determining if the vehicle should bounce after landing.protected floatgetLogicalFluidHeight(Fluid fluidType, int blockId) floatprotected org.cloudburstmc.math.vector.Vector2fGets the rotation to use for the vehicle.protected BlockStateThe block to use when calculating slipperiness and speed.protected floatprotected floatgetWorldFluidHeight(Fluid fluidType, int blockId) protected booleanprotected booleanisFlowBlocked(Fluid fluid, int adjacentBlockId) protected org.cloudburstmc.math.vector.Vector3djavaNormalize(org.cloudburstmc.math.vector.Vector3d vec) Java edition returns the zero vector if the length of the input vector is less than 0.0001protected voidprotected voidlavaMovement(VehicleComponent<T>.VehicleContext ctx, double lavaHeight) voidmoveAbsolute(double x, double y, double z) voidmoveAbsolute(org.cloudburstmc.math.vector.Vector3d vec) voidmoveRelative(double x, double y, double z) voidmoveRelative(org.cloudburstmc.math.vector.Vector3d vec) protected voidmoveVehicle(org.cloudburstmc.math.vector.Vector3d javaPos) Sets the new position for the vehicle and sends packets to both the java server and bedrock client.protected org.cloudburstmc.math.vector.Vector2fnormalizeInput(org.cloudburstmc.math.vector.Vector2f input) protected voidonBubbleColumnCollision(boolean drag) voidprotected voidvoidonMount()voidremoveEffect(org.geysermc.mcprotocollib.protocol.data.game.entity.Effect effect) voidsetEffect(org.geysermc.mcprotocollib.protocol.data.game.entity.Effect effect, int effectAmplifier) voidsetGravity(double gravity) voidsetHeight(float height) voidsetMoveSpeed(float moveSpeed) voidsetStepHeight(float stepHeight) voidsetWidth(float width) protected booleanshouldApplyFluidJumpBoost(VehicleComponent<T>.VehicleContext ctx, double originalY) voidCalled every session tick while the player is mounted on the vehicle.protected booleantravel(VehicleComponent<T>.VehicleContext ctx, float speed) Calculates the next position of the vehicle while checking for collision and adjusting velocity.protected it.unimi.dsi.fastutil.objects.ObjectDoublePair<Fluid>Adds velocity of all colliding fluids to the vehicle, and returns the height of the fluid to use for movement.protected void
-
Field Details
-
vehicle
-
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
-
-
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
-
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- contextiter- iterator of colliding blocksfluid- type of fluidspeed- multiplier for fluid motionminY- 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
-
getLogicalFluidHeight
-
isFlowBlocked
-
waterMovement
-
lavaMovement
-
landMovement
-
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
-
onHoneyBlockCollision
protected void onHoneyBlockCollision() -
onBubbleColumnCollision
protected void onBubbleColumnCollision(boolean drag) -
travel
Calculates the next position of the vehicle while checking for collision and adjusting velocity.- Returns:
- true if there was a horizontal collision
-
isClimbing
-
getInputVelocity
protected org.cloudburstmc.math.vector.Vector3f getInputVelocity(VehicleComponent<T>.VehicleContext ctx, float speed) Translates the player's input into velocity.- Parameters:
ctx- contextspeed- 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
Returns the block that is x amount of blocks under the main supporting block. -
getLandingBlock
The block to use when determining if the vehicle should bounce after landing. Currently just slime and bed blocks. -
getVelocityBlock
The block to use when calculating slipperiness and speed. If on a slab, this will be the block under the slab. -
getVelocityMultiplier
-
getJumpVelocityMultiplier
-