diff --git a/src/hdskins/java/com/minelittlepony/client/hdskins/ClientPonyConfigHDSkins.java b/src/hdskins/java/com/minelittlepony/client/hdskins/ClientPonyConfigHDSkins.java deleted file mode 100644 index e4e75b96..00000000 --- a/src/hdskins/java/com/minelittlepony/client/hdskins/ClientPonyConfigHDSkins.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.minelittlepony.client.hdskins; - -import com.minelittlepony.client.settings.ClientPonyConfig; -import com.minelittlepony.hdskins.HDSkins; -import com.minelittlepony.settings.PonyLevel; - -class ClientPonyConfigHDSkins extends ClientPonyConfig { - - @Override - public void setPonyLevel(PonyLevel ponylevel) { - // only trigger reloads when the value actually changes - if (ponylevel != getPonyLevel()) { - HDSkins.getInstance().getSkinParser().execute(); - } - - super.setPonyLevel(ponylevel); - } -} \ No newline at end of file diff --git a/src/hdskins/java/com/minelittlepony/client/hdskins/HDSkinsProxy.java b/src/hdskins/java/com/minelittlepony/client/hdskins/HDSkinsProxy.java index ff438e53..ffae97e8 100644 --- a/src/hdskins/java/com/minelittlepony/client/hdskins/HDSkinsProxy.java +++ b/src/hdskins/java/com/minelittlepony/client/hdskins/HDSkinsProxy.java @@ -13,14 +13,9 @@ public class HDSkinsProxy extends SkinsProxy { public Identifier getSkinTexture(GameProfile profile) { Identifier skin = HDSkins.getInstance().getTextures(profile).get(MinecraftProfileTexture.Type.SKIN); - if (skin != null && Pony.getBufferedImage(skin) != null) { + if (skin != null) { return skin; } return super.getSkinTexture(profile); } - - @Override - public void parseSkins() { - HDSkins.getInstance().getSkinParser().execute(); - } } diff --git a/src/hdskins/java/com/minelittlepony/client/hdskins/MineLPHDSkins.java b/src/hdskins/java/com/minelittlepony/client/hdskins/MineLPHDSkins.java index 44b6f519..3375908a 100644 --- a/src/hdskins/java/com/minelittlepony/client/hdskins/MineLPHDSkins.java +++ b/src/hdskins/java/com/minelittlepony/client/hdskins/MineLPHDSkins.java @@ -57,9 +57,4 @@ public class MineLPHDSkins { // Ponify the skins GUI. manager.setSkinsGui(GuiSkinsMineLP::new); } - -// @Override - protected ClientPonyConfig createConfig() { - return new ClientPonyConfigHDSkins(); - } } diff --git a/src/main/java/com/minelittlepony/client/MineLPClient.java b/src/main/java/com/minelittlepony/client/MineLPClient.java index 737a3292..4c485313 100644 --- a/src/main/java/com/minelittlepony/client/MineLPClient.java +++ b/src/main/java/com/minelittlepony/client/MineLPClient.java @@ -5,7 +5,6 @@ import com.minelittlepony.client.gui.GuiPonySettings; import com.minelittlepony.client.pony.PonyManager; import com.minelittlepony.client.render.tileentities.skull.PonySkullRenderer; import com.minelittlepony.client.settings.ClientPonyConfig; -import com.minelittlepony.common.event.SkinAvailableCallback; import com.minelittlepony.common.util.GamePaths; import com.minelittlepony.settings.JsonConfig; import com.minelittlepony.settings.PonyConfig; @@ -53,9 +52,6 @@ public class MineLPClient extends MineLittlePony { KeyBindingRegistry.INSTANCE.register(keyBinding); ResourceManagerHelper.get(ResourceType.CLIENT_RESOURCES).registerReloadListener(ponyManager); - - // Parse trigger pixel data - SkinAvailableCallback.EVENT.register(new PonySkinParser()); } protected ClientPonyConfig createConfig() { diff --git a/src/main/java/com/minelittlepony/client/PonySkinParser.java b/src/main/java/com/minelittlepony/client/PonySkinParser.java deleted file mode 100644 index 583ade25..00000000 --- a/src/main/java/com/minelittlepony/client/PonySkinParser.java +++ /dev/null @@ -1,35 +0,0 @@ -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 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)); - } - } -} diff --git a/src/main/java/com/minelittlepony/client/SkinsProxy.java b/src/main/java/com/minelittlepony/client/SkinsProxy.java index deabd58e..44ce1b5b 100644 --- a/src/main/java/com/minelittlepony/client/SkinsProxy.java +++ b/src/main/java/com/minelittlepony/client/SkinsProxy.java @@ -1,6 +1,5 @@ package com.minelittlepony.client; -import com.minelittlepony.client.pony.Pony; import com.mojang.authlib.GameProfile; import com.mojang.authlib.minecraft.MinecraftProfileTexture; import net.minecraft.client.MinecraftClient; @@ -18,16 +17,6 @@ public class SkinsProxy { PlayerSkinProvider skins = MinecraftClient.getInstance().getSkinProvider(); MinecraftProfileTexture texture = skins.getTextures(profile).get(MinecraftProfileTexture.Type.SKIN); - Identifier loc = skins.loadSkin(texture, MinecraftProfileTexture.Type.SKIN); - - if (Pony.getBufferedImage(loc) != null) { - return loc; - } - return null; - } - - public void parseSkins() { - // TODO probably doesn't work without hdskins installed. - // Find a way to re-parse skins without help of hdskins + return skins.loadSkin(texture, MinecraftProfileTexture.Type.SKIN); } } diff --git a/src/main/java/com/minelittlepony/client/mixin/MixinEntityRenderDispatcher.java b/src/main/java/com/minelittlepony/client/mixin/MixinEntityRenderDispatcher.java new file mode 100644 index 00000000..8baf6d7d --- /dev/null +++ b/src/main/java/com/minelittlepony/client/mixin/MixinEntityRenderDispatcher.java @@ -0,0 +1,26 @@ +package com.minelittlepony.client.mixin; + +import com.minelittlepony.MineLittlePony; +import com.minelittlepony.client.model.races.PlayerModels; +import net.minecraft.client.network.AbstractClientPlayerEntity; +import net.minecraft.client.render.entity.EntityRenderDispatcher; +import net.minecraft.entity.Entity; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(EntityRenderDispatcher.class) +public class MixinEntityRenderDispatcher { + + @Redirect( + method = "getRenderer(Lnet/minecraft/entity/Entity;)Lnet/minecraft/client/render/entity/EntityRenderer;", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/network/AbstractClientPlayerEntity;getModel()Ljava/lang/String;")) + private String getPlayerModel(AbstractClientPlayerEntity player, Entity entity) { + return PlayerModels.forRace(MineLittlePony.getInstance().getManager() + .getPony(player) + .getRace(false)) + .getId(player.getModel().contains("slim")); + } +} diff --git a/src/main/java/com/minelittlepony/client/pony/PonyManager.java b/src/main/java/com/minelittlepony/client/pony/PonyManager.java index 0cae781f..f1a00223 100644 --- a/src/main/java/com/minelittlepony/client/pony/PonyManager.java +++ b/src/main/java/com/minelittlepony/client/pony/PonyManager.java @@ -71,14 +71,14 @@ public class PonyManager implements IPonyManager, IdentifiableResourceReloadList @Override public IPony getPony(PlayerEntity player) { - if (player == null || player.getGameProfile() == null) { + if (player.getGameProfile() == null) { return getDefaultPony(player.getUuid()); } Identifier skin = getSkin(player); UUID uuid = player.getGameProfile().getId(); - if (Pony.getBufferedImage(skin) == null) { + if (skin == null) { return getDefaultPony(uuid); } @@ -86,7 +86,7 @@ public class PonyManager implements IPonyManager, IdentifiableResourceReloadList } @Nullable - Identifier getSkin(PlayerEntity player) { + private Identifier getSkin(PlayerEntity player) { if (player instanceof AbstractClientPlayerEntity) { return ((AbstractClientPlayerEntity)player).getSkinTexture(); } diff --git a/src/main/resources/minelp.mixin.json b/src/main/resources/minelp.mixin.json index f369c3f3..15f5d7ed 100644 --- a/src/main/resources/minelp.mixin.json +++ b/src/main/resources/minelp.mixin.json @@ -8,6 +8,7 @@ "IResizeable", "MixinCamera", "MixinDefaultPlayerSkin", + "MixinEntityRenderDispatcher", "MixinFirstPersonRenderer", "MixinGlStateManager", "MixinItemRenderer",