mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00: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,35 +123,26 @@ 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();
|
// Work around there being a floor at the bottom of the world and teleport the player below it
|
||||||
// The void floor is offset about 40 blocks below the bottom of the world
|
// Moving from below to above the void floor works fine
|
||||||
BedrockDimension bedrockDimension = session.getChunkCache().getBedrockDimension();
|
entity.setPosition(entity.getPosition().sub(0, 4f, 0));
|
||||||
int voidFloorLocation = bedrockDimension.minY() - 40;
|
MovePlayerPacket movePlayerPacket = new MovePlayerPacket();
|
||||||
if (floorY <= (voidFloorLocation + 2) && floorY >= voidFloorLocation) {
|
movePlayerPacket.setRuntimeEntityId(entity.getGeyserId());
|
||||||
// Work around there being a floor at the bottom of the world and teleport the player below it
|
movePlayerPacket.setPosition(entity.getPosition());
|
||||||
// Moving from below to above the void floor works fine
|
movePlayerPacket.setRotation(entity.getBedrockRotation());
|
||||||
entity.setPosition(entity.getPosition().sub(0, 4f, 0));
|
movePlayerPacket.setMode(MovePlayerPacket.Mode.TELEPORT);
|
||||||
MovePlayerPacket movePlayerPacket = new MovePlayerPacket();
|
movePlayerPacket.setTeleportationCause(MovePlayerPacket.TeleportationCause.BEHAVIOR);
|
||||||
movePlayerPacket.setRuntimeEntityId(entity.getGeyserId());
|
session.sendUpstreamPacket(movePlayerPacket);
|
||||||
movePlayerPacket.setPosition(entity.getPosition());
|
|
||||||
movePlayerPacket.setRotation(entity.getBedrockRotation());
|
|
||||||
movePlayerPacket.setMode(MovePlayerPacket.Mode.TELEPORT);
|
|
||||||
movePlayerPacket.setTeleportationCause(MovePlayerPacket.TeleportationCause.BEHAVIOR);
|
|
||||||
session.sendUpstreamPacket(movePlayerPacket);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
session.getSkullCache().updateVisibleSkulls();
|
session.getSkullCache().updateVisibleSkulls();
|
||||||
|
|
Loading…
Reference in a new issue