Commit 3cdee00f by Jonathan Thomas

Removing import net.minecraft.client.util.SkinTextures (fails on 1.20, 1.20.1),…

Removing import net.minecraft.client.util.SkinTextures (fails on 1.20, 1.20.1), adding 2 mixins for different Minecraft version support.
parent b931f57b
Pipeline #13256 failed with stages
in 15 seconds
......@@ -17,12 +17,12 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
* loading custom player icons in the unused UV coordinates of the player skin image.
*/
@Mixin(PlayerSkinTexture.class)
public abstract class MixinPlayerSkinTexture extends ResourceTexture implements IPlayerSkinTexture {
public abstract class MixinPlayerSkinTexture1202Plus extends ResourceTexture implements IPlayerSkinTexture {
@Unique
private NativeImage cachedSkinImage;
public MixinPlayerSkinTexture(Identifier location) {
public MixinPlayerSkinTexture1202Plus(Identifier location) {
super(location);
}
......
package com.owlmaddie.mixin.client;
import com.owlmaddie.utils.IPlayerSkinTexture;
import net.minecraft.client.texture.NativeImage;
import net.minecraft.client.texture.PlayerSkinTexture;
import net.minecraft.client.texture.ResourceTexture;
import net.minecraft.util.Identifier;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(PlayerSkinTexture.class)
public abstract class MixinPlayerSkinTexturePre1202 extends ResourceTexture implements IPlayerSkinTexture {
@Unique
private NativeImage cachedSkinImage;
public MixinPlayerSkinTexturePre1202(Identifier location) {
super(location);
}
@Inject(method = "onTextureLoaded", at = @At("HEAD"))
private void captureNativeImage(NativeImage image, CallbackInfo ci) {
this.cachedSkinImage = cloneNativeImage(image);
}
@Override
public NativeImage getLoadedImage() {
return this.cachedSkinImage;
}
private static NativeImage cloneNativeImage(NativeImage source) {
NativeImage copy = new NativeImage(source.getFormat(), source.getWidth(), source.getHeight(), false);
copy.copyFrom(source);
return copy;
}
}
......@@ -18,7 +18,6 @@ import net.minecraft.client.render.*;
import net.minecraft.client.render.entity.EntityRenderer;
import net.minecraft.client.texture.AbstractTexture;
import net.minecraft.client.texture.NativeImage;
import net.minecraft.client.util.SkinTextures;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.Entity;
import net.minecraft.entity.boss.dragon.EnderDragonEntity;
......@@ -363,13 +362,12 @@ public class BubbleRenderer {
@Nullable
public static NativeImage getPlayerSkinAsNativeImage(GameProfile profile) {
// 1. Ask the SkinProvider for the textures
SkinTextures skinTextures = MinecraftClient.getInstance().getSkinProvider().getSkinTextures(profile);
if (skinTextures == null) {
if (MinecraftClient.getInstance().getSkinProvider().getSkinTextures(profile) == null) {
return null; // No skin or still loading
}
// 2. Identify the texture ID
Identifier skinId = skinTextures.texture();
Identifier skinId = MinecraftClient.getInstance().getSkinProvider().getSkinTextures(profile).texture();
// 3. Get the AbstractTexture from the TextureManager
AbstractTexture tex = MinecraftClient.getInstance().getTextureManager().getTexture(skinId);
......
......@@ -3,9 +3,17 @@
"package": "com.owlmaddie.mixin.client",
"compatibilityLevel": "JAVA_17",
"client": [
"EntityRendererMixin",
"MixinPlayerSkinTexture"
"EntityRendererMixin"
],
"env": {
"client.MixinPlayerSkinTexturePre1202": {
"minVersion": "1.20",
"maxVersion": "1.20.1"
},
"client.MixinPlayerSkinTexture1202Plus": {
"minVersion": "1.20.2"
}
},
"injectors": {
"defaultRequire": 1
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment