Skip to content

Commit f66aec3

Browse files
authored
Fix: javaY precision (#6435)
* Fix javaY precision * Fix player offset * Clarify player offset * Implement requested changes
1 parent e40f4e8 commit f66aec3

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

core/src/main/java/org/geysermc/geyser/entity/EntityDefinitions.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,8 @@ public final class EntityDefinitions {
692692

693693
EntityDefinition<AvatarEntity> avatarEntityBase = EntityDefinition.<AvatarEntity>inherited(null, livingEntityBase)
694694
.height(1.8f).width(0.6f)
695-
.offset(1.62f)
695+
// This is the offset sent by Bedrock in its player position. Verified on Bedrock 26.23.
696+
.offset(1.62001f)
696697
.addTranslator(null) // Player main hand
697698
.addTranslator(MetadataTypes.BYTE, AvatarEntity::setSkinVisibility)
698699
.build();

core/src/main/java/org/geysermc/geyser/level/physics/CollisionManager.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public class CollisionManager {
6161
public static final BlockCollision FLUID_COLLISION = new OtherCollision(new BoundingBox[]{new BoundingBox(0.5, 0.25, 0.5, 1, 0.5, 1)});
6262
// If you read this, feel free to suggest a more proper way to detect the Bedrock player's own onGround status instead of using a margin
6363
private static final double POSITION_ADJUSTMENT_MARGIN = 0.05;
64+
private static final double PLAYER_OFFSET = Double.parseDouble(Float.toString(EntityDefinitions.PLAYER.offset()));
6465

6566
private final GeyserSession session;
6667

@@ -174,9 +175,10 @@ public BoundingBox getActiveBoundingBox() {
174175
if (pistonCache.isPlayerAttachedToHoney()) {
175176
return null;
176177
}
178+
177179
// We need to parse the float as a string since casting a float to a double causes us to
178180
// lose precision and thus, causes players to get stuck when walking near walls
179-
double javaY = Double.parseDouble(Float.toString(bedrockPosition.getY())) - EntityDefinitions.PLAYER.offset();
181+
double javaY = Double.parseDouble(Float.toString(bedrockPosition.getY())) - PLAYER_OFFSET;
180182

181183
Vector3d position = Vector3d.from(Double.parseDouble(Float.toString(bedrockPosition.getX())), javaY, Double.parseDouble(Float.toString(bedrockPosition.getZ())));
182184

0 commit comments

Comments
 (0)