Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #7419: Chain conveyor animation does not respect player's main hand #8032

Open
wants to merge 1 commit into
base: mc1.20.1/dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
import net.createmod.catnip.math.AngleHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel;
import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.HumanoidArm;
import net.minecraft.world.entity.player.Player;

public class PlayerSkyhookRenderer {
Expand All @@ -36,10 +38,10 @@ public static void beforeSetupAnim(Player player, HumanoidModel<?> model) {

public static void afterSetupAnim(Player player, HumanoidModel<?> model) {
if (hangingPlayers.contains(player.getUUID()))
setHangingPose(model);
setHangingPose(player.getMainArm() == HumanoidArm.LEFT, model);
}

private static void setHangingPose(HumanoidModel<?> model) {
private static void setHangingPose(boolean isLeftArmMain, HumanoidModel<?> model) {
if (Minecraft.getInstance().isPaused())
return;

Expand All @@ -56,57 +58,60 @@ private static void setHangingPose(HumanoidModel<?> model) {
float limbCycle = Mth.sin(((float) (time * 0.3f / Math.PI)));
float bodySwing = AngleHelper.rad(15 + (mainCycle * 10));
float limbSwing = AngleHelper.rad(limbCycle * 15);

if (isLeftArmMain) bodySwing = -bodySwing;
model.body.zRot = bodySwing;
model.head.zRot = bodySwing;
model.hat.zRot = bodySwing;

model.rightArm.y -= 3;
ModelPart hangingArm = isLeftArmMain ? model.leftArm : model.rightArm;
ModelPart otherArm = isLeftArmMain ? model.rightArm : model.leftArm;
hangingArm.y -= 3;

float offsetX = model.rightArm.x;
float offsetY = model.rightArm.y;
float offsetX = hangingArm.x;
float offsetY = hangingArm.y;
// model.rightArm.x = offsetX * Mth.cos(bodySwing) - offsetY * Mth.sin(bodySwing);
// model.rightArm.y = offsetX * Mth.sin(bodySwing) + offsetY * Mth.cos(bodySwing);
float armPivotX = offsetX * Mth.cos(bodySwing) - offsetY * Mth.sin(bodySwing) + 4.5f;
float armPivotX = offsetX * Mth.cos(bodySwing) - offsetY * Mth.sin(bodySwing) + (isLeftArmMain ? -1 : 1) * 4.5f;
float armPivotY = offsetX * Mth.sin(bodySwing) + offsetY * Mth.cos(bodySwing) + 2;
model.rightArm.xRot = -AngleHelper.rad(150);
model.rightArm.zRot = AngleHelper.rad(15);

offsetX = model.leftArm.x;
offsetY = model.leftArm.y;
model.leftArm.x = offsetX * Mth.cos(bodySwing) - offsetY * Mth.sin(bodySwing);
model.leftArm.y = offsetX * Mth.sin(bodySwing) + offsetY * Mth.cos(bodySwing);
model.leftArm.zRot = -AngleHelper.rad(20) + 0.5f * bodySwing + limbSwing;

model.rightLeg.y -= 0.2f;
offsetX = model.rightLeg.x;
offsetY = model.rightLeg.y;
model.rightLeg.x = offsetX * Mth.cos(bodySwing) - offsetY * Mth.sin(bodySwing);
model.rightLeg.y = offsetX * Mth.sin(bodySwing) + offsetY * Mth.cos(bodySwing);
model.rightLeg.xRot = -AngleHelper.rad(25);
model.rightLeg.zRot = AngleHelper.rad(10) + 0.5f * bodySwing + limbSwing;

model.leftLeg.y -= 0.8f;
offsetX = model.leftLeg.x;
offsetY = model.leftLeg.y;
model.leftLeg.x = offsetX * Mth.cos(bodySwing) - offsetY * Mth.sin(bodySwing);
model.leftLeg.y = offsetX * Mth.sin(bodySwing) + offsetY * Mth.cos(bodySwing);
model.leftLeg.xRot = AngleHelper.rad(10);
model.leftLeg.zRot = -AngleHelper.rad(10) + 0.5f * bodySwing + limbSwing;

hangingArm.xRot = -AngleHelper.rad(150);
hangingArm.zRot = (isLeftArmMain ? -1 : 1) * AngleHelper.rad(15);

offsetX = otherArm.x;
offsetY = otherArm.y;
otherArm.x = offsetX * Mth.cos(bodySwing) - offsetY * Mth.sin(bodySwing);
otherArm.y = offsetX * Mth.sin(bodySwing) + offsetY * Mth.cos(bodySwing);
otherArm.zRot = (isLeftArmMain ? -1 : 1) * (-AngleHelper.rad(20)) + 0.5f * bodySwing + limbSwing;

ModelPart leadingLeg = isLeftArmMain ? model.leftLeg : model.rightLeg;
ModelPart trailingLeg = isLeftArmMain ? model.rightLeg : model.leftLeg;

leadingLeg.y -= 0.2f;
offsetX = leadingLeg.x;
offsetY = leadingLeg.y;
leadingLeg.x = offsetX * Mth.cos(bodySwing) - offsetY * Mth.sin(bodySwing);
leadingLeg.y = offsetX * Mth.sin(bodySwing) + offsetY * Mth.cos(bodySwing);
leadingLeg.xRot = -AngleHelper.rad(25);
leadingLeg.zRot = (isLeftArmMain ? -1 : 1) * (AngleHelper.rad(10)) + 0.5f * bodySwing + limbSwing;
trailingLeg.y -= 0.8f;
offsetX = trailingLeg.x;
offsetY = trailingLeg.y;
trailingLeg.x = offsetX * Mth.cos(bodySwing) - offsetY * Mth.sin(bodySwing);
trailingLeg.y = offsetX * Mth.sin(bodySwing) + offsetY * Mth.cos(bodySwing);
trailingLeg.xRot = AngleHelper.rad(10);
trailingLeg.zRot = (isLeftArmMain ? -1 : 1) * (-AngleHelper.rad(10)) + 0.5f * bodySwing + limbSwing;
model.hat.x -= armPivotX;
model.head.x -= armPivotX;
model.body.x -= armPivotX;
model.leftArm.x -= armPivotX;
model.leftLeg.x -= armPivotX;
model.rightLeg.x -= armPivotX;
otherArm.x -= armPivotX;
trailingLeg.x -= armPivotX;
leadingLeg.x -= armPivotX;

model.hat.y -= armPivotY;
model.head.y -= armPivotY;
model.body.y -= armPivotY;
model.leftArm.y -= armPivotY;
model.leftLeg.y -= armPivotY;
model.rightLeg.y -= armPivotY;
otherArm.y -= armPivotY;
trailingLeg.y -= armPivotY;
leadingLeg.y -= armPivotY;
}

}