优化动画

This commit is contained in:
Atsuihsio 2024-06-01 22:10:18 +08:00
parent 8d57e58034
commit cbce62c0ee
4 changed files with 23 additions and 30 deletions

View file

@ -78,28 +78,21 @@ public class AK47ItemModel extends GeoModel<AK47Item> {
double fp = player.getPersistentData().getDouble("fire_pos");
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).zooming) {
shen.setPosZ(0.4f * (float) fp);
} else {
shen.setPosZ(1.01f * (float) fp);
}
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).zooming) {
shen.setPosY(0.01f * (float) fp);
} else {
shen.setPosY(0.07f * (float) fp);
}
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).zooming) {
shen.setPosZ(0.4f * (float) fp);
shen.setRotX(0.003f * (float) fp);
} else {
shen.setPosY(0.07f * (float) fp);
shen.setPosZ(1.01f * (float) fp);
shen.setRotX(0.025f * (float) fp);
shen.setRotZ(-0.04f * (float) fp);
}
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilHorizon == 1) {
shen.setRotZ(0.003f * (float) fp);
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilHorizon > 0) {
shen.setRotY(0.003f * (float) fp);
} else {
shen.setRotZ(-0.003f * (float) fp);
shen.setRotY(-0.003f * (float) fp);
}
shuan.setPosZ(2.4f * (float) fp);

View file

