Fix elytra gliding

This commit is contained in:
Ethan 2024-07-08 18:17:28 +08:00
parent 086f62289f
commit 5f48d92a00

View file

@ -121,14 +121,10 @@ public class BedrockActionTranslator extends PacketTranslator<PlayerActionPacket
}
}
case START_GLIDE -> {
// Otherwise gliding will not work in creative
ServerboundPlayerAbilitiesPacket playerAbilitiesPacket = new ServerboundPlayerAbilitiesPacket(false);
session.sendDownstreamGamePacket(playerAbilitiesPacket);
}
case STOP_GLIDE -> {
ServerboundPlayerCommandPacket glidePacket = new ServerboundPlayerCommandPacket(entity.getEntityId(), PlayerState.START_ELYTRA_FLYING);
session.sendDownstreamGamePacket(glidePacket);
stopPlayerFlyingAbilities(session, entity);
sendPlayerGlideState(session, entity);
}
case STOP_GLIDE -> sendPlayerGlideState(session, entity);
case START_SNEAK -> {
ServerboundPlayerCommandPacket startSneakPacket = new ServerboundPlayerCommandPacket(entity.getEntityId(), PlayerState.START_SNEAKING);
session.sendDownstreamGamePacket(startSneakPacket);
@ -275,7 +271,8 @@ public class BedrockActionTranslator extends PacketTranslator<PlayerActionPacket
session.sendUpstreamPacket(stopBreak);
}
// Handled in BedrockInventoryTransactionTranslator
case STOP_BREAK -> {}
case STOP_BREAK -> {
}
case DIMENSION_CHANGE_SUCCESS -> {
//sometimes the client doesn't feel like loading
PlayStatusPacket spawnPacket = new PlayStatusPacket();
@ -380,4 +377,15 @@ public class BedrockActionTranslator extends PacketTranslator<PlayerActionPacket
levelEventPacket.setData(session.getBlockMappings().getBedrockBlock(blockState).getRuntimeId());
session.sendUpstreamPacket(levelEventPacket);
}
private void sendPlayerGlideState(GeyserSession session, Entity entity) {
ServerboundPlayerCommandPacket glidePacket = new ServerboundPlayerCommandPacket(entity.getEntityId(), PlayerState.START_ELYTRA_FLYING);
session.sendDownstreamGamePacket(glidePacket);
}
private void stopPlayerFlyingAbilities(GeyserSession session, Entity entity) {
// Otherwise gliding will not work in creative
ServerboundPlayerAbilitiesPacket playerAbilitiesPacket = new ServerboundPlayerAbilitiesPacket(false);
session.sendDownstreamGamePacket(playerAbilitiesPacket);
}
}