Posted December 2, 20177 yr 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 December 3, 20177 yr by Melonslise
December 3, 20177 yr 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. Check out my tutorials here: http://jabelarminecraft.blogspot.com/
December 3, 20177 yr Author 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 December 3, 20177 yr by Melonslise
December 3, 20177 yr Author Ok I managed to fix the problem by closing the GUI if the player's health is higher than 0 in the the GUI's update method. It's a bit hacky, but it's the best I could come up with.
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.