2016-11-17 05:45:04 +01:00
|
|
|
package com.minelittlepony;
|
2015-08-02 00:36:33 +02:00
|
|
|
|
2018-06-20 23:21:21 +02:00
|
|
|
import com.minelittlepony.gui.GuiPonySettings;
|
2016-11-17 05:45:04 +01:00
|
|
|
import com.minelittlepony.hdskins.gui.GuiSkinsMineLP;
|
2019-03-23 18:48:20 +01:00
|
|
|
import com.minelittlepony.pony.data.PonyData;
|
2018-08-27 17:03:43 +02:00
|
|
|
import com.minelittlepony.pony.data.PonyDataSerialiser;
|
2018-12-09 22:18:17 +01:00
|
|
|
import com.minelittlepony.pony.data.PonyManager;
|
2018-09-05 10:12:38 +02:00
|
|
|
import com.minelittlepony.render.skull.PonySkullRenderer;
|
2016-01-26 09:20:39 +01:00
|
|
|
import com.voxelmodpack.hdskins.HDSkinManager;
|
2018-09-06 13:44:41 +02:00
|
|
|
import com.voxelmodpack.hdskins.server.LegacySkinServer;
|
|
|
|
import com.voxelmodpack.hdskins.server.SkinServer;
|
|
|
|
import com.voxelmodpack.hdskins.server.ValhallaSkinServer;
|
|
|
|
|
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;
|
2018-10-02 00:04:27 +02:00
|
|
|
import net.minecraft.util.text.Style;
|
|
|
|
import net.minecraft.util.text.TextComponentString;
|
|
|
|
import net.minecraft.util.text.TextComponentTranslation;
|
|
|
|
import net.minecraft.util.text.TextFormatting;
|
|
|
|
|
2016-11-24 08:01:23 +01:00
|
|
|
import org.lwjgl.input.Keyboard;
|
2015-11-17 06:17:35 +01:00
|
|
|
|
2018-04-25 21:29:49 +02:00
|
|
|
/**
|
|
|
|
* Static MineLittlePony singleton class. Everything's controlled from up here.
|
|
|
|
*/
|
2019-03-23 19:17:46 +01:00
|
|
|
public class MineLPClient extends MineLittlePony {
|
2018-04-25 21:29:49 +02:00
|
|
|
|
2018-07-28 21:35:41 +02:00
|
|
|
private static final String MINELP_VALHALLA_SERVER = "http://skins.minelittlepony-mod.com";
|
2018-07-14 05:05:21 +02:00
|
|
|
private static final String MINELP_LEGACY_SERVER = "http://minelpskins.voxelmodpack.com";
|
|
|
|
private static final String MINELP_LEGACY_GATEWAY = "http://minelpskinmanager.voxelmodpack.com";
|
2016-01-26 09:20:39 +01:00
|
|
|
|
2019-03-23 18:48:20 +01:00
|
|
|
static final KeyBinding SETTINGS_GUI = new KeyBinding("Settings", Keyboard.KEY_F9, "Mine Little Pony");
|
2016-01-26 09:20:39 +01:00
|
|
|
|
2018-10-02 00:04:27 +02:00
|
|
|
private static int modelUpdateCounter = 0;
|
|
|
|
private static boolean reloadingModels = false;
|
|
|
|
|
2019-03-23 18:48:20 +01:00
|
|
|
private PonyConfig config;
|
|
|
|
private PonyManager ponyManager;
|
2016-01-26 09:20:39 +01:00
|
|
|
|
2019-03-23 19:17:46 +01:00
|
|
|
private final PonyRenderManager renderManager = PonyRenderManager.getInstance();
|
2015-08-02 00:36:33 +02:00
|
|
|
|
2019-03-23 18:48:20 +01:00
|
|
|
void init(PonyConfig newConfig) {
|
|
|
|
config = newConfig;
|
2018-04-25 21:29:49 +02:00
|
|
|
ponyManager = new PonyManager(config);
|
2018-06-03 11:57:22 +02:00
|
|
|
|
2016-08-22 23:32:03 +02:00
|
|
|
IReloadableResourceManager irrm = (IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager();
|
2018-04-25 21:29:49 +02:00
|
|
|
irrm.registerReloadListener(ponyManager);
|
2016-11-24 08:01:23 +01:00
|
|
|
|
|
|
|
MetadataSerializer ms = Minecraft.getMinecraft().getResourcePackRepository().rprMetadataSerializer;
|
2019-03-23 18:48:20 +01:00
|
|
|
ms.registerMetadataSectionType(new PonyDataSerialiser(), PonyData.class);
|
2018-01-03 06:29:32 +01:00
|
|
|
|
|
|
|
// This also makes it the default gateway server.
|
2018-07-14 05:05:21 +02:00
|
|
|
SkinServer.defaultServers.add(new LegacySkinServer(MINELP_LEGACY_SERVER, MINELP_LEGACY_GATEWAY));
|
2018-07-28 21:35:41 +02:00
|
|
|
SkinServer.defaultServers.add(0, new ValhallaSkinServer(MINELP_VALHALLA_SERVER));
|
2016-01-26 09:20:39 +01:00
|
|
|
}
|
|
|
|
|
2018-04-25 21:29:49 +02:00
|
|
|
/**
|
|
|
|
* Called when the game is ready.
|
|
|
|
*/
|
2016-01-26 09:20:39 +01:00
|
|
|
void postInit(Minecraft minecraft) {
|
|
|
|
|
|
|
|
HDSkinManager manager = HDSkinManager.INSTANCE;
|
2017-08-08 22:34:09 +02:00
|
|
|
// manager.setSkinUrl(SKIN_SERVER_URL);
|
|
|
|
// manager.setGatewayURL(GATEWAY_URL);
|
2016-01-26 09:20:39 +01:00
|
|
|
manager.addSkinModifier(new PonySkinModifier());
|
2018-08-26 04:40:07 +02:00
|
|
|
manager.addSkinParser(new PonySkinParser());
|
2017-08-08 22:34:09 +02:00
|
|
|
// logger.info("Set MineLP skin server URL.");
|
2018-06-03 11:57:22 +02:00
|
|
|
manager.addClearListener(ponyManager);
|
2016-01-26 09:20:39 +01:00
|
|
|
|
2018-08-19 23:55:38 +02:00
|
|
|
manager.setSkinsGui(GuiSkinsMineLP::new);
|
2018-06-10 18:54:50 +02:00
|
|
|
|
2016-01-26 09:20:39 +01:00
|
|
|
RenderManager rm = minecraft.getRenderManager();
|
2019-03-23 19:17:46 +01:00
|
|
|
|
2018-04-25 21:29:49 +02:00
|
|
|
renderManager.initialisePlayerRenderers(rm);
|
|
|
|
renderManager.initializeMobRenderers(rm, config);
|
2018-06-20 23:12:12 +02:00
|
|
|
}
|
2018-06-10 21:55:13 +02:00
|
|
|
|
2018-06-20 23:21:21 +02:00
|
|
|
void onTick(Minecraft minecraft, boolean inGame) {
|
2018-10-02 00:04:27 +02:00
|
|
|
if (inGame && minecraft.currentScreen == null) {
|
|
|
|
if (SETTINGS_GUI.isPressed()) {
|
|
|
|
minecraft.displayGuiScreen(new GuiPonySettings());
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if ((Minecraft.getSystemTime() % 10) == 0) {
|
|
|
|
if (Keyboard.isKeyDown(Keyboard.KEY_F3) && Keyboard.isKeyDown(Keyboard.KEY_M)) {
|
|
|
|
if (!reloadingModels) {
|
|
|
|
minecraft.ingameGUI.getChatGUI().printChatMessage(
|
|
|
|
(new TextComponentString("")).appendSibling(
|
|
|
|
new TextComponentTranslation("debug.prefix")
|
|
|
|
.setStyle(new Style().setColor(TextFormatting.YELLOW).setBold(true)))
|
|
|
|
.appendText(" ")
|
|
|
|
.appendSibling(new TextComponentTranslation("minelp.debug.reload_models.message")));
|
|
|
|
|
|
|
|
reloadingModels = true;
|
|
|
|
modelUpdateCounter++;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
reloadingModels = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-06-20 23:21:21 +02:00
|
|
|
}
|
2018-06-20 23:28:29 +02:00
|
|
|
|
|
|
|
PonySkullRenderer.resolve();
|
2018-06-20 23:21:21 +02:00
|
|
|
}
|
|
|
|
|
2019-03-23 19:17:46 +01:00
|
|
|
@Override
|
2015-11-17 06:17:35 +01:00
|
|
|
public PonyManager getManager() {
|
2018-04-24 14:55:32 +02:00
|
|
|
return ponyManager;
|
2015-11-17 06:17:35 +01:00
|
|
|
}
|
2018-04-27 13:49:33 +02:00
|
|
|
|
2019-03-23 19:17:46 +01:00
|
|
|
@Override
|
|
|
|
public int getModelRevisionNumber() {
|
2018-10-02 00:04:27 +02:00
|
|
|
return modelUpdateCounter;
|
|
|
|
}
|
|
|
|
|
2018-04-25 21:29:49 +02:00
|
|
|
/**
|
|
|
|
* Gets the global MineLP client configuration.
|
|
|
|
*/
|
2019-03-23 19:17:46 +01:00
|
|
|
@Override
|
|
|
|
public PonyConfig getConfig() {
|
|
|
|
return config;
|
2015-08-02 00:36:33 +02:00
|
|
|
}
|
|
|
|
}
|