SetCameraEntityS2CPacket
is a clientbound packet that will be sent to client when player interacts an entity while in spectator mode. This packet is mainly used for setting the player's camera to entity's position.
But what if we send SetCameraEntityS2CPacket
when player is NOT in spectator mode? Surprisingly, player didn't kick themselves from server, plus their camera is now attached to target entity! The camera behavior is what you would normally expect like spectating mob the normal way (eg: hide hotbars, add linear interpolation to camera). Setting the camera to self (self as in the player whose connection handler is controlling) returns everything to normal. I haven't tested what happens when you set the camera to other players.
While the camera is attached to another entity, player's input like moving, sneaking, jumping and looking around will still working normally. You can