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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
/*
* Copyright (C) 2022 NotEnoughUpdates contributors
*
* This file is part of NotEnoughUpdates.
*
* NotEnoughUpdates is free software: you can redistribute it
* and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* NotEnoughUpdates is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>.
*/
package io.github.moulberry.notenoughupdates.mixins;
import com.mojang.authlib.GameProfile;
import io.github.moulberry.notenoughupdates.miscgui.itemcustomization.ItemCustomizeManager;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.entity.layers.LayerCustomHead;
import net.minecraft.client.renderer.tileentity.TileEntitySkullRenderer;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import org.lwjgl.opengl.GL11;
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.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(LayerCustomHead.class)
public class MixinLayerCustomHead {
private static String customGlintColour = null;
@Inject(method = "doRenderLayer", at = @At("HEAD"))
public void doRenderLayer(
EntityLivingBase entitylivingbaseIn, float p_177141_2_, float p_177141_3_, float partialTicks,
float p_177141_5_, float p_177141_6_, float p_177141_7_, float scale, CallbackInfo ci
) {
ItemStack stack = entitylivingbaseIn.getCurrentArmor(3);
ItemCustomizeManager.ItemData data = ItemCustomizeManager.getDataForItem(stack);
if (data != null && data.overrideEnchantGlint && data.enchantGlintValue) {
customGlintColour = data.customGlintColour;
} else {
customGlintColour = null;
}
}
@Redirect(method = "doRenderLayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/EntityLivingBase;getCurrentArmor(I)Lnet/minecraft/item/ItemStack;"))
public ItemStack doRenderLayer_getCurrentArmor(EntityLivingBase instance, int i) {
return ItemCustomizeManager.setHeadArmour(instance, i);
}
@Redirect(method = "doRenderLayer",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/renderer/tileentity/TileEntitySkullRenderer;renderSkull(FFFLnet/minecraft/util/EnumFacing;FILcom/mojang/authlib/GameProfile;I)V"
)
)
public void renderItem_renderSkull(
TileEntitySkullRenderer tileEntitySkullRenderer, float p_180543_1_, float p_180543_2_,
float p_180543_3_, EnumFacing p_180543_4_, float p_180543_5_, int p_180543_6_,
GameProfile p_180543_7_, int p_180543_8_
) {
GL11.glPushMatrix();
tileEntitySkullRenderer.renderSkull(p_180543_1_, p_180543_2_, p_180543_3_, p_180543_4_, p_180543_5_,
p_180543_6_, p_180543_7_, p_180543_8_
);
GL11.glPopMatrix();
if (customGlintColour != null) {
ItemCustomizeManager.renderEffectHook(customGlintColour, (color) -> {
float red = ((color >> 16) & 0xFF) / 255f;
float green = ((color >> 8) & 0xFF) / 255f;
float blue = (color & 0xFF) / 255f;
float alpha = ((color >> 24) & 0xFF) / 255f;
GlStateManager.color(red, green, blue, alpha);
GlStateManager.scale(1 / 8f, 1 / 8f, 1 / 8f);
GlStateManager.matrixMode(GL11.GL_MODELVIEW);
GL11.glPushMatrix();
ItemCustomizeManager.disableTextureBinding = true;
tileEntitySkullRenderer.renderSkull(p_180543_1_, p_180543_2_, p_180543_3_, p_180543_4_, p_180543_5_,
p_180543_6_, p_180543_7_, p_180543_8_
);
ItemCustomizeManager.disableTextureBinding = false;
GL11.glPopMatrix();
});
}
}
}
|