diff --git a/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/entity/player/input/BedrockMovePlayer.java b/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/entity/player/input/BedrockMovePlayer.java index dba6a6787d9..a3244db679d 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/entity/player/input/BedrockMovePlayer.java +++ b/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/entity/player/input/BedrockMovePlayer.java @@ -40,6 +40,7 @@ import org.geysermc.geyser.text.ChatColor; import org.geysermc.geyser.util.MathUtils; import org.geysermc.mcprotocollib.network.packet.Packet; +import org.geysermc.mcprotocollib.protocol.data.game.entity.player.GameMode; import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.player.ServerboundMovePlayerPosPacket; import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.player.ServerboundMovePlayerPosRotPacket; import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.player.ServerboundMovePlayerRotPacket; @@ -159,6 +160,8 @@ static void translate(GeyserSession session, PlayerAuthInputPacket packet) { session.setNoClip(!possibleOnGround); } + boolean forceJavaOnGround = session.isFlying() && session.getGameMode() != GameMode.SPECTATOR && !hasVehicle && !session.isNoClip(); + // This takes into account no movement sent from the client, but the player is trying to move anyway. // (Press into a wall in a corner - you're trying to move but nothing actually happens) // This isn't sent when a player is riding a vehicle (as of 1.21.62) @@ -168,7 +171,7 @@ static void translate(GeyserSession session, PlayerAuthInputPacket packet) { // This isn't needed, but it makes the packets closer to vanilla // It also means you can't "lag back" while only looking, in theory if (!positionChangedAndShouldUpdate && rotationChanged) { - ServerboundMovePlayerRotPacket playerRotationPacket = new ServerboundMovePlayerRotPacket(isOnGround, horizontalCollision, javaYaw, pitch); + ServerboundMovePlayerRotPacket playerRotationPacket = new ServerboundMovePlayerRotPacket(isOnGround || forceJavaOnGround, horizontalCollision, javaYaw, pitch); entity.setYaw(yaw); entity.setJavaYaw(javaYaw); @@ -193,7 +196,7 @@ static void translate(GeyserSession session, PlayerAuthInputPacket packet) { if (rotationChanged) { // Send rotation updates as well movePacket = new ServerboundMovePlayerPosRotPacket( - isOnGround, + isOnGround || forceJavaOnGround, horizontalCollision, position.getX(), position.getY(), position.getZ(), javaYaw, pitch @@ -204,7 +207,7 @@ static void translate(GeyserSession session, PlayerAuthInputPacket packet) { entity.setHeadYaw(headYaw); } else { // Rotation did not change; don't send an update with rotation - movePacket = new ServerboundMovePlayerPosPacket(isOnGround, horizontalCollision, position.getX(), position.getY(), position.getZ()); + movePacket = new ServerboundMovePlayerPosPacket(isOnGround || forceJavaOnGround, horizontalCollision, position.getX(), position.getY(), position.getZ()); } entity.setPositionManual(packet.getPosition()); @@ -224,7 +227,7 @@ static void translate(GeyserSession session, PlayerAuthInputPacket packet) { session.getCollisionManager().recalculatePosition(); } } else if (horizontalCollision != session.getInputCache().lastHorizontalCollision() || isOnGround != entity.isOnGround()) { - session.sendDownstreamGamePacket(new ServerboundMovePlayerStatusOnlyPacket(isOnGround, horizontalCollision)); + session.sendDownstreamGamePacket(new ServerboundMovePlayerStatusOnlyPacket(isOnGround || forceJavaOnGround, horizontalCollision)); } session.getInputCache().setLastHorizontalCollision(horizontalCollision); diff --git a/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/entity/player/input/BedrockPlayerAuthInputTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/entity/player/input/BedrockPlayerAuthInputTranslator.java index 8ac85d2d716..8918bd79eda 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/entity/player/input/BedrockPlayerAuthInputTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/entity/player/input/BedrockPlayerAuthInputTranslator.java @@ -77,8 +77,6 @@ public void translate(GeyserSession session, PlayerAuthInputPacket packet) { boolean wasJumping = session.getInputCache().wasJumping(); session.getInputCache().processInputs(entity, packet); - session.getBlockBreakHandler().handlePlayerAuthInputPacket(packet); - ServerboundPlayerCommandPacket sprintPacket = null; Set inputData = packet.getInputData(); @@ -185,7 +183,7 @@ public void translate(GeyserSession session, PlayerAuthInputPacket packet) { } // Java edition sends a cooldown when hitting air. - CooldownUtils.sendCooldown(session); + CooldownUtils.setCooldownHitTime(session); } } } @@ -209,7 +207,8 @@ public void translate(GeyserSession session, PlayerAuthInputPacket packet) { session.sendDownstreamGamePacket(sprintPacket); } - BedrockMovePlayer.translate(session, packet); + BedrockMovePlayer.translate(session, packet); + session.getBlockBreakHandler().handlePlayerAuthInputPacket(packet); // This is the best way send this since most modern anticheat will expect this to be in sync with the player movement packet. if (session.isSpawned()) { diff --git a/core/src/main/java/org/geysermc/geyser/util/BlockUtils.java b/core/src/main/java/org/geysermc/geyser/util/BlockUtils.java index 1921615920f..1a1440e386d 100644 --- a/core/src/main/java/org/geysermc/geyser/util/BlockUtils.java +++ b/core/src/main/java/org/geysermc/geyser/util/BlockUtils.java @@ -133,7 +133,7 @@ private static float getPlayerDestroySpeed(GeyserSession session, Block block, G destroySpeed *= (float) session.getPlayerEntity().getSubmergedMiningSpeed(); } - if (!session.getPlayerEntity().isOnGround()) { + if (!session.getPlayerEntity().isOnGround() && !session.isFlying()) { destroySpeed /= 5.0F; }