Jump to content

[1.7.10] Trying to generate a custom error message screen...


Korynkai

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 8) and put this in one of your client-side proxy calls (within the appropriate conditions):

 

throw new WhateverINamedMyNewDisplayException

 

 

Thanks diesieben07

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.

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.