2019-03-23 20:49:34 +01:00
|
|
|
package com.minelittlepony.client;
|
2015-08-02 00:36:33 +02:00
|
|
|
|
2019-03-23 20:58:50 +01:00
|
|
|
import com.minelittlepony.MineLittlePony;
|
2019-03-23 20:49:34 +01:00
|
|
|
import com.minelittlepony.client.gui.GuiPonySettings;
|
2019-03-23 20:58:50 +01:00
|
|
|
import com.minelittlepony.client.gui.hdskins.GuiSkinsMineLP;
|
2019-03-23 20:49:34 +01:00
|
|
|
import com.minelittlepony.client.pony.PonyManager;
|
|
|
|
import com.minelittlepony.client.render.tileentities.skull.PonySkullRenderer;
|
2019-03-24 00:04:54 +01:00
|
|
|
import com.minelittlepony.common.client.gui.GuiHost;
|
2019-03-27 08:46:24 +01:00
|
|
|
import com.minelittlepony.hdskins.HDSkins;
|
|
|
|
import com.minelittlepony.hdskins.net.LegacySkinServer;
|
|
|
|
import com.minelittlepony.hdskins.net.SkinServer;
|
|
|
|
import com.minelittlepony.hdskins.net.ValhallaSkinServer;
|
2019-03-23 20:58:50 +01:00
|
|
|
import com.minelittlepony.settings.PonyConfig;
|
2018-09-06 13:44:41 +02:00
|
|
|
|
2019-05-27 17:59:15 +02:00
|
|
|
import net.minecraft.ChatFormat;
|
|
|
|
import net.minecraft.client.MinecraftClient;
|
|
|
|
import net.minecraft.client.options.KeyBinding;
|
|
|
|
import net.minecraft.client.render.entity.EntityRenderDispatcher;
|
|
|
|
import net.minecraft.client.util.InputUtil;
|
|
|
|
import net.minecraft.network.chat.Style;
|
|
|
|
import net.minecraft.network.chat.TextComponent;
|
|
|
|
import net.minecraft.network.chat.TranslatableComponent;
|
|
|
|
import net.minecraft.resource.ReloadableResourceManager;
|
|
|
|
import net.minecraft.util.SystemUtil;
|
2018-10-02 00:04:27 +02:00
|
|
|
|
2019-03-24 21:03:39 +01:00
|
|
|
import org.lwjgl.glfw.GLFW;
|
|
|
|
|
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-24 21:03:39 +01:00
|
|
|
static final KeyBinding SETTINGS_GUI = new KeyBinding("Settings", GLFW.GLFW_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-24 00:04:54 +01:00
|
|
|
private final IModUtilities utilities;
|
|
|
|
|
2019-03-23 19:17:46 +01:00
|
|
|
private final PonyRenderManager renderManager = PonyRenderManager.getInstance();
|
2015-08-02 00:36:33 +02:00
|
|
|
|
2019-03-24 00:04:54 +01:00
|
|
|
public static MineLPClient getInstance() {
|
|
|
|
return (MineLPClient)MineLittlePony.getInstance();
|
|
|
|
}
|
|
|
|
|
|
|
|
public MineLPClient(IModUtilities utils) {
|
|
|
|
utilities = utils;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2019-05-27 17:59:15 +02:00
|
|
|
ReloadableResourceManager irrm = (ReloadableResourceManager) MinecraftClient.getInstance().getResourceManager();
|
|
|
|
irrm.registerListener(ponyManager);
|
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.
|
|
|
|
*/
|
2019-05-27 17:59:15 +02:00
|
|
|
void postInit(MinecraftClient minecraft) {
|
2016-01-26 09:20:39 +01:00
|
|
|
|
2019-03-27 08:46:24 +01:00
|
|
|
HDSkins manager = HDSkins.getInstance();
|
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
|
|
|
|
2019-05-27 17:59:15 +02:00
|
|
|
EntityRenderDispatcher rm = minecraft.getEntityRenderManager();
|
2019-03-23 19:17:46 +01:00
|
|
|
|
2019-05-27 17:59:15 +02:00
|
|
|
renderManager.initialiseRenderers(rm);
|
2018-06-20 23:12:12 +02:00
|
|
|
}
|
2018-06-10 21:55:13 +02:00
|
|
|
|
2019-05-27 17:59:15 +02:00
|
|
|
void onTick(MinecraftClient minecraft, boolean inGame) {
|
2018-10-02 00:04:27 +02:00
|
|
|
if (inGame && minecraft.currentScreen == null) {
|
|
|
|
if (SETTINGS_GUI.isPressed()) {
|
2019-05-27 17:59:15 +02:00
|
|
|
minecraft.disconnect(new GuiHost(new GuiPonySettings()));
|
2018-10-02 00:04:27 +02:00
|
|
|
} else {
|
2019-05-27 17:59:15 +02:00
|
|
|
long handle = minecraft.window.getHandle();
|
2018-10-02 00:04:27 +02:00
|
|
|
|
2019-05-27 17:59:15 +02:00
|
|
|
if ((SystemUtil.getMeasuringTimeMs() % 10) == 0) {
|
|
|
|
if (InputUtil.isKeyPressed(handle, GLFW.GLFW_KEY_F3) && InputUtil.isKeyPressed(handle, GLFW.GLFW_KEY_M)) {
|
2018-10-02 00:04:27 +02:00
|
|
|
if (!reloadingModels) {
|
2019-05-27 17:59:15 +02:00
|
|
|
minecraft.inGameHud.getChatHud().addMessage(
|
|
|
|
(new TextComponent("")).append(
|
|
|
|
new TranslatableComponent("debug.prefix")
|
|
|
|
.setStyle(new Style().setColor(ChatFormat.YELLOW).setBold(true)))
|
|
|
|
.append(" ")
|
|
|
|
.append(new TranslatableComponent("minelp.debug.reload_models.message")));
|
2018-10-02 00:04:27 +02:00
|
|
|
|
|
|
|
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
|
|
|
}
|
2019-03-24 00:04:54 +01:00
|
|
|
|
|
|
|
public IModUtilities getModUtilities() {
|
|
|
|
return utilities;
|
|
|
|
}
|
2015-08-02 00:36:33 +02:00
|
|
|
}
|