Jump to content

Best way to make the client close the deathscreen/respawn a player [1.16.5]


Recommended Posts

I'm trying to make a client respawn when certain conditions are met which I currently accomplish by just setting the player health to 20 however this does not cause the death screen to disapear.
Is there a way to eighter make the deathscreen disapear or send a message to the client to emulate a respawn button press?
If anyone knows of a better way to handle this that would work aswell.

Link to comment
Share on other sites

I think I have everything mostly down however this little bit of the packet sending is causing me grief:

    private static void respawnPlayer(ServerPlayerEntity player) {
        ImmortalityRespawnToClient msg = new ImmortalityRespawnToClient(true);
        PondWeaponMod.simpleChannel.send(PacketDistributor.PLAYER.with(player), msg);

I cannot figure out how the PacketDistributor#PLAYER.with function wants me to pass the ServerPlayerEntity.
It seems to ask for a Supplier<ServerPlayerEntity> but I cannot cast or figure out how to insert a ServerPlayerEntity into that.
If you could help me out here (or at least point me in the right direction) that would be greatly appreciated.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in

Sign In Now

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.