3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-10-03 08:21:06 +02:00

Fix: Implement 1.20.30 START_FLYING and STOP_FLYING cases (#4198)

Dieser Commit ist enthalten in:
chris 2023-10-08 00:31:23 +02:00 committet von GitHub
Ursprung 30cca70e56
Commit dec62e94e2
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
2 geänderte Dateien mit 35 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -42,6 +42,7 @@ public class BedrockRequestAbilityTranslator extends PacketTranslator<RequestAbi
@Override @Override
public void translate(GeyserSession session, RequestAbilityPacket packet) { public void translate(GeyserSession session, RequestAbilityPacket packet) {
// TODO: Since 1.20.30, this was replaced by a START_FLYING and STOP_FLYING case in BedrockActionTranslator
if (packet.getAbility() == Ability.FLYING) { if (packet.getAbility() == Ability.FLYING) {
boolean isFlying = packet.isBoolValue(); boolean isFlying = packet.isBoolValue();
if (!isFlying && session.getGameMode() == GameMode.SPECTATOR) { if (!isFlying && session.getGameMode() == GameMode.SPECTATOR) {

Datei anzeigen

@ -297,6 +297,40 @@ public class BedrockActionTranslator extends PacketTranslator<PlayerActionPacket
session.sendUpstreamPacket(animatePacket); session.sendUpstreamPacket(animatePacket);
} }
break; break;
case START_FLYING: // Since 1.20.30
if (session.isCanFly()) {
if (session.getGameMode() == GameMode.SPECTATOR) {
// should already be flying
session.sendAdventureSettings();
break;
}
if (session.getPlayerEntity().getFlag(EntityFlag.SWIMMING) && session.getCollisionManager().isPlayerInWater()) {
// As of 1.18.1, Java Edition cannot fly while in water, but it can fly while crawling
// If this isn't present, swimming on a 1.13.2 server and then attempting to fly will put you into a flying/swimming state that is invalid on JE
session.sendAdventureSettings();
break;
}
session.setFlying(true);
session.sendDownstreamPacket(new ServerboundPlayerAbilitiesPacket(true));
} else {
// update whether we can fly
session.sendAdventureSettings();
// stop flying
PlayerActionPacket stopFlyingPacket = new PlayerActionPacket();
stopFlyingPacket.setRuntimeEntityId(session.getPlayerEntity().getGeyserId());
stopFlyingPacket.setAction(PlayerActionType.STOP_FLYING);
stopFlyingPacket.setBlockPosition(Vector3i.ZERO);
stopFlyingPacket.setResultPosition(Vector3i.ZERO);
stopFlyingPacket.setFace(0);
session.sendUpstreamPacket(stopFlyingPacket);
}
break;
case STOP_FLYING:
session.setFlying(false);
session.sendDownstreamPacket(new ServerboundPlayerAbilitiesPacket(false));
break;
} }
} }
} }