2019-06-27 02:33:05 +02:00
|
|
|
package com.minelittlepony.client.hdskins;
|
2019-05-28 12:41:06 +02:00
|
|
|
|
2019-07-08 04:47:13 +02:00
|
|
|
import com.minelittlepony.client.MineLittlePony;
|
2019-06-30 04:01:28 +02:00
|
|
|
import com.minelittlepony.client.SkinsProxy;
|
2019-07-08 04:47:13 +02:00
|
|
|
import com.minelittlepony.common.event.ClientReadyCallback;
|
2020-01-28 11:40:44 +01:00
|
|
|
import com.minelittlepony.hdskins.client.SkinCacheClearCallback;
|
|
|
|
import com.minelittlepony.hdskins.client.gui.GuiSkins;
|
2020-03-27 19:14:50 +01:00
|
|
|
import com.minelittlepony.hdskins.profile.SkinType;
|
2019-11-26 22:55:39 +01:00
|
|
|
import com.minelittlepony.mson.api.Mson;
|
2019-12-09 16:44:47 +01:00
|
|
|
import com.mojang.authlib.GameProfile;
|
2019-11-23 18:28:42 +01:00
|
|
|
|
2019-12-09 16:44:47 +01:00
|
|
|
import net.fabricmc.api.ClientModInitializer;
|
|
|
|
import net.minecraft.util.Identifier;
|
2019-06-27 02:33:05 +02:00
|
|
|
|
2019-06-30 04:01:28 +02:00
|
|
|
import com.minelittlepony.client.pony.PonyManager;
|
2020-01-28 11:40:44 +01:00
|
|
|
import com.minelittlepony.hdskins.client.HDSkins;
|
2019-05-28 12:41:06 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* All the interactions with HD Skins.
|
|
|
|
*/
|
2019-12-09 16:44:47 +01:00
|
|
|
public class MineLPHDSkins extends SkinsProxy implements ClientModInitializer {
|
2019-05-28 12:41:06 +02:00
|
|
|
|
2019-12-09 16:44:47 +01:00
|
|
|
@Override
|
|
|
|
public void onInitializeClient() {
|
|
|
|
SkinsProxy.instance = this;
|
2019-06-30 04:01:28 +02:00
|
|
|
|
2019-12-09 16:44:47 +01:00
|
|
|
ClientReadyCallback.EVENT.register(client -> {
|
|
|
|
// Clear ponies when skins are cleared
|
|
|
|
PonyManager ponyManager = (PonyManager) MineLittlePony.getInstance().getManager();
|
2020-04-04 00:24:08 +02:00
|
|
|
SkinCacheClearCallback.EVENT.register(ponyManager::clearCache);
|
2019-12-09 16:44:47 +01:00
|
|
|
|
|
|
|
// Ponify the skins GUI.
|
2020-01-28 11:40:44 +01:00
|
|
|
GuiSkins.setSkinsGui(GuiSkinsMineLP::new);
|
2019-12-09 16:44:47 +01:00
|
|
|
});
|
2019-05-28 12:41:06 +02:00
|
|
|
|
2019-06-30 06:46:31 +02:00
|
|
|
// Preview on the select skin gui
|
2019-12-03 12:20:27 +01:00
|
|
|
Mson.getInstance().getEntityRendererRegistry().registerEntityRenderer(DummyPony.TYPE, DummyPonyRenderer::new);
|
2019-06-30 04:01:28 +02:00
|
|
|
}
|
2019-06-30 12:05:38 +02:00
|
|
|
|
2019-12-09 16:44:47 +01:00
|
|
|
@Override
|
|
|
|
public Identifier getSkinTexture(GameProfile profile) {
|
|
|
|
|
|
|
|
Identifier skin = HDSkins.getInstance().getProfileRepository().getTextures(profile).get(SkinType.SKIN);
|
2019-05-28 12:41:06 +02:00
|
|
|
|
2019-12-09 16:44:47 +01:00
|
|
|
if (skin != null) {
|
|
|
|
return skin;
|
|
|
|
}
|
2019-06-30 04:01:28 +02:00
|
|
|
|
2019-12-09 16:44:47 +01:00
|
|
|
return super.getSkinTexture(profile);
|
2019-05-28 12:41:06 +02:00
|
|
|
}
|
|
|
|
}
|