Skip to content

Commit

Permalink
oops
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro270707 committed Feb 18, 2024
1 parent d6b9679 commit 725417c
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import com.llamalad7.mixinextras.sugar.Local;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import net.minecraft.client.MinecraftClient;
import net.minecraft.item.ItemStack;
import net.minecraft.item.SkullItem;
import net.minecraft.item.PlayerHeadItem;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtElement;
import net.minecraft.nbt.NbtHelper;
Expand All @@ -15,15 +14,15 @@
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

@Mixin(SkullItem.class)
@Mixin(PlayerHeadItem.class)
public class ChangeHeadNameMixin {
@ModifyReturnValue(method = "getName", at = @At(value = "RETURN", ordinal = 0))
private Text headedrewritten$getCorrectName(Text original, @Local(ordinal = 0) ItemStack stack, @Local(ordinal = 0) String string) {
NbtCompound nbt = stack.getNbt();
if (nbt == null || !nbt.contains("SkullOwner", NbtElement.COMPOUND_TYPE)) return original;
GameProfile gameProfile = NbtHelper.toGameProfile(nbt.getCompound("SkullOwner"));
if (gameProfile != null && gameProfile.getProperties().containsKey("textures") && MinecraftClient.getInstance().getSkinProvider().getTextures(gameProfile).containsKey(MinecraftProfileTexture.Type.SKIN) && TextureToHeadMap.contains(MinecraftClient.getInstance().getSkinProvider().getTextures(gameProfile).get(MinecraftProfileTexture.Type.SKIN).getUrl())) {
return Text.translatable(((SkullItem)(Object)this).getTranslationKey() + ".named_headed_rewritten", string);
if (gameProfile != null && gameProfile.getProperties().containsKey("textures") && TextureToHeadMap.contains(MinecraftClient.getInstance().getSkinProvider().getSkinTextures(gameProfile).textureUrl())) {
return Text.translatable(((PlayerHeadItem)(Object)this).getTranslationKey() + ".named_headed_rewritten", string);
}
return original;
}
Expand Down

0 comments on commit 725417c

Please sign in to comment.