From 898706c66d726d87a50cafc7ec14365441336d24 Mon Sep 17 00:00:00 2001 From: Sollace Date: Mon, 9 Dec 2019 17:44:47 +0200 Subject: [PATCH] Use the entrypoint instead --- .../minelittlepony/client/MineLittlePony.java | 5 --- .../client/hdskins/DummyPonyModel.java | 3 +- .../client/hdskins/GuiSkinsMineLP.java | 2 +- .../client/hdskins/HDSkinsProxy.java | 22 ------------ .../client/hdskins/IndirectHDSkins.java | 13 ------- .../client/hdskins/MineLPHDSkins.java | 36 ++++++++++++------- src/main/resources/fabric.mod.json | 3 ++ 7 files changed, 29 insertions(+), 55 deletions(-) delete mode 100644 src/main/java/com/minelittlepony/client/hdskins/HDSkinsProxy.java delete mode 100644 src/main/java/com/minelittlepony/client/hdskins/IndirectHDSkins.java diff --git a/src/main/java/com/minelittlepony/client/MineLittlePony.java b/src/main/java/com/minelittlepony/client/MineLittlePony.java index 7ae2653f..c936451b 100644 --- a/src/main/java/com/minelittlepony/client/MineLittlePony.java +++ b/src/main/java/com/minelittlepony/client/MineLittlePony.java @@ -1,6 +1,5 @@ package com.minelittlepony.client; -import com.minelittlepony.client.hdskins.IndirectHDSkins; import com.minelittlepony.client.model.ModelType; import com.minelittlepony.client.pony.PonyManager; import com.minelittlepony.client.render.PonyRenderDispatcher; @@ -88,10 +87,6 @@ public class MineLittlePony implements ClientModInitializer { config.load(); - if (FabricLoader.getInstance().isModLoaded("hdskins")) { - IndirectHDSkins.initialize(); - } - ModelType.bootstrap(); } diff --git a/src/main/java/com/minelittlepony/client/hdskins/DummyPonyModel.java b/src/main/java/com/minelittlepony/client/hdskins/DummyPonyModel.java index f719e9db..fa318fb1 100644 --- a/src/main/java/com/minelittlepony/client/hdskins/DummyPonyModel.java +++ b/src/main/java/com/minelittlepony/client/hdskins/DummyPonyModel.java @@ -2,8 +2,7 @@ package com.minelittlepony.client.hdskins; import com.minelittlepony.client.model.entity.race.EarthPonyModel; -public class DummyPonyModel extends EarthPonyModel { - +class DummyPonyModel extends EarthPonyModel { public DummyPonyModel(boolean smallArms) { super(smallArms); } diff --git a/src/main/java/com/minelittlepony/client/hdskins/GuiSkinsMineLP.java b/src/main/java/com/minelittlepony/client/hdskins/GuiSkinsMineLP.java index 6a641cc3..b3923a2c 100644 --- a/src/main/java/com/minelittlepony/client/hdskins/GuiSkinsMineLP.java +++ b/src/main/java/com/minelittlepony/client/hdskins/GuiSkinsMineLP.java @@ -19,7 +19,7 @@ import net.minecraft.util.Identifier; /** * Skin uploading GUI. Usually displayed over the main menu. */ -public class GuiSkinsMineLP extends GuiSkins { +class GuiSkinsMineLP extends GuiSkins { private IPonyManager ponyManager = MineLittlePony.getInstance().getManager(); diff --git a/src/main/java/com/minelittlepony/client/hdskins/HDSkinsProxy.java b/src/main/java/com/minelittlepony/client/hdskins/HDSkinsProxy.java deleted file mode 100644 index e4f2ce99..00000000 --- a/src/main/java/com/minelittlepony/client/hdskins/HDSkinsProxy.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.minelittlepony.client.hdskins; - -import com.minelittlepony.client.SkinsProxy; -import com.minelittlepony.hdskins.HDSkins; -import com.minelittlepony.hdskins.profile.SkinType; -import com.mojang.authlib.GameProfile; -import net.minecraft.util.Identifier; - -class HDSkinsProxy extends SkinsProxy { - - @Override - public Identifier getSkinTexture(GameProfile profile) { - - Identifier skin = HDSkins.getInstance().getProfileRepository().getTextures(profile).get(SkinType.SKIN); - - if (skin != null) { - return skin; - } - - return super.getSkinTexture(profile); - } -} diff --git a/src/main/java/com/minelittlepony/client/hdskins/IndirectHDSkins.java b/src/main/java/com/minelittlepony/client/hdskins/IndirectHDSkins.java deleted file mode 100644 index 6a9e9f19..00000000 --- a/src/main/java/com/minelittlepony/client/hdskins/IndirectHDSkins.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.minelittlepony.client.hdskins; - -import org.apache.logging.log4j.LogManager; - -public final class IndirectHDSkins { - public static void initialize() { - try { - new MineLPHDSkins(); - } catch (Exception e) { - LogManager.getLogger().warn("Failed to initialize hooks for hdskins", e); - } - } -} diff --git a/src/main/java/com/minelittlepony/client/hdskins/MineLPHDSkins.java b/src/main/java/com/minelittlepony/client/hdskins/MineLPHDSkins.java index aa87ed90..1c00c3e3 100644 --- a/src/main/java/com/minelittlepony/client/hdskins/MineLPHDSkins.java +++ b/src/main/java/com/minelittlepony/client/hdskins/MineLPHDSkins.java @@ -4,9 +4,12 @@ import com.minelittlepony.client.MineLittlePony; import com.minelittlepony.client.SkinsProxy; import com.minelittlepony.common.event.ClientReadyCallback; import com.minelittlepony.hdskins.SkinCacheClearCallback; +import com.minelittlepony.hdskins.profile.SkinType; import com.minelittlepony.mson.api.Mson; +import com.mojang.authlib.GameProfile; -import net.minecraft.client.MinecraftClient; +import net.fabricmc.api.ClientModInitializer; +import net.minecraft.util.Identifier; import com.minelittlepony.client.pony.PonyManager; import com.minelittlepony.hdskins.HDSkins; @@ -14,25 +17,34 @@ import com.minelittlepony.hdskins.HDSkins; /** * All the interactions with HD Skins. */ -class MineLPHDSkins { +public class MineLPHDSkins extends SkinsProxy implements ClientModInitializer { - MineLPHDSkins() { - SkinsProxy.instance = new HDSkinsProxy(); + @Override + public void onInitializeClient() { + SkinsProxy.instance = this; - ClientReadyCallback.EVENT.register(this::postInit); + ClientReadyCallback.EVENT.register(client -> { + // Clear ponies when skins are cleared + PonyManager ponyManager = (PonyManager) MineLittlePony.getInstance().getManager(); + SkinCacheClearCallback.EVENT.register(ponyManager::onSkinCacheCleared); + + // Ponify the skins GUI. + HDSkins.getInstance().getSkinServerList().setSkinsGui(GuiSkinsMineLP::new); + }); // Preview on the select skin gui Mson.getInstance().getEntityRendererRegistry().registerEntityRenderer(DummyPony.TYPE, DummyPonyRenderer::new); } - private void postInit(MinecraftClient minecraft) { - HDSkins manager = HDSkins.getInstance(); + @Override + public Identifier getSkinTexture(GameProfile profile) { - // Clear ponies when skins are cleared - PonyManager ponyManager = (PonyManager) MineLittlePony.getInstance().getManager(); - SkinCacheClearCallback.EVENT.register(ponyManager::onSkinCacheCleared); + Identifier skin = HDSkins.getInstance().getProfileRepository().getTextures(profile).get(SkinType.SKIN); - // Ponify the skins GUI. - manager.getSkinServerList().setSkinsGui(GuiSkinsMineLP::new); + if (skin != null) { + return skin; + } + + return super.getSkinTexture(profile); } } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 73ae6616..76ed6a91 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -19,6 +19,9 @@ "client": [ "com.minelittlepony.client.MineLittlePony" ], + "hdskins": [ + "com.minelittlepony.client.hdskins.MineLPHDSkins" + ], "__disabled__modmenu": [ "com.minelittlepony.client.modmenu.MineLPModMenuFactory" ]