aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/example/mixin/MixinRendererManager.java
blob: eae11fa4e5bf2fba1785e8bdb4c86ba5abadf083 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package com.example.mixin;

import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityArmorStand;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(RenderManager.class)
public class MixinRendererManager {

    @Inject(method = "doRenderEntity", at = @At("HEAD"))
    public void doRender(
            Entity entity,
            double x,
            double y,
            double z,
            float entityYaw,
            float partialTicks,
            boolean p_147939_10_,
            CallbackInfoReturnable<Boolean> cir
    ) {

        if (entity instanceof EntityArmorStand) {
            if (((EntityArmorStand) entity).getHeldItem() != null && ((EntityArmorStand) entity).getHeldItem().getItem() == Items.skull) {
                ItemStack stack = ((EntityArmorStand) entity).getHeldItem();
                if (stack.hasTagCompound() && stack.getTagCompound().hasKey("SkullOwner")) {
                    NBTTagCompound skullOwner = stack.getTagCompound().getCompoundTag("SkullOwner");
                    if (skullOwner.hasKey("Properties")) {
                        NBTTagCompound properties = skullOwner.getCompoundTag("Properties");
                        if (properties.hasKey("textures")) {
                            if ("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTZjM2UzMWNmYzY2NzMzMjc1YzQyZmNmYjVkOWE0NDM0MmQ2NDNiNTVjZDE0YzljNzdkMjczYTIzNTIifX19"
                                    .equals(properties.getTagList("textures", 10).getCompoundTagAt(0).getString("Value")))
                                cir.cancel();
                        }

                    }

                }

            }
        }
    }
}