优化开火动画逻辑

This commit is contained in:
Atsuihsio 2024-09-20 05:21:06 +08:00
parent 4316f1d866
commit 29e77af9ab
34 changed files with 218 additions and 396 deletions

View file

@ -59,8 +59,8 @@ public class AK47ItemModel extends GeoModel<AK47Item> {
stack.getOrCreateTag().putBoolean("HoloHidden", !(gun.getPosX() > 1.8)); stack.getOrCreateTag().putBoolean("HoloHidden", !(gun.getPosX() > 1.8));
double fp = player.getPersistentData().getDouble("fire_pos"); double fp = ClientEventHandler.getFirePos();
double fr = player.getPersistentData().getDouble("fire_rot"); double fr = ClientEventHandler.getFireRot();
if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) { if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) {
@ -121,12 +121,6 @@ public class AK47ItemModel extends GeoModel<AK47Item> {
camera.setRotY(numR * camera.getRotY()); camera.setRotY(numR * camera.getRotY());
camera.setRotZ(numR * camera.getRotZ()); camera.setRotZ(numR * camera.getRotZ());
} }
ClientEventHandler.shake(Mth.RAD_TO_DEG * camera.getRotX(),Mth.RAD_TO_DEG * camera.getRotY(), Mth.RAD_TO_DEG * camera.getRotZ());
player.getPersistentData().putDouble("camera_rot_x", Mth.RAD_TO_DEG * camera.getRotX());
player.getPersistentData().putDouble("camera_rot_y", Mth.RAD_TO_DEG * camera.getRotY());
player.getPersistentData().putDouble("camera_rot_z", Mth.RAD_TO_DEG * camera.getRotZ());
} }
} }

View file

@ -51,8 +51,8 @@ public class Aa12ItemModel extends GeoModel<Aa12Item> {
gun.setRotZ((float) (0.02f * zpz)); gun.setRotZ((float) (0.02f * zpz));
gun.setScaleZ(1f - (0.4f * (float) zp)); gun.setScaleZ(1f - (0.4f * (float) zp));
double fp = player.getPersistentData().getDouble("fire_pos"); double fp = ClientEventHandler.getFirePos();
double fr = player.getPersistentData().getDouble("fire_rot"); double fr = ClientEventHandler.getFireRot();
if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) { if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) {
shen.setPosY(0.02f * (float) (fp + 2 * fr)); shen.setPosY(0.02f * (float) (fp + 2 * fr));
@ -109,9 +109,6 @@ public class Aa12ItemModel extends GeoModel<Aa12Item> {
camera.setRotY(numR * camera.getRotY()); camera.setRotY(numR * camera.getRotY());
camera.setRotZ(numR * camera.getRotZ()); camera.setRotZ(numR * camera.getRotZ());
} }
ClientEventHandler.shake(Mth.RAD_TO_DEG * camera.getRotX(),Mth.RAD_TO_DEG * camera.getRotY(), Mth.RAD_TO_DEG * camera.getRotZ());
player.getPersistentData().putDouble("camera_rot_x", Mth.RAD_TO_DEG * camera.getRotX());
player.getPersistentData().putDouble("camera_rot_y", Mth.RAD_TO_DEG * camera.getRotY());
player.getPersistentData().putDouble("camera_rot_z", Mth.RAD_TO_DEG * camera.getRotZ());
} }
} }

View file

@ -52,8 +52,8 @@ public class AbekiriItemModel extends GeoModel<AbekiriItem> {
gun.setRotZ((float) (0.05f * zpz)); gun.setRotZ((float) (0.05f * zpz));
double fp = player.getPersistentData().getDouble("fire_pos"); double fp = ClientEventHandler.getFirePos();
double fr = player.getPersistentData().getDouble("fire_rot"); double fr = ClientEventHandler.getFireRot();
shen.setPosX(-0.2f * (float) (fp + 2 * fr)); shen.setPosX(-0.2f * (float) (fp + 2 * fr));
shen.setPosY(0.2f * (float) (fp + 2 * fr)); shen.setPosY(0.2f * (float) (fp + 2 * fr));
@ -105,11 +105,6 @@ public class AbekiriItemModel extends GeoModel<AbekiriItem> {
camera.setRotY(numR * camera.getRotY()); camera.setRotY(numR * camera.getRotY());
camera.setRotZ(numR * camera.getRotZ()); camera.setRotZ(numR * camera.getRotZ());
} }
ClientEventHandler.shake(Mth.RAD_TO_DEG * camera.getRotX(),Mth.RAD_TO_DEG * camera.getRotY(), Mth.RAD_TO_DEG * camera.getRotZ());
player.getPersistentData().putDouble("camera_rot_x", Mth.RAD_TO_DEG * camera.getRotX());
player.getPersistentData().putDouble("camera_rot_y", Mth.RAD_TO_DEG * camera.getRotY());
player.getPersistentData().putDouble("camera_rot_z", Mth.RAD_TO_DEG * camera.getRotZ());
} }
} }

View file

@ -93,8 +93,8 @@ public class BocekItemModel extends GeoModel<BocekItem> {
stack.getOrCreateTag().putBoolean("HoloHidden", !((shen_pos.getPosX() < -0.7 && gun.getPosZ() < -2.6))); stack.getOrCreateTag().putBoolean("HoloHidden", !((shen_pos.getPosX() < -0.7 && gun.getPosZ() < -2.6)));
double fp = player.getPersistentData().getDouble("fire_pos"); double fp = ClientEventHandler.getFirePos();
double fr = player.getPersistentData().getDouble("fire_rot"); double fr = ClientEventHandler.getFireRot();
if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) { if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) {
fire.setPosY(-0.01f * (float) (fp + 2 * fr)); fire.setPosY(-0.01f * (float) (fp + 2 * fr));
@ -135,11 +135,6 @@ public class BocekItemModel extends GeoModel<BocekItem> {
move.setRotZ(2.7f * (float) mph + Mth.DEG_TO_RAD * (float) turnRotZ); move.setRotZ(2.7f * (float) mph + Mth.DEG_TO_RAD * (float) turnRotZ);
CoreGeoBone camera = getAnimationProcessor().getBone("camera"); CoreGeoBone camera = getAnimationProcessor().getBone("camera");
ClientEventHandler.shake(Mth.RAD_TO_DEG * camera.getRotX(),Mth.RAD_TO_DEG * camera.getRotY(), Mth.RAD_TO_DEG * camera.getRotZ());
player.getPersistentData().putDouble("camera_rot_x", Mth.RAD_TO_DEG * camera.getRotX());
player.getPersistentData().putDouble("camera_rot_y", Mth.RAD_TO_DEG * camera.getRotY());
player.getPersistentData().putDouble("camera_rot_z", Mth.RAD_TO_DEG * camera.getRotZ());
} }
} }

View file

@ -49,22 +49,13 @@ public class DevotionItemModel extends GeoModel<DevotionItem> {
double zpz = ClientEventHandler.getZoomPosZ(); double zpz = ClientEventHandler.getZoomPosZ();
gun.setPosX(2.17f * (float) zp); gun.setPosX(2.17f * (float) zp);
gun.setPosY(0.17f * (float) zp - (float) (0.5f * zpz)); gun.setPosY(0.17f * (float) zp - (float) (0.5f * zpz));
gun.setPosZ(8.8f * (float) zp + (float) (0.6f * zpz)); gun.setPosZ(8.8f * (float) zp + (float) (0.6f * zpz));
gun.setRotZ((float) (0.05f * zpz)); gun.setRotZ((float) (0.05f * zpz));
gun.setScaleZ(1f - (0.7f * (float) zp)); gun.setScaleZ(1f - (0.7f * (float) zp));
CoreGeoBone shen = getAnimationProcessor().getBone("shen"); CoreGeoBone shen = getAnimationProcessor().getBone("shen");
CoreGeoBone number = getAnimationProcessor().getBone("number"); CoreGeoBone number = getAnimationProcessor().getBone("number");
double bp = player.getPersistentData().getDouble("boltpos");
bolt.setPosZ(-2f * (float) bp);
CoreGeoBone holo = getAnimationProcessor().getBone("holo"); CoreGeoBone holo = getAnimationProcessor().getBone("holo");
if (gun.getPosX() > 1.2) { if (gun.getPosX() > 1.2) {
number.setScaleX(1); number.setScaleX(1);
@ -76,8 +67,8 @@ public class DevotionItemModel extends GeoModel<DevotionItem> {
stack.getOrCreateTag().putBoolean("HoloHidden", !(gun.getPosX() > 1.8)); stack.getOrCreateTag().putBoolean("HoloHidden", !(gun.getPosX() > 1.8));
double fp = player.getPersistentData().getDouble("fire_pos"); double fp = ClientEventHandler.getFirePos();
double fr = player.getPersistentData().getDouble("fire_rot"); double fr = ClientEventHandler.getFireRot();
if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) { if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) {
shen.setPosY(0.05f * (float) (fp + 2 * fr)); shen.setPosY(0.05f * (float) (fp + 2 * fr));
@ -91,8 +82,7 @@ public class DevotionItemModel extends GeoModel<DevotionItem> {
shen.setRotZ(-0.04f * (float) (fp + 1.3 * fr)); shen.setRotZ(-0.04f * (float) (fp + 1.3 * fr));
} }
shen.setPosX(0.5f * (float)fr * (float)((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).recoilHorizon * fp)); shen.setPosX(0.5f * (float)fr * (float)((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).recoilHorizon * fp));
bolt.setPosZ(-2f * (float) fp);
CoreGeoBone n0 = getAnimationProcessor().getBone("00"); CoreGeoBone n0 = getAnimationProcessor().getBone("00");
CoreGeoBone n1 = getAnimationProcessor().getBone("1"); CoreGeoBone n1 = getAnimationProcessor().getBone("1");
@ -661,11 +651,6 @@ public class DevotionItemModel extends GeoModel<DevotionItem> {
camera.setRotY(numR * camera.getRotY()); camera.setRotY(numR * camera.getRotY());
camera.setRotZ(numR * camera.getRotZ()); camera.setRotZ(numR * camera.getRotZ());
} }
ClientEventHandler.shake(Mth.RAD_TO_DEG * camera.getRotX(),Mth.RAD_TO_DEG * camera.getRotY(), Mth.RAD_TO_DEG * camera.getRotZ());
player.getPersistentData().putDouble("camera_rot_x", Mth.RAD_TO_DEG * camera.getRotX());
player.getPersistentData().putDouble("camera_rot_y", Mth.RAD_TO_DEG * camera.getRotY());
player.getPersistentData().putDouble("camera_rot_z", Mth.RAD_TO_DEG * camera.getRotZ());
} }
} }

View file

@ -57,8 +57,8 @@ public class Glock17ItemModel extends GeoModel<Glock17Item> {
gun.setRotZ(-11 * Mth.DEG_TO_RAD * (float) zp + (float) (0.05f * zpz)); gun.setRotZ(-11 * Mth.DEG_TO_RAD * (float) zp + (float) (0.05f * zpz));
double fp = player.getPersistentData().getDouble("fire_pos"); double fp = ClientEventHandler.getFirePos();
double fr = player.getPersistentData().getDouble("fire_rot"); double fr = ClientEventHandler.getFireRot();
if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) { if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) {
shen.setPosY(0.03f * (float) (fp + 2 * fr)); shen.setPosY(0.03f * (float) (fp + 2 * fr));
@ -137,11 +137,6 @@ public class Glock17ItemModel extends GeoModel<Glock17Item> {
camera.setRotY(numR * camera.getRotY()); camera.setRotY(numR * camera.getRotY());
camera.setRotZ(numR * camera.getRotZ()); camera.setRotZ(numR * camera.getRotZ());
} }
ClientEventHandler.shake(Mth.RAD_TO_DEG * camera.getRotX(),Mth.RAD_TO_DEG * camera.getRotY(), Mth.RAD_TO_DEG * camera.getRotZ());
player.getPersistentData().putDouble("camera_rot_x", Mth.RAD_TO_DEG * camera.getRotX());
player.getPersistentData().putDouble("camera_rot_y", Mth.RAD_TO_DEG * camera.getRotY());
player.getPersistentData().putDouble("camera_rot_z", Mth.RAD_TO_DEG * camera.getRotZ());
} }
} }

View file

@ -65,8 +65,8 @@ public class Glock18ItemModel extends GeoModel<Glock18Item> {
gun.setRotZ(-11 * Mth.DEG_TO_RAD * (float) zp + (float) (0.05f * zpz)); gun.setRotZ(-11 * Mth.DEG_TO_RAD * (float) zp + (float) (0.05f * zpz));
double fp = player.getPersistentData().getDouble("fire_pos"); double fp = ClientEventHandler.getFirePos();
double fr = player.getPersistentData().getDouble("fire_rot"); double fr = ClientEventHandler.getFireRot();
if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) { if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) {
shen.setPosY(0.03f * (float) (fp + 2 * fr)); shen.setPosY(0.03f * (float) (fp + 2 * fr));
@ -145,11 +145,6 @@ public class Glock18ItemModel extends GeoModel<Glock18Item> {
camera.setRotY(numR * camera.getRotY()); camera.setRotY(numR * camera.getRotY());
camera.setRotZ(numR * camera.getRotZ()); camera.setRotZ(numR * camera.getRotZ());
} }
ClientEventHandler.shake(Mth.RAD_TO_DEG * camera.getRotX(),Mth.RAD_TO_DEG * camera.getRotY(), Mth.RAD_TO_DEG * camera.getRotZ());
player.getPersistentData().putDouble("camera_rot_x", Mth.RAD_TO_DEG * camera.getRotX());
player.getPersistentData().putDouble("camera_rot_y", Mth.RAD_TO_DEG * camera.getRotY());
player.getPersistentData().putDouble("camera_rot_z", Mth.RAD_TO_DEG * camera.getRotZ());
} }
} }

View file

@ -55,8 +55,8 @@ public class Hk416ItemModel extends GeoModel<Hk416Item> {
stack.getOrCreateTag().putBoolean("HoloHidden", !(gun.getPosX() > 3.1)); stack.getOrCreateTag().putBoolean("HoloHidden", !(gun.getPosX() > 3.1));
double fp = player.getPersistentData().getDouble("fire_pos"); double fp = ClientEventHandler.getFirePos();
double fr = player.getPersistentData().getDouble("fire_rot"); double fr = ClientEventHandler.getFireRot();
if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) { if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) {
shen.setPosY(-0.01f * (float) (fp + 2 * fr)); shen.setPosY(-0.01f * (float) (fp + 2 * fr));
@ -114,11 +114,6 @@ public class Hk416ItemModel extends GeoModel<Hk416Item> {
camera.setRotY(numR * camera.getRotY()); camera.setRotY(numR * camera.getRotY());
camera.setRotZ(numR * camera.getRotZ()); camera.setRotZ(numR * camera.getRotZ());
} }
ClientEventHandler.shake(Mth.RAD_TO_DEG * camera.getRotX(),Mth.RAD_TO_DEG * camera.getRotY(), Mth.RAD_TO_DEG * camera.getRotZ());
player.getPersistentData().putDouble("camera_rot_x", Mth.RAD_TO_DEG * camera.getRotX());
player.getPersistentData().putDouble("camera_rot_y", Mth.RAD_TO_DEG * camera.getRotY());
player.getPersistentData().putDouble("camera_rot_z", Mth.RAD_TO_DEG * camera.getRotZ());
} }
} }

View file

@ -53,8 +53,8 @@ public class HuntingRifleItemModel extends GeoModel<HuntingRifleItem> {
gun.setScaleZ(1f - (0.5f * (float) zp)); gun.setScaleZ(1f - (0.5f * (float) zp));
double fp = player.getPersistentData().getDouble("fire_pos"); double fp = ClientEventHandler.getFirePos();
double fr = player.getPersistentData().getDouble("fire_rot"); double fr = ClientEventHandler.getFireRot();
shen.setPosX(-0.05f * (float) (fp + 0.2 * fr)); shen.setPosX(-0.05f * (float) (fp + 0.2 * fr));
shen.setPosY(0.3f * (float) (fp + 2 * fr)); shen.setPosY(0.3f * (float) (fp + 2 * fr));
@ -117,11 +117,6 @@ public class HuntingRifleItemModel extends GeoModel<HuntingRifleItem> {
camera.setRotY(numR * camera.getRotY()); camera.setRotY(numR * camera.getRotY());
camera.setRotZ(numR * camera.getRotZ()); camera.setRotZ(numR * camera.getRotZ());
} }
ClientEventHandler.shake(Mth.RAD_TO_DEG * camera.getRotX(),Mth.RAD_TO_DEG * camera.getRotY(), Mth.RAD_TO_DEG * camera.getRotZ());
player.getPersistentData().putDouble("camera_rot_x", Mth.RAD_TO_DEG * camera.getRotX());
player.getPersistentData().putDouble("camera_rot_y", Mth.RAD_TO_DEG * camera.getRotY());
player.getPersistentData().putDouble("camera_rot_z", Mth.RAD_TO_DEG * camera.getRotZ());
} }
} }

View file

@ -54,8 +54,8 @@ public class JavelinItemModel extends GeoModel<JavelinItem> {
javelin.setHidden(gun.getPosZ() > 15.85); javelin.setHidden(gun.getPosZ() > 15.85);
stack.getOrCreateTag().putBoolean("HoloHidden", !(gun.getPosZ() > 15.85)); stack.getOrCreateTag().putBoolean("HoloHidden", !(gun.getPosZ() > 15.85));
double fp = player.getPersistentData().getDouble("fire_pos"); double fp = ClientEventHandler.getFirePos();
double fr = player.getPersistentData().getDouble("fire_rot"); double fr = ClientEventHandler.getFireRot();
shen.setPosY(0.28f * (float) (fp + 2 * fr)); shen.setPosY(0.28f * (float) (fp + 2 * fr));
shen.setPosZ(3.8f * (float) (fp + 0.54f * fr)); shen.setPosZ(3.8f * (float) (fp + 0.54f * fr));
@ -90,11 +90,6 @@ public class JavelinItemModel extends GeoModel<JavelinItem> {
move.setRotZ(2.7f * (float) mph + Mth.DEG_TO_RAD * (float) turnRotZ); move.setRotZ(2.7f * (float) mph + Mth.DEG_TO_RAD * (float) turnRotZ);
CoreGeoBone camera = getAnimationProcessor().getBone("camera"); CoreGeoBone camera = getAnimationProcessor().getBone("camera");
ClientEventHandler.shake(Mth.RAD_TO_DEG * camera.getRotX(),Mth.RAD_TO_DEG * camera.getRotY(), Mth.RAD_TO_DEG * camera.getRotZ());
player.getPersistentData().putDouble("camera_rot_x", Mth.RAD_TO_DEG * camera.getRotX());
player.getPersistentData().putDouble("camera_rot_y", Mth.RAD_TO_DEG * camera.getRotY());
player.getPersistentData().putDouble("camera_rot_z", Mth.RAD_TO_DEG * camera.getRotZ());
} }
} }

View file

@ -63,8 +63,8 @@ public class K98ItemModel extends GeoModel<K98Item> {
gun.setScaleZ(1f - (0.7f * (float) zp)); gun.setScaleZ(1f - (0.7f * (float) zp));
double fp = player.getPersistentData().getDouble("fire_pos"); double fp = ClientEventHandler.getFirePos();
double fr = player.getPersistentData().getDouble("fire_rot"); double fr = ClientEventHandler.getFireRot();
if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) { if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) {
shen.setPosY(0.1f * (float) (fp + 2 * fr)); shen.setPosY(0.1f * (float) (fp + 2 * fr));
@ -130,11 +130,6 @@ public class K98ItemModel extends GeoModel<K98Item> {
camera.setRotY(numR * camera.getRotY()); camera.setRotY(numR * camera.getRotY());
camera.setRotZ(numR * camera.getRotZ()); camera.setRotZ(numR * camera.getRotZ());
} }
ClientEventHandler.shake(Mth.RAD_TO_DEG * camera.getRotX(),Mth.RAD_TO_DEG * camera.getRotY(), Mth.RAD_TO_DEG * camera.getRotZ());
player.getPersistentData().putDouble("camera_rot_x", Mth.RAD_TO_DEG * camera.getRotX());
player.getPersistentData().putDouble("camera_rot_y", Mth.RAD_TO_DEG * camera.getRotY());
player.getPersistentData().putDouble("camera_rot_z", Mth.RAD_TO_DEG * camera.getRotZ());
} }
} }

View file

@ -55,8 +55,8 @@ public class M1911ItemModel extends GeoModel<M1911Item> {
gun.setScaleZ(1f - (0.35f * (float) zp)); gun.setScaleZ(1f - (0.35f * (float) zp));
double fp = player.getPersistentData().getDouble("fire_pos"); double fp = ClientEventHandler.getFirePos();
double fr = player.getPersistentData().getDouble("fire_rot"); double fr = ClientEventHandler.getFireRot();
if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) { if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) {
shen.setPosY(0.03f * (float) (fp + 2 * fr)); shen.setPosY(0.03f * (float) (fp + 2 * fr));
@ -135,11 +135,6 @@ public class M1911ItemModel extends GeoModel<M1911Item> {
camera.setRotY(numR * camera.getRotY()); camera.setRotY(numR * camera.getRotY());
camera.setRotZ(numR * camera.getRotZ()); camera.setRotZ(numR * camera.getRotZ());
} }
ClientEventHandler.shake(Mth.RAD_TO_DEG * camera.getRotX(),Mth.RAD_TO_DEG * camera.getRotY(), Mth.RAD_TO_DEG * camera.getRotZ());
player.getPersistentData().putDouble("camera_rot_x", Mth.RAD_TO_DEG * camera.getRotX());
player.getPersistentData().putDouble("camera_rot_y", Mth.RAD_TO_DEG * camera.getRotY());
player.getPersistentData().putDouble("camera_rot_z", Mth.RAD_TO_DEG * camera.getRotZ());
} }
} }

View file

@ -55,8 +55,8 @@ public class M4ItemModel extends GeoModel<M4Item> {
gun.setRotZ((float) (0.05f * zpz)); gun.setRotZ((float) (0.05f * zpz));
double fp = player.getPersistentData().getDouble("fire_pos"); double fp = ClientEventHandler.getFirePos();
double fr = player.getPersistentData().getDouble("fire_rot"); double fr = ClientEventHandler.getFireRot();
if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) { if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) {
shen.setPosY(0.02f * (float) (fp + 2 * fr)); shen.setPosY(0.02f * (float) (fp + 2 * fr));
@ -114,11 +114,6 @@ public class M4ItemModel extends GeoModel<M4Item> {
camera.setRotY(numR * camera.getRotY()); camera.setRotY(numR * camera.getRotY());
camera.setRotZ(numR * camera.getRotZ()); camera.setRotZ(numR * camera.getRotZ());
} }
ClientEventHandler.shake(Mth.RAD_TO_DEG * camera.getRotX(),Mth.RAD_TO_DEG * camera.getRotY(), Mth.RAD_TO_DEG * camera.getRotZ());
player.getPersistentData().putDouble("camera_rot_x", Mth.RAD_TO_DEG * camera.getRotX());
player.getPersistentData().putDouble("camera_rot_y", Mth.RAD_TO_DEG * camera.getRotY());
player.getPersistentData().putDouble("camera_rot_z", Mth.RAD_TO_DEG * camera.getRotZ());
} }
} }

View file

@ -96,8 +96,8 @@ public class M60ItemModel extends GeoModel<M60Item> {
gun.setRotZ(-0.087f * (float) zp + (float) (0.05f * zpz)); gun.setRotZ(-0.087f * (float) zp + (float) (0.05f * zpz));
double fp = player.getPersistentData().getDouble("fire_pos"); double fp = ClientEventHandler.getFirePos();
double fr = player.getPersistentData().getDouble("fire_rot"); double fr = ClientEventHandler.getFireRot();
if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) { if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) {
shen.setPosY(-0.03f * (float) (fp + 2 * fr)); shen.setPosY(-0.03f * (float) (fp + 2 * fr));
@ -157,11 +157,6 @@ public class M60ItemModel extends GeoModel<M60Item> {
camera.setRotY(numR * camera.getRotY()); camera.setRotY(numR * camera.getRotY());
camera.setRotZ(numR * camera.getRotZ()); camera.setRotZ(numR * camera.getRotZ());
} }
ClientEventHandler.shake(Mth.RAD_TO_DEG * camera.getRotX(),Mth.RAD_TO_DEG * camera.getRotY(), Mth.RAD_TO_DEG * camera.getRotZ());
player.getPersistentData().putDouble("camera_rot_x", Mth.RAD_TO_DEG * camera.getRotX());
player.getPersistentData().putDouble("camera_rot_y", Mth.RAD_TO_DEG * camera.getRotY());
player.getPersistentData().putDouble("camera_rot_z", Mth.RAD_TO_DEG * camera.getRotZ());
} }
} }

View file

@ -53,8 +53,8 @@ public class M79ItemModel extends GeoModel<M79Item> {
gun.setRotZ((float) (0.05f * zpz)); gun.setRotZ((float) (0.05f * zpz));
double fp = player.getPersistentData().getDouble("fire_pos"); double fp = ClientEventHandler.getFirePos();
double fr = player.getPersistentData().getDouble("fire_rot"); double fr = ClientEventHandler.getFireRot();
if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) { if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) {
shen.setPosY(0.4f * (float) (fp + 2 * fr)); shen.setPosY(0.4f * (float) (fp + 2 * fr));
@ -112,11 +112,6 @@ public class M79ItemModel extends GeoModel<M79Item> {
camera.setRotY(numR * camera.getRotY()); camera.setRotY(numR * camera.getRotY());
camera.setRotZ(numR * camera.getRotZ()); camera.setRotZ(numR * camera.getRotZ());
} }
ClientEventHandler.shake(Mth.RAD_TO_DEG * camera.getRotX(),Mth.RAD_TO_DEG * camera.getRotY(), Mth.RAD_TO_DEG * camera.getRotZ());
player.getPersistentData().putDouble("camera_rot_x", Mth.RAD_TO_DEG * camera.getRotX());
player.getPersistentData().putDouble("camera_rot_y", Mth.RAD_TO_DEG * camera.getRotY());
player.getPersistentData().putDouble("camera_rot_z", Mth.RAD_TO_DEG * camera.getRotZ());
} }
} }

View file

@ -55,8 +55,8 @@ public class M870ItemModel extends GeoModel<M870Item> {
gun.setScaleZ(1f - (0.2f * (float) zp)); gun.setScaleZ(1f - (0.2f * (float) zp));
double fp = player.getPersistentData().getDouble("fire_pos"); double fp = ClientEventHandler.getFirePos();
double fr = player.getPersistentData().getDouble("fire_rot"); double fr = ClientEventHandler.getFireRot();
if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) { if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) {
shen.setPosY(0.2f * (float) (fp + 2 * fr)); shen.setPosY(0.2f * (float) (fp + 2 * fr));
@ -115,11 +115,6 @@ public class M870ItemModel extends GeoModel<M870Item> {
camera.setRotY(numR * camera.getRotY()); camera.setRotY(numR * camera.getRotY());
camera.setRotZ(numR * camera.getRotZ()); camera.setRotZ(numR * camera.getRotZ());
} }
ClientEventHandler.shake(Mth.RAD_TO_DEG * camera.getRotX(),Mth.RAD_TO_DEG * camera.getRotY(), Mth.RAD_TO_DEG * camera.getRotZ());
player.getPersistentData().putDouble("camera_rot_x", Mth.RAD_TO_DEG * camera.getRotX());
player.getPersistentData().putDouble("camera_rot_y", Mth.RAD_TO_DEG * camera.getRotY());
player.getPersistentData().putDouble("camera_rot_z", Mth.RAD_TO_DEG * camera.getRotZ());
} }
} }

View file

@ -41,8 +41,8 @@ public class M98bItemModel extends GeoModel<M98bItem> {
ItemStack stack = player.getMainHandItem(); ItemStack stack = player.getMainHandItem();
if (!stack.is(ModTags.Items.GUN)) return; if (!stack.is(ModTags.Items.GUN)) return;
double fp = player.getPersistentData().getDouble("fire_pos"); double fp = ClientEventHandler.getFirePos();
double fr = player.getPersistentData().getDouble("fire_rot"); double fr = ClientEventHandler.getFireRot();
if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) { if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) {
shen.setPosY(0.4f * (float) (fp + 2 * fr)); shen.setPosY(0.4f * (float) (fp + 2 * fr));
@ -124,11 +124,6 @@ public class M98bItemModel extends GeoModel<M98bItem> {
scope.setPosY(numP * scope.getPosY()); scope.setPosY(numP * scope.getPosY());
scope.setPosZ(numP * scope.getPosZ()); scope.setPosZ(numP * scope.getPosZ());
} }
ClientEventHandler.shake(Mth.RAD_TO_DEG * camera.getRotX(),Mth.RAD_TO_DEG * camera.getRotY(), Mth.RAD_TO_DEG * camera.getRotZ());
player.getPersistentData().putDouble("camera_rot_x", Mth.RAD_TO_DEG * camera.getRotX());
player.getPersistentData().putDouble("camera_rot_y", Mth.RAD_TO_DEG * camera.getRotY());
player.getPersistentData().putDouble("camera_rot_z", Mth.RAD_TO_DEG * camera.getRotZ());
} }
} }

View file

@ -54,8 +54,8 @@ public class MarlinItemModel extends GeoModel<MarlinItem> {
gun.setScaleZ(1f - (0.5f * (float) zp)); gun.setScaleZ(1f - (0.5f * (float) zp));
double fp = player.getPersistentData().getDouble("fire_pos"); double fp = ClientEventHandler.getFirePos();
double fr = player.getPersistentData().getDouble("fire_rot"); double fr = ClientEventHandler.getFireRot();
shen.setPosX(-0.2f * (float) (fp + 2 * fr)); shen.setPosX(-0.2f * (float) (fp + 2 * fr));
shen.setPosY(0.4f * (float) (fp + 2 * fr)); shen.setPosY(0.4f * (float) (fp + 2 * fr));
@ -112,11 +112,6 @@ public class MarlinItemModel extends GeoModel<MarlinItem> {
camera.setRotY(numR * camera.getRotY()); camera.setRotY(numR * camera.getRotY());
camera.setRotZ(numR * camera.getRotZ()); camera.setRotZ(numR * camera.getRotZ());
} }
ClientEventHandler.shake(Mth.RAD_TO_DEG * camera.getRotX(),Mth.RAD_TO_DEG * camera.getRotY(), Mth.RAD_TO_DEG * camera.getRotZ());
player.getPersistentData().putDouble("camera_rot_x", Mth.RAD_TO_DEG * camera.getRotX());
player.getPersistentData().putDouble("camera_rot_y", Mth.RAD_TO_DEG * camera.getRotY());
player.getPersistentData().putDouble("camera_rot_z", Mth.RAD_TO_DEG * camera.getRotZ());
} }
} }

View file

@ -54,8 +54,8 @@ public class MinigunItemModel extends GeoModel<MinigunItem> {
gun.setRotZ((float) (gun.getRotZ() + times * -0.008f * stack.getOrCreateTag().getDouble("minigun_rotation"))); gun.setRotZ((float) (gun.getRotZ() + times * -0.008f * stack.getOrCreateTag().getDouble("minigun_rotation")));
double fp = player.getPersistentData().getDouble("fire_pos"); double fp = ClientEventHandler.getFirePos();
double fr = player.getPersistentData().getDouble("fire_rot"); double fr = ClientEventHandler.getFireRot();
shen.setPosY(0.1f * (float) (fp + 2 * fr)); shen.setPosY(0.1f * (float) (fp + 2 * fr));
shen.setPosZ(2.2f * (float) (0.5 * fp + 1.54f * fr)); shen.setPosZ(2.2f * (float) (0.5 * fp + 1.54f * fr));
@ -90,11 +90,6 @@ public class MinigunItemModel extends GeoModel<MinigunItem> {
move.setRotZ(2.7f * (float) mph + Mth.DEG_TO_RAD * (float) turnRotZ); move.setRotZ(2.7f * (float) mph + Mth.DEG_TO_RAD * (float) turnRotZ);
CoreGeoBone camera = getAnimationProcessor().getBone("camera"); CoreGeoBone camera = getAnimationProcessor().getBone("camera");
ClientEventHandler.shake(Mth.RAD_TO_DEG * camera.getRotX(),Mth.RAD_TO_DEG * camera.getRotY(), Mth.RAD_TO_DEG * camera.getRotZ());
player.getPersistentData().putDouble("camera_rot_x", Mth.RAD_TO_DEG * camera.getRotX());
player.getPersistentData().putDouble("camera_rot_y", Mth.RAD_TO_DEG * camera.getRotY());
player.getPersistentData().putDouble("camera_rot_z", Mth.RAD_TO_DEG * camera.getRotZ());
} }
} }

View file

@ -71,8 +71,8 @@ public class Mk14ItemModel extends GeoModel<Mk14Item> {
CoreGeoBone shen = getAnimationProcessor().getBone("shen"); CoreGeoBone shen = getAnimationProcessor().getBone("shen");
double fp = player.getPersistentData().getDouble("fire_pos"); double fp = ClientEventHandler.getFirePos();
double fr = player.getPersistentData().getDouble("fire_rot"); double fr = ClientEventHandler.getFireRot();
if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) { if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) {
shen.setPosY(0.06f * (float) (fp + 2 * fr)); shen.setPosY(0.06f * (float) (fp + 2 * fr));
@ -145,11 +145,6 @@ public class Mk14ItemModel extends GeoModel<Mk14Item> {
camera.setRotY(numR * camera.getRotY()); camera.setRotY(numR * camera.getRotY());
camera.setRotZ(numR * camera.getRotZ()); camera.setRotZ(numR * camera.getRotZ());
} }
ClientEventHandler.shake(Mth.RAD_TO_DEG * camera.getRotX(),Mth.RAD_TO_DEG * camera.getRotY(), Mth.RAD_TO_DEG * camera.getRotZ());
player.getPersistentData().putDouble("camera_rot_x", Mth.RAD_TO_DEG * camera.getRotX());
player.getPersistentData().putDouble("camera_rot_y", Mth.RAD_TO_DEG * camera.getRotY());
player.getPersistentData().putDouble("camera_rot_z", Mth.RAD_TO_DEG * camera.getRotZ());
} }
} }

View file

@ -72,8 +72,8 @@ public class MosinNagantItemModel extends GeoModel<MosinNagantItem> {
stack.getOrCreateTag().putBoolean("HoloHidden", !(gun.getPosX() > 1.4)); stack.getOrCreateTag().putBoolean("HoloHidden", !(gun.getPosX() > 1.4));
double fp = player.getPersistentData().getDouble("fire_pos"); double fp = ClientEventHandler.getFirePos();
double fr = player.getPersistentData().getDouble("fire_rot"); double fr = ClientEventHandler.getFireRot();
if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) { if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) {
shen.setPosY(0.07f * (float) (fp + 2 * fr)); shen.setPosY(0.07f * (float) (fp + 2 * fr));
@ -142,11 +142,6 @@ public class MosinNagantItemModel extends GeoModel<MosinNagantItem> {
camera.setRotY(numR * camera.getRotY()); camera.setRotY(numR * camera.getRotY());
camera.setRotZ(numR * camera.getRotZ()); camera.setRotZ(numR * camera.getRotZ());
} }
ClientEventHandler.shake(Mth.RAD_TO_DEG * camera.getRotX(),Mth.RAD_TO_DEG * camera.getRotY(), Mth.RAD_TO_DEG * camera.getRotZ());
player.getPersistentData().putDouble("camera_rot_x", Mth.RAD_TO_DEG * camera.getRotX());
player.getPersistentData().putDouble("camera_rot_y", Mth.RAD_TO_DEG * camera.getRotY());
player.getPersistentData().putDouble("camera_rot_z", Mth.RAD_TO_DEG * camera.getRotZ());
} }
} }

View file

@ -49,8 +49,8 @@ public class Ntw20Model extends GeoModel<Ntw20Item> {
r.setRotX(-1.5f); r.setRotX(-1.5f);
} }
double fp = player.getPersistentData().getDouble("fire_pos"); double fp = ClientEventHandler.getFirePos();
double fr = player.getPersistentData().getDouble("fire_rot"); double fr = ClientEventHandler.getFireRot();
if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) { if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) {
shen.setPosY(0.4f * (float) (fp + 2 * fr)); shen.setPosY(0.4f * (float) (fp + 2 * fr));
@ -127,11 +127,6 @@ public class Ntw20Model extends GeoModel<Ntw20Item> {
camera.setRotY(numR * camera.getRotY()); camera.setRotY(numR * camera.getRotY());
camera.setRotZ(numR * camera.getRotZ()); camera.setRotZ(numR * camera.getRotZ());
} }
ClientEventHandler.shake(Mth.RAD_TO_DEG * camera.getRotX(),Mth.RAD_TO_DEG * camera.getRotY(), Mth.RAD_TO_DEG * camera.getRotZ());
player.getPersistentData().putDouble("camera_rot_x", Mth.RAD_TO_DEG * camera.getRotX());
player.getPersistentData().putDouble("camera_rot_y", Mth.RAD_TO_DEG * camera.getRotY());
player.getPersistentData().putDouble("camera_rot_z", Mth.RAD_TO_DEG * camera.getRotZ());
} }
} }

View file

@ -54,8 +54,8 @@ public class Qbz95ItemModel extends GeoModel<Qbz95Item> {
stack.getOrCreateTag().putBoolean("HoloHidden", !(gun.getPosX() > 3.1)); stack.getOrCreateTag().putBoolean("HoloHidden", !(gun.getPosX() > 3.1));
double fp = player.getPersistentData().getDouble("fire_pos"); double fp = ClientEventHandler.getFirePos();
double fr = player.getPersistentData().getDouble("fire_rot"); double fr = ClientEventHandler.getFireRot();
if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) { if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) {
shen.setPosY(-0.01f * (float) (fp + 2 * fr)); shen.setPosY(-0.01f * (float) (fp + 2 * fr));
@ -119,11 +119,6 @@ public class Qbz95ItemModel extends GeoModel<Qbz95Item> {
camera.setRotY(numR * camera.getRotY()); camera.setRotY(numR * camera.getRotY());
camera.setRotZ(numR * camera.getRotZ()); camera.setRotZ(numR * camera.getRotZ());
} }
ClientEventHandler.shake(Mth.RAD_TO_DEG * camera.getRotX(),Mth.RAD_TO_DEG * camera.getRotY(), Mth.RAD_TO_DEG * camera.getRotZ());
player.getPersistentData().putDouble("camera_rot_x", Mth.RAD_TO_DEG * camera.getRotX());
player.getPersistentData().putDouble("camera_rot_y", Mth.RAD_TO_DEG * camera.getRotY());
player.getPersistentData().putDouble("camera_rot_z", Mth.RAD_TO_DEG * camera.getRotZ());
} }
} }

View file

@ -46,8 +46,8 @@ public class RpgItemModel extends GeoModel<RpgItem> {
hammer.setRotX(-90 * Mth.DEG_TO_RAD); hammer.setRotX(-90 * Mth.DEG_TO_RAD);
} }
double fp = player.getPersistentData().getDouble("fire_pos"); double fp = ClientEventHandler.getFirePos();
double fr = player.getPersistentData().getDouble("fire_rot"); double fr = ClientEventHandler.getFireRot();
if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) { if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) {
shen.setPosY(0.02f * (float) (fp + 2 * fr)); shen.setPosY(0.02f * (float) (fp + 2 * fr));
@ -115,11 +115,6 @@ public class RpgItemModel extends GeoModel<RpgItem> {
camera.setRotY(numR * camera.getRotY()); camera.setRotY(numR * camera.getRotY());
camera.setRotZ(numR * camera.getRotZ()); camera.setRotZ(numR * camera.getRotZ());
} }
ClientEventHandler.shake(Mth.RAD_TO_DEG * camera.getRotX(),Mth.RAD_TO_DEG * camera.getRotY(), Mth.RAD_TO_DEG * camera.getRotZ());
player.getPersistentData().putDouble("camera_rot_x", Mth.RAD_TO_DEG * camera.getRotX());
player.getPersistentData().putDouble("camera_rot_y", Mth.RAD_TO_DEG * camera.getRotY());
player.getPersistentData().putDouble("camera_rot_z", Mth.RAD_TO_DEG * camera.getRotZ());
} }
} }

