优化开火,后坐力动画

This commit is contained in:
Atsuihsio 2024-06-02 14:13:21 +08:00
parent 312919daea
commit 22c2c1271d
4 changed files with 21 additions and 55 deletions

View file

@ -52,26 +52,12 @@ public class AbekiriItemModel extends GeoModel<Abekiri> {
double fp = player.getPersistentData().getDouble("fire_pos"); double fp = player.getPersistentData().getDouble("fire_pos");
double fr = player.getPersistentData().getDouble("fire_rot"); double fr = player.getPersistentData().getDouble("fire_rot");
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).zooming) { shen.setPosX(-0.2f * (float) (fp + 2 * fr));
shen.setPosY(0.04f * (float) (fp + 2 * fr)); shen.setPosY(0.2f * (float) (fp + 2 * fr));
shen.setPosZ(3f * (float) (fp + 0.54f * fr)); shen.setPosZ(4.2f * (float) (1.3 * fp + 0.54f * fr));
shen.setRotX(0.4f * (float) (fp + fr)); shen.setRotX(0.25f * (float) (1.28f * fp + fr));
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilHorizon > 0) { shen.setRotZ(-0.1f * (float) (fp + 1.3 * fr));
shen.setRotY(0.04f * (float) fr); shen.setRotY(-0.15f * (float) fr);
} else {
shen.setRotY(-0.04f * (float) fr);
}
} else {
shen.setPosY(0.08f * (float) (fp + 2 * fr));
shen.setPosZ(4f * (float) (fp + 0.54f * fr));
shen.setRotX(0.5f * (float) (0.18f * fp + fr));
shen.setRotZ(-0.16f * (float) (fp + 1.3 * fr));
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilHorizon > 0) {
shen.setRotY(0.09f * (float) fr);
} else {
shen.setRotY(-0.09f * (float) fr);
}
}
CoreGeoBone flare = getAnimationProcessor().getBone("flare"); CoreGeoBone flare = getAnimationProcessor().getBone("flare");

View file

@ -53,26 +53,12 @@ public class TracheliumItemModel extends GeoModel<Trachelium> {
double fp = player.getPersistentData().getDouble("fire_pos"); double fp = player.getPersistentData().getDouble("fire_pos");
double fr = player.getPersistentData().getDouble("fire_rot"); double fr = player.getPersistentData().getDouble("fire_rot");
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).zooming) { shen.setPosX(-0.2f * (float) (fp + 2 * fr));
shen.setPosY(0.4f * (float) (fp + 2 * fr)); shen.setPosY(0.2f * (float) (fp + 2 * fr));
shen.setPosZ(3.6f * (float) (fp + 0.54f * fr)); shen.setPosZ(4.2f * (float) (1.3 * fp + 0.54f * fr));
shen.setRotX(0.12f * (float) (fp + fr)); shen.setRotX(0.25f * (float) (1.28f * fp + fr));
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilHorizon > 0) { shen.setRotZ(-0.1f * (float) (fp + 1.3 * fr));
shen.setRotY(0.025f * (float) fr); shen.setRotY(-0.15f * (float) fr);
} else {
shen.setRotY(-0.025f * (float) fr);
}
} else {
shen.setPosY(0.7f * (float) (fp + 2 * fr));
shen.setPosZ(4.2f * (float) (fp + 0.54f * fr));
shen.setRotX(0.15f * (float) (0.18f * fp + fr));
shen.setRotZ(-0.01f * (float) (fp + 1.3 * fr));
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilHorizon > 0) {
shen.setRotY(0.045f * (float) fr);
} else {
shen.setRotY(-0.045f * (float) fr);
}
}
CoreGeoBone flare = getAnimationProcessor().getBone("flare"); CoreGeoBone flare = getAnimationProcessor().getBone("flare");

View file

@ -430,13 +430,13 @@ public class ClientEventHandler {
} }
} }
if (0 < data.getDouble("fire_rotx_time") && data.getDouble("fire_rotx_time") < 2) { if (0 < data.getDouble("fire_rotx_time") && data.getDouble("fire_rotx_time") < 1.8) {
data.putDouble("fire_rotx_time", (data.getDouble("fire_rotx_time") + 0.1 * (2.3 - data.getDouble("fire_rotx_time")) * times)); data.putDouble("fire_rotx_time", (data.getDouble("fire_rotx_time") + 0.1 * (1.9 - data.getDouble("fire_rotx_time")) * times));
} }
if (0 < data.getDouble("fire_rotx_time") && data.getDouble("fire_rotx_time") < 2) { if (0 < data.getDouble("fire_rotx_time") && data.getDouble("fire_rotx_time") < 1.8) {
data.putDouble("fire_rot", data.putDouble("fire_rot",
(pose * (1 / 6.3 * (data.getDouble("fire_rotx_time") - 0.5)) * Math.sin(6.3 * (data.getDouble("fire_rotx_time") - 0.5)) * (2.5 - data.getDouble("fire_rotx_time")))); (pose * (1 / 6.3 * (data.getDouble("fire_rotx_time") - 0.5)) * Math.sin(6.3 * (data.getDouble("fire_rotx_time") - 0.5)) * (3 - Math.pow(data.getDouble("fire_rotx_time") , 2))));
} }
if (0 <= data.getDouble("firetime") && data.getDouble("firetime") <= 0.25) { if (0 <= data.getDouble("firetime") && data.getDouble("firetime") <= 0.25) {
data.putDouble("boltpos", (-Math.pow(8 * data.getDouble("firetime") - 1, 2) + 1)); data.putDouble("boltpos", (-Math.pow(8 * data.getDouble("firetime") - 1, 2) + 1));
@ -447,7 +447,7 @@ public class ClientEventHandler {
if (data.getDouble("firetime") >= 1) { if (data.getDouble("firetime") >= 1) {
data.putDouble("firetime", 0); data.putDouble("firetime", 0);
} }
if (data.getDouble("fire_rotx_time") >= 2) { if (data.getDouble("fire_rotx_time") >= 1.8) {
data.putDouble("fire_rotx_time", 0); data.putDouble("fire_rotx_time", 0);
} }
} }

View file

@ -322,19 +322,13 @@ public class PlayerEventHandler {
double recoil = player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).map(c -> c.recoil).orElse(0d); double recoil = player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).map(c -> c.recoil).orElse(0d);
if (recoil >= 1) recoil = 0d; if (recoil >= 2) recoil = 0d;
if (recoil > 0) { if (0 < recoil && recoil < 2) {
recoil += 0.01; recoil = recoil + 0.01 * (2.5 - recoil);
double sinRes = 0; double sinRes = 0;
sinRes = 0.35 * Math.sin(Math.PI * (1.5 * recoil)) * (3 - Math.pow(recoil , 2)) + 0.018;
if (0 < recoil && recoil < 0.454) {
sinRes = (-18.34) * Math.pow(recoil, 2) + 8.58 * recoil;
}
if (0.454 <= recoil && recoil < 1) {
sinRes = 3.9 * Math.pow(recoil, 2) - 6.5 * recoil + 2.167;
}
float newPitch = ((float) (player.getXRot() - 7.5f * recoilY * ry * sinRes)); float newPitch = ((float) (player.getXRot() - 7.5f * recoilY * ry * sinRes));
player.setXRot(newPitch); player.setXRot(newPitch);