Posted August 24, 201411 yr How do I display a splash screen in the event of a fingerprint error? I already have a splash screen ready, and I am purposefully am giving it the wrong fingerprint to test this, but it will not work. Here is a copy of my fingerprint error event code: @EventHandler() public void invalidFingerprint(FMLFingerprintViolationEvent e) { if (References.FINGERPRINT.equals("FraWrk273tx9")) { LogHelper.info(Messages.CORRECT_FINGERPRINT_MESSAGE); } else { LogHelper.warn(Messages.INVALID_FINGERPRINT_MESSAGE); Minecraft.getMinecraft().displayGuiScreen(new GuiInvalidFingerprint()); } } It displays my log, but not the screen. I am the self-nominated Lord of the Mastodons and don't you dare deny it. Also, check out my YouTube channel: https://www.youtube.com/user/DerpDerp44/
August 24, 201411 yr Author I don't know if this is because I can't open a splash screen during preInit (where the FingerprintViolationEvent seems to be firing), or if I am doing something wrong. I am the self-nominated Lord of the Mastodons and don't you dare deny it. Also, check out my YouTube channel: https://www.youtube.com/user/DerpDerp44/
August 24, 201411 yr I don't know if this is because I can't open a splash screen during preInit (where the FingerprintViolationEvent seems to be firing), or if I am doing something wrong. It seems likely to me that that might be the problem -- not appropriate time for a GUI during pre-init. Maybe you can save a boolean that represents a fingerprint violation during the pre-init phase and then test that boolean later at a more appropriate time when GUI is possible. Check out my tutorials here: http://jabelarminecraft.blogspot.com/
August 24, 201411 yr Author I'd say you are probably right, however there seems to be no event that runs once the game starts up, and Minecraft itself does not seem to add any method that fires on startup, which would help create my own event. If anyone could post any links regarding this, I would very much appreciate it. I am the self-nominated Lord of the Mastodons and don't you dare deny it. Also, check out my YouTube channel: https://www.youtube.com/user/DerpDerp44/
August 24, 201411 yr Well, even post init might work better. But there are several more of these "FML lifecycle events" like server starting, server started, etc. that might also be appropriate. In my tutorial on events about a quarter of the way down, I list out all the FML lifecycle events: http://jabelarminecraft.blogspot.com/p/minecraft-forge-172-event-handling.html Check out my tutorials here: http://jabelarminecraft.blogspot.com/
August 24, 201411 yr CustomModLoadingErrorDisplayException I do Forge for free, however the servers to run it arn't free, so anything is appreciated. Consider supporting the team on Patreon
August 25, 201411 yr Author CustomModLoadingErrorDisplayException Is that an event, or an error log? I am the self-nominated Lord of the Mastodons and don't you dare deny it. Also, check out my YouTube channel: https://www.youtube.com/user/DerpDerp44/
August 25, 201411 yr Author Thank you so much Lex and diesieben, this helps a lot. My only question is how do I call it? I know that it says call it through a proxy, but I don't know how to do that. I am the self-nominated Lord of the Mastodons and don't you dare deny it. Also, check out my YouTube channel: https://www.youtube.com/user/DerpDerp44/
August 25, 201411 yr Author In a try/catch statement? I am the self-nominated Lord of the Mastodons and don't you dare deny it. Also, check out my YouTube channel: https://www.youtube.com/user/DerpDerp44/
August 25, 201411 yr Author Oh, now I understand. I throw CustomModLoadingErrorDisplayException from the invalidFingerprint method, right? I am the self-nominated Lord of the Mastodons and don't you dare deny it. Also, check out my YouTube channel: https://www.youtube.com/user/DerpDerp44/
August 25, 201411 yr Author But then how do I get it to display the splash screen? Sorry if it seems like I'm a bit of a noob, I just don't have too much experience in either java or modding. I am the self-nominated Lord of the Mastodons and don't you dare deny it. Also, check out my YouTube channel: https://www.youtube.com/user/DerpDerp44/
August 25, 201411 yr Author How do I read them? I am the self-nominated Lord of the Mastodons and don't you dare deny it. Also, check out my YouTube channel: https://www.youtube.com/user/DerpDerp44/
August 25, 201411 yr How do I read them? Okay, one of the biggest tips I can give new modders and programmers is to learn to use your IDE (Eclipse or IntelliJ) to *explore* and *investigate* the Minecraft / Forge / FML code. So if you know the name of a class, method or field, you can find it in several ways. In Eclipse you could do a Java search, but just make sure you correctly select what you're searching for (a method if it is a method, etc.) In this case you would search for a type of CustomModLoadingErrorDisplayException . You should see it come up in the search results pane and you can double-click to open the class. Another way is to take some class you've already got coded, type in CustomModLoadingErrorDisplayException somewhere and when Eclipse red-underlines it hover above and accept the suggested import. Then right click on it and select Open Declaration. That will take you right to the class. Lastly, you can hunt through the reference libraries themselves. I find this works okay if you already have a good idea where to look, but for something like this you might not be familiar enough to guess the right packages to check. Check out my tutorials here: http://jabelarminecraft.blogspot.com/
August 25, 201411 yr Author I opened the class, and it says this: If a mod throws this exception during loading, it will be called back to render the error screen through the methods below. This error will not be cleared, and will not allow the game to carry on, but might be useful if your mod wishes to report a fatal configuration error in a pretty way. Throw this through a proxy. It won't work on the dedicated server environment. So it's telling me to run the invalidFingerprint method through the proxy, which doesn't really make too much sense to me, because from what I know, the proxy is used for registering things like TileEntities and SpecialRenderers. I'm still not too clear how to call the initGui method inside the class as well. I am the self-nominated Lord of the Mastodons and don't you dare deny it. Also, check out my YouTube channel: https://www.youtube.com/user/DerpDerp44/
August 25, 201411 yr Author But then how do I specify which GuiScreen I want it to load? I can keep the invalidFingerprint method in my main mod class, but just instead of: public void invalidFingerprint(FMLFingerprintViolationEvent e) I write public void invalidFingerprint(FMLFingerprintViolationEvent e) throws CustomModLoadingErrorDisplayException I am the self-nominated Lord of the Mastodons and don't you dare deny it. Also, check out my YouTube channel: https://www.youtube.com/user/DerpDerp44/
August 25, 201411 yr Author So why is there an initGui method even in there? Also, my GuiScreen displays important information to the user, and the average Minecrafter is not smart enough to look closely at the error log and will most likely assume that my mod is broken and will delete it from their mods folder. I am the self-nominated Lord of the Mastodons and don't you dare deny it. Also, check out my YouTube channel: https://www.youtube.com/user/DerpDerp44/
August 25, 201411 yr Author Ok, so first of all, how do I access THAT method? What is the difference between a GuiErrorScreen and a GuiScreen? Do I make them the same way? I am the self-nominated Lord of the Mastodons and don't you dare deny it. Also, check out my YouTube channel: https://www.youtube.com/user/DerpDerp44/
August 25, 201411 yr Author Sorry if I seem like a real noob, I started java and modding very recently . So I can basically copy what was in my original drawScreen for the GuiScreen into the CustomModLoadingErrorDisplayException drawScreen? Again, sorry that I'm such a noob. If it helps at all, here's what was in my original GuiScreen class: public class GuiInvalidFingerprint extends CustomModLoadingErrorDisplayException { public void initGui() { this.buttonList.clear(); this.buttonList.add(new GuiOptionButton(0, this.width / 2 - 155 + 160, this.height / 4 + 120 + 12, I18n.format("gui.toMenu", new Object[0]))); this.buttonList.add(new GuiOptionButton(1, this.width / 2 - 155, this.height / 4 + 120 + 12, I18n.format("menu.quit", new Object [0]))); } protected void actionPerformed(GuiButton gb) { if(gb.id == 0) { this.mc.displayGuiScreen(new GuiMainMenu()); } else if(gb.id == 1) { this.mc.shutdown(); } } protected void keyTyped(char c, int i) { } public void drawScreen(int i, int j, float f) { this.drawDefaultBackground(); this.drawCenteredString(this.fontRendererObj, "Invalid Fingerprint Error!", this.width / 2, this.height - 60 + 20, 16777215); this.drawString(this.fontRendererObj, "Your mod " + References.MOD_NAME + " seems to have", this.width / 2 - 140, this.height - 60 + 60, 10526880); this.drawString(this.fontRendererObj, "an invalid fingerprint. This means that", this.width / 2 - 140, this.height - 60 + 60 + 18, 10526880); this.drawString(this.fontRendererObj, "in all likelihood, this version has been", this.width / 2 - 140, this.height - 60 + 60 + 27, 10526880); this.drawString(this.fontRendererObj, "tampered with, and may contain a virus.", this.width / 2 - 140, this.height - 60 + 60 + 36, 10526880); this.drawString(this.fontRendererObj, "It is suggested that you download it again", this.width / 2 - 140, this.height - 60 + 60 + 45, 1025880); this.drawString(this.fontRendererObj, "from the official site, which can be found", this.width / 2 - 140, this.height - 60 + 60 + 54, 1025880); this.drawString(this.fontRendererObj, "under " + References.MOD_NAME + ", in the 'Mods' page", this.width / 2 - 140, this.height - 60 + 60 + 63, 1025880); this.drawString(this.fontRendererObj, "of your startup screen.", this.width / 2 - 140, this.height - 60 + 60 + 72, 1025880); } } I am the self-nominated Lord of the Mastodons and don't you dare deny it. Also, check out my YouTube channel: https://www.youtube.com/user/DerpDerp44/
August 25, 201411 yr Author Again, sorry if I seem like a real noob. I am the self-nominated Lord of the Mastodons and don't you dare deny it. Also, check out my YouTube channel: https://www.youtube.com/user/DerpDerp44/
August 25, 201411 yr Author Is there something special I have to put in the initGui method? Because I am pretty sure it is throwing the exception, but the GUI is not showing up and Minecraft is not crashing. I am the self-nominated Lord of the Mastodons and don't you dare deny it. Also, check out my YouTube channel: https://www.youtube.com/user/DerpDerp44/
August 25, 201411 yr Author Ok, I understood that part about the buttons, I already knew that, but either it's not throwing the exception even though it's printing the log, or I'm missing something completely. Here's my new code: public class GuiInvalidFingerprint extends CustomModLoadingErrorDisplayException { @Override public void initGui(GuiErrorScreen errorScreen, FontRenderer fontRenderer) { } @Override public void drawScreen(GuiErrorScreen errorScreen, FontRenderer fontRenderer, int mouseRelX, int mouseRelY, float tickTime) { errorScreen.drawDefaultBackground(); errorScreen.drawCenteredString(fontRenderer, "Invalid Fingerprint Error!", errorScreen.width / 2, errorScreen.height - 60 + 20, 16777215); errorScreen.drawString(fontRenderer, "Your mod 'Atomic Fusion' seems to have", errorScreen.width / 2 - 140, errorScreen.height - 60 + 60, 10526880); errorScreen.drawString(fontRenderer, "an invalid fingerprint. This means that", errorScreen.width / 2 - 140, errorScreen.height - 60 + 60 + 18, 10526880); errorScreen.drawString(fontRenderer, "in all likelihood, this version has been", errorScreen.width / 2 - 140, errorScreen.height - 60 + 60 + 27, 10526880); errorScreen.drawString(fontRenderer, "tampered with, and may contain a virus.", errorScreen.width / 2 - 140, errorScreen.height - 60 + 60 + 36, 10526880); errorScreen.drawString(fontRenderer, "It is suggested that you download it again", errorScreen.width / 2 - 140, errorScreen.height - 60 + 60 + 45, 1025880); errorScreen.drawString(fontRenderer, "from the official site, which can be found", errorScreen.width / 2 - 140, errorScreen.height - 60 + 60 + 54, 1025880); errorScreen.drawString(fontRenderer, "under 'Atomic Fusion', in the 'Mods' page", errorScreen.width / 2 - 140, errorScreen.height - 60 + 60 + 63, 1025880); errorScreen.drawString(fontRenderer, "of your startup screen.", errorScreen.width / 2 - 140, errorScreen.height - 60 + 60 + 72, 1025880); } } And the invalidFingerprint method: @EventHandler() public void invalidFingerprint(FMLFingerprintViolationEvent e) throws CustomModLoadingErrorDisplayException { if (References.FINGERPRINT.equals("FraWrk273tx9")) { LogHelper.info(Messages.CORRECT_FINGERPRINT_MESSAGE); } else { LogHelper.warn(Messages.INVALID_FINGERPRINT_MESSAGE); } } I am the self-nominated Lord of the Mastodons and don't you dare deny it. Also, check out my YouTube channel: https://www.youtube.com/user/DerpDerp44/
August 25, 201411 yr Author The invalidFingerprint method throws the exception right after the first line, can't you see it? It specifically says, "throws CustomModLoadingErrorDisplayException". If there is any other place where I should be doing this, please let me know. I am the self-nominated Lord of the Mastodons and don't you dare deny it. Also, check out my YouTube channel: https://www.youtube.com/user/DerpDerp44/
August 25, 201411 yr Author I know the part about exceptions. They are thrown most of the time in a try/catch statement. The are basically the boolean of try/catch statements and if the catch part of the statement happens you can use the exception to log what went wrong and things like that. Another way to describe them is the else of an if statement. However, you said specifically not to use a try/catch statement inside my invalidFingerprint method, so the only other option I could think of is throwing the exception off of the class, which doesn't make sense because the code inside of there would never be fired. I am the self-nominated Lord of the Mastodons and don't you dare deny it. Also, check out my YouTube channel: https://www.youtube.com/user/DerpDerp44/
August 25, 201411 yr Author Then can you at least tell me what I should be doing? I will go look at a tutorial later today, as I have something I need to do now, but at least let me know how I can fix my problem. I am the self-nominated Lord of the Mastodons and don't you dare deny it. Also, check out my YouTube channel: https://www.youtube.com/user/DerpDerp44/
August 25, 201411 yr Author But WHERE/HOW do I throw it? I am the self-nominated Lord of the Mastodons and don't you dare deny it. Also, check out my YouTube channel: https://www.youtube.com/user/DerpDerp44/
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.