Skip to content

Commit

Permalink
Work around there being a void floor in Bedrock (#1405)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Camotoy authored Jan 1, 2021
1 parent a17f220 commit 77153e6
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,31 @@ public void translate(MovePlayerPacket packet, GeyserSession session) {
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.setOnGround(packet.isOnGround());

// Send final movement changes
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 {
// Not a valid move
session.getConnector().getLogger().debug("Recalculating position...");
Expand Down

0 comments on commit 77153e6

Please sign in to comment.