From 8eb19c117fd73b928317cf38cee3ff7dd877fb06 Mon Sep 17 00:00:00 2001 From: Matthew Messinger Date: Sat, 25 Aug 2018 16:53:42 -0400 Subject: [PATCH] Quick fix for mixin conflict which caused ponies to be broken --- .../hdskins/mixin/MixinPlayerInfo.java | 13 +++++----- .../mixin/MixinNetworkPlayerInfo.java | 26 ++----------------- 2 files changed, 9 insertions(+), 30 deletions(-) diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinPlayerInfo.java b/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinPlayerInfo.java index 8a922e22..9c80ff6a 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinPlayerInfo.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinPlayerInfo.java @@ -16,7 +16,6 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import java.util.HashMap; import java.util.Map; @@ -51,12 +50,14 @@ public abstract class MixinPlayerInfo implements INetworkPlayerInfo { return getResourceLocation(type).orElseGet(() -> playerTextures.get(type)); } - @Inject(method = "getSkinType", at = @At("RETURN"), cancellable = true) - private void getTextureModel(CallbackInfoReturnable cir) { - getProfileTexture(Type.SKIN).ifPresent(profile -> { + @Redirect(method = "getSkinType()Ljava/lang/String;", + at = @At(value = "FIELD", target = "Lnet/minecraft/client/network/NetworkPlayerInfo;skinType:Ljava/lang/String;")) + + private String getTextureModel(NetworkPlayerInfo self) { + return getProfileTexture(Type.SKIN).map(profile -> { String model = profile.getMetadata("model"); - cir.setReturnValue(model != null ? model : "default"); - }); + return model != null ? model : "default"; + }).orElse(this.skinType); } @Inject(method = "loadPlayerTextures", diff --git a/src/main/java/com/minelittlepony/mixin/MixinNetworkPlayerInfo.java b/src/main/java/com/minelittlepony/mixin/MixinNetworkPlayerInfo.java index 2439f2e8..a8778bdf 100644 --- a/src/main/java/com/minelittlepony/mixin/MixinNetworkPlayerInfo.java +++ b/src/main/java/com/minelittlepony/mixin/MixinNetworkPlayerInfo.java @@ -1,44 +1,22 @@ package com.minelittlepony.mixin; import com.minelittlepony.MineLittlePony; -import com.minelittlepony.PonyManager; -import com.mojang.authlib.GameProfile; -import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type; import com.voxelmodpack.hdskins.INetworkPlayerInfo; import net.minecraft.client.network.NetworkPlayerInfo; -import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(value = NetworkPlayerInfo.class, priority = 999) +@Mixin(NetworkPlayerInfo.class) public abstract class MixinNetworkPlayerInfo implements INetworkPlayerInfo { - @Shadow private String skinType; - - @Shadow @Final private GameProfile gameProfile; - @Inject(method = "getSkinType()Ljava/lang/String;", at = @At("RETURN"), cancellable = true) private void getSkinType(CallbackInfoReturnable info) { info.setReturnValue(MineLittlePony.getInstance().getManager() .getPony((NetworkPlayerInfo) (Object) this) .getRace(false) .getModel() - .getId(usesSlimArms())); - } - - private boolean usesSlimArms() { - if (skinType == null) { - - return getProfileTexture(Type.SKIN) - .map(profile -> profile.getMetadata("model")) - .filter("slim"::equals) - .isPresent() || PonyManager.isSlimSkin(this.gameProfile.getId()); - - } - - return "slim".equals(skinType); + .getId("slim".equals(info.getReturnValue()))); } }