Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand All @@ -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);
Expand All @@ -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
Expand All @@ -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());
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<PlayerAuthInputData> inputData = packet.getInputData();
Expand Down Expand Up @@ -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);
}
}
}
Expand All @@ -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()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Loading