mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-22 20:47:59 +01:00
Quick fix for mixin conflict which caused ponies to be broken
This commit is contained in:
parent
ca48785add
commit
8eb19c117f
2 changed files with 9 additions and 30 deletions
|
@ -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<String> 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",
|
||||
|
|
|
@ -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<String> 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())));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue