2019-06-27 02:33:05 +02:00
|
|
|
package com.minelittlepony.client.hdskins;
|
2019-05-28 12:41:06 +02:00
|
|
|
|
2019-06-27 02:33:05 +02:00
|
|
|
import com.minelittlepony.client.hdskins.gui.DummyPony;
|
|
|
|
import com.minelittlepony.client.hdskins.gui.GuiSkinsMineLP;
|
|
|
|
import com.minelittlepony.client.hdskins.gui.RenderDummyPony;
|
2019-07-03 01:57:45 +02:00
|
|
|
import net.fabricmc.fabric.api.client.render.EntityRendererRegistry;
|
2019-05-28 12:41:06 +02:00
|
|
|
import net.minecraft.client.MinecraftClient;
|
2019-06-30 12:05:38 +02:00
|
|
|
import net.minecraft.util.Identifier;
|
2019-05-28 12:41:06 +02:00
|
|
|
|
|
|
|
import com.minelittlepony.client.MineLPClient;
|
2019-06-27 02:33:05 +02:00
|
|
|
|
2019-07-03 16:13:07 +02:00
|
|
|
import com.minelittlepony.client.settings.ClientPonyConfig;
|
2019-06-30 12:38:36 +02:00
|
|
|
import com.minelittlepony.client.LegacySkinConverter;
|
2019-05-28 12:41:06 +02:00
|
|
|
import com.minelittlepony.hdskins.HDSkins;
|
|
|
|
import com.minelittlepony.hdskins.net.LegacySkinServer;
|
|
|
|
import com.minelittlepony.hdskins.net.SkinServer;
|
|
|
|
import com.minelittlepony.hdskins.net.ValhallaSkinServer;
|
2019-06-30 12:05:38 +02:00
|
|
|
import com.mojang.authlib.GameProfile;
|
|
|
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
|
|
|
|
|
|
|
import javax.annotation.Nullable;
|
|
|
|
|
|
|
|
import java.util.Map;
|
2019-05-28 12:41:06 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* All the interactions with HD Skins.
|
|
|
|
*/
|
2019-06-27 02:33:05 +02:00
|
|
|
public class MineLPHDSkins extends MineLPClient {
|
2019-05-28 12:41:06 +02:00
|
|
|
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";
|
|
|
|
|
2019-07-03 01:57:45 +02:00
|
|
|
public MineLPHDSkins() {
|
2019-06-11 01:06:17 +02:00
|
|
|
SkinServer legacy = new LegacySkinServer(MINELP_LEGACY_SERVER, MINELP_LEGACY_GATEWAY);
|
|
|
|
SkinServer valhalla = new ValhallaSkinServer(MINELP_VALHALLA_SERVER);
|
2019-05-28 12:41:06 +02:00
|
|
|
// Register pony servers
|
2019-06-11 01:06:17 +02:00
|
|
|
HDSkins.getInstance().addSkinServer(legacy);
|
|
|
|
HDSkins.getInstance().addSkinServer(valhalla);
|
|
|
|
|
|
|
|
SkinServer.defaultServers.add(legacy);
|
2019-05-28 12:41:06 +02:00
|
|
|
// And make valhalla the default
|
2019-06-11 01:06:17 +02:00
|
|
|
SkinServer.defaultServers.add(0, valhalla);
|
2019-05-28 12:41:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when the game is ready.
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public void postInit(MinecraftClient minecraft) {
|
|
|
|
super.postInit(minecraft);
|
|
|
|
|
2019-06-30 12:05:38 +02:00
|
|
|
// Preview on the select skin gui
|
2019-07-03 01:57:45 +02:00
|
|
|
EntityRendererRegistry.INSTANCE.register(DummyPony.class, RenderDummyPony::new);
|
2019-06-30 12:05:38 +02:00
|
|
|
|
2019-05-28 12:41:06 +02:00
|
|
|
HDSkins manager = HDSkins.getInstance();
|
|
|
|
|
|
|
|
// Convert legacy pony skins
|
2019-06-30 12:38:36 +02:00
|
|
|
manager.addSkinModifier(new LegacySkinConverter());
|
2019-05-28 12:41:06 +02:00
|
|
|
// Parse trigger pixel data
|
|
|
|
manager.addSkinParser(new PonySkinParser());
|
|
|
|
// Clear ponies when skins are cleared
|
2019-06-27 02:33:05 +02:00
|
|
|
manager.addClearListener(getManager()::onSkinCacheCleared);
|
2019-05-28 12:41:06 +02:00
|
|
|
// Ponify the skins GUI.
|
|
|
|
manager.setSkinsGui(GuiSkinsMineLP::new);
|
|
|
|
}
|
2019-06-30 12:05:38 +02:00
|
|
|
|
2019-07-03 16:13:07 +02:00
|
|
|
@Override
|
|
|
|
protected ClientPonyConfig createConfig() {
|
|
|
|
return new ClientPonyConfigHDSkins();
|
|
|
|
}
|
|
|
|
|
2019-06-30 12:05:38 +02:00
|
|
|
@Override
|
|
|
|
public Map<MinecraftProfileTexture.Type, Identifier> getProfileTextures(@Nullable GameProfile profile) {
|
|
|
|
return HDSkins.getInstance().getTextures(profile);
|
|
|
|
}
|
2019-05-28 12:41:06 +02:00
|
|
|
}
|