Apply emote animations to the first person arm

This commit is contained in:
Sollace 2022-09-12 17:52:26 +02:00
parent 054134545d
commit 802ba060ba
2 changed files with 20 additions and 0 deletions

View file

@ -9,6 +9,7 @@ import com.minelittlepony.unicopia.util.AnimationUtil;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.entity.model.BipedEntityModel;
import net.minecraft.client.render.entity.model.PlayerEntityModel;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.sound.SoundEvent;
@ -154,6 +155,14 @@ public class PlayerPoser {
}
default:
}
if (model instanceof PlayerEntityModel<?> m) {
m.leftSleeve.copyTransform(m.leftArm);
m.rightSleeve.copyTransform(m.rightArm);
m.leftPants.copyTransform(m.leftLeg);
m.rightPants.copyTransform(m.rightLeg);
}
model.hat.copyTransform(model.head);
}
private void rearUp(MatrixStack matrices, BipedEntityModel<?> model, float progress) {

View file

@ -4,9 +4,11 @@ import org.jetbrains.annotations.Nullable;
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.At.Shift;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import com.minelittlepony.unicopia.client.render.AccessoryFeatureRenderer;
import com.minelittlepony.unicopia.client.render.PlayerPoser;
import com.minelittlepony.unicopia.client.render.AccessoryFeatureRenderer.FeatureRoot;
import net.minecraft.client.model.ModelPart;
@ -42,4 +44,13 @@ abstract class MixinPlayerEntityRenderer extends LivingEntityRenderer<AbstractCl
Arm a = this.getModel().leftArm == arm ? Arm.LEFT : Arm.RIGHT;
getAccessories().renderArm(matrices, vertexConsumers, light, player, arm, a);
}
@Inject(method = "renderArm",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/render/entity/model/PlayerEntityModel;setAngles(Lnet/minecraft/entity/LivingEntity;FFFFF)V",
shift = Shift.AFTER))
private void onPoseArm(MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, AbstractClientPlayerEntity player, ModelPart arm, ModelPart sleeve, CallbackInfo info) {
PlayerPoser.INSTANCE.applyPosing(matrices, player, getModel());
}
}