Glowstone-Legacy icon indicating copy to clipboard operation
Glowstone-Legacy copied to clipboard

Spectator mode

Open choyiny opened this issue 9 years ago • 9 comments

Defaults back to survival mode when executing /gamemode 3

http://minecraft.gamepedia.com/Spectator

choyiny avatar Sep 20 '14 16:09 choyiny

Part of #131 (I think) as this is a 1.8 added feature.

Wild1145 avatar Sep 20 '14 21:09 Wild1145

#131 is more protocol, this is actual feature set.

turt2live avatar Sep 21 '14 02:09 turt2live

The flight thing should be fairly easy to fix in GlowPlayer#setGameMode, which automatically enforces allow-flight based on game mode. The challenge is figuring out where the noclip flag is transmitted to the client. Joining under creative mode and switching to spectator doesn't allow noclip. Joining under spectator and switching to creative still allows noclip and prevents hotbar selection. Both StateChangeMessage and PlayerAbilitiesMessage are sent in these switches and neither affects the noclip flag.

SpaceManiac avatar Oct 08 '14 05:10 SpaceManiac

Tried examining packet dumps to no avail.

Glowstone:

18:55:48 [INFO] SpaceManiac: Set own game mode to SPECTATOR mode
18:55:48 [INFO] !! StateChangeMessage(reason=3, value=3.0)
18:55:48 [INFO] !! PlayerAbilitiesMessage(flags=12, flySpeed=0.05, walkSpeed=0.1)
18:55:48 [INFO] !! ChatMessage(text=Message{"text":"Set own game mode to SPECTATOR mode"}, mode=0)
18:55:48 [INFO] !! PlayerAbilitiesMessage(flags=14, flySpeed=0.05, walkSpeed=0.1)
18:55:50 [INFO] <SpaceManiac> AFTER SET
18:55:50 [INFO] !! ChatMessage(text=Message{"text":"<SpaceManiac> AFTER SET"}, mode=0)
18:55:52 [INFO] !! TimeMessage(worldAge=22149000, time=22018)
18:55:53 [INFO] SpaceManiac issued command: /gamemode 0
18:55:53 [INFO] SpaceManiac: Set own game mode to SURVIVAL mode
18:55:53 [INFO] !! StateChangeMessage(reason=3, value=0.0)
18:55:53 [INFO] !! PlayerAbilitiesMessage(flags=0, flySpeed=0.05, walkSpeed=0.1)
18:55:53 [INFO] !! ChatMessage(text=Message{"text":"Set own game mode to SURVIVAL mode"}, mode=0)

Vanilla:

18:25:58 sock532 0b [00 39 07 3d 4c cc cd 3d cc cc cd] ..9.=L..=...
18:25:58 sock532 15 [00 38 01 01 9d a8 9f 95 b0 46 3d 46 b2 f9 0f ..8.......F=F...
18:25:58 sock532 7a c1 1c af 64 03] 07 [00 2b 03 40 40 00 00] 0b [00 z...d...+.@@....
18:25:58 sock532 39 07 3d 4c cc cd 3d cc cc cd] 24 [00 02 20 7b 22 9.=L..=...$.._{"
18:25:58 sock532 74 72 61 6e 73 6c 61 74 65 22 3a 22 67 61 6d 65 translate":"game
18:25:58 sock532 4d 6f 64 65 2e 63 68 61 6e 67 65 64 22 7d 01] Mode.changed"}.
18:25:58 sock532 06 [00 1c 01 00 20 7f] ....._.
18:25:58 sock532 12 [00 03 00 00 00 00 00 00 07 bb 00 00 00 00 00 ................
18:25:58 sock532 00 07 bb] ...

PlayerAbilitiesMessage(flags=7, flySpeed=0.05, walkSpeed=0.1)
UserListItemMessage(...)
StateChangeMessage(reason=3, value=3.0)
PlayerAbilitiesMessage(flags=7, flySpeed=0.05, walkSpeed=0.1)
ChatMessage(...)
EntityMetadataMessage(id=1, STATUS=0x20)
TimeMessage(...)

SpaceManiac avatar Nov 03 '14 04:11 SpaceManiac

It is actually the UserListItemMessage which causes the player to noclip. At the moment Glowstone isn't updating the player's gamemode in the 1.8 user list when it is changed, and as such that produces this issue. Fixing it is as simple as adding this to the end of setGameMode:

Message updateMessage = UserListItemMessage.gameModeOne(getUniqueId(), mode.getValue());
for (GlowPlayer player : server.getOnlinePlayers()) {
    if (player.canSee(this)) {
        player.getSession().send(updateMessage);
    }
}

coelho avatar Nov 14 '14 10:11 coelho

@coelho PR!

dequis avatar Nov 14 '14 18:11 dequis

The noclip bug discussed above was fixed by #546 in 060ff74eae7e8aa3dac1be841bc007b596f72d0d.

The full spectator mode remains to be implemented.

SpaceManiac avatar Nov 26 '14 07:11 SpaceManiac

The full spectator mode remains to be implemented

What's missing? I see invisibility was implemented in the last commnet of that PR, so no idea what else is that "full spectator mode" supposed to be.

dequis avatar Nov 27 '14 00:11 dequis

Being able to spectate entities (such as players) and use the spectator mode interface to teleport between players.

SpaceManiac avatar Nov 27 '14 01:11 SpaceManiac