Skip to content

Commit 0a72cbf

Browse files
committed
Fixed issue with visible parts in spectator mode
1 parent 5ab9306 commit 0a72cbf

File tree

5 files changed

+15
-55
lines changed

5 files changed

+15
-55
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
Fixed various bugs with first person animations.
1+
Fixed model parts being visible when they shouldn't be in spectator mode.
2+
More logs when an animation is not found.

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.3
6+
mod_version = 1.1.4
77
maven_group = com.zigythebird.playeranim
88
archives_base_name = PlayerAnimationLib
99

minecraft/common/src/main/java/com/zigythebird/playeranim/animation/PlayerAnimationController.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.mojang.blaze3d.vertex.PoseStack;
44
import com.mojang.math.Axis;
5+
import com.zigythebird.playeranim.PlayerAnimLibMod;
56
import com.zigythebird.playeranim.util.RenderUtil;
67
import com.zigythebird.playeranimcore.animation.AnimationController;
78
import com.zigythebird.playeranimcore.animation.AnimationData;
@@ -77,6 +78,7 @@ public boolean triggerAnimation(ResourceLocation newAnimation, float startAnimFr
7778
triggerAnimation(PlayerAnimResources.getAnimation(newAnimation), startAnimFrom);
7879
return true;
7980
}
81+
PlayerAnimLibMod.LOGGER.error("Could not find animation with the name:" + newAnimation);
8082
return false;
8183
}
8284

minecraft/common/src/main/java/com/zigythebird/playeranim/mixin/PlayerModelMixin.java

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -133,34 +133,21 @@ private void setupPlayerAnimation(Entity entity, float limbSwing, float limbSwin
133133
// Hiding all parts, because they should not be visible in first person
134134
playerAnimLib$setAllPartsVisible(false);
135135
// Showing arms based on configuration
136-
var skipRightArm = !config.isShowRightArm();
137-
var skipLeftArm = !config.isShowLeftArm();
138-
this.rightArm.skipDraw = skipRightArm;
139-
this.leftArm.skipDraw = skipLeftArm;
140-
141-
// These are children of those ^^^
142-
// this.rightSleeve.skipDraw = skipRightArm;
143-
// this.leftSleeve.skipDraw = skipLeftArm;
144-
} else {
145-
playerAnimLib$setAllPartsVisible(true);
136+
this.rightArm.visible = config.isShowRightArm();
137+
this.leftArm.visible = !config.isShowLeftArm();
138+
this.rightSleeve.visible = config.isShowRightArm();
139+
this.leftSleeve.visible = !config.isShowLeftArm();
146140
}
147141
}
148142

149143
@Unique
150144
private void playerAnimLib$setAllPartsVisible(boolean visible) {
151-
var skip = !visible;
152-
this.head.skipDraw = skip;
153-
this.head.getAllParts().forEach(p -> p.skipDraw = skip);
154-
this.body.skipDraw = skip;
155-
this.body.getAllParts().forEach(p -> p.skipDraw = skip);
156-
this.leftLeg.skipDraw = skip;
157-
this.leftLeg.getAllParts().forEach(p -> p.skipDraw = skip);
158-
this.rightLeg.skipDraw = skip;
159-
this.rightLeg.getAllParts().forEach(p -> p.skipDraw = skip);
160-
this.rightArm.skipDraw = skip;
161-
this.rightArm.getAllParts().forEach(p -> p.skipDraw = skip);
162-
this.leftArm.skipDraw = skip;
163-
this.leftArm.getAllParts().forEach(p -> p.skipDraw = skip);
145+
this.head.visible = visible;
146+
this.body.visible = visible;
147+
this.leftLeg.visible = visible;
148+
this.rightLeg.visible = visible;
149+
this.rightArm.visible = visible;
150+
this.leftArm.visible = visible;
164151

165152
this.hat.visible = visible;
166153
this.leftSleeve.visible = visible;

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

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@
2727
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
2828
import com.mojang.blaze3d.vertex.PoseStack;
2929
import com.zigythebird.playeranimcore.api.firstPerson.FirstPersonMode;
30-
import net.minecraft.client.Minecraft;
3130
import net.minecraft.client.model.EntityModel;
32-
import net.minecraft.client.model.PlayerModel;
33-
import net.minecraft.client.player.AbstractClientPlayer;
3431
import net.minecraft.client.player.LocalPlayer;
3532
import net.minecraft.client.renderer.MultiBufferSource;
3633
import net.minecraft.client.renderer.entity.LivingEntityRenderer;
@@ -40,37 +37,10 @@
4037
import net.minecraft.world.entity.Entity;
4138
import net.minecraft.world.entity.LivingEntity;
4239
import org.spongepowered.asm.mixin.Mixin;
43-
import org.spongepowered.asm.mixin.Shadow;
44-
import org.spongepowered.asm.mixin.Unique;
4540
import org.spongepowered.asm.mixin.injection.At;
46-
import org.spongepowered.asm.mixin.injection.Inject;
47-
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
4841

4942
@Mixin(value = LivingEntityRenderer.class, priority = 2001)
5043
public class LivingEntityRendererMixin<T extends LivingEntity, M extends EntityModel<T>> {
51-
@Shadow
52-
protected M model;
53-
54-
@Inject(method = "render(Lnet/minecraft/world/entity/LivingEntity;FFLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V", at = @At("TAIL"))
55-
private void render(T entity, float entityYaw, float partialTicks, PoseStack poseStack, MultiBufferSource buffer, int packedLight, CallbackInfo ci) {
56-
if (FirstPersonMode.isFirstPersonPass() && entity instanceof AbstractClientPlayer player
57-
&& player == Minecraft.getInstance().cameraEntity) {
58-
playerAnimLib$setAllPartsVisible(true);
59-
}
60-
}
61-
62-
@Unique
63-
private void playerAnimLib$setAllPartsVisible(boolean visible) {
64-
PlayerModel model = (PlayerModel)this.model;
65-
66-
model.head.visible = visible;
67-
model.body.visible = visible;
68-
model.leftLeg.visible = visible;
69-
model.rightLeg.visible = visible;
70-
model.rightArm.visible = visible;
71-
model.leftArm.visible = visible;
72-
}
73-
7444
@WrapWithCondition(
7545
method = "render(Lnet/minecraft/world/entity/LivingEntity;FFLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V",
7646
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"))

0 commit comments

Comments
 (0)