mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-26 14:27:59 +01:00
Use the entrypoint instead
This commit is contained in:
parent
afc5686915
commit
898706c66d
7 changed files with 29 additions and 55 deletions
|
@ -1,6 +1,5 @@
|
||||||
package com.minelittlepony.client;
|
package com.minelittlepony.client;
|
||||||
|
|
||||||
import com.minelittlepony.client.hdskins.IndirectHDSkins;
|
|
||||||
import com.minelittlepony.client.model.ModelType;
|
import com.minelittlepony.client.model.ModelType;
|
||||||
import com.minelittlepony.client.pony.PonyManager;
|
import com.minelittlepony.client.pony.PonyManager;
|
||||||
import com.minelittlepony.client.render.PonyRenderDispatcher;
|
import com.minelittlepony.client.render.PonyRenderDispatcher;
|
||||||
|
@ -88,10 +87,6 @@ public class MineLittlePony implements ClientModInitializer {
|
||||||
|
|
||||||
config.load();
|
config.load();
|
||||||
|
|
||||||
if (FabricLoader.getInstance().isModLoaded("hdskins")) {
|
|
||||||
IndirectHDSkins.initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
ModelType.bootstrap();
|
ModelType.bootstrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,7 @@ package com.minelittlepony.client.hdskins;
|
||||||
|
|
||||||
import com.minelittlepony.client.model.entity.race.EarthPonyModel;
|
import com.minelittlepony.client.model.entity.race.EarthPonyModel;
|
||||||
|
|
||||||
public class DummyPonyModel extends EarthPonyModel<DummyPony> {
|
class DummyPonyModel extends EarthPonyModel<DummyPony> {
|
||||||
|
|
||||||
public DummyPonyModel(boolean smallArms) {
|
public DummyPonyModel(boolean smallArms) {
|
||||||
super(smallArms);
|
super(smallArms);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ import net.minecraft.util.Identifier;
|
||||||
/**
|
/**
|
||||||
* Skin uploading GUI. Usually displayed over the main menu.
|
* Skin uploading GUI. Usually displayed over the main menu.
|
||||||
*/
|
*/
|
||||||
public class GuiSkinsMineLP extends GuiSkins {
|
class GuiSkinsMineLP extends GuiSkins {
|
||||||
|
|
||||||
private IPonyManager ponyManager = MineLittlePony.getInstance().getManager();
|
private IPonyManager ponyManager = MineLittlePony.getInstance().getManager();
|
||||||
|
|
||||||
|
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -4,9 +4,12 @@ import com.minelittlepony.client.MineLittlePony;
|
||||||
import com.minelittlepony.client.SkinsProxy;
|
import com.minelittlepony.client.SkinsProxy;
|
||||||
import com.minelittlepony.common.event.ClientReadyCallback;
|
import com.minelittlepony.common.event.ClientReadyCallback;
|
||||||
import com.minelittlepony.hdskins.SkinCacheClearCallback;
|
import com.minelittlepony.hdskins.SkinCacheClearCallback;
|
||||||
|
import com.minelittlepony.hdskins.profile.SkinType;
|
||||||
import com.minelittlepony.mson.api.Mson;
|
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.client.pony.PonyManager;
|
||||||
import com.minelittlepony.hdskins.HDSkins;
|
import com.minelittlepony.hdskins.HDSkins;
|
||||||
|
@ -14,25 +17,34 @@ import com.minelittlepony.hdskins.HDSkins;
|
||||||
/**
|
/**
|
||||||
* All the interactions with HD Skins.
|
* All the interactions with HD Skins.
|
||||||
*/
|
*/
|
||||||
class MineLPHDSkins {
|
public class MineLPHDSkins extends SkinsProxy implements ClientModInitializer {
|
||||||
|
|
||||||
MineLPHDSkins() {
|
@Override
|
||||||
SkinsProxy.instance = new HDSkinsProxy();
|
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
|
// Preview on the select skin gui
|
||||||
Mson.getInstance().getEntityRendererRegistry().registerEntityRenderer(DummyPony.TYPE, DummyPonyRenderer::new);
|
Mson.getInstance().getEntityRendererRegistry().registerEntityRenderer(DummyPony.TYPE, DummyPonyRenderer::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void postInit(MinecraftClient minecraft) {
|
@Override
|
||||||
HDSkins manager = HDSkins.getInstance();
|
public Identifier getSkinTexture(GameProfile profile) {
|
||||||
|
|
||||||
// Clear ponies when skins are cleared
|
Identifier skin = HDSkins.getInstance().getProfileRepository().getTextures(profile).get(SkinType.SKIN);
|
||||||
PonyManager ponyManager = (PonyManager) MineLittlePony.getInstance().getManager();
|
|
||||||
SkinCacheClearCallback.EVENT.register(ponyManager::onSkinCacheCleared);
|
|
||||||
|
|
||||||
// Ponify the skins GUI.
|
if (skin != null) {
|
||||||
manager.getSkinServerList().setSkinsGui(GuiSkinsMineLP::new);
|
return skin;
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.getSkinTexture(profile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,9 @@
|
||||||
"client": [
|
"client": [
|
||||||
"com.minelittlepony.client.MineLittlePony"
|
"com.minelittlepony.client.MineLittlePony"
|
||||||
],
|
],
|
||||||
|
"hdskins": [
|
||||||
|
"com.minelittlepony.client.hdskins.MineLPHDSkins"
|
||||||
|
],
|
||||||
"__disabled__modmenu": [
|
"__disabled__modmenu": [
|
||||||
"com.minelittlepony.client.modmenu.MineLPModMenuFactory"
|
"com.minelittlepony.client.modmenu.MineLPModMenuFactory"
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in a new issue