@ -88,7 +88,7 @@ public class CrossHairOverlay {
if (player == null) return false;
if (player.isSpectator()) return false;
if (!player.getMainHandItem().is(TargetModTags.Items.GUN) || !(player.getPersistentData().getDouble("zoom_animation_time") < 7))
if (!player.getMainHandItem().is(TargetModTags.Items.GUN) || !(player.getPersistentData().getDouble("zoom_animation_time") < 4))
return false;
return !(player.getMainHandItem().getItem() == TargetModItems.M_79.get())

View file

@ -342,13 +342,13 @@ public class ClientEventHandler {
if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).zooming) {
if (data.getDouble("zoom_time") < 1) {
data.putDouble("zoom_time",
(data.getDouble("zoom_time") + entity.getMainHandItem().getOrCreateTag().getDouble("zoom_speed") * 0.02 * times));
(data.getDouble("zoom_time") + entity.getMainHandItem().getOrCreateTag().getDouble("zoom_speed") * 0.03 * times));
} else {
data.putDouble("zoom_time", 1);
}
} else {
if (data.getDouble("zoom_time") > 0) {
data.putDouble("zoom_time", (data.getDouble("zoom_time") - 0.02 * times));
data.putDouble("zoom_time", (data.getDouble("zoom_time") - 0.04 * times));
} else {
data.putDouble("zoom_time", 0);
}
@ -402,7 +402,7 @@ public class ClientEventHandler {
if (0 < data.getDouble("firetime")) {
data.putDouble("firetime", (data.getDouble("firetime") + 0.075 * times));
}
if (0 < data.getDouble("firetime") && data.getDouble("firetime") < 0.2) {
if (0 < data.getDouble("firetime") && data.getDouble("firetime") < 0.454) {
data.putDouble("fire_pos",
(pose * ((-18.34) * Math.pow(data.getDouble("firetime"), 2) + 8.58 * data.getDouble("firetime") + data.getDouble("firepos2"))));
if ((capability.orElse(new TargetModVariables.PlayerVariables())).recoilHorizon > 0) {
@ -415,17 +415,17 @@ public class ClientEventHandler {
event.setRoll((float) (roll - amplitude * ((-18.34) * Math.pow(data.getDouble("firetime"), 2) + 8.58 * data.getDouble("firetime") + 0.7 * (2 * Math.random() - 1))));
}
}
if (0.2 <= data.getDouble("firetime") && data.getDouble("firetime") < 1) {
if (0.454 <= data.getDouble("firetime") && data.getDouble("firetime") < 1) {
data.putDouble("fire_pos",
(pose * (3.34 * Math.pow(data.getDouble("firetime"), 2) - 5.5 * data.getDouble("firetime") + 2.167 + data.getDouble("firepos2"))));
(pose * (4.34 * Math.pow(data.getDouble("firetime"), 2) - 6.5 * data.getDouble("firetime") + 2.167 + data.getDouble("firepos2"))));
if ((capability.orElse(new TargetModVariables.PlayerVariables())).recoilHorizon > 0) {
event.setYaw((float) (yaw - 0.2 * amplitude * (3.34 * Math.pow(data.getDouble("firetime"), 2) - 5.5 * data.getDouble("firetime") + 2.167 + 0.7 * (2 * Math.random() - 1))));
event.setPitch((float) (pitch + 0.2 * amplitude * (3.34 * Math.pow(data.getDouble("firetime"), 2) - 5.5 * data.getDouble("firetime") + 2.167 + 0.7 * (2 * Math.random() - 1))));
event.setRoll((float) (roll + amplitude * (3.34 * Math.pow(data.getDouble("firetime"), 2) - 5.5 * data.getDouble("firetime") + 2.167 + 0.7 * (2 * Math.random() - 1))));
event.setYaw((float) (yaw - 0.2 * amplitude * (4.34 * Math.pow(data.getDouble("firetime"), 2) - 5.5 * data.getDouble("firetime") + 2.167 + 0.7 * (2 * Math.random() - 1))));
event.setPitch((float) (pitch + 0.2 * amplitude * (4.34 * Math.pow(data.getDouble("firetime"), 2) - 5.5 * data.getDouble("firetime") + 2.167 + 0.7 * (2 * Math.random() - 1))));
event.setRoll((float) (roll + amplitude * (4.34 * Math.pow(data.getDouble("firetime"), 2) - 5.5 * data.getDouble("firetime") + 2.167 + 0.7 * (2 * Math.random() - 1))));
} else if ((capability.orElse(new TargetModVariables.PlayerVariables())).recoilHorizon <= 0) {
event.setYaw((float) (yaw + 0.2 * amplitude * (3.34 * Math.pow(data.getDouble("firetime"), 2) - 5.5 * data.getDouble("firetime") + 2.167 + 0.7 * (2 * Math.random() - 1))));
event.setPitch((float) (pitch - 0.2 * amplitude * (3.34 * Math.pow(data.getDouble("firetime"), 2) - 5.5 * data.getDouble("firetime") + 2.167 + 0.7 * (2 * Math.random() - 1))));
event.setRoll((float) (roll - amplitude * (3.34 * Math.pow(data.getDouble("firetime"), 2) - 5.5 * data.getDouble("firetime") + 2.167 + 0.7 * (2 * Math.random() - 1))));
event.setYaw((float) (yaw + 0.2 * amplitude * (4.34 * Math.pow(data.getDouble("firetime"), 2) - 5.5 * data.getDouble("firetime") + 2.167 + 0.7 * (2 * Math.random() - 1))));
event.setPitch((float) (pitch - 0.2 * amplitude * (4.34 * Math.pow(data.getDouble("firetime"), 2) - 5.5 * data.getDouble("firetime") + 2.167 + 0.7 * (2 * Math.random() - 1))));
event.setRoll((float) (roll - amplitude * (4.34 * Math.pow(data.getDouble("firetime"), 2) - 5.5 * data.getDouble("firetime") + 2.167 + 0.7 * (2 * Math.random() - 1))));
}
}
if (0 <= data.getDouble("firetime") && data.getDouble("firetime") <= 0.25) {

View file

@ -190,7 +190,7 @@ public class PlayerEventHandler {
});
if (player.getPersistentData().getInt("zoom_animation_time") < 10) {
player.getPersistentData().putInt("zoom_animation_time", player.getPersistentData().getInt("zoom_animation_time") + 1);
player.getPersistentData().putInt("zoom_animation_time", player.getPersistentData().getInt("zoom_animation_time") + 2);
}
} else {
player.getPersistentData().putInt("zoom_animation_time", 0);
@ -329,11 +329,11 @@ public class PlayerEventHandler {
double sinRes = 0;
if (0 < recoil && recoil < 0.2) {
if (0 < recoil && recoil < 0.454) {
sinRes = (-18.34) * Math.pow(recoil, 2) + 8.58 * recoil;
}
if (0.2 <= recoil && recoil < 1) {
sinRes = 2.7 * Math.pow(recoil, 2) - 5.5 * recoil + 2.167;
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));