Remove hdskins requirement for parsing skins

This commit is contained in:
Matthew Messinger 2019-07-03 20:38:39 -04:00
parent 4050cf23b0
commit 6f6182e331
4 changed files with 39 additions and 42 deletions

View file

@ -50,8 +50,6 @@ public class MineLPHDSkins {
// Convert legacy pony skins // Convert legacy pony skins
manager.addSkinModifier(new LegacySkinConverter()); manager.addSkinModifier(new LegacySkinConverter());
// Parse trigger pixel data
manager.addSkinParser(new PonySkinParser());
// Clear ponies when skins are cleared // Clear ponies when skins are cleared
PonyManager ponyManager = (PonyManager) MineLittlePony.getInstance().getManager(); PonyManager ponyManager = (PonyManager) MineLittlePony.getInstance().getManager();
manager.addClearListener(ponyManager::onSkinCacheCleared); manager.addClearListener(ponyManager::onSkinCacheCleared);

View file

@ -1,30 +0,0 @@
package com.minelittlepony.client.hdskins;
import com.minelittlepony.MineLittlePony;
import com.minelittlepony.client.model.races.PlayerModels;
import com.minelittlepony.hdskins.ISkinParser;
import com.minelittlepony.hdskins.VanillaModels;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import net.minecraft.util.Identifier;
import java.util.Map;
public class PonySkinParser implements ISkinParser {
@Override
public void parse(GameProfile profile, MinecraftProfileTexture.Type type, Identifier resource,
Map<String, String> metadata) {
if (type == MinecraftProfileTexture.Type.SKIN) {
boolean slim = VanillaModels.isSlim(metadata.get("model"));
// TODO use proper model metadata system
metadata.put("model", PlayerModels.forRace(MineLittlePony.getInstance().getManager()
.getPony(resource, profile.getId())
.getRace(false))
.getId(slim));
}
}
}

View file

@ -5,17 +5,10 @@ import com.minelittlepony.client.gui.GuiPonySettings;
import com.minelittlepony.client.pony.PonyManager; import com.minelittlepony.client.pony.PonyManager;
import com.minelittlepony.client.render.tileentities.skull.PonySkullRenderer; import com.minelittlepony.client.render.tileentities.skull.PonySkullRenderer;
import com.minelittlepony.client.settings.ClientPonyConfig; import com.minelittlepony.client.settings.ClientPonyConfig;
import com.minelittlepony.common.event.SkinAvailableCallback;
import com.minelittlepony.common.util.GamePaths; import com.minelittlepony.common.util.GamePaths;
import com.minelittlepony.settings.JsonConfig; import com.minelittlepony.settings.JsonConfig;
import com.minelittlepony.settings.PonyConfig; import com.minelittlepony.settings.PonyConfig;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import javax.annotation.Nullable;
import java.util.Map;
import java.util.stream.Collectors;
import net.fabricmc.fabric.api.client.keybinding.FabricKeyBinding; import net.fabricmc.fabric.api.client.keybinding.FabricKeyBinding;
import net.fabricmc.fabric.api.client.keybinding.KeyBindingRegistry; import net.fabricmc.fabric.api.client.keybinding.KeyBindingRegistry;
import net.fabricmc.fabric.api.resource.ResourceManagerHelper; import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
@ -23,7 +16,6 @@ import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.TitleScreen; import net.minecraft.client.gui.screen.TitleScreen;
import net.minecraft.client.options.KeyBinding; import net.minecraft.client.options.KeyBinding;
import net.minecraft.client.render.entity.EntityRenderDispatcher; import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.texture.PlayerSkinProvider;
import net.minecraft.client.util.InputUtil; import net.minecraft.client.util.InputUtil;
import net.minecraft.resource.ResourceType; import net.minecraft.resource.ResourceType;
import net.minecraft.text.LiteralText; import net.minecraft.text.LiteralText;
@ -32,7 +24,6 @@ import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting; import net.minecraft.util.Formatting;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.SystemUtil; import net.minecraft.util.SystemUtil;
import org.lwjgl.glfw.GLFW; import org.lwjgl.glfw.GLFW;
/** /**
@ -62,6 +53,9 @@ public class MineLPClient extends MineLittlePony {
KeyBindingRegistry.INSTANCE.register(keyBinding); KeyBindingRegistry.INSTANCE.register(keyBinding);
ResourceManagerHelper.get(ResourceType.CLIENT_RESOURCES).registerReloadListener(ponyManager); ResourceManagerHelper.get(ResourceType.CLIENT_RESOURCES).registerReloadListener(ponyManager);
// Parse trigger pixel data
SkinAvailableCallback.EVENT.register(new PonySkinParser());
} }
protected ClientPonyConfig createConfig() { protected ClientPonyConfig createConfig() {

View file

@ -0,0 +1,35 @@
package com.minelittlepony.client;
import com.minelittlepony.MineLittlePony;
import com.minelittlepony.client.model.races.PlayerModels;
import com.minelittlepony.common.event.SkinAvailableCallback;
import com.minelittlepony.common.util.ProfileTextureUtil;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import net.minecraft.util.Identifier;
import java.util.HashMap;
import java.util.Map;
public class PonySkinParser implements SkinAvailableCallback {
@Override
public void onSkinAvailable(MinecraftProfileTexture.Type type, Identifier id, MinecraftProfileTexture texture) {
if (type == MinecraftProfileTexture.Type.SKIN) {
Map<String, String> metadata = ProfileTextureUtil.getMetadata(texture);
if (metadata == null) {
metadata = new HashMap<>();
ProfileTextureUtil.setMetadata(texture, metadata);
}
boolean slim = "slim".equals(metadata.get("model"));
// TODO use proper model metadata system
metadata.put("model", PlayerModels.forRace(MineLittlePony.getInstance().getManager()
.getPony(id)
.getRace(false))
.getId(slim));
}
}
}