Use the entrypoint instead

This commit is contained in:
Sollace 2019-12-09 17:44:47 +02:00
parent afc5686915
commit 898706c66d
7 changed files with 29 additions and 55 deletions

View file

@ -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();
}

View file

@ -2,8 +2,7 @@ package com.minelittlepony.client.hdskins;
import com.minelittlepony.client.model.entity.race.EarthPonyModel;
public class DummyPonyModel extends EarthPonyModel<DummyPony> {
class DummyPonyModel extends EarthPonyModel<DummyPony> {
public DummyPonyModel(boolean smallArms) {
super(smallArms);
}

View file

@ -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();

View file

@ -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);
}
}

View file

@ -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);
}
}
}

View file

@ -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);
}
}

View file

@ -19,6 +19,9 @@
"client": [
"com.minelittlepony.client.MineLittlePony"
],
"hdskins": [
"com.minelittlepony.client.hdskins.MineLPHDSkins"
],
"__disabled__modmenu": [
"com.minelittlepony.client.modmenu.MineLPModMenuFactory"
]