MineLittlePony/src/main/java/com/minelittlepony/MineLittlePony.java

125 lines
4 KiB
Java
Raw Normal View History

2016-11-17 05:45:04 +01:00
package com.minelittlepony;
2015-08-02 00:36:33 +02:00
2016-11-17 05:45:04 +01:00
import com.minelittlepony.hdskins.gui.GuiSkinsMineLP;
import com.minelittlepony.pony.data.IPonyData;
import com.minelittlepony.pony.data.PonyDataSerialzier;
2016-01-26 09:20:39 +01:00
import com.mumfrey.liteloader.core.LiteLoader;
import com.voxelmodpack.hdskins.HDSkinManager;
import com.voxelmodpack.hdskins.gui.GuiSkins;
import com.voxelmodpack.hdskins.skins.SkinServer;
2015-08-02 00:36:33 +02:00
import net.minecraft.client.Minecraft;
2016-01-26 09:20:39 +01:00
import net.minecraft.client.renderer.entity.RenderManager;
2016-08-22 23:32:03 +02:00
import net.minecraft.client.resources.IReloadableResourceManager;
2016-11-24 08:01:23 +01:00
import net.minecraft.client.resources.data.MetadataSerializer;
2016-01-26 09:20:39 +01:00
import net.minecraft.client.settings.KeyBinding;
2016-11-25 05:40:19 +01:00
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.lwjgl.input.Keyboard;
/**
* Static MineLittlePony singleton class. Everything's controlled from up here.
*/
2016-01-26 09:16:11 +01:00
public class MineLittlePony {
2016-11-25 05:40:19 +01:00
public static final Logger logger = LogManager.getLogger("MineLittlePony");
public static final String MOD_NAME = "Mine Little Pony";
public static final String MOD_VERSION = "@VERSION@";
2018-05-01 19:30:47 +02:00
private static final String SKIN_SERVER_URL = "minelpskins.voxelmodpack.com";
private static final String GATEWAY_URL = "minelpskinmanager.voxelmodpack.com";
2016-01-26 09:20:39 +01:00
private static final KeyBinding SETTINGS_GUI = new KeyBinding("Settings", Keyboard.KEY_F9, "Mine Little Pony");
private static MineLittlePony instance;
private final PonyConfig config;
private final PonyManager ponyManager;
2015-08-02 00:36:33 +02:00
private final PonyRenderManager renderManager;
2016-01-26 09:20:39 +01:00
MineLittlePony() {
instance = this;
LiteLoader.getInput().registerKeyBinding(SETTINGS_GUI);
2015-08-02 00:36:33 +02:00
config = new PonyConfig();
ponyManager = new PonyManager(config);
renderManager = new PonyRenderManager();
LiteLoader.getInstance().registerExposable(config, null);
2016-08-22 23:32:03 +02:00
IReloadableResourceManager irrm = (IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager();
irrm.registerReloadListener(ponyManager);
2016-11-24 08:01:23 +01:00
MetadataSerializer ms = Minecraft.getMinecraft().getResourcePackRepository().rprMetadataSerializer;
ms.registerMetadataSectionType(new PonyDataSerialzier(), IPonyData.class);
// This also makes it the default gateway server.
SkinServer.defaultServers.add("legacy:" + SKIN_SERVER_URL + ";" + GATEWAY_URL);
2016-01-26 09:20:39 +01:00
}
/**
* Called when the game is ready.
*/
2016-01-26 09:20:39 +01:00
void postInit(Minecraft minecraft) {
HDSkinManager manager = HDSkinManager.INSTANCE;
// manager.setSkinUrl(SKIN_SERVER_URL);
// manager.setGatewayURL(GATEWAY_URL);
2016-01-26 09:20:39 +01:00
manager.addSkinModifier(new PonySkinModifier());
// logger.info("Set MineLP skin server URL.");
2016-01-26 09:20:39 +01:00
RenderManager rm = minecraft.getRenderManager();
renderManager.initialisePlayerRenderers(rm);
renderManager.initializeMobRenderers(rm, config);
2016-01-26 09:20:39 +01:00
}
/**
* Called on every update tick
*/
2016-01-26 09:20:39 +01:00
void onTick(Minecraft minecraft, boolean inGame) {
2016-01-26 09:20:39 +01:00
if (inGame && minecraft.currentScreen == null && SETTINGS_GUI.isPressed()) {
minecraft.displayGuiScreen(new PonySettingPanel());
}
boolean skins = minecraft.currentScreen instanceof GuiSkins
&& !(minecraft.currentScreen instanceof GuiSkinsMineLP);
if (skins) {
2016-01-26 09:20:39 +01:00
minecraft.displayGuiScreen(new GuiSkinsMineLP(ponyManager));
}
HDSkinManager.INSTANCE.setEnabled(config.hd);
2015-08-02 00:36:33 +02:00
}
/**
* Gets the global MineLP instance.
*/
2016-01-26 09:16:11 +01:00
public static MineLittlePony getInstance() {
return instance;
2015-08-02 00:36:33 +02:00
}
/**
* Gets the static pony manager instance.
*/
public PonyManager getManager() {
return ponyManager;
}
/**
* Gets the static pony render manager responsible for all entity renderers.
*/
public PonyRenderManager getRenderManager() {
return renderManager;
}
/**
* Gets the global MineLP client configuration.
*/
public static PonyConfig getConfig() {
2015-08-02 00:36:33 +02:00
return getInstance().config;
}
}