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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

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