Skip to content

Commit 5ab9306

Browse files
committed
Fixed various bugs with first person animations.
1 parent ebba7ab commit 5ab9306

File tree

7 files changed

+28
-128
lines changed

7 files changed

+28
-128
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Fixed crash when using certain modifiers. (Thanks to PROHitman for reporting the bug.)
1+
Fixed various bugs with first person animations.

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx2G
33
org.gradle.parallel=true
44

55
# Mod properties
6-
mod_version = 1.1.2
6+
mod_version = 1.1.3
77
maven_group = com.zigythebird.playeranim
88
archives_base_name = PlayerAnimationLib
99

minecraft/common/src/main/java/com/zigythebird/playeranim/ModMixinPlugin.java

Lines changed: 0 additions & 57 deletions
This file was deleted.

minecraft/common/src/main/java/com/zigythebird/playeranim/mixin/HumanoidArmorLayerMixin.java renamed to minecraft/common/src/main/java/com/zigythebird/playeranim/mixin/firstPerson/HumanoidArmorLayerMixin.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* SOFTWARE.
2323
*/
2424

25-
package com.zigythebird.playeranim.mixin;
25+
package com.zigythebird.playeranim.mixin.firstPerson;
2626

2727
import com.zigythebird.playeranim.accessors.IAnimatedPlayer;
2828
import com.zigythebird.playeranim.animation.PlayerAnimManager;
@@ -37,19 +37,17 @@
3737
import org.spongepowered.asm.mixin.injection.Inject;
3838
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
3939

40-
@Mixin(HumanoidArmorLayer.class)
40+
@Mixin(value = HumanoidArmorLayer.class, priority = 2000)
4141
@SuppressWarnings("rawtypes")
4242
public abstract class HumanoidArmorLayerMixin<T extends LivingEntity, A extends HumanoidModel<T>> {
4343
@Inject(method = "setPartVisibility", at = @At("HEAD"), cancellable = true)
4444
private void modifyArmorVisibility(A humanoidModel, EquipmentSlot equipmentSlot, CallbackInfo ci) {
4545
PlayerAnimManager emote = ((IAnimatedPlayer) Minecraft.getInstance().player).playerAnimLib$getAnimManager();
46-
if (emote.isActive() && emote.getFirstPersonMode() == FirstPersonMode.THIRD_PERSON_MODEL &&
47-
emote.getFirstPersonConfiguration().isShowArmor() && FirstPersonMode.isFirstPersonPass()) {
46+
if (emote.isActive() && emote.getFirstPersonMode() == FirstPersonMode.THIRD_PERSON_MODEL && FirstPersonMode.isFirstPersonPass()) {
4847
humanoidModel.setAllVisible(false);
49-
if (equipmentSlot == EquipmentSlot.CHEST) {
48+
if (equipmentSlot == EquipmentSlot.CHEST && emote.getFirstPersonConfiguration().isShowArmor()) {
5049
humanoidModel.rightArm.visible = emote.getFirstPersonConfiguration().isShowRightArm();
5150
humanoidModel.leftArm.visible = emote.getFirstPersonConfiguration().isShowLeftArm();
52-
humanoidModel.body.visible = false;
5351
}
5452
ci.cancel();
5553
}

minecraft/common/src/main/java/com/zigythebird/playeranim/mixin/LivingEntityRendererMixin.java renamed to minecraft/common/src/main/java/com/zigythebird/playeranim/mixin/firstPerson/LivingEntityRendererMixin.java

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,22 @@
2222
* SOFTWARE.
2323
*/
2424

25-
package com.zigythebird.playeranim.mixin;
25+
package com.zigythebird.playeranim.mixin.firstPerson;
2626

27+
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
2728
import com.mojang.blaze3d.vertex.PoseStack;
2829
import com.zigythebird.playeranimcore.api.firstPerson.FirstPersonMode;
2930
import net.minecraft.client.Minecraft;
3031
import net.minecraft.client.model.EntityModel;
3132
import net.minecraft.client.model.PlayerModel;
3233
import net.minecraft.client.player.AbstractClientPlayer;
34+
import net.minecraft.client.player.LocalPlayer;
3335
import net.minecraft.client.renderer.MultiBufferSource;
3436
import net.minecraft.client.renderer.entity.LivingEntityRenderer;
37+
import net.minecraft.client.renderer.entity.layers.HumanoidArmorLayer;
38+
import net.minecraft.client.renderer.entity.layers.PlayerItemInHandLayer;
39+
import net.minecraft.client.renderer.entity.layers.RenderLayer;
40+
import net.minecraft.world.entity.Entity;
3541
import net.minecraft.world.entity.LivingEntity;
3642
import org.spongepowered.asm.mixin.Mixin;
3743
import org.spongepowered.asm.mixin.Shadow;
@@ -40,9 +46,10 @@
4046
import org.spongepowered.asm.mixin.injection.Inject;
4147
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
4248

43-
@Mixin(LivingEntityRenderer.class)
49+
@Mixin(value = LivingEntityRenderer.class, priority = 2001)
4450
public class LivingEntityRendererMixin<T extends LivingEntity, M extends EntityModel<T>> {
45-
@Shadow protected M model;
51+
@Shadow
52+
protected M model;
4653

4754
@Inject(method = "render(Lnet/minecraft/world/entity/LivingEntity;FFLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V", at = @At("TAIL"))
4855
private void render(T entity, float entityYaw, float partialTicks, PoseStack poseStack, MultiBufferSource buffer, int packedLight, CallbackInfo ci) {
@@ -63,4 +70,14 @@ private void render(T entity, float entityYaw, float partialTicks, PoseStack pos
6370
model.rightArm.visible = visible;
6471
model.leftArm.visible = visible;
6572
}
73+
74+
@WrapWithCondition(
75+
method = "render(Lnet/minecraft/world/entity/LivingEntity;FFLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V",
76+
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/layers/RenderLayer;render(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;ILnet/minecraft/world/entity/Entity;FFFFFF)V"))
77+
private boolean filterLayers(RenderLayer layer, PoseStack poseStack, MultiBufferSource multiBufferSource, int i, Entity entity, float v, float v1, float v2, float v3, float v4, float v5) {
78+
if (entity instanceof LocalPlayer && FirstPersonMode.isFirstPersonPass()) {
79+
return layer instanceof PlayerItemInHandLayer || layer instanceof HumanoidArmorLayer<?,?,?>;
80+
}
81+
return true;
82+
}
6683
}

minecraft/common/src/main/java/com/zigythebird/playeranim/mixin/firstPerson/LivingEntityRendererMixin_noPA.java

Lines changed: 0 additions & 56 deletions
This file was deleted.

minecraft/common/src/main/resources/player_animation_library.mixins.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
{
22
"required": true,
33
"package": "com.zigythebird.playeranim.mixin",
4-
"plugin": "com.zigythebird.playeranim.ModMixinPlugin",
54
"compatibilityLevel": "JAVA_21",
65
"minVersion": "0.8",
76
"client": [
87
"AbstractClientPlayerMixin",
98
"CameraAccessor",
109
"CapeLayerMixin",
1110
"ElytraLayerMixin",
12-
"HumanoidArmorLayerMixin",
11+
"firstPerson.HumanoidArmorLayerMixin",
1312
"HumanoidModelMixin",
1413
"ItemInHandLayerMixin",
15-
"LivingEntityRendererMixin",
1614
"PlayerModelAccessor",
1715
"PlayerModelMixin",
1816
"PlayerRendererMixin",
1917
"firstPerson.EntityRenderDispatcherMixin",
2018
"firstPerson.ItemInHandRendererMixin",
2119
"firstPerson.LevelRendererMixin",
22-
"firstPerson.LivingEntityRendererMixin_noPA"
20+
"firstPerson.LivingEntityRendererMixin"
2321
],
2422
"mixins": [],
2523
"injectors": {

0 commit comments

Comments
 (0)