Skip to content

Commit ea967a0

Browse files
Fix: boat bounding box while driving (#5700)
* Fixed boat bounding box. * Update core/src/main/java/org/geysermc/geyser/entity/type/player/SessionPlayerEntity.java Co-authored-by: chris <github@onechris.mozmail.com> * Update core/src/main/java/org/geysermc/geyser/entity/type/player/SessionPlayerEntity.java Co-authored-by: chris <github@onechris.mozmail.com> --------- Co-authored-by: chris <github@onechris.mozmail.com>
1 parent 61a1ddd commit ea967a0

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

core/src/main/java/org/geysermc/geyser/entity/type/player/SessionPlayerEntity.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
import org.cloudburstmc.protocol.bedrock.packet.UpdateAttributesPacket;
4040
import org.geysermc.geyser.entity.EntityDefinitions;
4141
import org.geysermc.geyser.entity.attribute.GeyserAttributeType;
42+
import org.geysermc.geyser.entity.type.BoatEntity;
43+
import org.geysermc.geyser.entity.type.Entity;
4244
import org.geysermc.geyser.inventory.GeyserItemStack;
4345
import org.geysermc.geyser.item.Items;
4446
import org.geysermc.geyser.level.BedrockDimension;
@@ -425,6 +427,28 @@ public void setVehicleJumpStrength(int vehicleJumpStrength) {
425427
this.vehicleJumpStrength = MathUtils.constrain(vehicleJumpStrength, 0, 100);
426428
}
427429

430+
@Override
431+
public void setVehicle(Entity entity) {
432+
// For boats, we send width = 0.6 and height = 1.6 since there is otherwise a problem with player "clipping" into the boat when standing on it or running into it.
433+
// Having a wide bounding box fixed that, however, it is technically incorrect and creates certain problems
434+
// when you're actually riding the boat (https://github.com/GeyserMC/Geyser/issues/3106), since the box is way too big
435+
// the boat's motion stops right before the block is hit and doesn't let the actual bounding clip collide into the block,
436+
// causing the issues. So to fix this, everytime player enter a boat we send the java bounding box and only send the
437+
// definition box when player is not riding the boat.
438+
if (entity instanceof BoatEntity) {
439+
// These bounding box values are based off 1.21.7
440+
entity.setBoundingBoxWidth(1.375F);
441+
entity.setBoundingBoxHeight(0.5625F);
442+
entity.updateBedrockMetadata();
443+
} else if (entity == null && this.vehicle instanceof BoatEntity) {
444+
this.vehicle.setBoundingBoxWidth(this.vehicle.getDefinition().width());
445+
this.vehicle.setBoundingBoxHeight(this.vehicle.getDefinition().height());
446+
this.vehicle.updateBedrockMetadata();
447+
}
448+
449+
super.setVehicle(entity);
450+
}
451+
428452
private boolean isBelowVoidFloor() {
429453
return position.getY() < voidFloorPosition();
430454
}

0 commit comments

Comments
 (0)