diff --git a/src/main/java/com/brohoof/minelittlepony/LiteModMineLittlePony.java b/src/main/java/com/brohoof/minelittlepony/LiteModMineLittlePony.java index 8e70b409..eb7ee080 100644 --- a/src/main/java/com/brohoof/minelittlepony/LiteModMineLittlePony.java +++ b/src/main/java/com/brohoof/minelittlepony/LiteModMineLittlePony.java @@ -2,52 +2,23 @@ package com.brohoof.minelittlepony; import java.io.File; -import org.lwjgl.input.Keyboard; - -import com.brohoof.minelittlepony.gui.PonySettingPanel; -import com.brohoof.minelittlepony.hdskins.gui.EntityPonyModel; -import com.brohoof.minelittlepony.hdskins.gui.GuiSkinsMineLP; -import com.brohoof.minelittlepony.hdskins.gui.RenderPonyModel; -import com.brohoof.minelittlepony.renderer.RenderPonySkeleton; -import com.brohoof.minelittlepony.renderer.RenderPonyVillager; -import com.brohoof.minelittlepony.renderer.RenderPonyZombie; -import com.brohoof.minelittlepony.util.MineLPLogger; import com.mumfrey.liteloader.InitCompleteListener; import com.mumfrey.liteloader.core.LiteLoader; -import com.mumfrey.liteloader.util.ModUtilities; -import com.voxelmodpack.hdskins.HDSkinManager; -import com.voxelmodpack.hdskins.gui.GuiSkins; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiMainMenu; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.client.settings.KeyBinding; -import net.minecraft.entity.monster.EntityPigZombie; -import net.minecraft.entity.monster.EntitySkeleton; -import net.minecraft.entity.monster.EntityZombie; -import net.minecraft.entity.passive.EntityVillager; public class LiteModMineLittlePony implements InitCompleteListener { - public static final String MOD_VERSION = "@VERSION@"; - public static final String MOD_NAME = "Mine Little Pony"; - public static final String SKIN_SERVER_URL = "minelpskins.voxelmodpack.com"; - public static final String GATEWAY_URL = "minelpskinmanager.voxelmodpack.com"; - public static final String UPLOAD_URL = "http://minelpskinmanager.voxelmodpack.com/"; - private static final KeyBinding guiKeybinding = new KeyBinding("Settings", Keyboard.KEY_F9, "Mine Little Pony"); - private static final KeyBinding skinKeybinding = new KeyBinding("Skin Manager", Keyboard.KEY_F1, "Mine Little Pony"); - - private PonyConfig config; - private PonyManager ponyManager; + private MineLittlePony mlp; @Override public String getName() { - return MOD_NAME; + return MineLittlePony.MOD_NAME; } @Override public String getVersion() { - return MOD_VERSION; + return MineLittlePony.MOD_VERSION; } @Override @@ -55,68 +26,19 @@ public class LiteModMineLittlePony implements InitCompleteListener { @Override public void init(File configPath) { - LiteLoader.getInput().registerKeyBinding(guiKeybinding); - LiteLoader.getInput().registerKeyBinding(skinKeybinding); + this.mlp = new MineLittlePony(); + this.mlp.init(); - // SettingsPanelManager.addSettingsPanel("Pony", - // MineLittlePonyGUI.class); - // SettingsPanelManager.addSettingsPanel("Pony Mobs", - // MineLittlePonyGUIMob.class); - - this.config = MineLittlePony.getConfig(); - this.ponyManager = MineLittlePony.getInstance().getManager(); - - LiteLoader.getInstance().registerExposable(config, null); } @Override public void onInitCompleted(Minecraft minecraft, LiteLoader loader) { - - HDSkinManager.clearSkinCache(); - HDSkinManager manager = HDSkinManager.INSTANCE; - manager.setSkinUrl(config.skinfix ? GATEWAY_URL : SKIN_SERVER_URL); - manager.setGatewayURL(GATEWAY_URL); - manager.addSkinModifier(new PonySkinModifier()); - MineLPLogger.info("Set MineLP skin server URL."); - - RenderManager rm = minecraft.getRenderManager(); - ModUtilities.addRenderer(EntityPonyModel.class, new RenderPonyModel(rm)); - if (this.config.villagers) { - ModUtilities.addRenderer(EntityVillager.class, new RenderPonyVillager(rm)); - MineLPLogger.info("Villagers are now ponies."); - } - - if (this.config.zombies) { - ModUtilities.addRenderer(EntityZombie.class, new RenderPonyZombie(rm)); - MineLPLogger.info("Zombies are now ponies."); - } - - if (this.config.pigzombies) { - ModUtilities.addRenderer(EntityPigZombie.class, new RenderPonyZombie(rm)); - MineLPLogger.info("Zombie pigmen are now ponies."); - } - - if (this.config.skeletons) { - ModUtilities.addRenderer(EntitySkeleton.class, new RenderPonySkeleton(rm)); - MineLPLogger.info("Skeletons are now ponies."); - } - + this.mlp.postInit(minecraft); } @Override public void onTick(Minecraft minecraft, float partialTicks, boolean inGame, boolean clock) { - if (inGame && minecraft.currentScreen == null && guiKeybinding.isPressed()) { - minecraft.displayGuiScreen(new PonySettingPanel()); - } - - boolean pressed = minecraft.currentScreen instanceof GuiMainMenu - && Keyboard.isKeyDown(skinKeybinding.getKeyCode()); - boolean skins = minecraft.currentScreen instanceof GuiSkins - && !(minecraft.currentScreen instanceof GuiSkinsMineLP); - if (pressed || skins) { - minecraft.displayGuiScreen(new GuiSkinsMineLP(ponyManager)); - } - HDSkinManager.INSTANCE.setEnabled(config.hd); + this.mlp.onTick(minecraft, inGame); } } diff --git a/src/main/java/com/brohoof/minelittlepony/MineLittlePony.java b/src/main/java/com/brohoof/minelittlepony/MineLittlePony.java index 7152c8ab..bc636528 100644 --- a/src/main/java/com/brohoof/minelittlepony/MineLittlePony.java +++ b/src/main/java/com/brohoof/minelittlepony/MineLittlePony.java @@ -1,25 +1,112 @@ package com.brohoof.minelittlepony; +import org.lwjgl.input.Keyboard; + +import com.brohoof.minelittlepony.gui.PonySettingPanel; +import com.brohoof.minelittlepony.hdskins.gui.EntityPonyModel; +import com.brohoof.minelittlepony.hdskins.gui.GuiSkinsMineLP; +import com.brohoof.minelittlepony.hdskins.gui.RenderPonyModel; +import com.brohoof.minelittlepony.model.PMAPI; +import com.brohoof.minelittlepony.renderer.RenderPonySkeleton; +import com.brohoof.minelittlepony.renderer.RenderPonyVillager; +import com.brohoof.minelittlepony.renderer.RenderPonyZombie; +import com.brohoof.minelittlepony.util.MineLPLogger; +import com.mumfrey.liteloader.core.LiteLoader; +import com.mumfrey.liteloader.util.ModUtilities; +import com.voxelmodpack.hdskins.HDSkinManager; +import com.voxelmodpack.hdskins.gui.GuiSkins; + import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiMainMenu; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.settings.KeyBinding; +import net.minecraft.entity.monster.EntityPigZombie; +import net.minecraft.entity.monster.EntitySkeleton; +import net.minecraft.entity.monster.EntityZombie; +import net.minecraft.entity.passive.EntityVillager; public class MineLittlePony { + public static final String MOD_NAME = "Mine Little Pony"; + public static final String MOD_VERSION = "@VERSION@"; + + private static final String SKIN_SERVER_URL = "minelpskins.voxelmodpack.com"; + private static final String GATEWAY_URL = "minelpskinmanager.voxelmodpack.com"; + private static final KeyBinding SETTINGS_GUI = new KeyBinding("Settings", Keyboard.KEY_F9, "Mine Little Pony"); + private static final KeyBinding SKIN_MANAGER = new KeyBinding("Skin Manager", Keyboard.KEY_F1, "Mine Little Pony"); + private static MineLittlePony instance; private PonyConfig config; private PonyManager ponyManager; private ProxyContainer proxy; - private MineLittlePony() { + MineLittlePony() { + instance = this; + } + + void init() { + LiteLoader.getInput().registerKeyBinding(SETTINGS_GUI); + LiteLoader.getInput().registerKeyBinding(SKIN_MANAGER); this.config = new PonyConfig(); this.ponyManager = new PonyManager(config); this.proxy = new ProxyContainer(); + + } + + void postInit(Minecraft minecraft) { + + HDSkinManager.clearSkinCache(); + HDSkinManager manager = HDSkinManager.INSTANCE; + manager.setSkinUrl(SKIN_SERVER_URL); + manager.setGatewayURL(GATEWAY_URL); + manager.addSkinModifier(new PonySkinModifier()); + MineLPLogger.info("Set MineLP skin server URL."); + + RenderManager rm = minecraft.getRenderManager(); + ModUtilities.addRenderer(EntityPonyModel.class, new RenderPonyModel(rm)); + if (this.config.villagers) { + ModUtilities.addRenderer(EntityVillager.class, new RenderPonyVillager(rm)); + MineLPLogger.info("Villagers are now ponies."); + } + + if (this.config.zombies) { + ModUtilities.addRenderer(EntityZombie.class, new RenderPonyZombie(rm)); + MineLPLogger.info("Zombies are now ponies."); + } + + if (this.config.pigzombies) { + ModUtilities.addRenderer(EntityPigZombie.class, new RenderPonyZombie(rm)); + MineLPLogger.info("Zombie pigmen are now ponies."); + } + + if (this.config.skeletons) { + ModUtilities.addRenderer(EntitySkeleton.class, new RenderPonySkeleton(rm)); + MineLPLogger.info("Skeletons are now ponies."); + } + + } + + void onTick(Minecraft minecraft, boolean inGame) { + if (inGame && minecraft.currentScreen == null && SETTINGS_GUI.isPressed()) { + minecraft.displayGuiScreen(new PonySettingPanel()); + } + + boolean pressed = minecraft.currentScreen instanceof GuiMainMenu + && Keyboard.isKeyDown(SKIN_MANAGER.getKeyCode()); + boolean skins = minecraft.currentScreen instanceof GuiSkins + && !(minecraft.currentScreen instanceof GuiSkinsMineLP); + if (pressed || skins) { + minecraft.displayGuiScreen(new GuiSkinsMineLP(ponyManager)); + } + HDSkinManager.INSTANCE.setEnabled(config.hd); + if (Keyboard.isKeyDown(Keyboard.KEY_O)) { + PMAPI.init(); + } } public static MineLittlePony getInstance() { - if (instance == null) - instance = new MineLittlePony(); return instance; } @@ -38,4 +125,5 @@ public class MineLittlePony { public static String getSPUsername() { return Minecraft.getMinecraft().getSession().getUsername(); } + }