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;
|
|
|
|
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-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;
|
2019-05-30 21:25:20 +02:00
|
|
|
import net.minecraft.client.gui.MainMenuScreen;
|
2019-05-27 17:59:15 +02:00
|
|
|
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-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-05-30 14:09:24 +02:00
|
|
|
private KeyBinding keyBinding;
|
|
|
|
|
2019-03-24 00:04:54 +01:00
|
|
|
public static MineLPClient getInstance() {
|
|
|
|
return (MineLPClient)MineLittlePony.getInstance();
|
|
|
|
}
|
|
|
|
|
|
|
|
public MineLPClient(IModUtilities utils) {
|
|
|
|
utilities = utils;
|
|
|
|
}
|
|
|
|
|
2019-05-28 12:41:06 +02:00
|
|
|
protected void init(PonyConfig newConfig) {
|
2019-03-23 18:48:20 +01:00
|
|
|
config = newConfig;
|
2018-04-25 21:29:49 +02:00
|
|
|
ponyManager = new PonyManager(config);
|
2019-05-30 22:08:25 +02:00
|
|
|
keyBinding = utilities.registerKeybind("key.categories.misc", GLFW.GLFW_KEY_F9, "key.minelittlepony.settings");
|
2016-01-26 09:20:39 +01:00
|
|
|
}
|
|
|
|
|
2018-04-25 21:29:49 +02:00
|
|
|
/**
|
|
|
|
* Called when the game is ready.
|
|
|
|
*/
|
2019-05-28 12:41:06 +02:00
|
|
|
public void postInit(MinecraftClient minecraft) {
|
2019-05-27 17:59:15 +02:00
|
|
|
EntityRenderDispatcher rm = minecraft.getEntityRenderManager();
|
|
|
|
renderManager.initialiseRenderers(rm);
|
2019-05-28 12:41:06 +02:00
|
|
|
|
|
|
|
ReloadableResourceManager irrm = (ReloadableResourceManager) MinecraftClient.getInstance().getResourceManager();
|
|
|
|
irrm.registerListener(ponyManager);
|
2018-06-20 23:12:12 +02:00
|
|
|
}
|
2018-06-10 21:55:13 +02:00
|
|
|
|
2019-05-30 14:09:24 +02:00
|
|
|
public void onTick(MinecraftClient minecraft, boolean inGame) {
|
2019-05-30 21:25:20 +02:00
|
|
|
|
|
|
|
inGame &= minecraft.currentScreen == null;
|
|
|
|
|
|
|
|
boolean mainMenu = minecraft.currentScreen instanceof MainMenuScreen;
|
|
|
|
|
|
|
|
if (!inGame && mainMenu) {
|
|
|
|
KeyBinding.updatePressedStates();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((mainMenu || inGame) && keyBinding.isPressed()) {
|
|
|
|
minecraft.openScreen(new GuiHost(new GuiPonySettings()));
|
|
|
|
} else if (inGame) {
|
|
|
|
long handle = minecraft.window.getHandle();
|
|
|
|
|
|
|
|
if ((SystemUtil.getMeasuringTimeMs() % 10) == 0) {
|
|
|
|
if (InputUtil.isKeyPressed(handle, GLFW.GLFW_KEY_F3) && InputUtil.isKeyPressed(handle, GLFW.GLFW_KEY_M)) {
|
|
|
|
if (!reloadingModels) {
|
|
|
|
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")));
|
|
|
|
|
|
|
|
reloadingModels = true;
|
|
|
|
modelUpdateCounter++;
|
2018-10-02 00:04:27 +02:00
|
|
|
}
|
2019-05-30 21:25:20 +02:00
|
|
|
} else {
|
|
|
|
reloadingModels = false;
|
2018-10-02 00:04:27 +02:00
|
|
|
}
|
|
|
|
}
|
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
|
|
|
}
|