mirror of
https://github.com/FatherToast/SpecialMobs.git
synced 2025-08-16 07:01:23 +00:00
config button!
This commit is contained in:
parent
cb85ac2945
commit
2c3ee5d601
2 changed files with 48 additions and 0 deletions
|
@ -0,0 +1,47 @@
|
||||||
|
package fathertoast.specialmobs.client;
|
||||||
|
|
||||||
|
import fathertoast.specialmobs.common.config.Config;
|
||||||
|
import fathertoast.specialmobs.common.core.SpecialMobs;
|
||||||
|
import mcp.MethodsReturnNonnullByDefault;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
|
import net.minecraft.util.Util;
|
||||||
|
import net.minecraft.util.text.StringTextComponent;
|
||||||
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
import net.minecraftforge.client.event.GuiOpenEvent;
|
||||||
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
|
import net.minecraftforge.fml.ExtensionPoint;
|
||||||
|
import net.minecraftforge.fml.ModLoadingContext;
|
||||||
|
import net.minecraftforge.fml.common.Mod;
|
||||||
|
|
||||||
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
|
||||||
|
@ParametersAreNonnullByDefault
|
||||||
|
@MethodsReturnNonnullByDefault
|
||||||
|
@Mod.EventBusSubscriber( value = Dist.CLIENT, modid = SpecialMobs.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE )
|
||||||
|
public class ClientEventHandler {
|
||||||
|
|
||||||
|
static void registerConfigGUIFactory() {
|
||||||
|
ModLoadingContext.get().registerExtensionPoint( ExtensionPoint.CONFIGGUIFACTORY,
|
||||||
|
() -> ClientEventHandler.OpenConfigFolderScreen::new );
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public static void onGuiOpen( GuiOpenEvent event ) {
|
||||||
|
if( event.getGui() instanceof OpenConfigFolderScreen ) {
|
||||||
|
event.setCanceled( true );
|
||||||
|
Util.getPlatform().openFile( Config.CONFIG_DIR );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This screen is effectively a redirect. It is opened when the "mod config" button is pressed with the goal of behaving
|
||||||
|
* like the "mods folder" button; i.e. just opens the appropriate folder.
|
||||||
|
*/
|
||||||
|
private static class OpenConfigFolderScreen extends Screen {
|
||||||
|
private OpenConfigFolderScreen( Minecraft game, Screen parent ) {
|
||||||
|
// We don't need to localize the name or do anything since the opening of this screen is always canceled
|
||||||
|
super( new StringTextComponent( "Opening mod config folder" ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -23,6 +23,7 @@ public class ClientRegister {
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onClientSetup( FMLClientSetupEvent event ) {
|
public static void onClientSetup( FMLClientSetupEvent event ) {
|
||||||
|
ClientEventHandler.registerConfigGUIFactory();
|
||||||
registerEntityRenderers();
|
registerEntityRenderers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue