优化动画

This commit is contained in:
Atsuihsio 2024-06-02 16:35:32 +08:00
parent 22c2c1271d
commit bacb94c66c
7 changed files with 32 additions and 54 deletions

View file

@ -55,26 +55,12 @@ public class MarlinItemModel extends GeoModel<MarlinItem> {
double fp = player.getPersistentData().getDouble("fire_pos");
double fr = player.getPersistentData().getDouble("fire_rot");
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).zooming) {
shen.setPosY(-0.01f * (float) (fp + 2 * fr));
shen.setPosZ(1.4f * (float) (fp + 0.54f * fr));
shen.setRotX(0.003f * (float) (fp + fr));
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilHorizon > 0) {
shen.setRotY(0.015f * (float) fr);
} else {
shen.setRotY(-0.015f * (float) fr);
}
} else {
shen.setPosY(-0.03f * (float) (fp + 2 * fr));
shen.setPosZ(1.8f * (float) (fp + 0.54f * fr));
shen.setRotX(0.07f * (float) (0.18f * fp + fr));
shen.setRotZ(-0.04f * (float) (fp + 1.3 * fr));
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilHorizon > 0) {
shen.setRotY(0.03f * (float) fr);
} else {
shen.setRotY(-0.03f * (float) fr);
}
}
shen.setPosX(-0.2f * (float) (fp + 2 * fr));
shen.setPosY(0.4f * (float) (fp + 2 * fr));
shen.setPosZ(1.9f * (float) (1.3 * fp + 0.54f * fr));
shen.setRotX(0.085f * (float) (1.28f * fp + fr));
shen.setRotZ(-0.03f * (float) (fp + 1.3 * fr));
shen.setRotY(-0.05f * (float) fr);
CoreGeoBone flare = getAnimationProcessor().getBone("flare");

View file

@ -70,6 +70,7 @@ public class SentinelItemModel extends GeoModel<SentinelItem> {
CoreGeoBone holo = getAnimationProcessor().getBone("holo");
if (gun.getPosX() > 1.8) {
holo.setPosY(0.09f);
holo.setScaleX(1);
holo.setScaleY(1);
} else {

View file

@ -53,12 +53,12 @@ public class TracheliumItemModel extends GeoModel<Trachelium> {
double fp = player.getPersistentData().getDouble("fire_pos");
double fr = player.getPersistentData().getDouble("fire_rot");
shen.setPosX(-0.2f * (float) (fp + 2 * fr));
shen.setPosY(0.2f * (float) (fp + 2 * fr));
shen.setPosX(-0.4f * (float) (fp + 2 * fr));
shen.setPosY(0.4f * (float) (fp + 2 * fr));
shen.setPosZ(4.2f * (float) (1.3 * fp + 0.54f * fr));
shen.setRotX(0.25f * (float) (1.28f * fp + fr));
shen.setRotX(0.125f * (float) (1.28f * fp + fr));
shen.setRotY(0.15f * (float) fr);
shen.setRotZ(-0.1f * (float) (fp + 1.3 * fr));
shen.setRotY(-0.15f * (float) fr);
CoreGeoBone flare = getAnimationProcessor().getBone("flare");

View file

@ -389,54 +389,45 @@ public class ClientEventHandler {
var capability = entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null);
if (capability.orElse(new TargetModVariables.PlayerVariables()).firing > 0) {
data.putDouble("firetime", 0.2);
data.putDouble("fire_rotx_time", 0.2);
if (0.3 > data.getDouble("firepos2")) {
data.putDouble("firetime", 0.02);
data.putDouble("fire_rotx_time", 0.02);
if (data.getDouble("firepos2") < 0.6) {
data.putDouble("firepos2", (data.getDouble("firepos2") + 0.04 * times));
}
}
if (0 < data.getDouble("firepos2")) {
data.putDouble("firepos2", (data.getDouble("firepos2") - 0.02 * times));
data.putDouble("firepos2", (data.getDouble("firepos2") - 0.01 * times));
} else {
data.putDouble("firepos2", 0);
}
if (0 < data.getDouble("firetime")) {
data.putDouble("firetime", (data.getDouble("firetime") + 0.075 * times));
data.putDouble("firetime", (data.getDouble("firetime") + 0.12 * (1.1 - data.getDouble("firetime")) * times));
}
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) {
event.setYaw((float) (yaw - 0.2 * amplitude * ((-18.34) * Math.pow(data.getDouble("firetime"), 2) + 8.58 * data.getDouble("firetime") + 0.7 * (2 * Math.random() - 1))));
event.setPitch((float) (pitch + 0.2 * amplitude * ((-18.34) * Math.pow(data.getDouble("firetime"), 2) + 8.58 * data.getDouble("firetime") + 0.7 * (2 * Math.random() - 1))));
event.setRoll((float) (roll + amplitude * ((-18.34) * Math.pow(data.getDouble("firetime"), 2) + 8.58 * data.getDouble("firetime") + 0.7 * (2 * Math.random() - 1))));
} else if ((capability.orElse(new TargetModVariables.PlayerVariables())).recoilHorizon <= 0) {
event.setYaw((float) (yaw - 0.2 * amplitude * ((-18.34) * Math.pow(data.getDouble("firetime"), 2) + 8.58 * data.getDouble("firetime") + 0.7 * (2 * Math.random() - 1))));
event.setPitch((float) (pitch + 0.2 * amplitude * ((-18.34) * Math.pow(data.getDouble("firetime"), 2) + 8.58 * data.getDouble("firetime") + 0.7 * (2 * Math.random() - 1))));
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.454 <= data.getDouble("firetime") && data.getDouble("firetime") < 1) {
data.putDouble("fire_pos",
(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 * (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 * (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("fire_rotx_time") && data.getDouble("fire_rotx_time") < 1.8) {
data.putDouble("fire_rotx_time", (data.getDouble("fire_rotx_time") + 0.1 * (1.9 - data.getDouble("fire_rotx_time")) * times));
data.putDouble("fire_rotx_time", (data.getDouble("fire_rotx_time") + 0.12 * (1.9 - data.getDouble("fire_rotx_time")) * times));
}
if (0 < data.getDouble("fire_rotx_time") && data.getDouble("fire_rotx_time") < 1.8) {
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)) * (3 - Math.pow(data.getDouble("fire_rotx_time") , 2))));
if ((capability.orElse(new TargetModVariables.PlayerVariables())).recoilHorizon > 0) {
event.setYaw((float) (yaw - 1.3 * amplitude * (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)) + 1 * Mth.clamp(0.3 - data.getDouble("fire_rotx_time"),0,1) * (2 * Math.random() - 1)));
event.setPitch((float) (pitch + 1.3 * amplitude * (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)) + 1 * Mth.clamp(0.3 - data.getDouble("fire_rotx_time"),0,1) * (2 * Math.random() - 1)));
event.setRoll((float) (roll + 4.2 * amplitude * (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)) + 3 * Mth.clamp(0.5 - data.getDouble("fire_rotx_time"),0,0.5) * (2 * Math.random() - 1)));
} else if ((capability.orElse(new TargetModVariables.PlayerVariables())).recoilHorizon <= 0) {
event.setYaw((float) (yaw + 1.3 * amplitude * (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)) + 1 * Mth.clamp(0.3 - data.getDouble("fire_rotx_time"),0,1) * (2 * Math.random() - 1)));
event.setPitch((float) (pitch - 1.3 * amplitude * (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)) + 1 * Mth.clamp(0.3 - data.getDouble("fire_rotx_time"),0,1) * (2 * Math.random() - 1)));
event.setRoll((float) (roll - 4.2 * amplitude * (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)) + 3 * Mth.clamp(0.5 - data.getDouble("fire_rotx_time"),0,0.5) * (2 * Math.random() - 1)));
}
}
if (0 <= data.getDouble("firetime") && data.getDouble("firetime") <= 0.25) {
data.putDouble("boltpos", (-Math.pow(8 * data.getDouble("firetime") - 1, 2) + 1));

View file

@ -299,22 +299,22 @@ public class GunEventHandler {
String name = origin.substring(origin.lastIndexOf(".") + 1);
if (player.getMainHandItem().getItem() == TargetModItems.SENTINEL.get() && stack.getOrCreateTag().getDouble("power") > 0) {
SoundEvent sound1p = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(TargetMod.MODID, name + "_charge_fire_1p"));
SoundEvent sound1p = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(TargetMod.MODID, "sentinel_charge_fire_1p"));
if (sound1p != null && player instanceof ServerPlayer serverPlayer) {
SoundTool.playLocalSound(serverPlayer, sound1p, 2f, 1f);
}
SoundEvent sound3p = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(TargetMod.MODID, name + "v_fire_3p"));
SoundEvent sound3p = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(TargetMod.MODID, "sentinel_charge_fire_3p"));
if (sound3p != null) {
player.level().playSound(null, player.getOnPos(), sound3p, SoundSource.PLAYERS, 4f, 1f);
}
SoundEvent soundFar = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(TargetMod.MODID, name + "_charge_far"));
SoundEvent soundFar = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(TargetMod.MODID, "sentinel_charge_far"));
if (soundFar != null) {
player.playSound(soundFar, 12f, 1f);
}
SoundEvent soundVeryFar = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(TargetMod.MODID, name + "_charge_veryfar"));
SoundEvent soundVeryFar = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(TargetMod.MODID, "sentinel_charge_veryfar"));
if (soundVeryFar != null) {
player.playSound(soundVeryFar, 24f, 1f);
}

View file

@ -325,10 +325,10 @@ public class PlayerEventHandler {
if (recoil >= 2) recoil = 0d;
if (0 < recoil && recoil < 2) {
recoil = recoil + 0.01 * (2.5 - recoil);
recoil = recoil + 0.013 * (2.1 - recoil);
double sinRes = 0;
sinRes = 0.35 * Math.sin(Math.PI * (1.5 * recoil)) * (3 - Math.pow(recoil , 2)) + 0.018;
sinRes = 0.35 * Math.sin(Math.PI * (1.5 * recoil)) * (3 - Math.pow(recoil , 2)) + 0.046;
float newPitch = ((float) (player.getXRot() - 7.5f * recoilY * ry * sinRes));
player.setXRot(newPitch);