|
33 | 33 | import org.geysermc.geyser.entity.type.player.SessionPlayerEntity; |
34 | 34 | import org.geysermc.geyser.level.physics.CollisionResult; |
35 | 35 | import org.geysermc.geyser.session.GeyserSession; |
| 36 | +import org.geysermc.geyser.session.cache.tags.BlockTag; |
36 | 37 | import org.geysermc.geyser.text.ChatColor; |
37 | 38 | import org.geysermc.mcprotocollib.network.packet.Packet; |
38 | 39 | import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.player.ServerboundMovePlayerPosPacket; |
@@ -86,15 +87,28 @@ static void translate(GeyserSession session, PlayerAuthInputPacket packet) { |
86 | 87 | session.setLookBackScheduledFuture(null); |
87 | 88 | } |
88 | 89 |
|
| 90 | + // Simulate jumping since it happened this tick, not from the last tick end. |
| 91 | + if (entity.isOnGround() && packet.getInputData().contains(PlayerAuthInputData.START_JUMPING)) { |
| 92 | + entity.setLastTickEndVelocity(Vector3f.from(entity.getLastTickEndVelocity().getX(), Math.max(entity.getLastTickEndVelocity().getY(), entity.getJumpVelocity()), entity.getLastTickEndVelocity().getZ())); |
| 93 | + } |
| 94 | + |
| 95 | + // Due to how ladder works on Bedrock, we won't get climbing velocity from tick end unless if you're colliding horizontally. So we account for it ourselves. |
| 96 | + boolean onClimbableBlock = session.getTagCache().is(BlockTag.CLIMBABLE, session.getGeyser().getWorldManager().blockAt(session, entity.getPosition().sub(0, EntityDefinitions.PLAYER.offset(), 0).toInt()).block()); |
| 97 | + if (onClimbableBlock && packet.getInputData().contains(PlayerAuthInputData.JUMPING)) { |
| 98 | + entity.setLastTickEndVelocity(Vector3f.from(entity.getLastTickEndVelocity().getX(), 0.2F, entity.getLastTickEndVelocity().getZ())); |
| 99 | + } |
| 100 | + |
89 | 101 | // Client is telling us it wants to move down, but something is blocking it from doing so. |
90 | 102 | boolean isOnGround; |
91 | 103 | if (hasVehicle) { |
92 | 104 | // VERTICAL_COLLISION is not accurate while in a vehicle (as of 1.21.62) |
93 | | - isOnGround = Math.abs(packet.getDelta().getY()) < 0.1; |
| 105 | + isOnGround = Math.abs(entity.getLastTickEndVelocity().getY()) < 0.1; |
94 | 106 | } else { |
95 | | - isOnGround = packet.getInputData().contains(PlayerAuthInputData.VERTICAL_COLLISION) && packet.getDelta().getY() < 0; |
| 107 | + isOnGround = packet.getInputData().contains(PlayerAuthInputData.VERTICAL_COLLISION) && entity.getLastTickEndVelocity().getY() < 0; |
96 | 108 | } |
97 | 109 |
|
| 110 | + entity.setLastTickEndVelocity(packet.getDelta()); |
| 111 | + |
98 | 112 | // This takes into account no movement sent from the client, but the player is trying to move anyway. |
99 | 113 | // (Press into a wall in a corner - you're trying to move but nothing actually happens) |
100 | 114 | // This isn't sent when a player is riding a vehicle (as of 1.21.62) |
|
0 commit comments