diff --git a/src/main/java/com/minelittlepony/PonyManager.java b/src/main/java/com/minelittlepony/PonyManager.java index 3a32070e..f8ffef56 100644 --- a/src/main/java/com/minelittlepony/PonyManager.java +++ b/src/main/java/com/minelittlepony/PonyManager.java @@ -9,7 +9,9 @@ import com.minelittlepony.model.PMAPI; import com.minelittlepony.pony.data.Pony; import com.minelittlepony.pony.data.PonyLevel; +import net.minecraft.client.Minecraft; import net.minecraft.client.entity.AbstractClientPlayer; +import net.minecraft.client.network.NetworkPlayerInfo; import net.minecraft.client.resources.DefaultPlayerSkin; import net.minecraft.client.resources.IResource; import net.minecraft.client.resources.IResourceManager; @@ -75,13 +77,16 @@ public class PonyManager implements IResourceManagerReloadListener { * @param player the player */ public Pony getPony(AbstractClientPlayer player) { - Pony pony = getPony(player.getLocationSkin(), IPlayerInfo.getPlayerInfo(player).usesSlimArms()); - - if (config.getPonyLevel() == PonyLevel.PONIES && pony.getMetadata().getRace().isHuman()) { - return getBackgroundPony(player.getUniqueID()); - } - - return pony; + return getPony(IPlayerInfo.getPlayerInfo(player).unwrap()); + } + + public Pony getPony(NetworkPlayerInfo playerInfo) { + ResourceLocation skin = playerInfo.getLocationSkin(); + UUID uuid = playerInfo.getGameProfile().getId(); + + if (skin == null) return getDefaultPony(uuid); + + return getPony(skin, uuid); } /** @@ -118,13 +123,19 @@ public class PonyManager implements IResourceManagerReloadListener { } private Pony getBackgroundPony(UUID uuid) { - if (getNumberOfPonies() == 0) return getPony(getDefaultSkin(uuid), isSlimSkin(uuid)); + if (getNumberOfPonies() == 0 || isUser(uuid)) { + return getPony(getDefaultSkin(uuid), isSlimSkin(uuid)); + } - int bgi = uuid.hashCode() % this.getNumberOfPonies(); - while (bgi < 0) bgi += this.getNumberOfPonies(); + int bgi = uuid.hashCode() % getNumberOfPonies(); + while (bgi < 0) bgi += getNumberOfPonies(); return getPony(backgroundPonyList.get(bgi), false); } + + private boolean isUser(UUID uuid) { + return Minecraft.getMinecraft().player != null && Minecraft.getMinecraft().player.getUniqueID().equals(uuid); + } /** * De-registers a pony from the cache. @@ -164,7 +175,7 @@ public class PonyManager implements IResourceManagerReloadListener { * Returns true if the given uuid is of a player would would use the ALEX skin type. */ public static boolean isSlimSkin(UUID uuid) { - return (uuid.hashCode() & 1) == 1; + return false;//(uuid.hashCode() & 1) == 1; } private int getNumberOfPonies() { diff --git a/src/main/java/com/minelittlepony/ducks/IPlayerInfo.java b/src/main/java/com/minelittlepony/ducks/IPlayerInfo.java index ef74e6ea..a8474fd3 100644 --- a/src/main/java/com/minelittlepony/ducks/IPlayerInfo.java +++ b/src/main/java/com/minelittlepony/ducks/IPlayerInfo.java @@ -1,16 +1,10 @@ package com.minelittlepony.ducks; -import com.minelittlepony.pony.data.Pony; - import net.minecraft.client.Minecraft; import net.minecraft.client.entity.AbstractClientPlayer; +import net.minecraft.client.network.NetworkPlayerInfo; public interface IPlayerInfo { - /** - * Gets the pony associated with this player. - */ - Pony getPony(); - /** * Returns true if the vanilla skin (the one returned by NetworkPlayerInfo.getSkinLocation) uses the ALEX model type. */ @@ -22,4 +16,8 @@ public interface IPlayerInfo { public static IPlayerInfo getPlayerInfo(AbstractClientPlayer player) { return (IPlayerInfo)Minecraft.getMinecraft().getConnection().getPlayerInfo(player.getUniqueID()); } + + default NetworkPlayerInfo unwrap() { + return (NetworkPlayerInfo)this; + } } diff --git a/src/main/java/com/minelittlepony/mixin/MixinNetworkPlayerInfo.java b/src/main/java/com/minelittlepony/mixin/MixinNetworkPlayerInfo.java index 89356ba0..ab91b363 100644 --- a/src/main/java/com/minelittlepony/mixin/MixinNetworkPlayerInfo.java +++ b/src/main/java/com/minelittlepony/mixin/MixinNetworkPlayerInfo.java @@ -9,7 +9,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import com.minelittlepony.MineLittlePony; import com.minelittlepony.PonyManager; import com.minelittlepony.ducks.IPlayerInfo; -import com.minelittlepony.pony.data.Pony; import com.mojang.authlib.GameProfile; import net.minecraft.client.network.NetworkPlayerInfo; @@ -29,16 +28,7 @@ public abstract class MixinNetworkPlayerInfo implements IPlayerInfo { @Inject(method = "getSkinType()Ljava/lang/String;", at = @At("RETURN"), cancellable = true) private void getSkinType(CallbackInfoReturnable info) { - info.setReturnValue(getPony().getRace(false).getModel().getId(usesSlimArms())); - } - - @Override - public Pony getPony() { - ResourceLocation skin = getLocationSkin(); - if (skin == null) { - return MineLittlePony.getInstance().getManager().getDefaultPony(getGameProfile().getId()); - } - return MineLittlePony.getInstance().getManager().getPony(skin, getGameProfile().getId()); + info.setReturnValue(MineLittlePony.getInstance().getManager().getPony(unwrap()).getRace(false).getModel().getId(usesSlimArms())); } @Override