forked from GeyserMC/Geyser
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
This commit is contained in:
parent
a17f2203a8
commit
77153e6d4a
1 changed files with 20 additions and 0 deletions
|
@ -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...");
|
||||||
|
|
Loading…
Reference in a new issue