3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-03 14:50:19 +01:00

Work around there being a void floor in Bedrock (#1405)

* Work around there being a void floor in Bedrock

If the player's Y coordinate is -38 or below, we teleport the player below the void floor and they can safely die. :)

* Don't teleport if below Y -40

* sigh

* Have floorY be its own variable

* Add more comment

* More comments

* Finish my thought
Dieser Commit ist enthalten in:
Camotoy 2020-12-31 20:05:00 -05:00 committet von GitHub
Ursprung a17f2203a8
Commit 77153e6d4a
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23

Datei anzeigen

@ -100,11 +100,31 @@ public class BedrockMovePlayerTranslator extends PacketTranslator<MovePlayerPack
movePacket = new ClientPlayerPositionPacket(packet.isOnGround(), position.getX(), position.getY(), position.getZ()); movePacket = new ClientPlayerPositionPacket(packet.isOnGround(), 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.setPosition(packet.getPosition(), false); entity.setPosition(packet.getPosition(), false);
entity.setOnGround(packet.isOnGround()); entity.setOnGround(packet.isOnGround());
// Send final movement changes // Send final movement changes
session.sendDownstreamPacket(movePacket); session.sendDownstreamPacket(movePacket);
if (notMovingUp) {
int floorY = position.getFloorY();
if (floorY <= -38 && floorY >= -40) {
// Work around there being a floor at Y -40 and teleport the player below it
// Moving from below Y -40 to above the void floor works fine
//TODO: This will need to be changed for 1.17
entity.setPosition(entity.getPosition().sub(0, 4f, 0));
MovePlayerPacket movePlayerPacket = new MovePlayerPacket();
movePlayerPacket.setRuntimeEntityId(entity.getGeyserId());
movePlayerPacket.setPosition(entity.getPosition());
movePlayerPacket.setRotation(entity.getBedrockRotation());
movePlayerPacket.setMode(MovePlayerPacket.Mode.TELEPORT);
movePlayerPacket.setTeleportationCause(MovePlayerPacket.TeleportationCause.BEHAVIOR);
session.sendUpstreamPacket(movePlayerPacket);
}
}
} else { } else {
// Not a valid move // Not a valid move
session.getConnector().getLogger().debug("Recalculating position..."); session.getConnector().getLogger().debug("Recalculating position...");