fix: initialize player abilities based on gamemode on first join (#1373)

when a player first joins with creative or spectator mode, their abilities
(flying, invulnerability, creative mode flag) were not being set, this caused
blocks to not display properly and flying to be disabled until switching
gamemodes

now calls set_for_gamemode() during player::new() to match vanilla

fixes #1367
This commit is contained in:
Purdze
2026-01-25 15:51:30 +00:00
committed by GitHub
parent 7d11858dc0
commit fc537c7e93

View File

@@ -452,6 +452,10 @@ impl Player {
PlayerScreenHandler::new(&inventory, None, 0).await,
));
// Initialize abilities based on gamemode (like vanilla's GameMode.setAbilities())
let mut abilities = Abilities::default();
abilities.set_for_gamemode(gamemode);
Self {
living_entity,
config: RwLock::new(config),
@@ -471,7 +475,7 @@ impl Player {
teleport_id_count: AtomicI32::new(0),
mining: AtomicBool::new(false),
mining_pos: Mutex::new(BlockPos::ZERO),
abilities: Mutex::new(Abilities::default()),
abilities: Mutex::new(abilities),
gamemode: AtomicCell::new(gamemode),
previous_gamemode: AtomicCell::new(None),
// TODO: Send the CPlayerSpawnPosition packet when the client connects with proper values