View file

@ -70,8 +70,8 @@ public class RpkItemModel extends GeoModel<RpkItem> {
stack.getOrCreateTag().putBoolean("HoloHidden", !(gun.getPosX() > 1.65)); stack.getOrCreateTag().putBoolean("HoloHidden", !(gun.getPosX() > 1.65));
double fp = player.getPersistentData().getDouble("fire_pos"); double fp = ClientEventHandler.getFirePos();
double fr = player.getPersistentData().getDouble("fire_rot"); double fr = ClientEventHandler.getFireRot();
if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) { if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) {
shen.setPosY(-0.01f * (float) (fp + 2 * fr)); shen.setPosY(-0.01f * (float) (fp + 2 * fr));
@ -131,11 +131,6 @@ public class RpkItemModel extends GeoModel<RpkItem> {
camera.setRotY(numR * camera.getRotY()); camera.setRotY(numR * camera.getRotY());
camera.setRotZ(numR * camera.getRotZ()); camera.setRotZ(numR * camera.getRotZ());
} }
ClientEventHandler.shake(Mth.RAD_TO_DEG * camera.getRotX(),Mth.RAD_TO_DEG * camera.getRotY(), Mth.RAD_TO_DEG * camera.getRotZ());
player.getPersistentData().putDouble("camera_rot_x", Mth.RAD_TO_DEG * camera.getRotX());
player.getPersistentData().putDouble("camera_rot_y", Mth.RAD_TO_DEG * camera.getRotY());
player.getPersistentData().putDouble("camera_rot_z", Mth.RAD_TO_DEG * camera.getRotZ());
} }
} }

View file

@ -71,8 +71,8 @@ public class SentinelItemModel extends GeoModel<SentinelItem> {
CoreGeoBone holo = getAnimationProcessor().getBone("holo"); CoreGeoBone holo = getAnimationProcessor().getBone("holo");
holo.setPosY(0.09f); holo.setPosY(0.09f);
double fp = player.getPersistentData().getDouble("fire_pos"); double fp = ClientEventHandler.getFirePos();
double fr = player.getPersistentData().getDouble("fire_rot"); double fr = ClientEventHandler.getFireRot();
if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) { if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) {
shen.setPosY(0.4f * (float) (fp + 2 * fr)); shen.setPosY(0.4f * (float) (fp + 2 * fr));
@ -138,11 +138,6 @@ public class SentinelItemModel extends GeoModel<SentinelItem> {
camera.setRotY(numR * camera.getRotY()); camera.setRotY(numR * camera.getRotY());
camera.setRotZ(numR * camera.getRotZ()); camera.setRotZ(numR * camera.getRotZ());
} }
ClientEventHandler.shake(Mth.RAD_TO_DEG * camera.getRotX(),Mth.RAD_TO_DEG * camera.getRotY(), Mth.RAD_TO_DEG * camera.getRotZ());
player.getPersistentData().putDouble("camera_rot_x", Mth.RAD_TO_DEG * camera.getRotX());
player.getPersistentData().putDouble("camera_rot_y", Mth.RAD_TO_DEG * camera.getRotY());
player.getPersistentData().putDouble("camera_rot_z", Mth.RAD_TO_DEG * camera.getRotZ());
} }
} }

View file

@ -65,8 +65,8 @@ public class SksItemModel extends GeoModel<SksItem> {
CoreGeoBone shen = getAnimationProcessor().getBone("shen"); CoreGeoBone shen = getAnimationProcessor().getBone("shen");
double fp = player.getPersistentData().getDouble("fire_pos"); double fp = ClientEventHandler.getFirePos();
double fr = player.getPersistentData().getDouble("fire_rot"); double fr = ClientEventHandler.getFireRot();
if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) { if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) {
shen.setPosY(0.04f * (float) (fp + 2 * fr)); shen.setPosY(0.04f * (float) (fp + 2 * fr));
@ -126,11 +126,6 @@ public class SksItemModel extends GeoModel<SksItem> {
camera.setRotY(numR * camera.getRotY()); camera.setRotY(numR * camera.getRotY());
camera.setRotZ(numR * camera.getRotZ()); camera.setRotZ(numR * camera.getRotZ());
} }
ClientEventHandler.shake(Mth.RAD_TO_DEG * camera.getRotX(),Mth.RAD_TO_DEG * camera.getRotY(), Mth.RAD_TO_DEG * camera.getRotZ());
player.getPersistentData().putDouble("camera_rot_x", Mth.RAD_TO_DEG * camera.getRotX());
player.getPersistentData().putDouble("camera_rot_y", Mth.RAD_TO_DEG * camera.getRotY());
player.getPersistentData().putDouble("camera_rot_z", Mth.RAD_TO_DEG * camera.getRotZ());
} }
} }

View file

@ -75,8 +75,8 @@ public class SvdItemModel extends GeoModel<SvdItem> {
CoreGeoBone shen = getAnimationProcessor().getBone("shen"); CoreGeoBone shen = getAnimationProcessor().getBone("shen");
double fp = player.getPersistentData().getDouble("fire_pos"); double fp = ClientEventHandler.getFirePos();
double fr = player.getPersistentData().getDouble("fire_rot"); double fr = ClientEventHandler.getFireRot();
if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) { if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) {
shen.setPosY(0.02f * (float) (fp + 2 * fr)); shen.setPosY(0.02f * (float) (fp + 2 * fr));
@ -142,11 +142,6 @@ public class SvdItemModel extends GeoModel<SvdItem> {
camera.setRotY(numR * camera.getRotY()); camera.setRotY(numR * camera.getRotY());
camera.setRotZ(numR * camera.getRotZ()); camera.setRotZ(numR * camera.getRotZ());
} }
ClientEventHandler.shake(Mth.RAD_TO_DEG * camera.getRotX(),Mth.RAD_TO_DEG * camera.getRotY(), Mth.RAD_TO_DEG * camera.getRotZ());
player.getPersistentData().putDouble("camera_rot_x", Mth.RAD_TO_DEG * camera.getRotX());
player.getPersistentData().putDouble("camera_rot_y", Mth.RAD_TO_DEG * camera.getRotY());
player.getPersistentData().putDouble("camera_rot_z", Mth.RAD_TO_DEG * camera.getRotZ());
} }
} }

View file

@ -73,8 +73,8 @@ public class TaserItemModel extends GeoModel<TaserItem> {
redcover.setScaleZ(1); redcover.setScaleZ(1);
} }
double fp = player.getPersistentData().getDouble("fire_pos"); double fp = ClientEventHandler.getFirePos();
double fr = player.getPersistentData().getDouble("fire_rot"); double fr = ClientEventHandler.getFireRot();
shen.setPosX(-0.05f * (float) (fp + 0.2 * fr)); shen.setPosX(-0.05f * (float) (fp + 0.2 * fr));
shen.setPosY(0.1f * (float) (fp + 2 * fr)); shen.setPosY(0.1f * (float) (fp + 2 * fr));
@ -138,11 +138,6 @@ public class TaserItemModel extends GeoModel<TaserItem> {
camera.setRotY(numR * camera.getRotY()); camera.setRotY(numR * camera.getRotY());
camera.setRotZ(numR * camera.getRotZ()); camera.setRotZ(numR * camera.getRotZ());
} }
ClientEventHandler.shake(Mth.RAD_TO_DEG * camera.getRotX(),Mth.RAD_TO_DEG * camera.getRotY(), Mth.RAD_TO_DEG * camera.getRotZ());
player.getPersistentData().putDouble("camera_rot_x", Mth.RAD_TO_DEG * camera.getRotX());
player.getPersistentData().putDouble("camera_rot_y", Mth.RAD_TO_DEG * camera.getRotY());
player.getPersistentData().putDouble("camera_rot_z", Mth.RAD_TO_DEG * camera.getRotZ());
} }
} }

View file

@ -53,8 +53,8 @@ public class TracheliumItemModel extends GeoModel<Trachelium> {
gun.setScaleZ(1f - (0.2f * (float) zp)); gun.setScaleZ(1f - (0.2f * (float) zp));
double fp = player.getPersistentData().getDouble("fire_pos"); double fp = ClientEventHandler.getFirePos();
double fr = player.getPersistentData().getDouble("fire_rot"); double fr = ClientEventHandler.getFireRot();
shen.setPosX(-0.4f * (float) (fp + 0.2 * fr)); shen.setPosX(-0.4f * (float) (fp + 0.2 * fr));
shen.setPosY(0.6f * (float) (fp + 2 * fr)); shen.setPosY(0.6f * (float) (fp + 2 * fr));
@ -106,11 +106,6 @@ public class TracheliumItemModel extends GeoModel<Trachelium> {
camera.setRotY(numR * camera.getRotY()); camera.setRotY(numR * camera.getRotY());
camera.setRotZ(numR * camera.getRotZ()); camera.setRotZ(numR * camera.getRotZ());
} }
ClientEventHandler.shake(Mth.RAD_TO_DEG * camera.getRotX(),Mth.RAD_TO_DEG * camera.getRotY(), Mth.RAD_TO_DEG * camera.getRotZ());
player.getPersistentData().putDouble("camera_rot_x", Mth.RAD_TO_DEG * camera.getRotX());
player.getPersistentData().putDouble("camera_rot_y", Mth.RAD_TO_DEG * camera.getRotY());
player.getPersistentData().putDouble("camera_rot_z", Mth.RAD_TO_DEG * camera.getRotZ());
} }
} }

View file

@ -71,8 +71,8 @@ public class VectorItemModel extends GeoModel<VectorItem> {
stack.getOrCreateTag().putBoolean("HoloHidden", !(gun.getPosX() > 2)); stack.getOrCreateTag().putBoolean("HoloHidden", !(gun.getPosX() > 2));
double fp = player.getPersistentData().getDouble("fire_pos"); double fp = ClientEventHandler.getFirePos();
double fr = player.getPersistentData().getDouble("fire_rot"); double fr = ClientEventHandler.getFireRot();
if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) { if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) {
shen.setPosY(0.05f * (float) (fp + 2 * fr)); shen.setPosY(0.05f * (float) (fp + 2 * fr));
@ -130,11 +130,6 @@ public class VectorItemModel extends GeoModel<VectorItem> {
camera.setRotY(numR * camera.getRotY()); camera.setRotY(numR * camera.getRotY());
camera.setRotZ(numR * camera.getRotZ()); camera.setRotZ(numR * camera.getRotZ());
} }
ClientEventHandler.shake(Mth.RAD_TO_DEG * camera.getRotX(),Mth.RAD_TO_DEG * camera.getRotY(), Mth.RAD_TO_DEG * camera.getRotZ());
player.getPersistentData().putDouble("camera_rot_x", Mth.RAD_TO_DEG * camera.getRotX());
player.getPersistentData().putDouble("camera_rot_y", Mth.RAD_TO_DEG * camera.getRotY());
player.getPersistentData().putDouble("camera_rot_z", Mth.RAD_TO_DEG * camera.getRotZ());
} }
} }

View file

@ -2,10 +2,10 @@ package net.mcreator.superbwarfare.entity.model;
import net.mcreator.superbwarfare.ModUtils; import net.mcreator.superbwarfare.ModUtils;
import net.mcreator.superbwarfare.entity.Mk42Entity; import net.mcreator.superbwarfare.entity.Mk42Entity;
import net.mcreator.superbwarfare.event.ClientEventHandler;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import software.bernie.geckolib.constant.DataTickets; import software.bernie.geckolib.constant.DataTickets;
import software.bernie.geckolib.core.animatable.model.CoreGeoBone; import software.bernie.geckolib.core.animatable.model.CoreGeoBone;
@ -52,10 +52,6 @@ public class Mk42Model extends GeoModel<Mk42Entity> {
CoreGeoBone camera = getAnimationProcessor().getBone("camera"); CoreGeoBone camera = getAnimationProcessor().getBone("camera");
if (animatable.getFirstPassenger() == null) return; if (animatable.getFirstPassenger() == null) return;
Entity gunner = animatable.getFirstPassenger(); ClientEventHandler.shake(Mth.RAD_TO_DEG * camera.getRotX(),Mth.RAD_TO_DEG * camera.getRotY(), Mth.RAD_TO_DEG * camera.getRotZ());
gunner.getPersistentData().putDouble("cannon_camera_rot_x", Mth.RAD_TO_DEG * camera.getRotX());
gunner.getPersistentData().putDouble("cannon_camera_rot_y", Mth.RAD_TO_DEG * camera.getRotY());
gunner.getPersistentData().putDouble("cannon_camera_rot_z", Mth.RAD_TO_DEG * camera.getRotZ());
} }
} }

View file

@ -2,10 +2,10 @@ package net.mcreator.superbwarfare.entity.model;
import net.mcreator.superbwarfare.ModUtils; import net.mcreator.superbwarfare.ModUtils;
import net.mcreator.superbwarfare.entity.Mle1934Entity; import net.mcreator.superbwarfare.entity.Mle1934Entity;
import net.mcreator.superbwarfare.event.ClientEventHandler;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import software.bernie.geckolib.constant.DataTickets; import software.bernie.geckolib.constant.DataTickets;
import software.bernie.geckolib.core.animatable.model.CoreGeoBone; import software.bernie.geckolib.core.animatable.model.CoreGeoBone;
@ -52,10 +52,6 @@ public class Mle1934Model extends GeoModel<Mle1934Entity> {
CoreGeoBone camera = getAnimationProcessor().getBone("camera"); CoreGeoBone camera = getAnimationProcessor().getBone("camera");
if (animatable.getFirstPassenger() == null) return; if (animatable.getFirstPassenger() == null) return;
Entity gunner = animatable.getFirstPassenger(); ClientEventHandler.shake(Mth.RAD_TO_DEG * camera.getRotX(),Mth.RAD_TO_DEG * camera.getRotY(), Mth.RAD_TO_DEG * camera.getRotZ());
gunner.getPersistentData().putDouble("cannon_camera_rot_x", Mth.RAD_TO_DEG * camera.getRotX());
gunner.getPersistentData().putDouble("cannon_camera_rot_y", Mth.RAD_TO_DEG * camera.getRotY());
gunner.getPersistentData().putDouble("cannon_camera_rot_z", Mth.RAD_TO_DEG * camera.getRotZ());
} }
} }

View file

@ -34,25 +34,35 @@ import static net.mcreator.superbwarfare.entity.DroneEntity.ROT_Z;
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT) @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT)
public class ClientEventHandler { public class ClientEventHandler {
protected static double zoomTime = 0; private static double zoomTimer = 0;
protected static double zoomPos = 0; private static double zoomPos = 0;
protected static double zoomPosZ = 0; private static double zoomPosZ = 0;
private static double swayTime = 0; private static double swayTimer = 0;
private static double swayX = 0;
private static double swayY = 0;
private static double moveXTimer = 0;
private static double moveYTimer = 0;
private static double movePosX = 0;
private static double movePosY = 0;
private static double moveRotZ = 0;
private static double movePosHorizon = 0;
private static double velocityY = 0;
private static double turnRotX = 0;
private static double turnRotY = 0;
private static double turnRotZ = 0;
private static double cameraRotX = 0;
private static double cameraRotY = 0;
private static double cameraRotZ = 0;
private static double firePosTimer = 0;
private static double fireRotTimer = 0;
private static double firePos = 0;
private static double firePosZ = 0;
private static double fireRot = 0;
private static double droneCameraRotX = 0;
private static double droneCameraRotY = 0;
private static double droneRotX = 0;
private static double droneRotZ = 0;
protected static double swayX = 0;
protected static double swayY = 0;
private static double moveXTime = 0;
private static double moveYTime = 0;
protected static double movePosX = 0;
protected static double movePosY = 0;
protected static double moveRotZ = 0;
protected static double movePosHorizon = 0;
protected static double velocityY = 0;
protected static double turnRotX = 0;
protected static double turnRotY = 0;
protected static double turnRotZ = 0;
@SubscribeEvent @SubscribeEvent
public static void handleWeaponTurn(RenderHandEvent event) { public static void handleWeaponTurn(RenderHandEvent event) {
@ -65,12 +75,12 @@ public class ClientEventHandler {
float yRotOffset = Mth.lerp(event.getPartialTick(), player.yBobO, player.yBob); float yRotOffset = Mth.lerp(event.getPartialTick(), player.yBobO, player.yBob);
float xRot = player.getViewXRot(event.getPartialTick()) - xRotOffset; float xRot = player.getViewXRot(event.getPartialTick()) - xRotOffset;
float yRot = player.getViewYRot(event.getPartialTick()) - yRotOffset; float yRot = player.getViewYRot(event.getPartialTick()) - yRotOffset;
turnRotX = Mth.clamp(0.05 * xRot, -5, 5) * (1 - 0.75 * zoomTime); turnRotX = Mth.clamp(0.05 * xRot, -5, 5) * (1 - 0.75 * zoomTimer);
turnRotY = Mth.clamp(0.05 * yRot, -10, 10) * (1 - 0.75 * zoomTime); turnRotY = Mth.clamp(0.05 * yRot, -10, 10) * (1 - 0.75 * zoomTimer);
turnRotZ = Mth.clamp(0.1 * yRot, -10, 10) * (1 - zoomTime); turnRotZ = Mth.clamp(0.1 * yRot, -10, 10) * (1 - zoomTimer);
data.putDouble("droneCameraRotX", Mth.clamp(0.25f * xRot, -10, 10)); droneCameraRotX = Mth.clamp(0.25f * xRot, -10, 10);
data.putDouble("droneCameraRotY", Mth.clamp(0.25f * yRot, -20, 10)); droneCameraRotY = Mth.clamp(0.25f * yRot, -20, 10);
} }
public static double getTurnRotX() { public static double getTurnRotX() {
@ -89,9 +99,9 @@ public class ClientEventHandler {
public static void computeCameraAngles(ViewportEvent.ComputeCameraAngles event) { public static void computeCameraAngles(ViewportEvent.ComputeCameraAngles event) {
ClientLevel level = Minecraft.getInstance().level; ClientLevel level = Minecraft.getInstance().level;
Entity entity = event.getCamera().getEntity(); Entity entity = event.getCamera().getEntity();
if (level != null && entity instanceof LivingEntity living && entity.isPassenger() && entity.getVehicle() instanceof ICannonEntity) {
handleCannonCamera(event, living); handlePlayerCameraShake(event);
}
if (level != null && entity instanceof LivingEntity living if (level != null && entity instanceof LivingEntity living
&& living.getMainHandItem().is(ModItems.MONITOR.get()) && living.getMainHandItem().is(ModItems.MONITOR.get())
&& living.getMainHandItem().getOrCreateTag().getBoolean("Using") && living.getMainHandItem().getOrCreateTag().getBoolean("Using")
@ -101,8 +111,6 @@ public class ClientEventHandler {
if (Minecraft.getInstance().gameRenderer.currentEffect() != null && Minecraft.getInstance().gameRenderer.currentEffect().getName().equals("superbwarfare:shaders/post/scan_pincushion.json")) { if (Minecraft.getInstance().gameRenderer.currentEffect() != null && Minecraft.getInstance().gameRenderer.currentEffect().getName().equals("superbwarfare:shaders/post/scan_pincushion.json")) {
Minecraft.getInstance().gameRenderer.shutdownEffect(); Minecraft.getInstance().gameRenderer.shutdownEffect();
} }
} }
if (level != null && entity instanceof LivingEntity living && living.getMainHandItem().is(ModTags.Items.GUN)) { if (level != null && entity instanceof LivingEntity living && living.getMainHandItem().is(ModTags.Items.GUN)) {
handleWeaponSway(living); handleWeaponSway(living);
@ -111,7 +119,6 @@ public class ClientEventHandler {
handlePlayerBreath(living); handlePlayerBreath(living);
handleWeaponFire(event, living); handleWeaponFire(event, living);
handleShockCamera(event, living); handleShockCamera(event, living);
handlePlayerCameraShake(event, living);
handleBowPullAnimation(living); handleBowPullAnimation(living);
} }
} }
@ -127,20 +134,20 @@ public class ClientEventHandler {
if (drone != null) { if (drone != null) {
if (data.getDouble("droneRotZ") > drone.getEntityData().get(ROT_Z)) { if (droneRotZ > drone.getEntityData().get(ROT_Z)) {
data.putDouble("droneRotZ", Mth.clamp(data.getDouble("droneRotZ") - 0.3 * Math.pow(drone.getEntityData().get(ROT_Z) - data.getDouble("droneRotZ"), 2), drone.getEntityData().get(ROT_Z), Double.POSITIVE_INFINITY)); droneRotZ = Mth.clamp(droneRotZ - 0.3 * Math.pow(drone.getEntityData().get(ROT_Z) - droneRotZ, 2), drone.getEntityData().get(ROT_Z), Double.POSITIVE_INFINITY);
} else { } else {
data.putDouble("droneRotZ", Mth.clamp(data.getDouble("droneRotZ") + 0.3 * Math.pow(drone.getEntityData().get(ROT_Z) - data.getDouble("droneRotZ"), 2), Double.NEGATIVE_INFINITY, drone.getEntityData().get(ROT_Z))); droneRotZ = Mth.clamp(droneRotZ + 0.3 * Math.pow(drone.getEntityData().get(ROT_Z) - droneRotZ, 2), Double.NEGATIVE_INFINITY, drone.getEntityData().get(ROT_Z));
} }
if (data.getDouble("droneRotX") > drone.getEntityData().get(ROT_X)) { if (droneRotX > drone.getEntityData().get(ROT_X)) {
data.putDouble("droneRotX", Mth.clamp(data.getDouble("droneRotX") - 0.2 * Math.pow(drone.getEntityData().get(ROT_X) - data.getDouble("droneRotX"), 2), drone.getEntityData().get(ROT_X), Double.POSITIVE_INFINITY)); droneRotX = Mth.clamp(droneRotX - 0.2 * Math.pow(drone.getEntityData().get(ROT_X) - droneRotX, 2), drone.getEntityData().get(ROT_X), Double.POSITIVE_INFINITY);
} else { } else {
data.putDouble("droneRotX", Mth.clamp(data.getDouble("droneRotX") + 0.2 * Math.pow(drone.getEntityData().get(ROT_X) - data.getDouble("droneRotX"), 2), Double.NEGATIVE_INFINITY, drone.getEntityData().get(ROT_X))); droneRotX = Mth.clamp(droneRotX + 0.2 * Math.pow(drone.getEntityData().get(ROT_X) - droneRotX, 2), Double.NEGATIVE_INFINITY, drone.getEntityData().get(ROT_X));
} }
event.setPitch((float) (pitch + data.getDouble("droneCameraRotX") - 0.15f * Mth.RAD_TO_DEG * data.getDouble("droneRotZ"))); event.setPitch((float) (pitch + droneCameraRotX - 0.15f * Mth.RAD_TO_DEG * droneRotZ));
event.setRoll((float) (roll + data.getDouble("droneCameraRotY") - 0.5f * Mth.RAD_TO_DEG * data.getDouble("droneRotX"))); event.setRoll((float) (roll + droneCameraRotY - 0.5f * Mth.RAD_TO_DEG * droneRotX));
} }
if (drone != null && stack.getOrCreateTag().getBoolean("Using")) { if (drone != null && stack.getOrCreateTag().getBoolean("Using")) {
@ -168,17 +175,6 @@ public class ClientEventHandler {
} }
} }
private static void handleCannonCamera(ViewportEvent.ComputeCameraAngles event, LivingEntity entity) {
var data = entity.getPersistentData();
double yaw = event.getYaw();
double pitch = event.getPitch();
double roll = event.getRoll();
event.setPitch((float) (pitch + data.getDouble("cannon_camera_rot_x")));
event.setYaw((float) (yaw + data.getDouble("cannon_camera_rot_y")));
event.setRoll((float) (roll + data.getDouble("cannon_camera_rot_z")));
}
@SubscribeEvent @SubscribeEvent
public static void onRenderHand(RenderHandEvent event) { public static void onRenderHand(RenderHandEvent event) {
Player player = Minecraft.getInstance().player; Player player = Minecraft.getInstance().player;
@ -216,9 +212,9 @@ public class ClientEventHandler {
pose = 1; pose = 1;
} }
swayTime += 0.05 * times; swayTimer += 0.05 * times;
swayX = pose * -0.008 * Math.sin(swayTime) * (1 - 0.95 * zoomTime); swayX = pose * -0.008 * Math.sin(swayTimer) * (1 - 0.95 * zoomTimer);
swayY = pose * 0.125 * Math.sin(swayTime - 1.585) * (1 - 0.95 * zoomTime) - 3 * moveRotZ; swayY = pose * 0.125 * Math.sin(swayTimer - 1.585) * (1 - 0.95 * zoomTimer) - 3 * moveRotZ;
} }
} }
@ -246,7 +242,7 @@ public class ClientEventHandler {
on_ground = 0.001; on_ground = 0.001;
} }
if (Minecraft.getInstance().options.keyUp.isDown() && data.getDouble("firetime") == 0 && zoomTime == 0) { if (Minecraft.getInstance().options.keyUp.isDown() && firePosTimer == 0 && zoomTimer == 0) {
moveRotZ = Mth.clamp(moveRotZ + 0.007 * times,0,0.14); moveRotZ = Mth.clamp(moveRotZ + 0.007 * times,0,0.14);
} else { } else {
moveRotZ = Mth.clamp(moveRotZ - 0.007 * times,0,0.14); moveRotZ = Mth.clamp(moveRotZ - 0.007 * times,0,0.14);
@ -255,46 +251,46 @@ public class ClientEventHandler {
if ((Minecraft.getInstance().options.keyLeft.isDown() if ((Minecraft.getInstance().options.keyLeft.isDown()
|| Minecraft.getInstance().options.keyRight.isDown() || Minecraft.getInstance().options.keyRight.isDown()
|| Minecraft.getInstance().options.keyUp.isDown() || Minecraft.getInstance().options.keyUp.isDown()
|| Minecraft.getInstance().options.keyDown.isDown()) && data.getDouble("firetime") == 0) { || Minecraft.getInstance().options.keyDown.isDown()) && firePosTimer == 0) {
if (moveYTime < 1.25) { if (moveYTimer < 1.25) {
moveYTime += 1.2 * on_ground * times * move_speed; moveYTimer += 1.2 * on_ground * times * move_speed;
} else { } else {
moveYTime = 0.25; moveYTimer = 0.25;
} }
if (moveXTime < 2) { if (moveXTimer < 2) {
moveXTime += 1.2 * on_ground * times * move_speed; moveXTimer += 1.2 * on_ground * times * move_speed;
} else { } else {
moveXTime = 0; moveXTimer = 0;
} }
movePosX= 0.2 * Math.sin(1 * Math.PI * moveXTime) * (1 - 0.95 * zoomTime); movePosX= 0.2 * Math.sin(1 * Math.PI * moveXTimer) * (1 - 0.95 * zoomTimer);
movePosY = -0.135 * Math.sin(2 * Math.PI * (moveYTime - 0.25)) * (1 - 0.95 * zoomTime); movePosY = -0.135 * Math.sin(2 * Math.PI * (moveYTimer - 0.25)) * (1 - 0.95 * zoomTimer);
} else { } else {
if (moveYTime > 0.25) { if (moveYTimer > 0.25) {
moveYTime -= 0.5 * times; moveYTimer -= 0.5 * times;
} else { } else {
moveYTime = 0.25; moveYTimer = 0.25;
} }
if (moveXTime > 0) { if (moveXTimer > 0) {
moveXTime -= 0.5 * times; moveXTimer -= 0.5 * times;
} else { } else {
moveXTime = 0; moveXTimer = 0;
} }
if (movePosX > 0) { if (movePosX > 0) {
movePosX -= 1.5 * (Math.pow(movePosX, 2) * times) * (1 - 0.75 * zoomTime); movePosX -= 1.5 * (Math.pow(movePosX, 2) * times) * (1 - 0.75 * zoomTimer);
} else { } else {
movePosX += 1.5 * (Math.pow(movePosX, 2) * times) * (1 - 0.75 * zoomTime); movePosX += 1.5 * (Math.pow(movePosX, 2) * times) * (1 - 0.75 * zoomTimer);
} }
if (movePosY > 0) { if (movePosY > 0) {
movePosY -= 1.5 * (Math.pow(movePosY, 2) * times) * (1 - 0.75 * zoomTime); movePosY -= 1.5 * (Math.pow(movePosY, 2) * times) * (1 - 0.75 * zoomTimer);
} else { } else {
movePosY += 1.5 * (Math.pow(movePosY, 2) * times) * (1 - 0.75 * zoomTime); movePosY += 1.5 * (Math.pow(movePosY, 2) * times) * (1 - 0.75 * zoomTimer);
} }
} }
@ -304,18 +300,18 @@ public class ClientEventHandler {
movePosHorizon -= 2 * times * Math.pow(movePosHorizon, 2); movePosHorizon -= 2 * times * Math.pow(movePosHorizon, 2);
} }
if (Minecraft.getInstance().options.keyRight.isDown()) { if (Minecraft.getInstance().options.keyRight.isDown()) {
movePosHorizon = Mth.clamp(movePosHorizon + Math.pow(Math.abs(movePosHorizon) + 0.05, 2) * 0.2 * times, -0.5,0.5) * (1 - zoomTime); movePosHorizon = Mth.clamp(movePosHorizon + Math.pow(Math.abs(movePosHorizon) + 0.05, 2) * 0.2 * times, -0.5,0.5) * (1 - zoomTimer);
} else if (Minecraft.getInstance().options.keyLeft.isDown()) { } else if (Minecraft.getInstance().options.keyLeft.isDown()) {
movePosHorizon = Mth.clamp(movePosHorizon - Math.pow(Math.abs(movePosHorizon) + 0.05, 2) * 0.2 * times, -0.5,0.5) * (1 - zoomTime); movePosHorizon = Mth.clamp(movePosHorizon - Math.pow(Math.abs(movePosHorizon) + 0.05, 2) * 0.2 * times, -0.5,0.5) * (1 - zoomTimer);
} }
double velocity = entity.getDeltaMovement().y(); double velocity = entity.getDeltaMovement().y();
if (-0.8 < velocity + 0.078 && velocity + 0.078 < 0.8) { if (-0.8 < velocity + 0.078 && velocity + 0.078 < 0.8) {
if (velocityY < entity.getDeltaMovement().y() + 0.078) { if (velocityY < entity.getDeltaMovement().y() + 0.078) {
velocityY = Mth.clamp((velocityY + 0.55 * Math.pow((velocity + 0.078) - velocityY , 2)), -0.8, 0.8) * (1 - 0.8 * zoomTime); velocityY = Mth.clamp((velocityY + 0.55 * Math.pow((velocity + 0.078) - velocityY , 2)), -0.8, 0.8) * (1 - 0.8 * zoomTimer);
} else { } else {
velocityY = Mth.clamp((velocityY - 0.55 * Math.pow((velocity + 0.078) - velocityY , 2)), -0.8, 0.8) * (1 - 0.8 * zoomTime); velocityY = Mth.clamp((velocityY - 0.55 * Math.pow((velocity + 0.078) - velocityY , 2)), -0.8, 0.8) * (1 - 0.8 * zoomTimer);
} }
} }
} }
@ -344,16 +340,16 @@ public class ClientEventHandler {
private static void handleWeaponZoom() { private static void handleWeaponZoom() {
float times = 5 * Minecraft.getInstance().getDeltaFrameTime(); float times = 5 * Minecraft.getInstance().getDeltaFrameTime();
if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) { if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) {
zoomTime = Mth.clamp(zoomTime + 0.03 * times,0,1); zoomTimer = Mth.clamp(zoomTimer + 0.03 * times,0,1);
} else { } else {
zoomTime = Mth.clamp(zoomTime - 0.04 * times,0,1); zoomTimer = Mth.clamp(zoomTimer - 0.04 * times,0,1);
} }
zoomPos = 0.5 * Math.cos(Math.PI * Math.pow(Math.pow(zoomTime, 2) - 1, 2)) + 0.5; zoomPos = 0.5 * Math.cos(Math.PI * Math.pow(Math.pow(zoomTimer, 2) - 1, 2)) + 0.5;
zoomPosZ = -Math.pow(2 * zoomTime - 1, 2) + 1; zoomPosZ = -Math.pow(2 * zoomTimer - 1, 2) + 1;
} }
public static double getZoomTime() { public static double getZoomTime() {
return zoomTime; return zoomTimer;
} }
public static double getZoomPos() { public static double getZoomPos() {
@ -373,62 +369,60 @@ public class ClientEventHandler {
ItemStack stack = entity.getMainHandItem(); ItemStack stack = entity.getMainHandItem();
amplitude = 15000 * stack.getOrCreateTag().getDouble("recoil_y") amplitude = 15000 * stack.getOrCreateTag().getDouble("recoil_y")
* stack.getOrCreateTag().getDouble("recoil_x"); * stack.getOrCreateTag().getDouble("recoil_x");
var data = entity.getPersistentData();
var capability = entity.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null); var capability = entity.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null);
if (capability.orElse(new ModVariables.PlayerVariables()).firing > 0) { if (capability.orElse(new ModVariables.PlayerVariables()).firing > 0) {
data.putDouble("firetime", 0.001); firePosTimer = 0.001;
data.putDouble("fire_rotx_time", 0.001); fireRotTimer = 0.001;
data.putDouble("firepos2", 0.1); firePosZ = 0.1;
} }
data.putDouble("firepos2", Mth.clamp(data.getDouble("firepos2") - 0.01 * times, 0, 0.6)); firePosZ = Mth.clamp(firePosZ - 0.01 * times, 0, 0.6);
if (0 < data.getDouble("firetime")) { if (0 < firePosTimer) {
data.putDouble("firetime", (data.getDouble("firetime") + 0.25 * (1.1 - data.getDouble("firetime")) * times)); firePosTimer += 0.25 * (1.1 - firePosTimer) * times;
} }
if (0 < data.getDouble("firetime") && data.getDouble("firetime") < 0.454) { if (0 < firePosTimer && firePosTimer < 0.454) {
data.putDouble("fire_pos", firePos = (-18.34) * Math.pow(firePosTimer, 2) + 8.58 * firePosTimer + firePosZ;
((-18.34) * Math.pow(data.getDouble("firetime"), 2) + 8.58 * data.getDouble("firetime") + data.getDouble("firepos2")));
} }
if (0.454 <= data.getDouble("firetime") && data.getDouble("firetime") < 1) { if (0.454 <= firePosTimer && firePosTimer < 1) {
data.putDouble("fire_pos", firePos = 4.34 * Math.pow(firePosTimer, 2) - 6.5 * firePosTimer + 2.167 + firePosZ;
(4.34 * Math.pow(data.getDouble("firetime"), 2) - 6.5 * data.getDouble("firetime") + 2.167 + data.getDouble("firepos2")));
} }
if (0 < fireRotTimer && fireRotTimer < 1.732) {
if (0 < data.getDouble("fire_rotx_time") && data.getDouble("fire_rotx_time") < 1.732) { fireRotTimer += 0.18 * (1.9 - fireRotTimer) * times;
data.putDouble("fire_rotx_time", (data.getDouble("fire_rotx_time") + 0.18 * (1.9 - data.getDouble("fire_rotx_time")) * times));
} }
if (0 < data.getDouble("fire_rotx_time") && data.getDouble("fire_rotx_time") < 1.732) { if (0 < fireRotTimer && fireRotTimer < 1.732) {
data.putDouble("fire_rot", fireRot = 1 / 6.3 * (fireRotTimer - 0.5) * Math.sin(6.3 * (fireRotTimer - 0.5)) * (3 - Math.pow(fireRotTimer, 2));
(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 ModVariables.PlayerVariables())).recoilHorizon > 0) { if ((capability.orElse(new ModVariables.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.setYaw((float) (yaw - 1.3 * amplitude * (1 / 6.3 * (fireRotTimer - 0.5)) * Math.sin(6.3 * (fireRotTimer - 0.5)) * (3 - Math.pow(fireRotTimer, 2)) + 1 * Mth.clamp(0.3 - fireRotTimer, 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.setPitch((float) (pitch + 1.3 * amplitude * (1 / 6.3 * (fireRotTimer - 0.5)) * Math.sin(6.3 * (fireRotTimer - 0.5)) * (3 - Math.pow(fireRotTimer, 2)) + 1 * Mth.clamp(0.3 - fireRotTimer, 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))); event.setRoll((float) (roll + 4.2 * amplitude * (1 / 6.3 * (fireRotTimer - 0.5)) * Math.sin(6.3 * (fireRotTimer - 0.5)) * (3 - Math.pow(fireRotTimer, 2)) + 3 * Mth.clamp(0.5 - fireRotTimer, 0, 0.5) * (2 * Math.random() - 1)));
} else if ((capability.orElse(new ModVariables.PlayerVariables())).recoilHorizon <= 0) { } else if ((capability.orElse(new ModVariables.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.setYaw((float) (yaw + 1.3 * amplitude * (1 / 6.3 * (fireRotTimer - 0.5)) * Math.sin(6.3 * (fireRotTimer - 0.5)) * (3 - Math.pow(fireRotTimer, 2)) + 1 * Mth.clamp(0.3 - fireRotTimer, 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.setPitch((float) (pitch - 1.3 * amplitude * (1 / 6.3 * (fireRotTimer - 0.5)) * Math.sin(6.3 * (fireRotTimer - 0.5)) * (3 - Math.pow(fireRotTimer, 2)) + 1 * Mth.clamp(0.3 - fireRotTimer, 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))); event.setRoll((float) (roll - 4.2 * amplitude * (1 / 6.3 * (fireRotTimer - 0.5)) * Math.sin(6.3 * (fireRotTimer - 0.5)) * (3 - Math.pow(fireRotTimer, 2)) + 3 * Mth.clamp(0.5 - fireRotTimer, 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)); if (firePosTimer >= 1) {
firePosTimer = 0;
} }
if (0.25 < data.getDouble("firetime") && data.getDouble("firetime") < 1) { if (fireRotTimer >= 1.732) {
data.putDouble("boltpos", 0); fireRotTimer = 0;
} fireRot = 0;
if (data.getDouble("firetime") >= 1) {
data.putDouble("firetime", 0);
}
if (data.getDouble("fire_rotx_time") >= 1.732) {
data.putDouble("fire_rotx_time", 0);
data.putDouble("fire_rot", 0);
} }
} }
public static double getFirePos() {
return firePos;
}
public static double getFireRot() {
return fireRot;
}
private static void handlePlayerBreath(LivingEntity entity) { private static void handlePlayerBreath(LivingEntity entity) {
float times = 4 * Minecraft.getInstance().getDeltaFrameTime(); float times = 4 * Minecraft.getInstance().getDeltaFrameTime();
var data = entity.getPersistentData(); var data = entity.getPersistentData();
@ -448,19 +442,19 @@ public class ClientEventHandler {
} }
} }
private static void handlePlayerCameraShake(ViewportEvent.ComputeCameraAngles event, LivingEntity entity) { public static void shake(double boneRotX, double boneRotY, double boneRotZ) {
var data = entity.getPersistentData(); cameraRotX = boneRotX;
cameraRotY = boneRotY;
cameraRotZ = boneRotZ;
}
private static void handlePlayerCameraShake(ViewportEvent.ComputeCameraAngles event) {
double yaw = event.getYaw(); double yaw = event.getYaw();
double pitch = event.getPitch(); double pitch = event.getPitch();
double roll = event.getRoll(); double roll = event.getRoll();
if (entity.getMainHandItem().is(ModTags.Items.GUN)) { event.setPitch((float) (pitch + cameraRotX + 0.2 * turnRotX + 3 * velocityY));
event.setYaw((float) (yaw + cameraRotY + 0.8 * turnRotY));
event.setPitch((float) (pitch + data.getDouble("camera_rot_x") + 0.2 * data.getDouble("xRot") + 3 * data.getDouble("vy"))); event.setRoll((float) (roll + cameraRotZ + 0.35 * turnRotZ));
event.setYaw((float) (yaw + data.getDouble("camera_rot_y") + 0.8 * data.getDouble("yRot")));
event.setRoll((float) (roll + data.getDouble("camera_rot_z") + 0.35 * data.getDouble("zRot")));
}
} }
private static void handleBowPullAnimation(LivingEntity entity) { private static void handleBowPullAnimation(LivingEntity entity) {