Carpet

Carpet

2M Downloads

[Bug][Bots] Players spawned in survival while spawning player is in spectator, spawn flying in survival

Crec0 opened this issue ยท 2 comments

commented

Basically the title.

Steps to reproduce

  • Run /player Steve spawn at x y z facing u v in minecraft:overworld in survival, y being any y level mid air, while in spectator,

Expectation

  • Steve should fall on ground since its in survival mode

Observation

  • Steve will spawn flying midair in survival mode. If you do /player Steve move forward they walk forward mid air

Version info

  • Game: 1.17.1
  • Carpet 1.4.56
commented

boolean flying = false;
try
{
ServerPlayerEntity player = context.getSource().getPlayer();
mode = player.interactionManager.getGameMode();
flying = player.getAbilities().flying;
}

This is the problematic line of code, and looking at it it also applies to creative

commented

More info on the bug: It only occurs when the summoning player is actually flying (so doesn't work when walking in creative mode), and ye that's basically it.
Tbh it's an understandable mistake, and the fix is just as easy. I basically check if the game mode we're spawning the player in is survival-like and if so set flying abilities to false.