mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-11-26 16:57:14 +01:00
Fix #3521
This commit is contained in:
parent
29f234d030
commit
c909b2b1a5
1 changed files with 32 additions and 23 deletions
|
@ -92,11 +92,29 @@ public class BedrockMovePlayerTranslator extends PacketTranslator<MovePlayerPack
|
||||||
if (isValidMove(session, entity.getPosition(), packet.getPosition())) {
|
if (isValidMove(session, entity.getPosition(), packet.getPosition())) {
|
||||||
Vector3d position = session.getCollisionManager().adjustBedrockPosition(packet.getPosition(), packet.isOnGround(), packet.getMode() == MovePlayerPacket.Mode.TELEPORT);
|
Vector3d position = session.getCollisionManager().adjustBedrockPosition(packet.getPosition(), packet.isOnGround(), packet.getMode() == MovePlayerPacket.Mode.TELEPORT);
|
||||||
if (position != null) { // A null return value cancels the packet
|
if (position != null) { // A null return value cancels the packet
|
||||||
|
boolean onGround = packet.isOnGround();
|
||||||
|
|
||||||
|
boolean teleportThroughVoidFloor;
|
||||||
|
// Compare positions here for void floor fix below before the player's position variable is set to the packet position
|
||||||
|
if (entity.getPosition().getY() >= packet.getPosition().getY()) {
|
||||||
|
int floorY = position.getFloorY();
|
||||||
|
// The void floor is offset about 40 blocks below the bottom of the world
|
||||||
|
BedrockDimension bedrockDimension = session.getChunkCache().getBedrockDimension();
|
||||||
|
int voidFloorLocation = bedrockDimension.minY() - 40;
|
||||||
|
teleportThroughVoidFloor = floorY <= (voidFloorLocation + 2) && floorY >= voidFloorLocation;
|
||||||
|
if (teleportThroughVoidFloor) {
|
||||||
|
// https://github.com/GeyserMC/Geyser/issues/3521 - no void floor in Java so we cannot be on the ground.
|
||||||
|
onGround = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
teleportThroughVoidFloor = false;
|
||||||
|
}
|
||||||
|
|
||||||
Packet movePacket;
|
Packet movePacket;
|
||||||
if (rotationChanged) {
|
if (rotationChanged) {
|
||||||
// Send rotation updates as well
|
// Send rotation updates as well
|
||||||
movePacket = new ServerboundMovePlayerPosRotPacket(
|
movePacket = new ServerboundMovePlayerPosRotPacket(
|
||||||
packet.isOnGround(),
|
onGround,
|
||||||
position.getX(), position.getY(), position.getZ(),
|
position.getX(), position.getY(), position.getZ(),
|
||||||
yaw, pitch
|
yaw, pitch
|
||||||
);
|
);
|
||||||
|
@ -105,24 +123,16 @@ public class BedrockMovePlayerTranslator extends PacketTranslator<MovePlayerPack
|
||||||
entity.setHeadYaw(headYaw);
|
entity.setHeadYaw(headYaw);
|
||||||
} else {
|
} else {
|
||||||
// Rotation did not change; don't send an update with rotation
|
// Rotation did not change; don't send an update with rotation
|
||||||
movePacket = new ServerboundMovePlayerPosPacket(packet.isOnGround(), position.getX(), position.getY(), position.getZ());
|
movePacket = new ServerboundMovePlayerPosPacket(onGround, position.getX(), position.getY(), position.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compare positions here for void floor fix below before the player's position variable is set to the packet position
|
|
||||||
boolean notMovingUp = entity.getPosition().getY() >= packet.getPosition().getY();
|
|
||||||
|
|
||||||
entity.setPositionManual(packet.getPosition());
|
entity.setPositionManual(packet.getPosition());
|
||||||
entity.setOnGround(packet.isOnGround());
|
entity.setOnGround(onGround);
|
||||||
|
|
||||||
// Send final movement changes
|
// Send final movement changes
|
||||||
session.sendDownstreamPacket(movePacket);
|
session.sendDownstreamPacket(movePacket);
|
||||||
|
|
||||||
if (notMovingUp) {
|
if (teleportThroughVoidFloor) {
|
||||||
int floorY = position.getFloorY();
|
|
||||||
// The void floor is offset about 40 blocks below the bottom of the world
|
|
||||||
BedrockDimension bedrockDimension = session.getChunkCache().getBedrockDimension();
|
|
||||||
int voidFloorLocation = bedrockDimension.minY() - 40;
|
|
||||||
if (floorY <= (voidFloorLocation + 2) && floorY >= voidFloorLocation) {
|
|
||||||
// Work around there being a floor at the bottom of the world and teleport the player below it
|
// Work around there being a floor at the bottom of the world and teleport the player below it
|
||||||
// Moving from below to above the void floor works fine
|
// Moving from below to above the void floor works fine
|
||||||
entity.setPosition(entity.getPosition().sub(0, 4f, 0));
|
entity.setPosition(entity.getPosition().sub(0, 4f, 0));
|
||||||
|
@ -134,7 +144,6 @@ public class BedrockMovePlayerTranslator extends PacketTranslator<MovePlayerPack
|
||||||
movePlayerPacket.setTeleportationCause(MovePlayerPacket.TeleportationCause.BEHAVIOR);
|
movePlayerPacket.setTeleportationCause(MovePlayerPacket.TeleportationCause.BEHAVIOR);
|
||||||
session.sendUpstreamPacket(movePlayerPacket);
|
session.sendUpstreamPacket(movePlayerPacket);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
session.getSkullCache().updateVisibleSkulls();
|
session.getSkullCache().updateVisibleSkulls();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue