Class VehicleComponent<T extends Entity & ClientVehicle>
java.lang.Object
org.geysermc.geyser.entity.vehicle.VehicleComponent<T>
- Direct Known Subclasses:
BoatVehicleComponent,BoostableVehicleComponent,CamelVehicleComponent,HappyGhastVehicleComponent,HorseVehicleComponent,NautilusVehicleComponent
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final BoundingBoxprotected intprotected booleanprotected booleanprotected doubleprotected doubleprotected floatprotected doubleprotected floatprotected final Tprotected double -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidbooleanprotected Fluidorg.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.floatprotected 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.Vector3fgetInputVector(VehicleComponent<T>.VehicleContext ctx, float speed, org.cloudburstmc.math.vector.Vector3f input) protected floatprotected BlockStateThe block to use when determining if the vehicle should bounce after landing.protected floatgetLogicalFluidHeight(Fluid fluidType, int blockId) doublefloatprotected org.cloudburstmc.math.vector.Vector2fGets the rotation to use for the vehicle.doublegetScale()protected BlockStateThe block to use when calculating slipperiness and speed.protected floatdoubleprotected floatprotected floatgetWorldFluidHeight(Fluid fluidType, int blockId) protected booleanprotected booleanisFlowBlocked(Fluid fluid, int adjacentBlockId) booleanbooleanprotected 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.00001fprotected 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, org.cloudburstmc.math.vector.Vector3f lastRotation) Sets the new position for the vehicle and sends packets to both the java server and bedrock client.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) voidsetMovementEfficiency(double movementEfficiency) voidsetMoveSpeed(float moveSpeed) voidsetScale(double scale) voidsetStepHeight(float stepHeight) voidsetWaterMovementEfficiency(double waterMovementEfficiency) 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 voidUpdate the rotation of the vehicle.protected voidwaterMovement(VehicleComponent<T>.VehicleContext ctx, double height)
-
Field Details
-
vehicle
-
boundingBox
-
stepHeight
protected float stepHeight -
moveSpeed
protected float moveSpeed -
gravity
protected double gravity -
waterMovementEfficiency
protected double waterMovementEfficiency -
movementEfficiency
protected double movementEfficiency -
scale
protected double scale -
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) -
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) -
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. -
isPushedByFluid
public boolean isPushedByFluid() -
canFloatWhileRidden
public boolean canFloatWhileRidden() -
getEyeHeight
public float getEyeHeight() -
updateRotation
protected void updateRotation()Update the rotation of the vehicle. Should be called once per tick, and before getInputVector. -
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.00001f -
getWorldFluidHeight
-
getLogicalFluidHeight
-
isFlowBlocked
-
waterMovement
-
getWaterSlowDown
protected float getWaterSlowDown() -
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
-
getInputVector
protected org.cloudburstmc.math.vector.Vector3f getInputVector(VehicleComponent<T>.VehicleContext ctx, float speed, org.cloudburstmc.math.vector.Vector3f input) -
getRiddenRotation
protected org.cloudburstmc.math.vector.Vector2f getRiddenRotation()Gets the rotation to use for the vehicle. This is based on the player's head rotation.- Returns:
- (yaw, pitch)
-
moveVehicle
protected void moveVehicle(org.cloudburstmc.math.vector.Vector3d javaPos, org.cloudburstmc.math.vector.Vector3f lastRotation) 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 vehiclelastRotation- the previous rotation of the vehicle (pitch, yaw, headYaw)
-
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
-
checkForFluid
-
getBoundingBox
-
isInWater
public boolean isInWater() -
getMoveSpeed
public float getMoveSpeed() -
setMoveSpeed
public void setMoveSpeed(float moveSpeed) -
getWaterMovementEfficiency
public double getWaterMovementEfficiency() -
getMovementEfficiency
public double getMovementEfficiency() -
getScale
public double getScale() -
setWaterMovementEfficiency
public void setWaterMovementEfficiency(double waterMovementEfficiency) -
setMovementEfficiency
public void setMovementEfficiency(double movementEfficiency) -
setScale
public void setScale(double scale)
-