blob: 83812274c6a5c1de774126cf412c1bc911647ac2 (
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
50
51
|
package moe.nea.firmament.mixins.custommodels;
import moe.nea.firmament.features.texturepack.HeadModelChooser;
import net.minecraft.client.item.ItemModelManager;
import net.minecraft.client.render.entity.LivingEntityRenderer;
import net.minecraft.client.render.entity.model.EntityModel;
import net.minecraft.client.render.entity.state.LivingEntityRenderState;
import net.minecraft.client.render.item.ItemRenderState;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.ModelTransformationMode;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
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(LivingEntityRenderer.class)
public class ReplaceHeadModel<T extends LivingEntity, S extends LivingEntityRenderState, M extends EntityModel<? super S>> {
@Shadow
@Final
protected ItemModelManager itemModelResolver;
@Unique
private ItemRenderState tempRenderState = new ItemRenderState();
@Inject(
method = "updateRenderState(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/client/render/entity/state/LivingEntityRenderState;F)V",
at = @At("TAIL")
)
private void replaceHeadModel(
T livingEntity, S livingEntityRenderState, float f, CallbackInfo ci
) {
var headItemStack = livingEntity.getEquippedStack(EquipmentSlot.HEAD);
HeadModelChooser.INSTANCE.getIS_CHOOSING_HEAD_MODEL().set(true);
tempRenderState.clear();
this.itemModelResolver.updateForLivingEntity(tempRenderState, headItemStack, ModelTransformationMode.HEAD, false, livingEntity);
HeadModelChooser.INSTANCE.getIS_CHOOSING_HEAD_MODEL().set(false);
if (HeadModelChooser.HasExplicitHeadModelMarker.cast(tempRenderState)
.isExplicitHeadModel_Firmament()) {
livingEntityRenderState.wearingSkullType = null;
var temp = livingEntityRenderState.headItemRenderState;
livingEntityRenderState.headItemRenderState = tempRenderState;
tempRenderState = temp;
}
}
}
|