Sort out loading errors

This commit is contained in:
Sollace 2019-05-28 12:41:06 +02:00
parent 078fae82f3
commit 0ac4d4cba6
5 changed files with 97 additions and 33 deletions

View file

@ -9,6 +9,7 @@ import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.render.entity.EntityRenderer;
import net.minecraft.entity.Entity;
import com.minelittlepony.client.gui.hdskins.MineLPHDSkins;
import com.minelittlepony.client.settings.ClientPonyConfig;
import com.minelittlepony.hdskins.mixin.MixinEntityRenderDispatcher;
import com.minelittlepony.settings.SensibleJsonConfig;
@ -18,12 +19,17 @@ import java.util.function.Function;
public class FabMod implements ClientModInitializer, IModUtilities {
private final MineLPClient mlp = new MineLPClient(this);
@Override
public void onInitializeClient() {
mlp.init(SensibleJsonConfig.of(getConfigDirectory(), ClientPonyConfig::new));
mlp.postInit(MinecraftClient.getInstance());
MineLPClient mlp;
if (FabricLoader.getInstance().isModLoaded("hdskins")) {
mlp = new MineLPHDSkins(this);
} else {
mlp = new MineLPClient(this);
}
mlp.init(SensibleJsonConfig.of(getConfigDirectory().resolve("minelp.json"), ClientPonyConfig::new));
}
@Override

View file

@ -2,14 +2,9 @@ package com.minelittlepony.client;
import com.minelittlepony.MineLittlePony;
import com.minelittlepony.client.gui.GuiPonySettings;
import com.minelittlepony.client.gui.hdskins.GuiSkinsMineLP;
import com.minelittlepony.client.pony.PonyManager;
import com.minelittlepony.client.render.tileentities.skull.PonySkullRenderer;
import com.minelittlepony.common.client.gui.GuiHost;
import com.minelittlepony.hdskins.HDSkins;
import com.minelittlepony.hdskins.net.LegacySkinServer;
import com.minelittlepony.hdskins.net.SkinServer;
import com.minelittlepony.hdskins.net.ValhallaSkinServer;
import com.minelittlepony.settings.PonyConfig;
import net.minecraft.ChatFormat;
@ -30,9 +25,6 @@ import org.lwjgl.glfw.GLFW;
*/
public class MineLPClient extends MineLittlePony {
private static final String MINELP_VALHALLA_SERVER = "http://skins.minelittlepony-mod.com";
private static final String MINELP_LEGACY_SERVER = "http://minelpskins.voxelmodpack.com";
private static final String MINELP_LEGACY_GATEWAY = "http://minelpskinmanager.voxelmodpack.com";
static final KeyBinding SETTINGS_GUI = new KeyBinding("Settings", GLFW.GLFW_KEY_F9, "Mine Little Pony");
@ -54,36 +46,20 @@ public class MineLPClient extends MineLittlePony {
utilities = utils;
}
void init(PonyConfig newConfig) {
protected void init(PonyConfig newConfig) {
config = newConfig;
ponyManager = new PonyManager(config);
ReloadableResourceManager irrm = (ReloadableResourceManager) MinecraftClient.getInstance().getResourceManager();
irrm.registerListener(ponyManager);
// This also makes it the default gateway server.
SkinServer.defaultServers.add(new LegacySkinServer(MINELP_LEGACY_SERVER, MINELP_LEGACY_GATEWAY));
SkinServer.defaultServers.add(0, new ValhallaSkinServer(MINELP_VALHALLA_SERVER));
}
/**
* Called when the game is ready.
*/
void postInit(MinecraftClient minecraft) {
HDSkins manager = HDSkins.getInstance();
// manager.setSkinUrl(SKIN_SERVER_URL);
// manager.setGatewayURL(GATEWAY_URL);
manager.addSkinModifier(new PonySkinModifier());
manager.addSkinParser(new PonySkinParser());
// logger.info("Set MineLP skin server URL.");
manager.addClearListener(ponyManager);
manager.setSkinsGui(GuiSkinsMineLP::new);
public void postInit(MinecraftClient minecraft) {
EntityRenderDispatcher rm = minecraft.getEntityRenderManager();
renderManager.initialiseRenderers(rm);
ReloadableResourceManager irrm = (ReloadableResourceManager) MinecraftClient.getInstance().getResourceManager();
irrm.registerListener(ponyManager);
}
void onTick(MinecraftClient minecraft, boolean inGame) {

View file

@ -0,0 +1,57 @@
package com.minelittlepony.client.gui.hdskins;
import net.minecraft.client.MinecraftClient;
import com.minelittlepony.client.IModUtilities;
import com.minelittlepony.client.MineLPClient;
import com.minelittlepony.client.PonySkinModifier;
import com.minelittlepony.client.PonySkinParser;
import com.minelittlepony.hdskins.HDSkins;
import com.minelittlepony.hdskins.net.LegacySkinServer;
import com.minelittlepony.hdskins.net.SkinServer;
import com.minelittlepony.hdskins.net.ValhallaSkinServer;
import com.minelittlepony.settings.PonyConfig;
/**
* All the interactions with HD Skins.
*/
public class MineLPHDSkins extends MineLPClient {
private static final String MINELP_VALHALLA_SERVER = "http://skins.minelittlepony-mod.com";
private static final String MINELP_LEGACY_SERVER = "http://minelpskins.voxelmodpack.com";
private static final String MINELP_LEGACY_GATEWAY = "http://minelpskinmanager.voxelmodpack.com";
public MineLPHDSkins(IModUtilities utils) {
super(utils);
}
@Override
protected void init(PonyConfig newConfig) {
super.init(newConfig);
// Register pony servers
SkinServer.defaultServers.add(new LegacySkinServer(MINELP_LEGACY_SERVER, MINELP_LEGACY_GATEWAY));
// And make valhalla the default
SkinServer.defaultServers.add(0, new ValhallaSkinServer(MINELP_VALHALLA_SERVER));
}
/**
* Called when the game is ready.
*/
@Override
public void postInit(MinecraftClient minecraft) {
super.postInit(minecraft);
HDSkins manager = HDSkins.getInstance();
// Convert legacy pony skins
manager.addSkinModifier(new PonySkinModifier());
// Parse trigger pixel data
manager.addSkinParser(new PonySkinParser());
// Clear ponies when skins are cleared
manager.addClearListener(getManager());
// Ponify the skins GUI.
manager.setSkinsGui(GuiSkinsMineLP::new);
}
}

View file

@ -0,0 +1,24 @@
package com.minelittlepony.client.mixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import com.minelittlepony.client.MineLPClient;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.WindowEventHandler;
import net.minecraft.util.NonBlockingThreadExecutor;
import net.minecraft.util.snooper.SnooperListener;
@Mixin(MinecraftClient.class)
public abstract class MixinMinecraftClient extends NonBlockingThreadExecutor<Runnable> implements SnooperListener, WindowEventHandler, AutoCloseable {
public MixinMinecraftClient() { super(null); }
@Inject(method = "init()V", at = @At("RETURN"))
private void onInit(CallbackInfo info) {
MineLPClient.getInstance().postInit(MinecraftClient.getInstance());
}
}

View file

@ -10,6 +10,7 @@
"MixinFirstPersonRenderer",
"MixinGlStateManager",
"MixinItemRenderer",
"MixinMinecraftClient",
"MixinRenderManager",
"MixinThreadDownloadImageData"
]