Jump to content

Recommended Posts

Posted (edited)

The GuiGameOver screen is fired a second time on the OpenGuiEvent when the respawn button is pressed which is causing me serious problems. I've investigated the problem and it seems to stem from Minecraft's displayGuiScreen method which displays this screen if the player is below 0 hp. I don't know how vanilla isn't affected by this, but my own replacement GUI which is mostly copied from the GuiGameOver is displayed again after the respawn button is clicked.

I tried copying the displayGuiScreen method and removing the part which opens the GuiGameOver and using it in my GUI, but that didn't change anything. I have no idea why this is happening.

Edited by Melonslise
Posted
12 hours ago, Melonslise said:

1. The GuiGameOver screen is fired a second time on the OpenGuiEvent when the respawn button is pressed which is causing me serious problems. I've investigated the problem and it seems to stem from Minecraft's displayGuiScreen method which displays this screen if the player is below 0 hp.

 

You're right that the code is a bit convoluted. You'll notice that it only checks for < 0 health if the guiScreenIn parameter is null. It seems that the screen passed in is null when "escaping" from some GUIs and so then this section of code will check if the death GUI should be shown. I guess they do this instead of going back to the parent GUI (the normal thing you do when exiting a GUI) because there is a chance that you died while you had the other inventory up on the screen. 

 

The Minecraft#displayGuiScreen() method with GuiGameOver is also called from the NetHandlerPlayClient when it receives a SPacketCombatEvent for ENTITY_DIED in the case where the entity is the player.

 

So I suppose there could be a "race" condition that causes the event to fire twice -- once when client decides player health is < 0 and also when it receives packet from server notifying of the death. However, it is not clear to me that this would happen after pressing the respawn button.

  • Like 1

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted (edited)
55 minutes ago, jabelar said:

You're right that the code is a bit convoluted. You'll notice that it only checks for < 0 health if the guiScreenIn parameter is null. It seems that the screen passed in is null when "escaping" from some GUIs and so then this section of code will check if the death GUI should be shown. I guess they do this instead of going back to the parent GUI (the normal thing you do when exiting a GUI) because there is a chance that you died while you had the other inventory up on the screen. 

 

The Minecraft#displayGuiScreen() method with GuiGameOver is also called from the NetHandlerPlayClient when it receives a SPacketCombatEvent for ENTITY_DIED in the case where the entity is the player.

 

So I suppose there could be a "race" condition that causes the event to fire twice -- once when client decides player health is < 0 and also when it receives packet from server notifying of the death. However, it is not clear to me that this would happen after pressing the respawn button.

I thought that the reason was that the displayGuiScreen method was called from the respawn button. As I said, I tried writing my own version of the method and added it to the respawn button, however that didn't change anything. I urgently need to figure out how to fix this issue.

EDIT: Also I noticed that none of these bugs happen to the vanilla GUI. Even when you have a different screen open when you die. I don't understand why this happens to my custom gui only.

Edited by Melonslise

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.

Guest
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.

Announcements



×
×
  • Create New...

Important Information

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