diff --git a/server/session/player.go b/server/session/player.go index 0552af589..30d7a4a57 100644 --- a/server/session/player.go +++ b/server/session/player.go @@ -398,31 +398,33 @@ func (s *Session) SendGameMode(mode world.GameMode) { // sendAbilities sends the abilities of the Controllable entity of the session to the client. func (s *Session) sendAbilities() { - mode, abilities := s.c.GameMode(), uint32(0) + abilities := uint32(0) | protocol.AbilityMayFly | protocol.AbilityFlying | protocol.AbilityNoClip | protocol.AbilityInvulnerable | protocol.AbilityInstantBuild | protocol.AbilityBuild | protocol.AbilityMine | protocol.AbilityDoorsAndSwitches | protocol.AbilityOpenContainers | protocol.AbilityAttackPlayers | protocol.AbilityAttackMobs + mode, abilitiesValues := s.c.GameMode(), uint32(0) + if mode.AllowsFlying() { - abilities |= protocol.AbilityMayFly + abilitiesValues |= protocol.AbilityMayFly if s.c.Flying() { - abilities |= protocol.AbilityFlying + abilitiesValues |= protocol.AbilityFlying } } if !mode.HasCollision() { - abilities |= protocol.AbilityNoClip + abilitiesValues |= protocol.AbilityNoClip defer s.c.StartFlying() // If the client is currently on the ground and turned to spectator mode, it will be unable to sprint during // flight. In order to allow this, we force the client to be flying through a MovePlayer packet. s.ViewEntityTeleport(s.c, s.c.Position()) } if !mode.AllowsTakingDamage() { - abilities |= protocol.AbilityInvulnerable + abilitiesValues |= protocol.AbilityInvulnerable } if mode.CreativeInventory() { - abilities |= protocol.AbilityInstantBuild + abilitiesValues |= protocol.AbilityInstantBuild } if mode.AllowsEditing() { - abilities |= protocol.AbilityBuild | protocol.AbilityMine + abilitiesValues |= protocol.AbilityBuild | protocol.AbilityMine } if mode.AllowsInteraction() { - abilities |= protocol.AbilityDoorsAndSwitches | protocol.AbilityOpenContainers | protocol.AbilityAttackPlayers | protocol.AbilityAttackMobs + abilitiesValues |= protocol.AbilityDoorsAndSwitches | protocol.AbilityOpenContainers | protocol.AbilityAttackPlayers | protocol.AbilityAttackMobs } s.writePacket(&packet.UpdateAbilities{AbilityData: protocol.AbilityData{ EntityUniqueID: selfEntityRuntimeID, @@ -431,8 +433,8 @@ func (s *Session) sendAbilities() { Layers: []protocol.AbilityLayer{ // TODO: Support customization of fly and walk speeds. { Type: protocol.AbilityLayerTypeBase, - Abilities: protocol.AbilityCount - 1, - Values: abilities, + Abilities: abilities, + Values: abilitiesValues, FlySpeed: protocol.AbilityBaseFlySpeed, WalkSpeed: protocol.AbilityBaseWalkSpeed, },