Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

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

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

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.