Posted January 3, 201510 yr Hello all, I've been doing quite a bit of work on MachineMuse's Modular Powersuits lately and, after I realized that when one mod is loaded another must be loaded or issues with the player model occurs, I started trying to figure out how to generate a custom error screen when this condition arises, to prompt the user to install the required mod. Unfortunately, I can't seem to figure out how to generate said error, currently my client just breezes through the call as if there were nothing there. I must mention I'm not to concerned about the conditions at this point, I just want this error screen to display whenever the client starts up (the conditionals for this are simple enough and I'll be writing these in when I'm able to generate the error screen properly). my RenderPlayerAPIRequiredDisplayException class (language: scala) package net.machinemuse.general.gui import net.minecraft.client.gui.{GuiErrorScreen, FontRenderer} import cpw.mods.fml.client.CustomModLoadingErrorDisplayException class RenderPlayerAPIRequiredDisplayException extends CustomModLoadingErrorDisplayException { override def initGui(errorScreen: GuiErrorScreen, fontRenderer: FontRenderer) { errorScreen.initGui } override def drawScreen(errorScreen: GuiErrorScreen, fontRenderer: FontRenderer, mouseRelX: Int, mouseRelY: Int, tickTime: Float) { errorScreen.drawDefaultBackground var offset: Int = 75 errorScreen.drawCenteredString(fontRenderer, "A required mod is missing. Minecraft cannot continue loading.", errorScreen.width / 2, offset, 0xFFFFFF) offset += 15 errorScreen.drawCenteredString(fontRenderer, "The mod \'MachineMuse Modular Powersuits\' requires an additional mod \'RenderPlayerAPI\' when \'SmartMoving\' is loaded.", errorScreen.width / 2, offset, 0xEEEEEE) offset += 15 errorScreen.drawCenteredString(fontRenderer, "Please install \'RenderPlayerAPI\' to continue.", errorScreen.width / 2, offset, 0xFFFFFF) } } which is being called as such (the call is floating, still trying to determine where this goes and whether or not it's exactly the correct call to make): FMLClientHandler.instance.getClient.displayGuiScreen(new GuiCustomModLoadingErrorScreen(new RenderPlayerAPIRequiredDisplayException)) For the most part, I've been calling this in the client-side eventhandler methods within our CommonProxy class. I assumed this was the correct place to call this, else it would be trying to call this on the server (which would cause other errors)...
January 3, 201510 yr Author Read the Javadocs on CustomModLoadingErrorDisplayException. It says that you need to throw the exception' date=' not create a GuiScreen for it or anything.[/quote'] This was actually one of my initial tests, which threw a standard exception to the console rather than displaying the handled exception as intended... Attempting to reproduce this as we speak.
January 3, 201510 yr Author Oh, wow, I stand corrected, and I think I know why... The error was originally regarding "errorScreen.initGui" being called recursively (resulting in a stack overflow). Not sure why I thought this call was necessary, but this now works properly with line 8 of that class removed. For anybody else looking for how to do this, just modify the above class for your error message (make sure to remove "errorScreen.initGui" from line and put this in one of your client-side proxy calls (within the appropriate conditions): throw new WhateverINamedMyNewDisplayException Thanks diesieben07
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.