From 95e9f1e37e9b8ff3b453538a5d33af918a64e996 Mon Sep 17 00:00:00 2001 From: Atsuihsio <842960157@qq.com> Date: Thu, 19 Sep 2024 21:38:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=9E=84=E5=87=86=E5=8A=A8?= =?UTF-8?q?=E7=94=BB=E7=9B=B8=E5=85=B3=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/model/item/AK47ItemModel.java | 22 +-- .../client/model/item/Aa12ItemModel.java | 19 ++- .../client/model/item/AbekiriItemModel.java | 23 ++- .../client/model/item/BocekItemModel.java | 18 +- .../client/model/item/DevotionItemModel.java | 32 ++-- .../client/model/item/Glock17ItemModel.java | 22 +-- .../client/model/item/Glock18ItemModel.java | 22 +-- .../client/model/item/Hk416ItemModel.java | 22 +-- .../model/item/HuntingRifleItemModel.java | 31 ++-- .../client/model/item/JavelinItemModel.java | 18 +- .../client/model/item/K98ItemModel.java | 20 ++- .../client/model/item/M1911ItemModel.java | 20 ++- .../client/model/item/M4ItemModel.java | 22 +-- .../client/model/item/M60ItemModel.java | 21 +-- .../client/model/item/M79ItemModel.java | 20 ++- .../client/model/item/M870ItemModel.java | 22 +-- .../client/model/item/M98bItemModel.java | 33 ++-- .../client/model/item/MarlinItemModel.java | 22 +-- .../client/model/item/Mk14ItemModel.java | 26 +-- .../model/item/MosinNagantItemModel.java | 26 +-- .../client/model/item/Ntw20Model.java | 24 +-- .../client/model/item/Qbz95ItemModel.java | 22 +-- .../client/model/item/RpgItemModel.java | 22 +-- .../client/model/item/RpkItemModel.java | 30 ++-- .../client/model/item/SentinelItemModel.java | 25 +-- .../client/model/item/SksItemModel.java | 21 +-- .../client/model/item/SvdItemModel.java | 28 ++-- .../client/model/item/TaserItemModel.java | 20 ++- .../model/item/TracheliumItemModel.java | 22 +-- .../client/model/item/VectorItemModel.java | 22 +-- .../client/screens/CrossHairOverlay.java | 13 +- .../client/screens/M79UIOverlay.java | 8 - .../client/screens/SpyglassRangeOverlay.java | 46 ++++-- .../event/ClientEventHandler.java | 156 ++++++++---------- .../event/PlayerEventHandler.java | 34 ---- .../superbwarfare/network/ModVariables.java | 5 - 36 files changed, 468 insertions(+), 491 deletions(-) diff --git a/src/main/java/net/mcreator/superbwarfare/client/model/item/AK47ItemModel.java b/src/main/java/net/mcreator/superbwarfare/client/model/item/AK47ItemModel.java index 35a7e6df4..5a802867e 100644 --- a/src/main/java/net/mcreator/superbwarfare/client/model/item/AK47ItemModel.java +++ b/src/main/java/net/mcreator/superbwarfare/client/model/item/AK47ItemModel.java @@ -1,6 +1,7 @@ package net.mcreator.superbwarfare.client.model.item; import net.mcreator.superbwarfare.ModUtils; +import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.item.gun.rifle.AK47Item; import net.mcreator.superbwarfare.network.ModVariables; @@ -44,14 +45,15 @@ public class AK47ItemModel extends GeoModel { ItemStack stack = player.getMainHandItem(); if (!stack.is(ModTags.Items.GUN)) return; - double p = player.getPersistentData().getDouble("zoom_pos"); - double zp = player.getPersistentData().getDouble("zoom_pos_z"); + double zt = ClientEventHandler.getZoom_time(); + double zp = ClientEventHandler.getZoom_pos(); + double zpz = ClientEventHandler.getZoom_pos_z(); - gun.setPosX(1.97f * (float) p); - gun.setPosY(0.011f * (float) p - (float) (0.2f * zp)); - gun.setPosZ(3.8f * (float) p + (float) (0.5f * zp)); - gun.setScaleZ(1f - (0.2f * (float) p)); - scope.setScaleZ(1f - (0.4f * (float) p)); + gun.setPosX(1.97f * (float) zp); + gun.setPosY(0.011f * (float) zp - (float) (0.2f * zpz)); + gun.setPosZ(3.8f * (float) zp + (float) (0.5f * zpz)); + gun.setScaleZ(1f - (0.2f * (float) zp)); + scope.setScaleZ(1f - (0.4f * (float) zp)); stack.getOrCreateTag().putBoolean("HoloHidden", !(gun.getPosX() > 1.8)); @@ -119,9 +121,9 @@ public class AK47ItemModel extends GeoModel { CoreGeoBone camera = getAnimationProcessor().getBone("camera"); CoreGeoBone main = getAnimationProcessor().getBone("0"); - var data = player.getPersistentData(); - float numR = (float) (1 - 0.94 * data.getDouble("zoom_time")); - float numP = (float) (1 - 0.8 * data.getDouble("zoom_time")); + + float numR = (float) (1 - 0.94 * zt); + float numP = (float) (1 - 0.8 * zt); if (stack.getOrCreateTag().getInt("gun_reloading_time") > 0) { main.setRotX(numR * main.getRotX()); diff --git a/src/main/java/net/mcreator/superbwarfare/client/model/item/Aa12ItemModel.java b/src/main/java/net/mcreator/superbwarfare/client/model/item/Aa12ItemModel.java index 05e525605..9bbd0cdd8 100644 --- a/src/main/java/net/mcreator/superbwarfare/client/model/item/Aa12ItemModel.java +++ b/src/main/java/net/mcreator/superbwarfare/client/model/item/Aa12ItemModel.java @@ -1,6 +1,7 @@ package net.mcreator.superbwarfare.client.model.item; import net.mcreator.superbwarfare.ModUtils; +import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.item.gun.shotgun.Aa12Item; import net.mcreator.superbwarfare.network.ModVariables; @@ -40,15 +41,16 @@ public class Aa12ItemModel extends GeoModel { ItemStack stack = player.getMainHandItem(); if (!stack.is(ModTags.Items.GUN)) return; - double p = player.getPersistentData().getDouble("zoom_pos"); - double zp = player.getPersistentData().getDouble("zoom_pos_z"); + double zt = ClientEventHandler.getZoom_time(); + double zp = ClientEventHandler.getZoom_pos(); + double zpz = ClientEventHandler.getZoom_pos_z(); - gun.setPosX(2.105f * (float) p); - gun.setPosY(0.17f * (float) p - (float) (0.2f * zp)); + gun.setPosX(2.105f * (float) zp); + gun.setPosY(0.17f * (float) zp - (float) (0.2f * zpz)); - gun.setPosZ(0.1f * (float) p + (float) (0.3f * zp)); + gun.setPosZ(0.1f * (float) zp + (float) (0.3f * zpz)); gun.setRotZ((float) (0.02f * zp)); - gun.setScaleZ(1f - (0.4f * (float) p)); + gun.setScaleZ(1f - (0.4f * (float) zp)); double fp = player.getPersistentData().getDouble("fire_pos"); double fr = player.getPersistentData().getDouble("fire_rot"); @@ -101,9 +103,8 @@ public class Aa12ItemModel extends GeoModel { CoreGeoBone camera = getAnimationProcessor().getBone("camera"); CoreGeoBone main = getAnimationProcessor().getBone("0"); - var data = player.getPersistentData(); - float numR = (float) (1 - 0.82 * data.getDouble("zoom_time")); - float numP = (float) (1 - 0.68 * data.getDouble("zoom_time")); + float numR = (float) (1 - 0.82 * zt); + float numP = (float) (1 - 0.68 * zt); if (stack.getOrCreateTag().getInt("gun_reloading_time") > 0) { main.setRotX(numR * main.getRotX()); diff --git a/src/main/java/net/mcreator/superbwarfare/client/model/item/AbekiriItemModel.java b/src/main/java/net/mcreator/superbwarfare/client/model/item/AbekiriItemModel.java index 444532ec9..0e47f1f08 100644 --- a/src/main/java/net/mcreator/superbwarfare/client/model/item/AbekiriItemModel.java +++ b/src/main/java/net/mcreator/superbwarfare/client/model/item/AbekiriItemModel.java @@ -1,6 +1,7 @@ package net.mcreator.superbwarfare.client.model.item; import net.mcreator.superbwarfare.ModUtils; +import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.item.gun.shotgun.AbekiriItem; import net.minecraft.client.Minecraft; @@ -39,19 +40,17 @@ public class AbekiriItemModel extends GeoModel { ItemStack stack = player.getMainHandItem(); if (!stack.is(ModTags.Items.GUN)) return; - double p = 0; - p = player.getPersistentData().getDouble("zoom_pos"); + double zt = ClientEventHandler.getZoom_time(); + double zp = ClientEventHandler.getZoom_pos(); + double zpz = ClientEventHandler.getZoom_pos_z(); - double zp = 0; - zp = player.getPersistentData().getDouble("zoom_pos_z"); + gun.setPosX(2.45f * (float) zp); - gun.setPosX(2.45f * (float) p); + gun.setPosY(1.7f * (float) zp - (float) (0.4f * zpz)); - gun.setPosY(1.7f * (float) p - (float) (0.4f * zp)); + gun.setPosZ(2f * (float) zp + (float) (0.3f * zpz)); - gun.setPosZ(2f * (float) p + (float) (0.3f * zp)); - - gun.setRotZ((float) (0.05f * zp)); + gun.setRotZ((float) (0.05f * zpz)); double fp = player.getPersistentData().getDouble("fire_pos"); double fr = player.getPersistentData().getDouble("fire_rot"); @@ -109,9 +108,9 @@ public class AbekiriItemModel extends GeoModel { CoreGeoBone camera = getAnimationProcessor().getBone("camera"); CoreGeoBone main = getAnimationProcessor().getBone("0"); - var data = player.getPersistentData(); - float numR = (float) (1 - 0.42 * data.getDouble("zoom_time")); - float numP = (float) (1 - 0.48 * data.getDouble("zoom_time")); + + float numR = (float) (1 - 0.42 * zt); + float numP = (float) (1 - 0.48 * zt); if (stack.getOrCreateTag().getInt("gun_reloading_time") > 0) { main.setRotX(numR * main.getRotX()); diff --git a/src/main/java/net/mcreator/superbwarfare/client/model/item/BocekItemModel.java b/src/main/java/net/mcreator/superbwarfare/client/model/item/BocekItemModel.java index 5a1a3b1ca..e58c25a7d 100644 --- a/src/main/java/net/mcreator/superbwarfare/client/model/item/BocekItemModel.java +++ b/src/main/java/net/mcreator/superbwarfare/client/model/item/BocekItemModel.java @@ -1,6 +1,7 @@ package net.mcreator.superbwarfare.client.model.item; import net.mcreator.superbwarfare.ModUtils; +import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.item.gun.special.BocekItem; import net.minecraft.client.Minecraft; @@ -78,15 +79,16 @@ public class BocekItemModel extends GeoModel { deng3.setPosZ(0.05f * (float) bp); deng.setScaleZ(1f + (0.07f * (float) bp)); - double p = player.getPersistentData().getDouble("zoom_pos"); - double zp = player.getPersistentData().getDouble("zoom_pos_z"); + double zt = ClientEventHandler.getZoom_time(); + double zp = ClientEventHandler.getZoom_pos(); + double zpz = ClientEventHandler.getZoom_pos_z(); - lh.setRotX(0.2f * (float) p); - shen_pos.setPosX(-3.4f * (float) p); - shen_pos.setPosY(6.76f * (float) p - (float) (0.2f * zp)); - shen_pos.setPosZ(6.4f * (float) p + (float) (0.3f * zp)); - r.setScaleZ(1f - (0.31f * (float) p)); - shen.setRotZ(60 * Mth.DEG_TO_RAD * (float) p + (float) (0.05f * zp) - 0.2f); + lh.setRotX(0.2f * (float) zp); + shen_pos.setPosX(-3.4f * (float) zp); + shen_pos.setPosY(6.76f * (float) zp - (float) (0.2f * zpz)); + shen_pos.setPosZ(6.4f * (float) zp + (float) (0.3f * zpz)); + r.setScaleZ(1f - (0.31f * (float) zp)); + shen.setRotZ(60 * Mth.DEG_TO_RAD * (float) zp + (float) (0.05f * zpz) - 0.2f); stack.getOrCreateTag().putBoolean("HoloHidden", !((shen_pos.getPosX() < -0.7 && gun.getPosZ() < -2.6))); diff --git a/src/main/java/net/mcreator/superbwarfare/client/model/item/DevotionItemModel.java b/src/main/java/net/mcreator/superbwarfare/client/model/item/DevotionItemModel.java index c9d5ac5ca..64fd97d9b 100644 --- a/src/main/java/net/mcreator/superbwarfare/client/model/item/DevotionItemModel.java +++ b/src/main/java/net/mcreator/superbwarfare/client/model/item/DevotionItemModel.java @@ -1,6 +1,7 @@ package net.mcreator.superbwarfare.client.model.item; import net.mcreator.superbwarfare.ModUtils; +import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.item.gun.machinegun.DevotionItem; import net.mcreator.superbwarfare.network.ModVariables; @@ -43,25 +44,24 @@ public class DevotionItemModel extends GeoModel { ItemStack stack = player.getMainHandItem(); if (!stack.is(ModTags.Items.GUN)) return; - double p = player.getPersistentData().getDouble("zoom_pos"); + double zt = ClientEventHandler.getZoom_time(); + double zp = ClientEventHandler.getZoom_pos(); + double zpz = ClientEventHandler.getZoom_pos_z(); - double zp = player.getPersistentData().getDouble("zoom_pos_z"); + gun.setPosX(2.17f * (float) zp); - gun.setPosX(2.17f * (float) p); + gun.setPosY(0.17f * (float) zp - (float) (0.5f * zpz)); - gun.setPosY(0.17f * (float) p - (float) (0.5f * zp)); + gun.setPosZ(8.8f * (float) zp + (float) (0.6f * zpz)); - gun.setPosZ(8.8f * (float) p + (float) (0.6f * zp)); + gun.setRotZ((float) (0.05f * zpz)); - gun.setRotZ((float) (0.05f * zp)); - - gun.setScaleZ(1f - (0.7f * (float) p)); + gun.setScaleZ(1f - (0.7f * (float) zp)); CoreGeoBone shen = getAnimationProcessor().getBone("shen"); CoreGeoBone number = getAnimationProcessor().getBone("number"); - double bp = 0; - bp = player.getPersistentData().getDouble("boltpos"); + double bp = player.getPersistentData().getDouble("boltpos"); bolt.setPosZ(-2f * (float) bp); @@ -618,10 +618,8 @@ public class DevotionItemModel extends GeoModel { float PosX = (float)player.getPersistentData().getDouble("gun_move_posX"); float PosY = (float)player.getPersistentData().getDouble("gun_move_posY"); - double y = 0; - double x = 0; - y = player.getPersistentData().getDouble("y"); - x = player.getPersistentData().getDouble("x"); + double y = player.getPersistentData().getDouble("y"); + double x = player.getPersistentData().getDouble("x"); root.setPosX(PosX); @@ -664,9 +662,9 @@ public class DevotionItemModel extends GeoModel { CoreGeoBone camera = getAnimationProcessor().getBone("camera"); CoreGeoBone main = getAnimationProcessor().getBone("0"); - var data = player.getPersistentData(); - float numR = (float) (1 - 0.82 * data.getDouble("zoom_time")); - float numP = (float) (1 - 0.78 * data.getDouble("zoom_time")); + + float numR = (float) (1 - 0.82 * zt); + float numP = (float) (1 - 0.78 * zt); if (stack.getOrCreateTag().getInt("gun_reloading_time") > 0) { main.setRotX(numR * main.getRotX()); diff --git a/src/main/java/net/mcreator/superbwarfare/client/model/item/Glock17ItemModel.java b/src/main/java/net/mcreator/superbwarfare/client/model/item/Glock17ItemModel.java index 418f2e8ff..3f9643e65 100644 --- a/src/main/java/net/mcreator/superbwarfare/client/model/item/Glock17ItemModel.java +++ b/src/main/java/net/mcreator/superbwarfare/client/model/item/Glock17ItemModel.java @@ -1,6 +1,7 @@ package net.mcreator.superbwarfare.client.model.item; import net.mcreator.superbwarfare.ModUtils; +import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.item.gun.handgun.Glock17Item; import net.mcreator.superbwarfare.network.ModVariables; @@ -42,18 +43,19 @@ public class Glock17ItemModel extends GeoModel { ItemStack stack = player.getMainHandItem(); if (!stack.is(ModTags.Items.GUN)) return; - double p = player.getPersistentData().getDouble("zoom_pos"); - double zp = player.getPersistentData().getDouble("zoom_pos_z"); + double zt = ClientEventHandler.getZoom_time(); + double zp = ClientEventHandler.getZoom_pos(); + double zpz = ClientEventHandler.getZoom_pos_z(); - gun.setPosX(-1.34f * (float) p); + gun.setPosX(-1.34f * (float) zp); - gun.setPosY(5.05f * (float) p - (float) (0.2f * zp)); + gun.setPosY(5.05f * (float) zp - (float) (0.2f * zpz)); - gun.setPosZ(5f * (float) p + (float) (0.3f * zp)); + gun.setPosZ(5f * (float) zp + (float) (0.3f * zpz)); - gun.setScaleZ(1f - (0.35f * (float) p)); + gun.setScaleZ(1f - (0.35f * (float) zp)); - gun.setRotZ(-11 * Mth.DEG_TO_RAD * (float) p + (float) (0.05f * zp)); + gun.setRotZ(-11 * Mth.DEG_TO_RAD * (float) zp + (float) (0.05f * zpz)); double fp = player.getPersistentData().getDouble("fire_pos"); double fr = player.getPersistentData().getDouble("fire_rot"); @@ -130,9 +132,9 @@ public class Glock17ItemModel extends GeoModel { CoreGeoBone camera = getAnimationProcessor().getBone("camera"); CoreGeoBone main = getAnimationProcessor().getBone("0"); CoreGeoBone body = getAnimationProcessor().getBone("gun"); - var data = player.getPersistentData(); - float numR = (float) (1 - 0.12 * data.getDouble("zoom_time")); - float numP = (float) (1 - 0.68 * data.getDouble("zoom_time")); + + float numR = (float) (1 - 0.12 * zt); + float numP = (float) (1 - 0.68 * zt); if (stack.getOrCreateTag().getInt("gun_reloading_time") > 0) { main.setRotX(numR * main.getRotX()); diff --git a/src/main/java/net/mcreator/superbwarfare/client/model/item/Glock18ItemModel.java b/src/main/java/net/mcreator/superbwarfare/client/model/item/Glock18ItemModel.java index 6a0e9ea3a..0a4c15bc6 100644 --- a/src/main/java/net/mcreator/superbwarfare/client/model/item/Glock18ItemModel.java +++ b/src/main/java/net/mcreator/superbwarfare/client/model/item/Glock18ItemModel.java @@ -1,6 +1,7 @@ package net.mcreator.superbwarfare.client.model.item; import net.mcreator.superbwarfare.ModUtils; +import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.item.gun.handgun.Glock18Item; import net.mcreator.superbwarfare.network.ModVariables; @@ -50,18 +51,19 @@ public class Glock18ItemModel extends GeoModel { switch_.setRotX(0); } - double p = player.getPersistentData().getDouble("zoom_pos"); - double zp = player.getPersistentData().getDouble("zoom_pos_z"); + double zt = ClientEventHandler.getZoom_time(); + double zp = ClientEventHandler.getZoom_pos(); + double zpz = ClientEventHandler.getZoom_pos_z(); - gun.setPosX(-1.34f * (float) p); + gun.setPosX(-1.34f * (float) zp); - gun.setPosY(5.05f * (float) p - (float) (0.2f * zp)); + gun.setPosY(5.05f * (float) zp - (float) (0.2f * zpz)); - gun.setPosZ(5f * (float) p + (float) (0.3f * zp)); + gun.setPosZ(5f * (float) zp + (float) (0.3f * zpz)); - gun.setScaleZ(1f - (0.35f * (float) p)); + gun.setScaleZ(1f - (0.35f * (float) zp)); - gun.setRotZ(-11 * Mth.DEG_TO_RAD * (float) p + (float) (0.05f * zp)); + gun.setRotZ(-11 * Mth.DEG_TO_RAD * (float) zp + (float) (0.05f * zpz)); double fp = player.getPersistentData().getDouble("fire_pos"); double fr = player.getPersistentData().getDouble("fire_rot"); @@ -138,9 +140,9 @@ public class Glock18ItemModel extends GeoModel { CoreGeoBone camera = getAnimationProcessor().getBone("camera"); CoreGeoBone main = getAnimationProcessor().getBone("0"); CoreGeoBone body = getAnimationProcessor().getBone("gun"); - var data = player.getPersistentData(); - float numR = (float) (1 - 0.12 * data.getDouble("zoom_time")); - float numP = (float) (1 - 0.68 * data.getDouble("zoom_time")); + + float numR = (float) (1 - 0.12 * zt); + float numP = (float) (1 - 0.68 * zt); if (stack.getOrCreateTag().getInt("gun_reloading_time") > 0) { main.setRotX(numR * main.getRotX()); diff --git a/src/main/java/net/mcreator/superbwarfare/client/model/item/Hk416ItemModel.java b/src/main/java/net/mcreator/superbwarfare/client/model/item/Hk416ItemModel.java index 858c3ee22..760346efe 100644 --- a/src/main/java/net/mcreator/superbwarfare/client/model/item/Hk416ItemModel.java +++ b/src/main/java/net/mcreator/superbwarfare/client/model/item/Hk416ItemModel.java @@ -1,6 +1,7 @@ package net.mcreator.superbwarfare.client.model.item; import net.mcreator.superbwarfare.ModUtils; +import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.item.gun.rifle.Hk416Item; import net.mcreator.superbwarfare.network.ModVariables; @@ -41,15 +42,16 @@ public class Hk416ItemModel extends GeoModel { ItemStack stack = player.getMainHandItem(); if (!stack.is(ModTags.Items.GUN)) return; - double p = player.getPersistentData().getDouble("zoom_pos"); - double zp = player.getPersistentData().getDouble("zoom_pos_z"); + double zt = ClientEventHandler.getZoom_time(); + double zp = ClientEventHandler.getZoom_pos(); + double zpz = ClientEventHandler.getZoom_pos_z(); - gun.setPosX(3.34f * (float) p); - gun.setPosY(0.54f * (float) p - (float) (0.2f * zp)); - gun.setPosZ(2.5f * (float) p + (float) (0.3f * zp)); - gun.setRotZ((float) (0.05f * zp)); + gun.setPosX(3.34f * (float) zp); + gun.setPosY(0.54f * (float) zp - (float) (0.2f * zpz)); + gun.setPosZ(2.5f * (float) zp + (float) (0.3f * zpz)); + gun.setRotZ((float) (0.05f * zpz)); - scope.setScaleZ(1f - (0.7f * (float) p)); + scope.setScaleZ(1f - (0.7f * (float) zp)); stack.getOrCreateTag().putBoolean("HoloHidden", !(gun.getPosX() > 3.1)); @@ -111,9 +113,9 @@ public class Hk416ItemModel extends GeoModel { CoreGeoBone camera = getAnimationProcessor().getBone("camera"); CoreGeoBone main = getAnimationProcessor().getBone("0"); - var data = player.getPersistentData(); - float numR = (float) (1 - 0.88 * data.getDouble("zoom_time")); - float numP = (float) (1 - 0.78 * data.getDouble("zoom_time")); + + float numR = (float) (1 - 0.88 * zt); + float numP = (float) (1 - 0.78 * zt); if (stack.getOrCreateTag().getInt("gun_reloading_time") > 0) { main.setRotX(numR * main.getRotX()); diff --git a/src/main/java/net/mcreator/superbwarfare/client/model/item/HuntingRifleItemModel.java b/src/main/java/net/mcreator/superbwarfare/client/model/item/HuntingRifleItemModel.java index 8d42149ec..0ac9b50c0 100644 --- a/src/main/java/net/mcreator/superbwarfare/client/model/item/HuntingRifleItemModel.java +++ b/src/main/java/net/mcreator/superbwarfare/client/model/item/HuntingRifleItemModel.java @@ -1,6 +1,7 @@ package net.mcreator.superbwarfare.client.model.item; import net.mcreator.superbwarfare.ModUtils; +import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.item.gun.sniper.HuntingRifleItem; import net.minecraft.client.Minecraft; @@ -38,21 +39,19 @@ public class HuntingRifleItemModel extends GeoModel { ItemStack stack = player.getMainHandItem(); if (!stack.is(ModTags.Items.GUN)) return; - double p = 0; - p = player.getPersistentData().getDouble("zoom_pos"); + double zt = ClientEventHandler.getZoom_time(); + double zp = ClientEventHandler.getZoom_pos(); + double zpz = ClientEventHandler.getZoom_pos_z(); - double zp = 0; - zp = player.getPersistentData().getDouble("zoom_pos_z"); + gun.setPosX(1.95f * (float) zp); - gun.setPosX(1.95f * (float) p); + gun.setPosY(1.32f * (float) zp - (float) (0.2f * zpz)); - gun.setPosY(1.32f * (float) p - (float) (0.2f * zp)); + gun.setPosZ(3f * (float) zp + (float) (0.5f * zpz)); - gun.setPosZ(3f * (float) p + (float) (0.5f * zp)); + gun.setRotZ((float) (0.05f * zpz)); - gun.setRotZ((float) (0.05f * zp)); - - gun.setScaleZ(1f - (0.5f * (float) p)); + gun.setScaleZ(1f - (0.5f * (float) zp)); double fp = player.getPersistentData().getDouble("fire_pos"); double fr = player.getPersistentData().getDouble("fire_rot"); @@ -80,10 +79,8 @@ public class HuntingRifleItemModel extends GeoModel { float PosX = (float)player.getPersistentData().getDouble("gun_move_posX"); float PosY = (float)player.getPersistentData().getDouble("gun_move_posY"); - double y = 0; - double x = 0; - y = player.getPersistentData().getDouble("y"); - x = player.getPersistentData().getDouble("x"); + double y = player.getPersistentData().getDouble("y"); + double x = player.getPersistentData().getDouble("x"); root.setPosX(PosX); @@ -121,9 +118,9 @@ public class HuntingRifleItemModel extends GeoModel { CoreGeoBone camera = getAnimationProcessor().getBone("camera"); CoreGeoBone main = getAnimationProcessor().getBone("0"); - var data = player.getPersistentData(); - float numR = (float) (1 - 0.82 * data.getDouble("zoom_time")); - float numP = (float) (1 - 0.78 * data.getDouble("zoom_time")); + + float numR = (float) (1 - 0.82 * zt); + float numP = (float) (1 - 0.78 * zt); if (stack.getOrCreateTag().getInt("gun_reloading_time") > 0) { main.setRotX(numR * main.getRotX()); diff --git a/src/main/java/net/mcreator/superbwarfare/client/model/item/JavelinItemModel.java b/src/main/java/net/mcreator/superbwarfare/client/model/item/JavelinItemModel.java index 92089319a..ea6d2e4d5 100644 --- a/src/main/java/net/mcreator/superbwarfare/client/model/item/JavelinItemModel.java +++ b/src/main/java/net/mcreator/superbwarfare/client/model/item/JavelinItemModel.java @@ -1,6 +1,7 @@ package net.mcreator.superbwarfare.client.model.item; import net.mcreator.superbwarfare.ModUtils; +import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.item.gun.launcher.JavelinItem; import net.mcreator.superbwarfare.network.ModVariables; @@ -39,15 +40,16 @@ public class JavelinItemModel extends GeoModel { if (player == null) return; ItemStack stack = player.getMainHandItem(); if (!stack.is(ModTags.Items.GUN)) return; - - double p = player.getPersistentData().getDouble("zoom_pos"); - double zp = player.getPersistentData().getDouble("zoom_pos_z"); - gun.setPosX(1.66f * (float) p + (float) (0.2f * zp)); - gun.setPosY(5.5f * (float) p + (float) (0.8f * zp)); - gun.setPosZ(15.9f * (float) p); - gun.setScaleZ(1f - (0.8f * (float) p)); - gun.setRotZ(-4.75f * Mth.DEG_TO_RAD * (float) p + (float) (0.02f * zp)); + double zt = ClientEventHandler.getZoom_time(); + double zp = ClientEventHandler.getZoom_pos(); + double zpz = ClientEventHandler.getZoom_pos_z(); + + gun.setPosX(1.66f * (float) zp + (float) (0.2f * zpz)); + gun.setPosY(5.5f * (float) zp + (float) (0.8f * zpz)); + gun.setPosZ(15.9f * (float) zp); + gun.setScaleZ(1f - (0.8f * (float) zp)); + gun.setRotZ(-4.75f * Mth.DEG_TO_RAD * (float) zp + (float) (0.02f * zpz)); javelin.setHidden(gun.getPosZ() > 15.85); stack.getOrCreateTag().putBoolean("HoloHidden", !(gun.getPosZ() > 15.85)); diff --git a/src/main/java/net/mcreator/superbwarfare/client/model/item/K98ItemModel.java b/src/main/java/net/mcreator/superbwarfare/client/model/item/K98ItemModel.java index af082072e..74549e3a5 100644 --- a/src/main/java/net/mcreator/superbwarfare/client/model/item/K98ItemModel.java +++ b/src/main/java/net/mcreator/superbwarfare/client/model/item/K98ItemModel.java @@ -1,6 +1,7 @@ package net.mcreator.superbwarfare.client.model.item; import net.mcreator.superbwarfare.ModUtils; +import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.item.gun.sniper.K98Item; import net.mcreator.superbwarfare.network.ModVariables; @@ -52,13 +53,14 @@ public class K98ItemModel extends GeoModel { clip.setScaleZ(1); } - double p = player.getPersistentData().getDouble("zoom_pos"); - double zp = player.getPersistentData().getDouble("zoom_pos_z"); + double zt = ClientEventHandler.getZoom_time(); + double zp = ClientEventHandler.getZoom_pos(); + double zpz = ClientEventHandler.getZoom_pos_z(); - gun.setPosX(2.11f * (float) p); - gun.setPosY(1.52f * (float) p - (float) (0.2f * zp)); - gun.setPosZ(10f * (float) p + (float) (0.3f * zp)); - gun.setScaleZ(1f - (0.7f * (float) p)); + gun.setPosX(2.11f * (float) zp); + gun.setPosY(1.52f * (float) zp - (float) (0.2f * zpz)); + gun.setPosZ(10f * (float) zp + (float) (0.3f * zpz)); + gun.setScaleZ(1f - (0.7f * (float) zp)); double fp = player.getPersistentData().getDouble("fire_pos"); @@ -121,9 +123,9 @@ public class K98ItemModel extends GeoModel { CoreGeoBone camera = getAnimationProcessor().getBone("camera"); CoreGeoBone main = getAnimationProcessor().getBone("0"); CoreGeoBone body = getAnimationProcessor().getBone("roll"); - var data = player.getPersistentData(); - float numR = (float) (1 - 0.52 * data.getDouble("zoom_time")); - float numP = (float) (1 - 0.58 * data.getDouble("zoom_time")); + + float numR = (float) (1 - 0.52 * zt); + float numP = (float) (1 - 0.58 * zt); if (stack.getOrCreateTag().getInt("gun_reloading_time") > 0 || stack.getOrCreateTag().getBoolean("reloading")) { main.setRotX(numR * main.getRotX()); diff --git a/src/main/java/net/mcreator/superbwarfare/client/model/item/M1911ItemModel.java b/src/main/java/net/mcreator/superbwarfare/client/model/item/M1911ItemModel.java index f76af10ce..77a6ffe2b 100644 --- a/src/main/java/net/mcreator/superbwarfare/client/model/item/M1911ItemModel.java +++ b/src/main/java/net/mcreator/superbwarfare/client/model/item/M1911ItemModel.java @@ -1,6 +1,7 @@ package net.mcreator.superbwarfare.client.model.item; import net.mcreator.superbwarfare.ModUtils; +import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.item.gun.handgun.M1911Item; import net.mcreator.superbwarfare.network.ModVariables; @@ -42,16 +43,17 @@ public class M1911ItemModel extends GeoModel { ItemStack stack = player.getMainHandItem(); if (!stack.is(ModTags.Items.GUN)) return; - double p = player.getPersistentData().getDouble("zoom_pos"); - double zp = player.getPersistentData().getDouble("zoom_pos_z"); + double zt = ClientEventHandler.getZoom_time(); + double zp = ClientEventHandler.getZoom_pos(); + double zpz = ClientEventHandler.getZoom_pos_z(); - gun.setPosX(1.86f * (float) p); + gun.setPosX(1.86f * (float) zp); - gun.setPosY(1.55f * (float) p - (float) (0.2f * zp)); + gun.setPosY(1.55f * (float) zp - (float) (0.2f * zpz)); - gun.setPosZ(2f * (float) p + (float) (0.3f * zp)); + gun.setPosZ(2f * (float) zp + (float) (0.3f * zpz)); - gun.setScaleZ(1f - (0.35f * (float) p)); + gun.setScaleZ(1f - (0.35f * (float) zp)); double fp = player.getPersistentData().getDouble("fire_pos"); double fr = player.getPersistentData().getDouble("fire_rot"); @@ -128,9 +130,9 @@ public class M1911ItemModel extends GeoModel { CoreGeoBone camera = getAnimationProcessor().getBone("camera"); CoreGeoBone main = getAnimationProcessor().getBone("0"); CoreGeoBone body = getAnimationProcessor().getBone("gun"); - var data = player.getPersistentData(); - float numR = (float) (1 - 0.12 * data.getDouble("zoom_time")); - float numP = (float) (1 - 0.68 * data.getDouble("zoom_time")); + + float numR = (float) (1 - 0.12 * zt); + float numP = (float) (1 - 0.68 * zt); if (stack.getOrCreateTag().getInt("gun_reloading_time") > 0) { main.setRotX(numR * main.getRotX()); diff --git a/src/main/java/net/mcreator/superbwarfare/client/model/item/M4ItemModel.java b/src/main/java/net/mcreator/superbwarfare/client/model/item/M4ItemModel.java index b7d7eb107..d7e42a717 100644 --- a/src/main/java/net/mcreator/superbwarfare/client/model/item/M4ItemModel.java +++ b/src/main/java/net/mcreator/superbwarfare/client/model/item/M4ItemModel.java @@ -1,6 +1,7 @@ package net.mcreator.superbwarfare.client.model.item; import net.mcreator.superbwarfare.ModUtils; +import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.item.gun.rifle.M4Item; import net.mcreator.superbwarfare.network.ModVariables; @@ -40,18 +41,19 @@ public class M4ItemModel extends GeoModel { ItemStack stack = player.getMainHandItem(); if (!stack.is(ModTags.Items.GUN)) return; - double p = player.getPersistentData().getDouble("zoom_pos"); - double zp = player.getPersistentData().getDouble("zoom_pos_z"); + double zt = ClientEventHandler.getZoom_time(); + double zp = ClientEventHandler.getZoom_pos(); + double zpz = ClientEventHandler.getZoom_pos_z(); - gun.setPosX(2.935f * (float) p); + gun.setPosX(2.935f * (float) zp); - gun.setPosY(0.65f * (float) p - (float) (0.2f * zp)); + gun.setPosY(0.65f * (float) zp - (float) (0.2f * zpz)); - gun.setPosZ(3f * (float) p + (float) (0.2f * zp)); + gun.setPosZ(3f * (float) zp + (float) (0.2f * zpz)); - gun.setScaleZ(1f - (0.2f * (float) p)); + gun.setScaleZ(1f - (0.2f * (float) zp)); - gun.setRotZ((float) (0.05f * zp)); + gun.setRotZ((float) (0.05f * zpz)); double fp = player.getPersistentData().getDouble("fire_pos"); double fr = player.getPersistentData().getDouble("fire_rot"); @@ -113,9 +115,9 @@ public class M4ItemModel extends GeoModel { CoreGeoBone camera = getAnimationProcessor().getBone("camera"); CoreGeoBone main = getAnimationProcessor().getBone("0"); - var data = player.getPersistentData(); - float numR = (float) (1 - 0.8 * data.getDouble("zoom_time")); - float numP = (float) (1 - 0.65 * data.getDouble("zoom_time")); + + float numR = (float) (1 - 0.8 * zt); + float numP = (float) (1 - 0.65 * zt); if (stack.getOrCreateTag().getInt("gun_reloading_time") > 0) { main.setRotX(numR * main.getRotX()); diff --git a/src/main/java/net/mcreator/superbwarfare/client/model/item/M60ItemModel.java b/src/main/java/net/mcreator/superbwarfare/client/model/item/M60ItemModel.java index b6c24387f..719e3b82c 100644 --- a/src/main/java/net/mcreator/superbwarfare/client/model/item/M60ItemModel.java +++ b/src/main/java/net/mcreator/superbwarfare/client/model/item/M60ItemModel.java @@ -1,6 +1,7 @@ package net.mcreator.superbwarfare.client.model.item; import net.mcreator.superbwarfare.ModUtils; +import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.item.gun.machinegun.M60Item; import net.mcreator.superbwarfare.network.ModVariables; @@ -83,17 +84,17 @@ public class M60ItemModel extends GeoModel { b1.setScaleZ(0); } - double p = player.getPersistentData().getDouble("zoom_pos"); + double zt = ClientEventHandler.getZoom_time(); + double zp = ClientEventHandler.getZoom_pos(); + double zpz = ClientEventHandler.getZoom_pos_z(); - double zp = player.getPersistentData().getDouble("zoom_pos_z"); + gun.setPosX(3.74f * (float) zp); - gun.setPosX(3.74f * (float) p); + gun.setPosY(-0.1f * (float) zp - (float) (0.1f * zpz)); - gun.setPosY(-0.1f * (float) p - (float) (0.1f * zp)); + gun.setPosZ((float) zp + (float) (0.3f * zpz)); - gun.setPosZ((float) p + (float) (0.3f * zp)); - - gun.setRotZ(-0.087f * (float) p + (float) (0.05f * zp)); + gun.setRotZ(-0.087f * (float) zp + (float) (0.05f * zpz)); double fp = player.getPersistentData().getDouble("fire_pos"); double fr = player.getPersistentData().getDouble("fire_rot"); @@ -156,9 +157,9 @@ public class M60ItemModel extends GeoModel { CoreGeoBone camera = getAnimationProcessor().getBone("camera"); CoreGeoBone main = getAnimationProcessor().getBone("0"); - var data = player.getPersistentData(); - float numR = (float) (1 - 0.88 * data.getDouble("zoom_time")); - float numP = (float) (1 - 0.28 * data.getDouble("zoom_time")); + + float numR = (float) (1 - 0.88 * zt); + float numP = (float) (1 - 0.28 * zt); if (stack.getOrCreateTag().getInt("gun_reloading_time") > 0) { main.setRotX(numR * main.getRotX()); diff --git a/src/main/java/net/mcreator/superbwarfare/client/model/item/M79ItemModel.java b/src/main/java/net/mcreator/superbwarfare/client/model/item/M79ItemModel.java index 779cbf31b..178d89345 100644 --- a/src/main/java/net/mcreator/superbwarfare/client/model/item/M79ItemModel.java +++ b/src/main/java/net/mcreator/superbwarfare/client/model/item/M79ItemModel.java @@ -1,6 +1,7 @@ package net.mcreator.superbwarfare.client.model.item; import net.mcreator.superbwarfare.ModUtils; +import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.item.gun.launcher.M79Item; import net.mcreator.superbwarfare.network.ModVariables; @@ -40,16 +41,17 @@ public class M79ItemModel extends GeoModel { ItemStack stack = player.getMainHandItem(); if (!stack.is(ModTags.Items.GUN)) return; - double p = player.getPersistentData().getDouble("zoom_pos"); - double zp = player.getPersistentData().getDouble("zoom_pos_z"); + double zt = ClientEventHandler.getZoom_time(); + double zp = ClientEventHandler.getZoom_pos(); + double zpz = ClientEventHandler.getZoom_pos_z(); - gun.setPosX(2.2f * (float) p); + gun.setPosX(2.2f * (float) zp); - gun.setPosY(0.8f * (float) p - (float) (0.7f * zp)); + gun.setPosY(0.8f * (float) zp - (float) (0.7f * zpz)); - gun.setPosZ((float) p + (float) (0.6f * zp)); + gun.setPosZ((float) zp + (float) (0.6f * zpz)); - gun.setRotZ((float) (0.05f * zp)); + gun.setRotZ((float) (0.05f * zpz)); double fp = player.getPersistentData().getDouble("fire_pos"); double fr = player.getPersistentData().getDouble("fire_rot"); @@ -111,9 +113,9 @@ public class M79ItemModel extends GeoModel { CoreGeoBone camera = getAnimationProcessor().getBone("camera"); CoreGeoBone main = getAnimationProcessor().getBone("0"); - var data = player.getPersistentData(); - float numR = (float) (1 - 0.58 * data.getDouble("zoom_time")); - float numP = (float) (1 - 0.58 * data.getDouble("zoom_time")); + + float numR = (float) (1 - 0.58 * zt); + float numP = (float) (1 - 0.58 * zt); if (stack.getOrCreateTag().getInt("gun_reloading_time") > 0) { main.setRotX(numR * main.getRotX()); diff --git a/src/main/java/net/mcreator/superbwarfare/client/model/item/M870ItemModel.java b/src/main/java/net/mcreator/superbwarfare/client/model/item/M870ItemModel.java index 27971bdf2..66306abbd 100644 --- a/src/main/java/net/mcreator/superbwarfare/client/model/item/M870ItemModel.java +++ b/src/main/java/net/mcreator/superbwarfare/client/model/item/M870ItemModel.java @@ -1,6 +1,7 @@ package net.mcreator.superbwarfare.client.model.item; import net.mcreator.superbwarfare.ModUtils; +import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.item.gun.shotgun.M870Item; import net.mcreator.superbwarfare.network.ModVariables; @@ -40,18 +41,19 @@ public class M870ItemModel extends GeoModel { ItemStack stack = player.getMainHandItem(); if (!stack.is(ModTags.Items.GUN)) return; - double p = player.getPersistentData().getDouble("zoom_pos"); - double zp = player.getPersistentData().getDouble("zoom_pos_z"); + double zt = ClientEventHandler.getZoom_time(); + double zp = ClientEventHandler.getZoom_pos(); + double zpz = ClientEventHandler.getZoom_pos_z(); - gun.setPosX(1.7f * (float) p); + gun.setPosX(1.7f * (float) zp); - gun.setPosY(1.12f * (float) p - (float) (0.2f * zp)); + gun.setPosY(1.12f * (float) zp - (float) (0.2f * zpz)); - gun.setPosZ(1.5f * (float) p + (float) (0.9f * zp)); + gun.setPosZ(1.5f * (float) zp + (float) (0.9f * zpz)); - gun.setRotZ((float) (0.02f * zp)); + gun.setRotZ((float) (0.02f * zpz)); - gun.setScaleZ(1f - (0.2f * (float) p)); + gun.setScaleZ(1f - (0.2f * (float) zp)); double fp = player.getPersistentData().getDouble("fire_pos"); double fr = player.getPersistentData().getDouble("fire_rot"); @@ -114,9 +116,9 @@ public class M870ItemModel extends GeoModel { CoreGeoBone camera = getAnimationProcessor().getBone("camera"); CoreGeoBone main = getAnimationProcessor().getBone("main"); - var data = player.getPersistentData(); - float numR = (float) (1 - 0.72 * data.getDouble("zoom_time")); - float numP = (float) (1 - 0.82 * data.getDouble("zoom_time")); + + float numR = (float) (1 - 0.72 * zt); + float numP = (float) (1 - 0.82 * zt); if (stack.getOrCreateTag().getBoolean("reloading")) { main.setRotX(numR * main.getRotX()); diff --git a/src/main/java/net/mcreator/superbwarfare/client/model/item/M98bItemModel.java b/src/main/java/net/mcreator/superbwarfare/client/model/item/M98bItemModel.java index 7d03ffe64..9cfb52aaa 100644 --- a/src/main/java/net/mcreator/superbwarfare/client/model/item/M98bItemModel.java +++ b/src/main/java/net/mcreator/superbwarfare/client/model/item/M98bItemModel.java @@ -1,6 +1,7 @@ package net.mcreator.superbwarfare.client.model.item; import net.mcreator.superbwarfare.ModUtils; +import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.item.gun.sniper.M98bItem; import net.mcreator.superbwarfare.network.ModVariables; @@ -34,7 +35,6 @@ public class M98bItemModel extends GeoModel { public void setCustomAnimations(M98bItem animatable, long instanceId, AnimationState animationState) { CoreGeoBone gun = getAnimationProcessor().getBone("bone"); CoreGeoBone shen = getAnimationProcessor().getBone("shen"); - CoreGeoBone shi = getAnimationProcessor().getBone("shi"); Player player = Minecraft.getInstance().player; if (player == null) return; @@ -57,29 +57,17 @@ public class M98bItemModel extends GeoModel { } shen.setPosX(0.5f * (float)fr * (float)((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).recoilHorizon * fp)); - double p = player.getPersistentData().getDouble("zoom_pos"); - double zp = player.getPersistentData().getDouble("zoom_pos_z"); + double zt = ClientEventHandler.getZoom_time(); + double zp = ClientEventHandler.getZoom_pos(); + double zpz = ClientEventHandler.getZoom_pos_z(); - gun.setPosX(2.245f * (float) p); + gun.setPosX(2.245f * (float) zp); - gun.setPosY(0.3f * (float) p - (float) (0.2f * zp)); + gun.setPosY(0.3f * (float) zp - (float) (0.2f * zpz)); - gun.setPosZ(4.2f * (float) p + (float) (0.3f * zp)); + gun.setPosZ(4.2f * (float) zp + (float) (0.3f * zpz)); - gun.setRotZ((float) (0.02f * zp)); - -// CoreGeoBone holo = getAnimationProcessor().getBone("scope2"); -// CoreGeoBone qiang = getAnimationProcessor().getBone("qiang"); - - stack.getOrCreateTag().putBoolean("HoloHidden", !(gun.getPosX() > 1.9)); - -// if (gun.getPosX() > 1.9) { -// holo.setHidden(false); -// qiang.setHidden(true); -// } else { -// holo.setHidden(true); -// qiang.setHidden(false); -// } + gun.setRotZ((float) (0.02f * zpz)); CoreGeoBone root = getAnimationProcessor().getBone("root"); CoreGeoBone zhunxing = getAnimationProcessor().getBone("shi"); @@ -132,9 +120,8 @@ public class M98bItemModel extends GeoModel { CoreGeoBone main = getAnimationProcessor().getBone("0"); CoreGeoBone scope = getAnimationProcessor().getBone("scope2"); - var data = player.getPersistentData(); - float numR = (float) (1 - 0.88 * data.getDouble("zoom_time")); - float numP = (float) (1 - 0.68 * data.getDouble("zoom_time")); + float numR = (float) (1 - 0.88 * zt); + float numP = (float) (1 - 0.68 * zt); if (stack.getOrCreateTag().getInt("gun_reloading_time") > 0) { main.setRotX(numR * main.getRotX()); diff --git a/src/main/java/net/mcreator/superbwarfare/client/model/item/MarlinItemModel.java b/src/main/java/net/mcreator/superbwarfare/client/model/item/MarlinItemModel.java index a772d70ff..bc5e26088 100644 --- a/src/main/java/net/mcreator/superbwarfare/client/model/item/MarlinItemModel.java +++ b/src/main/java/net/mcreator/superbwarfare/client/model/item/MarlinItemModel.java @@ -1,6 +1,7 @@ package net.mcreator.superbwarfare.client.model.item; import net.mcreator.superbwarfare.ModUtils; +import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.item.gun.rifle.MarlinItem; import net.minecraft.client.Minecraft; @@ -39,18 +40,19 @@ public class MarlinItemModel extends GeoModel { ItemStack stack = player.getMainHandItem(); if (!stack.is(ModTags.Items.GUN)) return; - double p = player.getPersistentData().getDouble("zoom_pos"); - double zp = player.getPersistentData().getDouble("zoom_pos_z"); + double zt = ClientEventHandler.getZoom_time(); + double zp = ClientEventHandler.getZoom_pos(); + double zpz = ClientEventHandler.getZoom_pos_z(); - gun.setPosX(1.712f * (float) p); + gun.setPosX(1.712f * (float) zp); - gun.setPosY(1.06f * (float) p - (float) (0.7f * zp)); + gun.setPosY(1.06f * (float) zp - (float) (0.7f * zpz)); - gun.setPosZ(4f * (float) p + (float) (0.9f * zp)); + gun.setPosZ(4f * (float) zp + (float) (0.9f * zpz)); - gun.setRotZ((float) (0.02f * zp)); + gun.setRotZ((float) (0.02f * zpz)); - gun.setScaleZ(1f - (0.5f * (float) p)); + gun.setScaleZ(1f - (0.5f * (float) zp)); double fp = player.getPersistentData().getDouble("fire_pos"); double fr = player.getPersistentData().getDouble("fire_rot"); @@ -111,9 +113,9 @@ public class MarlinItemModel extends GeoModel { CoreGeoBone camera = getAnimationProcessor().getBone("camera"); CoreGeoBone main = getAnimationProcessor().getBone("0"); - var data = player.getPersistentData(); - float numR = (float) (1 - 0.55 * data.getDouble("zoom_time")); - float numP = (float) (1 - 0.88 * data.getDouble("zoom_time")); + + float numR = (float) (1 - 0.55 * zt); + float numP = (float) (1 - 0.88 * zt); if (stack.getOrCreateTag().getBoolean("reloading")) { main.setRotX(numR * main.getRotX()); diff --git a/src/main/java/net/mcreator/superbwarfare/client/model/item/Mk14ItemModel.java b/src/main/java/net/mcreator/superbwarfare/client/model/item/Mk14ItemModel.java index bd4be5fe1..1b6c54445 100644 --- a/src/main/java/net/mcreator/superbwarfare/client/model/item/Mk14ItemModel.java +++ b/src/main/java/net/mcreator/superbwarfare/client/model/item/Mk14ItemModel.java @@ -1,6 +1,7 @@ package net.mcreator.superbwarfare.client.model.item; import net.mcreator.superbwarfare.ModUtils; +import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.item.gun.rifle.Mk14Item; import net.mcreator.superbwarfare.network.ModVariables; @@ -50,22 +51,23 @@ public class Mk14ItemModel extends GeoModel { r.setRotX(-1.5f); } - double p = player.getPersistentData().getDouble("zoom_pos"); - double zp = player.getPersistentData().getDouble("zoom_pos_z"); + double zt = ClientEventHandler.getZoom_time(); + double zp = ClientEventHandler.getZoom_pos(); + double zpz = ClientEventHandler.getZoom_pos_z(); - gun.setPosX(3.105f * (float) p); + gun.setPosX(3.105f * (float) zp); - gun.setPosY(0.53f * (float) p - (float) (0.2f * zp)); + gun.setPosY(0.53f * (float) zp - (float) (0.2f * zpz)); - gun.setPosZ(3.7f * (float) p + (float) (0.2f * zp)); + gun.setPosZ(3.7f * (float) zp + (float) (0.2f * zpz)); - gun.setRotZ((float) (0.05f * zp)); + gun.setRotZ((float) (0.05f * zpz)); - gun.setScaleZ(1f - (0.7f * (float) p)); + gun.setScaleZ(1f - (0.7f * (float) zp)); - scope.setScaleZ(1f - (0.7f * (float) p)); + scope.setScaleZ(1f - (0.7f * (float) zp)); - yugu.setScaleZ(1f - (0.7f * (float) p)); + yugu.setScaleZ(1f - (0.7f * (float) zp)); CoreGeoBone shen = getAnimationProcessor().getBone("shen"); @@ -144,9 +146,9 @@ public class Mk14ItemModel extends GeoModel { CoreGeoBone camera = getAnimationProcessor().getBone("camera"); CoreGeoBone main = getAnimationProcessor().getBone("0"); - var data = player.getPersistentData(); - float numR = (float) (1 - 0.95 * data.getDouble("zoom_time")); - float numP = (float) (1 - 0.94 * data.getDouble("zoom_time")); + + float numR = (float) (1 - 0.95 * zt); + float numP = (float) (1 - 0.94 * zt); if (stack.getOrCreateTag().getInt("gun_reloading_time") > 0) { main.setRotX(numR * main.getRotX()); diff --git a/src/main/java/net/mcreator/superbwarfare/client/model/item/MosinNagantItemModel.java b/src/main/java/net/mcreator/superbwarfare/client/model/item/MosinNagantItemModel.java index 4fb8bb02d..c64a9ca6e 100644 --- a/src/main/java/net/mcreator/superbwarfare/client/model/item/MosinNagantItemModel.java +++ b/src/main/java/net/mcreator/superbwarfare/client/model/item/MosinNagantItemModel.java @@ -1,6 +1,7 @@ package net.mcreator.superbwarfare.client.model.item; import net.mcreator.superbwarfare.ModUtils; +import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.item.gun.sniper.MosinNagantItem; import net.mcreator.superbwarfare.network.ModVariables; @@ -46,17 +47,18 @@ public class MosinNagantItemModel extends GeoModel { if (!stack.is(ModTags.Items.GUN)) return; - double p = player.getPersistentData().getDouble("zoom_pos"); - double zp = player.getPersistentData().getDouble("zoom_pos_z"); + double zt = ClientEventHandler.getZoom_time(); + double zp = ClientEventHandler.getZoom_pos(); + double zpz = ClientEventHandler.getZoom_pos_z(); - gun.setPosX(2.105f * (float) p); - gun.setPosY(0.766f * (float) p - (float) (0.2f * zp)); - gun.setPosZ(12.95f * (float) p + (float) (0.3f * zp)); - gun.setScaleZ(1f - (0.9f * (float) p)); + gun.setPosX(2.105f * (float) zp); + gun.setPosY(0.766f * (float) zp - (float) (0.2f * zpz)); + gun.setPosZ(12.95f * (float) zp + (float) (0.3f * zpz)); + gun.setScaleZ(1f - (0.9f * (float) zp)); - pu.setScaleZ(1f - (0.5f * (float) p)); - bone16.setScaleZ(1f - (0.93f * (float) p)); - bone15.setScaleX(1f - (0.2f * (float) p)); + pu.setScaleZ(1f - (0.5f * (float) zp)); + bone16.setScaleZ(1f - (0.93f * (float) zp)); + bone15.setScaleX(1f - (0.2f * (float) zp)); if (gun.getPosX() > 1.4) { qiangshen.setScaleX(0); @@ -133,9 +135,9 @@ public class MosinNagantItemModel extends GeoModel { CoreGeoBone camera = getAnimationProcessor().getBone("camera"); CoreGeoBone main = getAnimationProcessor().getBone("0"); CoreGeoBone body = getAnimationProcessor().getBone("roll"); - var data = player.getPersistentData(); - float numR = (float) (1 - 0.97 * data.getDouble("zoom_time")); - float numP = (float) (1 - 0.81 * data.getDouble("zoom_time")); + + float numR = (float) (1 - 0.97 * zt); + float numP = (float) (1 - 0.81 * zt); if (stack.getOrCreateTag().getBoolean("reloading") || stack.getOrCreateTag().getInt("bolt_action_anim") > 0) { main.setRotX(numR * main.getRotX()); diff --git a/src/main/java/net/mcreator/superbwarfare/client/model/item/Ntw20Model.java b/src/main/java/net/mcreator/superbwarfare/client/model/item/Ntw20Model.java index 335944916..ae7aad19f 100644 --- a/src/main/java/net/mcreator/superbwarfare/client/model/item/Ntw20Model.java +++ b/src/main/java/net/mcreator/superbwarfare/client/model/item/Ntw20Model.java @@ -1,6 +1,7 @@ package net.mcreator.superbwarfare.client.model.item; import net.mcreator.superbwarfare.ModUtils; +import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.item.gun.sniper.Ntw20Item; import net.mcreator.superbwarfare.network.ModVariables; @@ -65,20 +66,21 @@ public class Ntw20Model extends GeoModel { shen.setPosX(0.5f * (float)fr * (float)((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).recoilHorizon * fp)); - double p = player.getPersistentData().getDouble("zoom_pos"); - double zp = player.getPersistentData().getDouble("zoom_pos_z"); + double zt = ClientEventHandler.getZoom_time(); + double zp = ClientEventHandler.getZoom_pos(); + double zpz = ClientEventHandler.getZoom_pos_z(); - gun.setPosX(4.54f * (float) p); + gun.setPosX(4.54f * (float) zp); - gun.setPosY(-0.45f * (float) p - (float) (0.2f * zp)); + gun.setPosY(-0.45f * (float) zp - (float) (0.2f * zpz)); - gun.setPosZ(10.0f * (float) p + (float) (0.3f * zp)); + gun.setPosZ(10.0f * (float) zp + (float) (0.3f * zpz)); - gun.setRotZ((float) (0.02f * zp)); + gun.setRotZ((float) (0.02f * zpz)); - gun.setScaleZ(1f - (0.8f * (float) p)); + gun.setScaleZ(1f - (0.8f * (float) zp)); - scope.setScaleZ(1f - (0.85f * (float) p)); + scope.setScaleZ(1f - (0.85f * (float) zp)); stack.getOrCreateTag().putBoolean("HoloHidden", !(gun.getPosX() > 4.3)); @@ -126,9 +128,9 @@ public class Ntw20Model extends GeoModel { CoreGeoBone camera = getAnimationProcessor().getBone("camera"); CoreGeoBone main = getAnimationProcessor().getBone("0"); - var data = player.getPersistentData(); - float numR = (float) (1 - 0.92 * data.getDouble("zoom_time")); - float numP = (float) (1 - 0.88 * data.getDouble("zoom_time")); + + float numR = (float) (1 - 0.92 * zt); + float numP = (float) (1 - 0.88 * zt); if (stack.getOrCreateTag().getInt("gun_reloading_time") > 0 || stack.getOrCreateTag().getInt("bolt_action_anim") > 0) { main.setRotX(numR * main.getRotX()); diff --git a/src/main/java/net/mcreator/superbwarfare/client/model/item/Qbz95ItemModel.java b/src/main/java/net/mcreator/superbwarfare/client/model/item/Qbz95ItemModel.java index 76e235eba..e4905a143 100644 --- a/src/main/java/net/mcreator/superbwarfare/client/model/item/Qbz95ItemModel.java +++ b/src/main/java/net/mcreator/superbwarfare/client/model/item/Qbz95ItemModel.java @@ -1,6 +1,7 @@ package net.mcreator.superbwarfare.client.model.item; import net.mcreator.superbwarfare.ModUtils; +import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.item.gun.rifle.Qbz95Item; import net.mcreator.superbwarfare.network.ModVariables; @@ -41,14 +42,15 @@ public class Qbz95ItemModel extends GeoModel { ItemStack stack = player.getMainHandItem(); if (!stack.is(ModTags.Items.GUN)) return; - double p = player.getPersistentData().getDouble("zoom_pos"); - double zp = player.getPersistentData().getDouble("zoom_pos_z"); + double zt = ClientEventHandler.getZoom_time(); + double zp = ClientEventHandler.getZoom_pos(); + double zpz = ClientEventHandler.getZoom_pos_z(); - gun.setPosX(3.73f * (float) p); - gun.setPosY(-0.5f * (float) p - (float) (0.2f * zp)); - gun.setPosZ(13f * (float) p + (float) (0.3f * zp)); - gun.setRotZ((float) (0.05f * zp)); - gun.setScaleZ(1f - (0.7f * (float) p)); + gun.setPosX(3.73f * (float) zp); + gun.setPosY(-0.5f * (float) zp - (float) (0.2f * zpz)); + gun.setPosZ(13f * (float) zp + (float) (0.3f * zpz)); + gun.setRotZ((float) (0.05f * zpz)); + gun.setScaleZ(1f - (0.7f * (float) zp)); stack.getOrCreateTag().putBoolean("HoloHidden", !(gun.getPosX() > 3.1)); @@ -116,9 +118,9 @@ public class Qbz95ItemModel extends GeoModel { CoreGeoBone camera = getAnimationProcessor().getBone("camera"); CoreGeoBone main = getAnimationProcessor().getBone("0"); - var data = player.getPersistentData(); - float numR = (float) (1 - 0.92 * data.getDouble("zoom_time")); - float numP = (float) (1 - 0.88 * data.getDouble("zoom_time")); + + float numR = (float) (1 - 0.92 * zt); + float numP = (float) (1 - 0.88 * zt); if (stack.getOrCreateTag().getInt("gun_reloading_time") > 0) { main.setRotX(numR * main.getRotX()); diff --git a/src/main/java/net/mcreator/superbwarfare/client/model/item/RpgItemModel.java b/src/main/java/net/mcreator/superbwarfare/client/model/item/RpgItemModel.java index ee564ecb3..eea73896c 100644 --- a/src/main/java/net/mcreator/superbwarfare/client/model/item/RpgItemModel.java +++ b/src/main/java/net/mcreator/superbwarfare/client/model/item/RpgItemModel.java @@ -1,6 +1,7 @@ package net.mcreator.superbwarfare.client.model.item; import net.mcreator.superbwarfare.ModUtils; +import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.item.gun.launcher.RpgItem; import net.mcreator.superbwarfare.network.ModVariables; @@ -61,14 +62,15 @@ public class RpgItemModel extends GeoModel { } shen.setPosX(0.5f * (float)fr * (float)((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).recoilHorizon * fp)); - double p = player.getPersistentData().getDouble("zoom_pos"); - double zp = player.getPersistentData().getDouble("zoom_pos_z"); + double zt = ClientEventHandler.getZoom_time(); + double zp = ClientEventHandler.getZoom_pos(); + double zpz = ClientEventHandler.getZoom_pos_z(); - gun.setPosX(0.91f * (float) p); - gun.setPosY(-0.04f * (float) p - (float) (0.2f * zp)); - gun.setPosZ(2f * (float) p + (float) (0.15f * zp)); - gun.setRotZ(0.45f * (float) p + (float) (0.02f * zp)); - gun.setScaleZ(1f - (0.5f * (float) p)); + gun.setPosX(0.91f * (float) zp); + gun.setPosY(-0.04f * (float) zp - (float) (0.2f * zpz)); + gun.setPosZ(2f * (float) zp + (float) (0.15f * zpz)); + gun.setRotZ(0.45f * (float) zp + (float) (0.02f * zpz)); + gun.setScaleZ(1f - (0.5f * (float) zp)); CoreGeoBone root = getAnimationProcessor().getBone("root"); @@ -114,9 +116,9 @@ public class RpgItemModel extends GeoModel { CoreGeoBone camera = getAnimationProcessor().getBone("camera"); CoreGeoBone main = getAnimationProcessor().getBone("0"); - var data = player.getPersistentData(); - float numR = (float) (1 - 0.82 * data.getDouble("zoom_time")); - float numP = (float) (1 - 0.78 * data.getDouble("zoom_time")); + + float numR = (float) (1 - 0.82 * zt); + float numP = (float) (1 - 0.78 * zt); if (stack.getOrCreateTag().getInt("gun_reloading_time") > 0) { main.setRotX(numR * main.getRotX()); diff --git a/src/main/java/net/mcreator/superbwarfare/client/model/item/RpkItemModel.java b/src/main/java/net/mcreator/superbwarfare/client/model/item/RpkItemModel.java index a6e1d45a7..a2fbcf72c 100644 --- a/src/main/java/net/mcreator/superbwarfare/client/model/item/RpkItemModel.java +++ b/src/main/java/net/mcreator/superbwarfare/client/model/item/RpkItemModel.java @@ -1,6 +1,7 @@ package net.mcreator.superbwarfare.client.model.item; import net.mcreator.superbwarfare.ModUtils; +import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.item.gun.machinegun.RpkItem; import net.mcreator.superbwarfare.network.ModVariables; @@ -44,26 +45,27 @@ public class RpkItemModel extends GeoModel { ItemStack stack = player.getMainHandItem(); if (!stack.is(ModTags.Items.GUN)) return; - double p = player.getPersistentData().getDouble("zoom_pos"); - double zp = player.getPersistentData().getDouble("zoom_pos_z"); + double zt = ClientEventHandler.getZoom_time(); + double zp = ClientEventHandler.getZoom_pos(); + double zpz = ClientEventHandler.getZoom_pos_z(); - gun.setPosX(1.69f * (float) p); + gun.setPosX(1.69f * (float) zp); - gun.setPosY(-0.33f * (float) p - (float) (0.1f * zp)); + gun.setPosY(-0.33f * (float) zp - (float) (0.1f * zpz)); - gun.setPosZ(3.2f * (float) p + (float) (0.2f * zp)); + gun.setPosZ(3.2f * (float) zp + (float) (0.2f * zpz)); - gun.setRotZ((float) (0.05f * zp)); + gun.setRotZ((float) (0.05f * zpz)); - gun.setScaleZ(1f - (0.55f * (float) p)); + gun.setScaleZ(1f - (0.55f * (float) zp)); - scope.setScaleZ(1f - (0.9f * (float) p)); + scope.setScaleZ(1f - (0.9f * (float) zp)); - button.setScaleX(1f - (0.2f * (float) p)); + button.setScaleX(1f - (0.2f * (float) zp)); - button.setScaleY(1f - (0.3f * (float) p)); + button.setScaleY(1f - (0.3f * (float) zp)); - button.setScaleZ(1f - (0.3f * (float) p)); + button.setScaleZ(1f - (0.3f * (float) zp)); stack.getOrCreateTag().putBoolean("HoloHidden", !(gun.getPosX() > 1.65)); @@ -129,9 +131,9 @@ public class RpkItemModel extends GeoModel { CoreGeoBone camera = getAnimationProcessor().getBone("camera"); CoreGeoBone main = getAnimationProcessor().getBone("0"); - var data = player.getPersistentData(); - float numR = (float) (1 - 0.94 * data.getDouble("zoom_time")); - float numP = (float) (1 - 0.8 * data.getDouble("zoom_time")); + + float numR = (float) (1 - 0.94 * zt); + float numP = (float) (1 - 0.8 * zt); if (stack.getOrCreateTag().getInt("gun_reloading_time") > 0) { main.setRotX(numR * main.getRotX()); diff --git a/src/main/java/net/mcreator/superbwarfare/client/model/item/SentinelItemModel.java b/src/main/java/net/mcreator/superbwarfare/client/model/item/SentinelItemModel.java index 70cd8188b..f60ab4425 100644 --- a/src/main/java/net/mcreator/superbwarfare/client/model/item/SentinelItemModel.java +++ b/src/main/java/net/mcreator/superbwarfare/client/model/item/SentinelItemModel.java @@ -1,6 +1,7 @@ package net.mcreator.superbwarfare.client.model.item; import net.mcreator.superbwarfare.ModUtils; +import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.item.gun.sniper.SentinelItem; import net.mcreator.superbwarfare.network.ModVariables; @@ -43,21 +44,21 @@ public class SentinelItemModel extends GeoModel { ItemStack stack = player.getMainHandItem(); if (!stack.is(ModTags.Items.GUN)) return; - double p = player.getPersistentData().getDouble("zoom_pos"); + double zt = ClientEventHandler.getZoom_time(); + double zp = ClientEventHandler.getZoom_pos(); + double zpz = ClientEventHandler.getZoom_pos_z(); - double zp = player.getPersistentData().getDouble("zoom_pos_z"); + gun.setPosX(2.928f * (float) zp); - gun.setPosX(2.928f * (float) p); + gun.setPosY(-0.062f * (float) zp - (float) (0.1f * zpz)); - gun.setPosY(-0.062f * (float) p - (float) (0.1f * zp)); + gun.setPosZ(10f * (float) zp + (float) (0.3f * zpz)); - gun.setPosZ(10f * (float) p + (float) (0.3f * zp)); + gun.setRotZ((float) (0.05f * zpz)); - gun.setRotZ((float) (0.05f * zp)); + gun.setScaleZ(1f - (0.7f * (float) zp)); - gun.setScaleZ(1f - (0.7f * (float) p)); - - scope.setScaleZ(1f - (0.8f * (float) p)); + scope.setScaleZ(1f - (0.8f * (float) zp)); float fps = Minecraft.getInstance().getFps(); if (fps <= 0) { @@ -138,9 +139,9 @@ public class SentinelItemModel extends GeoModel { CoreGeoBone camera = getAnimationProcessor().getBone("camera"); CoreGeoBone main = getAnimationProcessor().getBone("0"); - var data = player.getPersistentData(); - float numR = (float) (1 - 0.9 * data.getDouble("zoom_time")); - float numP = (float) (1 - 0.98 * data.getDouble("zoom_time")); + + float numR = (float) (1 - 0.9 * zt); + float numP = (float) (1 - 0.98 * zt); if (stack.getOrCreateTag().getInt("gun_reloading_time") > 0 || stack.getOrCreateTag().getBoolean("sentinel_is_charging")) { main.setRotX(numR * main.getRotX()); diff --git a/src/main/java/net/mcreator/superbwarfare/client/model/item/SksItemModel.java b/src/main/java/net/mcreator/superbwarfare/client/model/item/SksItemModel.java index 0ce98a1a2..8f2d9352f 100644 --- a/src/main/java/net/mcreator/superbwarfare/client/model/item/SksItemModel.java +++ b/src/main/java/net/mcreator/superbwarfare/client/model/item/SksItemModel.java @@ -1,6 +1,7 @@ package net.mcreator.superbwarfare.client.model.item; import net.mcreator.superbwarfare.ModUtils; +import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.item.gun.rifle.SksItem; import net.mcreator.superbwarfare.network.ModVariables; @@ -34,7 +35,6 @@ public class SksItemModel extends GeoModel { @Override public void setCustomAnimations(SksItem animatable, long instanceId, AnimationState animationState) { CoreGeoBone gun = getAnimationProcessor().getBone("bone"); - CoreGeoBone flare = getAnimationProcessor().getBone("flare"); CoreGeoBone bolt = getAnimationProcessor().getBone("bolt"); CoreGeoBone shuan = getAnimationProcessor().getBone("bolt2"); @@ -47,16 +47,17 @@ public class SksItemModel extends GeoModel { bolt.setPosZ(2.5f); } - double p = player.getPersistentData().getDouble("zoom_pos"); - double zp = player.getPersistentData().getDouble("zoom_pos_z"); + double zt = ClientEventHandler.getZoom_time(); + double zp = ClientEventHandler.getZoom_pos(); + double zpz = ClientEventHandler.getZoom_pos_z(); - gun.setPosX(1.53f * (float) p); + gun.setPosX(1.53f * (float) zp); - gun.setPosY(0.34f * (float) p - (float) (0.6f * zp)); + gun.setPosY(0.34f * (float) zp - (float) (0.6f * zpz)); - gun.setPosZ(2.5f * (float) p + (float) (0.5f * zp)); + gun.setPosZ(2.5f * (float) zp + (float) (0.5f * zpz)); - gun.setRotZ((float) (0.05f * zp)); + gun.setRotZ((float) (0.05f * zpz)); CoreGeoBone holo = getAnimationProcessor().getBone("holo"); @@ -125,9 +126,9 @@ public class SksItemModel extends GeoModel { CoreGeoBone camera = getAnimationProcessor().getBone("camera"); CoreGeoBone main = getAnimationProcessor().getBone("0"); - var data = player.getPersistentData(); - float numR = (float) (1 - 0.92 * data.getDouble("zoom_time")); - float numP = (float) (1 - 0.88 * data.getDouble("zoom_time")); + + float numR = (float) (1 - 0.92 * zt); + float numP = (float) (1 - 0.88 * zt); if (stack.getOrCreateTag().getInt("gun_reloading_time") > 0) { main.setRotX(numR * main.getRotX()); diff --git a/src/main/java/net/mcreator/superbwarfare/client/model/item/SvdItemModel.java b/src/main/java/net/mcreator/superbwarfare/client/model/item/SvdItemModel.java index 947efd58a..1cc7534e3 100644 --- a/src/main/java/net/mcreator/superbwarfare/client/model/item/SvdItemModel.java +++ b/src/main/java/net/mcreator/superbwarfare/client/model/item/SvdItemModel.java @@ -1,6 +1,7 @@ package net.mcreator.superbwarfare.client.model.item; import net.mcreator.superbwarfare.ModUtils; +import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.item.gun.sniper.SvdItem; import net.mcreator.superbwarfare.network.ModVariables; @@ -50,24 +51,25 @@ public class SvdItemModel extends GeoModel { bolt.setPosZ(3.25f); } - double p = player.getPersistentData().getDouble("zoom_pos"); - double zp = player.getPersistentData().getDouble("zoom_pos_z"); + double zt = ClientEventHandler.getZoom_time(); + double zp = ClientEventHandler.getZoom_pos(); + double zpz = ClientEventHandler.getZoom_pos_z(); - gun.setPosX(2.02f * (float) p); + gun.setPosX(2.02f * (float) zp); - gun.setPosY(0.85f * (float) p - (float) (0.6f * zp)); + gun.setPosY(0.85f * (float) zp - (float) (0.6f * zpz)); - gun.setPosZ(13.2f * (float) p + (float) (0.5f * zp)); + gun.setPosZ(13.2f * (float) zp + (float) (0.5f * zpz)); - gun.setRotZ((float) (0.05f * zp)); + gun.setRotZ((float) (0.05f * zpz)); - gun.setScaleZ(1f - (0.8f * (float) p)); + gun.setScaleZ(1f - (0.8f * (float) zp)); - scope.setScaleZ(1f - (0.95f * (float) p)); + scope.setScaleZ(1f - (0.95f * (float) zp)); - bt1.setScaleY(1f - (0.5f * (float) p)); + bt1.setScaleY(1f - (0.5f * (float) zp)); - bt2.setScaleX(1f - (0.5f * (float) p)); + bt2.setScaleX(1f - (0.5f * (float) zp)); stack.getOrCreateTag().putBoolean("HoloHidden", !(gun.getPosX() > 1.9)); @@ -142,9 +144,9 @@ public class SvdItemModel extends GeoModel { CoreGeoBone camera = getAnimationProcessor().getBone("camera"); CoreGeoBone main = getAnimationProcessor().getBone("0"); - var data = player.getPersistentData(); - float numR = (float) (1 - 0.94 * data.getDouble("zoom_time")); - float numP = (float) (1 - 0.88 * data.getDouble("zoom_time")); + + float numR = (float) (1 - 0.94 * zt); + float numP = (float) (1 - 0.88 * zt); if (stack.getOrCreateTag().getInt("gun_reloading_time") > 0) { main.setRotX(numR * main.getRotX()); diff --git a/src/main/java/net/mcreator/superbwarfare/client/model/item/TaserItemModel.java b/src/main/java/net/mcreator/superbwarfare/client/model/item/TaserItemModel.java index 093bf5628..ff68fd3d1 100644 --- a/src/main/java/net/mcreator/superbwarfare/client/model/item/TaserItemModel.java +++ b/src/main/java/net/mcreator/superbwarfare/client/model/item/TaserItemModel.java @@ -1,6 +1,7 @@ package net.mcreator.superbwarfare.client.model.item; import net.mcreator.superbwarfare.ModUtils; +import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.init.ModPerks; import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.item.gun.special.TaserItem; @@ -82,16 +83,17 @@ public class TaserItemModel extends GeoModel { shen.setRotY(0.02f * (float) fr); shen.setRotZ(-0.02f * (float) (fp + 1.3 * fr)); - double p = player.getPersistentData().getDouble("zoom_pos"); - double zp = player.getPersistentData().getDouble("zoom_pos_z"); + double zt = ClientEventHandler.getZoom_time(); + double zp = ClientEventHandler.getZoom_pos(); + double zpz = ClientEventHandler.getZoom_pos_z(); - gun.setPosX(1.82f * (float) p); + gun.setPosX(1.82f * (float) zp); - gun.setPosY(1.3f * (float) p - (float) (0.3f * zp)); + gun.setPosY(1.3f * (float) zp - (float) (0.3f * zpz)); - gun.setPosZ((float) p + (float) (0.5f * zp)); + gun.setPosZ((float) zp + (float) (0.5f * zpz)); - gun.setRotZ((float) (0.05f * zp)); + gun.setRotZ((float) (0.05f * zpz)); CoreGeoBone root = getAnimationProcessor().getBone("root"); @@ -137,9 +139,9 @@ public class TaserItemModel extends GeoModel { CoreGeoBone camera = getAnimationProcessor().getBone("camera"); CoreGeoBone main = getAnimationProcessor().getBone("0"); - var data = player.getPersistentData(); - float numR = (float) (1 - 0.72 * data.getDouble("zoom_time")); - float numP = (float) (1 - 0.68 * data.getDouble("zoom_time")); + + float numR = (float) (1 - 0.72 * zt); + float numP = (float) (1 - 0.68 * zt); if (stack.getOrCreateTag().getInt("gun_reloading_time") > 0) { main.setRotX(numR * main.getRotX()); diff --git a/src/main/java/net/mcreator/superbwarfare/client/model/item/TracheliumItemModel.java b/src/main/java/net/mcreator/superbwarfare/client/model/item/TracheliumItemModel.java index 40b023774..8e226d4a0 100644 --- a/src/main/java/net/mcreator/superbwarfare/client/model/item/TracheliumItemModel.java +++ b/src/main/java/net/mcreator/superbwarfare/client/model/item/TracheliumItemModel.java @@ -1,6 +1,7 @@ package net.mcreator.superbwarfare.client.model.item; import net.mcreator.superbwarfare.ModUtils; +import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.item.gun.handgun.Trachelium; import net.minecraft.client.Minecraft; @@ -38,18 +39,19 @@ public class TracheliumItemModel extends GeoModel { ItemStack stack = player.getMainHandItem(); if (!stack.is(ModTags.Items.GUN)) return; - double p = player.getPersistentData().getDouble("zoom_pos"); - double zp = player.getPersistentData().getDouble("zoom_pos_z"); + double zt = ClientEventHandler.getZoom_time(); + double zp = ClientEventHandler.getZoom_pos(); + double zpz = ClientEventHandler.getZoom_pos_z(); - gun.setPosX(1.48f * (float) p); + gun.setPosX(1.48f * (float) zp); - gun.setPosY(3.2f * (float) p - (float) (0.6f * zp)); + gun.setPosY(3.2f * (float) zp - (float) (0.6f * zpz)); - gun.setPosZ((float) p + (float) (0.5f * zp)); + gun.setPosZ((float) zp + (float) (0.5f * zpz)); - gun.setRotZ(-0.087f * (float) p + (float) (0.05f * zp)); + gun.setRotZ(-0.087f * (float) zp + (float) (0.05f * zpz)); - gun.setScaleZ(1f - (0.2f * (float) p)); + gun.setScaleZ(1f - (0.2f * (float) zp)); double fp = player.getPersistentData().getDouble("fire_pos"); double fr = player.getPersistentData().getDouble("fire_rot"); @@ -105,9 +107,9 @@ public class TracheliumItemModel extends GeoModel { CoreGeoBone camera = getAnimationProcessor().getBone("camera"); CoreGeoBone main = getAnimationProcessor().getBone("0"); - var data = player.getPersistentData(); - float numR = (float) (1 - 0.22 * data.getDouble("zoom_time")); - float numP = (float) (1 - 0.48 * data.getDouble("zoom_time")); + + float numR = (float) (1 - 0.22 * zt); + float numP = (float) (1 - 0.48 * zt); if (stack.getOrCreateTag().getInt("gun_reloading_time") > 0) { main.setRotX(numR * main.getRotX()); diff --git a/src/main/java/net/mcreator/superbwarfare/client/model/item/VectorItemModel.java b/src/main/java/net/mcreator/superbwarfare/client/model/item/VectorItemModel.java index b874b4854..a6870c705 100644 --- a/src/main/java/net/mcreator/superbwarfare/client/model/item/VectorItemModel.java +++ b/src/main/java/net/mcreator/superbwarfare/client/model/item/VectorItemModel.java @@ -1,6 +1,7 @@ package net.mcreator.superbwarfare.client.model.item; import net.mcreator.superbwarfare.ModUtils; +import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.item.gun.smg.VectorItem; import net.mcreator.superbwarfare.network.ModVariables; @@ -52,18 +53,19 @@ public class VectorItemModel extends GeoModel { kmj.setRotX(0); } - double p = player.getPersistentData().getDouble("zoom_pos"); - double zp = player.getPersistentData().getDouble("zoom_pos_z"); + double zt = ClientEventHandler.getZoom_time(); + double zp = ClientEventHandler.getZoom_pos(); + double zpz = ClientEventHandler.getZoom_pos_z(); - gun.setPosX(2.35f * (float) p); + gun.setPosX(2.35f * (float) zp); - gun.setPosY(0.74f * (float) p - (float) (0.2f * zp)); + gun.setPosY(0.74f * (float) zp - (float) (0.2f * zpz)); - gun.setPosZ(5f * (float) p + (float) (0.3f * zp)); + gun.setPosZ(5f * (float) zp + (float) (0.3f * zpz)); - gun.setScaleZ(1f - (0.5f * (float) p)); + gun.setScaleZ(1f - (0.5f * (float) zp)); - scope.setScaleZ(1f - (0.2f * (float) p)); + scope.setScaleZ(1f - (0.2f * (float) zp)); CoreGeoBone holo = getAnimationProcessor().getBone("holo"); @@ -129,9 +131,9 @@ public class VectorItemModel extends GeoModel { CoreGeoBone camera = getAnimationProcessor().getBone("camera"); CoreGeoBone main = getAnimationProcessor().getBone("0"); - var data = player.getPersistentData(); - float numR = (float) (1 - 0.92 * data.getDouble("zoom_time")); - float numP = (float) (1 - 0.88 * data.getDouble("zoom_time")); + + float numR = (float) (1 - 0.92 * zt); + float numP = (float) (1 - 0.88 * zt); if (stack.getOrCreateTag().getInt("gun_reloading_time") > 0) { main.setRotX(numR * main.getRotX()); diff --git a/src/main/java/net/mcreator/superbwarfare/client/screens/CrossHairOverlay.java b/src/main/java/net/mcreator/superbwarfare/client/screens/CrossHairOverlay.java index afdd59448..42678e860 100644 --- a/src/main/java/net/mcreator/superbwarfare/client/screens/CrossHairOverlay.java +++ b/src/main/java/net/mcreator/superbwarfare/client/screens/CrossHairOverlay.java @@ -38,7 +38,10 @@ public class CrossHairOverlay { return; } ItemStack stack = player.getMainHandItem(); - double spread = player.getPersistentData().getDouble("crosshair"); + boolean zoom = GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS; + double normalSpread = stack.getOrCreateTag().getDouble("spread"); + double zoomSpread = stack.getOrCreateTag().getDouble("zoomSpread"); + double spread = (zoom ? zoomSpread : normalSpread); RenderSystem.disableDepthTest(); RenderSystem.depthMask(false); @@ -49,10 +52,10 @@ public class CrossHairOverlay { if (shouldRenderCrossHair(player) || stack.is(ModItems.MINIGUN.get()) || (stack.is(ModItems.BOCEK.get()) && stack.getOrCreateTag().getBoolean("HoloHidden"))) { preciseBlit(event.getGuiGraphics(), new ResourceLocation(ModUtils.MODID, "textures/screens/point.png"), w / 2f - 7.5f, h / 2f - 8, 0, 0, 16, 16, 16, 16); - preciseBlit(event.getGuiGraphics(), new ResourceLocation(ModUtils.MODID, "textures/screens/rexheng.png"), w / 2f - 9.5f - 2.8f * (float) spread, h / 2f - 8, 0, 0, 16, 16, 16, 16); - preciseBlit(event.getGuiGraphics(), new ResourceLocation(ModUtils.MODID, "textures/screens/rexheng.png"), w / 2f - 6.5f + 2.8f * (float) spread, h / 2f - 8, 0, 0, 16, 16, 16, 16); - preciseBlit(event.getGuiGraphics(), new ResourceLocation(ModUtils.MODID, "textures/screens/rexshu.png"), w / 2f - 7.5f, h / 2f - 7 + 2.8f * (float) spread, 0, 0, 16, 16, 16, 16); - preciseBlit(event.getGuiGraphics(), new ResourceLocation(ModUtils.MODID, "textures/screens/rexshu.png"), w / 2f - 7.5f, h / 2f - 10 - 2.8f * (float) spread, 0, 0, 16, 16, 16, 16); + preciseBlit(event.getGuiGraphics(), new ResourceLocation(ModUtils.MODID, "textures/screens/rexheng.png"), (float) (w / 2f - 9.5f - 2.8f * spread), h / 2f - 8, 0, 0, 16, 16, 16, 16); + preciseBlit(event.getGuiGraphics(), new ResourceLocation(ModUtils.MODID, "textures/screens/rexheng.png"), (float) (w / 2f - 6.5f + 2.8f * spread), h / 2f - 8, 0, 0, 16, 16, 16, 16); + preciseBlit(event.getGuiGraphics(), new ResourceLocation(ModUtils.MODID, "textures/screens/rexshu.png"), w / 2f - 7.5f, (float) (h / 2f - 7 + 2.8f * spread), 0, 0, 16, 16, 16, 16); + preciseBlit(event.getGuiGraphics(), new ResourceLocation(ModUtils.MODID, "textures/screens/rexshu.png"), w / 2f - 7.5f, (float) (h / 2f - 10 - 2.8f * spread), 0, 0, 16, 16, 16, 16); } float ww = w / 2f - 7.5f + (float) (2 * (Math.random() - 0.5f)); diff --git a/src/main/java/net/mcreator/superbwarfare/client/screens/M79UIOverlay.java b/src/main/java/net/mcreator/superbwarfare/client/screens/M79UIOverlay.java index a4d77dd76..211c8b26f 100644 --- a/src/main/java/net/mcreator/superbwarfare/client/screens/M79UIOverlay.java +++ b/src/main/java/net/mcreator/superbwarfare/client/screens/M79UIOverlay.java @@ -48,12 +48,4 @@ public class M79UIOverlay { && (Minecraft.getInstance().options.getCameraType() == CameraType.FIRST_PERSON || (player.isPassenger() && player.getVehicle() instanceof ICannonEntity)) && GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) != GLFW.GLFW_PRESS; } -// private static boolean shouldRenderCrossHair2(Player player) { -// if (player == null) return false; -// return !player.isSpectator() -// && GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) != GLFW.GLFW_PRESS -// && player.isPassenger() -// && player.getVehicle() instanceof ICannonEntity -// && !(player.getMainHandItem().getItem() instanceof GunItem); -// } } diff --git a/src/main/java/net/mcreator/superbwarfare/client/screens/SpyglassRangeOverlay.java b/src/main/java/net/mcreator/superbwarfare/client/screens/SpyglassRangeOverlay.java index 1b57c9e0c..7f83334fe 100644 --- a/src/main/java/net/mcreator/superbwarfare/client/screens/SpyglassRangeOverlay.java +++ b/src/main/java/net/mcreator/superbwarfare/client/screens/SpyglassRangeOverlay.java @@ -2,10 +2,12 @@ package net.mcreator.superbwarfare.client.screens; import net.mcreator.superbwarfare.tools.TraceTool; import net.minecraft.client.Minecraft; +import net.minecraft.network.chat.Component; import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Items; +import net.minecraft.world.level.ClipContext; +import net.minecraft.world.phys.Vec3; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.event.RenderGuiEvent; import net.minecraftforge.eventbus.api.EventPriority; @@ -23,22 +25,34 @@ public class SpyglassRangeOverlay { int h = event.getWindow().getGuiScaledHeight(); Player player = Minecraft.getInstance().player; if (player != null && (player.getMainHandItem().getItem() == Items.SPYGLASS || player.getOffhandItem().getItem() == Items.SPYGLASS) && player.isUsingItem()) { - event.getGuiGraphics().drawString( - Minecraft.getInstance().font, - getDistanceString(player), - w / 2 + 19, - h / 2 - 23, - -1, - false - ); - } - } + boolean lookAtEntity = false; + double block_range = player.position().distanceTo((Vec3.atLowerCornerOf(player.level().clip( + new ClipContext(player.getEyePosition(), player.getEyePosition().add(player.getLookAngle().scale(520)), + ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, player)).getBlockPos()))); - private static String getDistanceString(Player entity) { - Entity looking = TraceTool.findLookingEntity(entity, 1024); - if (looking instanceof LivingEntity) { - return looking.getDisplayName().getString() + ":" + new DecimalFormat("##.#").format(entity.position().distanceTo(looking.position())) + "M"; + double entity_range = 0; + + Entity lookingEntity = TraceTool.findLookingEntity(player, 520); + + if (lookingEntity != null) { + lookAtEntity = true; + entity_range = player.distanceTo(lookingEntity); + } + + if (lookAtEntity) { + event.getGuiGraphics().drawString(Minecraft.getInstance().font, Component.translatable("des.superbwarfare.drone.range") + .append(Component.literal(new DecimalFormat("##.#").format(entity_range) + "M " + lookingEntity.getDisplayName().getString())), + w / 2 + 12, h / 2 - 28, -1, false); + } else { + if (block_range > 512) { + event.getGuiGraphics().drawString(Minecraft.getInstance().font, Component.translatable("des.superbwarfare.drone.range") + .append(Component.literal("---M")), w / 2 + 12, h / 2 - 28, -1, false); + } else { + event.getGuiGraphics().drawString(Minecraft.getInstance().font, Component.translatable("des.superbwarfare.drone.range") + .append(Component.literal(new DecimalFormat("##.#").format(block_range) + "M")), + w / 2 + 12, h / 2 - 28, -1, false); + } + } } - return ""; } } diff --git a/src/main/java/net/mcreator/superbwarfare/event/ClientEventHandler.java b/src/main/java/net/mcreator/superbwarfare/event/ClientEventHandler.java index 23f47550e..0ace34b6d 100644 --- a/src/main/java/net/mcreator/superbwarfare/event/ClientEventHandler.java +++ b/src/main/java/net/mcreator/superbwarfare/event/ClientEventHandler.java @@ -34,6 +34,9 @@ import static net.mcreator.superbwarfare.entity.DroneEntity.ROT_Z; @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT) public class ClientEventHandler { + protected static double zoom_time = 0; + protected static double zoom_pos = 0; + protected static double zoom_pos_z = 0; @SubscribeEvent public static void handleWeaponTurn(RenderHandEvent event) { @@ -46,9 +49,9 @@ public class ClientEventHandler { float yRotOffset = Mth.lerp(event.getPartialTick(), player.yBobO, player.yBob); float xRot = player.getViewXRot(event.getPartialTick()) - xRotOffset; float yRot = player.getViewYRot(event.getPartialTick()) - yRotOffset; - data.putDouble("xRot", Mth.clamp(0.05 * xRot, -5, 5) * (1 - 0.75 * data.getDouble("zoom_time"))); - data.putDouble("yRot", Mth.clamp(0.05 * yRot, -10, 10) * (1 - 0.75 * data.getDouble("zoom_time"))); - data.putDouble("zRot", Mth.clamp(0.1 * yRot, -10, 10) * (1 - data.getDouble("zoom_time"))); + data.putDouble("xRot", Mth.clamp(0.05 * xRot, -5, 5) * (1 - 0.75 * zoom_time)); + data.putDouble("yRot", Mth.clamp(0.05 * yRot, -10, 10) * (1 - 0.75 * zoom_time)); + data.putDouble("zRot", Mth.clamp(0.1 * yRot, -10, 10) * (1 - zoom_time)); data.putDouble("droneCameraRotX", Mth.clamp(0.25f * xRot, -10, 10)); data.putDouble("droneCameraRotY", Mth.clamp(0.25f * yRot, -20, 10)); @@ -77,7 +80,7 @@ public class ClientEventHandler { handleWeaponCrossHair(living); handleWeaponSway(living); handleWeaponMove(living); - handleWeaponZoom(living); + handleWeaponZoom(); handlePlayerBreath(living); handleWeaponFire(event, living); handleShockCamera(event, living); @@ -173,37 +176,27 @@ public class ClientEventHandler { } private static void handleWeaponCrossHair(LivingEntity entity) { - if (entity.getMainHandItem().is(ModTags.Items.GUN)) { - float fps = Minecraft.getInstance().getFps(); - if (fps <= 30) { - fps = 30f; - } - float times = 90f / fps; - var data = entity.getPersistentData(); - ItemStack stack = entity.getMainHandItem(); - - boolean zoom = GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS; - - double spread = stack.getOrCreateTag().getDouble("spread"); - double zoomSpread = stack.getOrCreateTag().getDouble("zoomSpread"); - - double gunSpread = (float) (zoom ? zoomSpread : spread); - - if (data.getDouble("crosshair") > gunSpread) { - data.putDouble("crosshair", data.getDouble("crosshair") - 0.05 * Math.pow(gunSpread - data.getDouble("crosshair"), 2) * times); - } else { - data.putDouble("crosshair", data.getDouble("crosshair") + 0.05 * Math.pow(gunSpread - data.getDouble("crosshair"), 2) * times); - } - } +// if (entity.getMainHandItem().is(ModTags.Items.GUN)) { +// +// float times = 3 * Minecraft.getInstance().getDeltaFrameTime(); +// var data = entity.getPersistentData(); +// ItemStack stack = entity.getMainHandItem(); +// boolean zoom = GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS; +// double spread = stack.getOrCreateTag().getDouble("spread"); +// double zoomSpread = stack.getOrCreateTag().getDouble("zoomSpread"); +// double gunSpread = (float) (zoom ? zoomSpread : spread); +// +// if (data.getDouble("crosshair") > gunSpread) { +// data.putDouble("crosshair", data.getDouble("crosshair") - 0.05 * Math.pow(gunSpread - data.getDouble("crosshair"), 2) * times); +// } else { +// data.putDouble("crosshair", data.getDouble("crosshair") + 0.05 * Math.pow(gunSpread - data.getDouble("crosshair"), 2) * times); +// } +// } } private static void handleWeaponSway(LivingEntity entity) { if (entity.getMainHandItem().is(ModTags.Items.GUN)) { - float fps = Minecraft.getInstance().getFps(); - if (fps <= 30) { - fps = 30f; - } - float times = 90f / fps; + float times = 2 * Minecraft.getInstance().getDeltaFrameTime(); double pose; var data = entity.getPersistentData(); @@ -215,20 +208,15 @@ public class ClientEventHandler { pose = 1; } - data.putDouble("sway_time", data.getDouble("sway_time") + 0.015 * times); - data.putDouble("x", (pose * -0.008 * Math.sin(data.getDouble("sway_time")) * (1 - 0.95 * data.getDouble("zoom_time")))); - data.putDouble("y", (pose * 0.125 * Math.sin(data.getDouble("sway_time") - 1.585) * (1 - 0.95 * data.getDouble("zoom_time"))) - 3 * data.getDouble("gun_move_rotZ")); + data.putDouble("sway_time", data.getDouble("sway_time") + 0.05 * times); + data.putDouble("x", (pose * -0.008 * Math.sin(data.getDouble("sway_time")) * (1 - 0.95 * zoom_time))); + data.putDouble("y", (pose * 0.125 * Math.sin(data.getDouble("sway_time") - 1.585) * (1 - 0.95 * zoom_time)) - 3 * data.getDouble("gun_move_rotZ")); } } private static void handleWeaponMove(LivingEntity entity) { if (entity.getMainHandItem().is(ModTags.Items.GUN)) { - float fps = Minecraft.getInstance().getFps(); - if (fps <= 30) { - fps = 30f; - } - - float times = 90f / fps; + float times = 4.5f * Minecraft.getInstance().getDeltaFrameTime(); var data = entity.getPersistentData(); double move_speed = (float) Mth.clamp(entity.getDeltaMovement().horizontalDistanceSqr(), 0, 0.02); double on_ground; @@ -242,7 +230,7 @@ public class ClientEventHandler { on_ground = 0.001; } - if (Minecraft.getInstance().options.keyUp.isDown() && data.getDouble("firetime") == 0 && data.getDouble("zoom_time") == 0) { + if (Minecraft.getInstance().options.keyUp.isDown() && data.getDouble("firetime") == 0 && zoom_time == 0) { if (data.getDouble("gun_move_rotZ") < 0.14) { data.putDouble("gun_move_rotZ", data.getDouble("gun_move_rotZ") + 0.007 * times); } @@ -271,9 +259,9 @@ public class ClientEventHandler { data.putDouble("gun_moveX_time", 0); } - data.putDouble("gun_move_posY", -0.135 * Math.sin(2 * Math.PI * (data.getDouble("gun_moveY_time") - 0.25)) * (1 - 0.95 * data.getDouble("zoom_time"))); + data.putDouble("gun_move_posY", -0.135 * Math.sin(2 * Math.PI * (data.getDouble("gun_moveY_time") - 0.25)) * (1 - 0.95 * zoom_time)); - data.putDouble("gun_move_posX", 0.2 * Math.sin(1 * Math.PI * data.getDouble("gun_moveX_time")) * (1 - 0.95 * data.getDouble("zoom_time"))); + data.putDouble("gun_move_posX", 0.2 * Math.sin(1 * Math.PI * data.getDouble("gun_moveX_time")) * (1 - 0.95 * zoom_time)); } else { if (data.getDouble("gun_moveY_time") > 0.25) { @@ -289,79 +277,78 @@ public class ClientEventHandler { } if (data.getDouble("gun_move_posX") > 0) { - data.putDouble("gun_move_posX", data.getDouble("gun_move_posX") - 1.5 * (Math.pow(data.getDouble("gun_move_posX"), 2) * times) * (1 - 0.75 * data.getDouble("zoom_time"))); + data.putDouble("gun_move_posX", data.getDouble("gun_move_posX") - 1.5 * (Math.pow(data.getDouble("gun_move_posX"), 2) * times) * (1 - 0.75 * zoom_time)); } else { - data.putDouble("gun_move_posX", data.getDouble("gun_move_posX") + 1.5 * (Math.pow(data.getDouble("gun_move_posX"), 2) * times) * (1 - 0.75 * data.getDouble("zoom_time"))); + data.putDouble("gun_move_posX", data.getDouble("gun_move_posX") + 1.5 * (Math.pow(data.getDouble("gun_move_posX"), 2) * times) * (1 - 0.75 * zoom_time)); } if (data.getDouble("gun_move_posY") > 0) { - data.putDouble("gun_move_posY", data.getDouble("gun_move_posY") - 1.5 * (Math.pow(data.getDouble("gun_move_posY"), 2) * times) * (1 - 0.75 * data.getDouble("zoom_time"))); + data.putDouble("gun_move_posY", data.getDouble("gun_move_posY") - 1.5 * (Math.pow(data.getDouble("gun_move_posY"), 2) * times) * (1 - 0.75 * zoom_time)); } else { - data.putDouble("gun_move_posY", data.getDouble("gun_move_posY") + 1.5 * (Math.pow(data.getDouble("gun_move_posY"), 2) * times) * (1 - 0.75 * data.getDouble("zoom_time"))); + data.putDouble("gun_move_posY", data.getDouble("gun_move_posY") + 1.5 * (Math.pow(data.getDouble("gun_move_posY"), 2) * times) * (1 - 0.75 * zoom_time)); } } if (data.getDouble("move") < 0) { - data.putDouble("move", ((data.getDouble("move") + 1 * times * Math.pow(data.getDouble("move"), 2) * (1 - 0.6 * data.getDouble("zoom_time"))) - * (1 - 1 * data.getDouble("zoom_time")))); + data.putDouble("move", ((data.getDouble("move") + 1 * times * Math.pow(data.getDouble("move"), 2) * (1 - 0.6 * zoom_time)) + * (1 - 1 * zoom_time))); } else { - data.putDouble("move", ((data.getDouble("move") - 1 * times * Math.pow(data.getDouble("move"), 2) * (1 - 0.6 * data.getDouble("zoom_time"))) - * (1 - 1 * data.getDouble("zoom_time")))); + data.putDouble("move", ((data.getDouble("move") - 1 * times * Math.pow(data.getDouble("move"), 2) * (1 - 0.6 * zoom_time)) + * (1 - 1 * zoom_time))); } if (Minecraft.getInstance().options.keyRight.isDown()) { data.putDouble("move", - ((data.getDouble("move") + Math.pow(Math.abs(data.getDouble("move")) + 0.05, 2) * 0.2 * times * (1 - 0.1 * data.getDouble("zoom_time"))) - * (1 - 0.1 * data.getDouble("zoom_time")))); + ((data.getDouble("move") + Math.pow(Math.abs(data.getDouble("move")) + 0.05, 2) * 0.2 * times * (1 - 0.1 * zoom_time)) + * (1 - 0.1 * zoom_time))); } else if (Minecraft.getInstance().options.keyLeft.isDown()) { data.putDouble("move", - ((data.getDouble("move") - Math.pow(Math.abs(data.getDouble("move")) + 0.05, 2) * 0.2 * times * (1 - 0.1 * data.getDouble("zoom_time"))) - * (1 - 0.1 * data.getDouble("zoom_time")))); + ((data.getDouble("move") - Math.pow(Math.abs(data.getDouble("move")) + 0.05, 2) * 0.2 * times * (1 - 0.1 * zoom_time)) + * (1 - 0.1 * zoom_time))); } double velocity = entity.getDeltaMovement().y(); if (-0.8 < velocity + 0.078 && velocity + 0.078 < 0.8) { if (data.getDouble("vy") < entity.getDeltaMovement().y() + 0.078) { - data.putDouble("vy", Mth.clamp(((data.getDouble("vy") + 0.35 * Math.pow((velocity + 0.078) - data.getDouble("vy"), 2)) * (1 - 0.8 * data.getDouble("zoom_time"))), -0.8, 0.8)); + data.putDouble("vy", Mth.clamp(((data.getDouble("vy") + 0.35 * Math.pow((velocity + 0.078) - data.getDouble("vy"), 2)) * (1 - 0.8 * zoom_time)), -0.8, 0.8)); } else { - data.putDouble("vy", Mth.clamp(((data.getDouble("vy") - 0.35 * Math.pow((velocity + 0.078) - data.getDouble("vy"), 2)) * (1 - 0.8 * data.getDouble("zoom_time"))), -0.8, 0.8)); + data.putDouble("vy", Mth.clamp(((data.getDouble("vy") - 0.35 * Math.pow((velocity + 0.078) - data.getDouble("vy"), 2)) * (1 - 0.8 * zoom_time)), -0.8, 0.8)); } } } } - private static void handleWeaponZoom(LivingEntity entity) { - float fps = Minecraft.getInstance().getFps(); - if (fps <= 0) { - fps = 1f; - } - float times = 110f / fps; - var data = entity.getPersistentData(); - + private static void handleWeaponZoom() { + float times = 5 * Minecraft.getInstance().getDeltaFrameTime(); if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) { - data.putDouble("zoom_time", Mth.clamp(data.getDouble("zoom_time") + 0.03 * times,0,1)); + zoom_time = Mth.clamp(zoom_time + 0.03 * times,0,1); } else { - data.putDouble("zoom_time", Mth.clamp(data.getDouble("zoom_time") - 0.04 * times,0,1)); + zoom_time = Mth.clamp(zoom_time - 0.04 * times,0,1); } - data.putDouble("zoom_pos", (0.5 * Math.cos(Math.PI * Math.pow(Math.pow(data.getDouble("zoom_time"), 2) - 1, 2)) + 0.5)); - data.putDouble("zoom_pos_z", (-Math.pow(2 * data.getDouble("zoom_time") - 1, 2) + 1)); + zoom_pos = 0.5 * Math.cos(Math.PI * Math.pow(Math.pow(zoom_time, 2) - 1, 2)) + 0.5; + zoom_pos_z = -Math.pow(2 * zoom_time - 1, 2) + 1; + } + + public static double getZoom_time() { + return zoom_time; + } + + public static double getZoom_pos() { + return zoom_pos; + } + + public static double getZoom_pos_z() { + return zoom_pos_z; } private static void handleWeaponFire(ViewportEvent.ComputeCameraAngles event, LivingEntity entity) { + float times = 1.5f * Minecraft.getInstance().getDeltaFrameTime(); double yaw = event.getYaw(); double pitch = event.getPitch(); double roll = event.getRoll(); - double amplitude; - float fps = Minecraft.getInstance().getFps(); - if (fps <= 0) { - fps = 1f; - } - ItemStack stack = entity.getMainHandItem(); - - float times = 45f / fps; amplitude = 15000 * stack.getOrCreateTag().getDouble("recoil_y") * stack.getOrCreateTag().getDouble("recoil_x"); var data = entity.getPersistentData(); @@ -421,11 +408,7 @@ public class ClientEventHandler { } private static void handlePlayerBreath(LivingEntity entity) { - float fps = Minecraft.getInstance().getFps(); - if (fps <= 0) { - fps = 1f; - } - float times = 110f / fps; + float times = 4 * Minecraft.getInstance().getDeltaFrameTime(); var data = entity.getPersistentData(); if ((entity.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).breath) { @@ -459,12 +442,7 @@ public class ClientEventHandler { } private static void handleBowPullAnimation(LivingEntity entity) { - float fps = Minecraft.getInstance().getFps(); - if (fps <= 0) { - fps = 1f; - } - - float times = 90f / fps; + float times = 4 * Minecraft.getInstance().getDeltaFrameTime(); CompoundTag persistentData = entity.getPersistentData(); if ((entity.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).bowPull) { @@ -499,7 +477,7 @@ public class ClientEventHandler { return; } - double p = player.getPersistentData().getDouble("zoom_pos"); + double p = zoom_pos; double zoom = stack.getOrCreateTag().getDouble("zoom") + stack.getOrCreateTag().getDouble("custom_zoom"); event.setFOV(event.getFOV() / (1.0 + p * (zoom - 1)) * (1 - 0.4 * player.getPersistentData().getDouble("BreathTime"))); diff --git a/src/main/java/net/mcreator/superbwarfare/event/PlayerEventHandler.java b/src/main/java/net/mcreator/superbwarfare/event/PlayerEventHandler.java index f6221c83d..fdd559b22 100644 --- a/src/main/java/net/mcreator/superbwarfare/event/PlayerEventHandler.java +++ b/src/main/java/net/mcreator/superbwarfare/event/PlayerEventHandler.java @@ -9,7 +9,6 @@ import net.mcreator.superbwarfare.network.message.SimulationDistanceMessage; import net.mcreator.superbwarfare.tools.SoundTool; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; -import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundSource; @@ -19,10 +18,7 @@ import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.effect.MobEffects; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Items; -import net.minecraft.world.level.ClipContext; import net.minecraft.world.level.Level; -import net.minecraft.world.phys.Vec3; import net.minecraftforge.event.AnvilUpdateEvent; import net.minecraftforge.event.TickEvent; import net.minecraftforge.event.entity.player.PlayerEvent; @@ -30,8 +26,6 @@ import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.network.PacketDistributor; -import java.text.DecimalFormat; - @Mod.EventBusSubscriber public class PlayerEventHandler { @@ -94,7 +88,6 @@ public class PlayerEventHandler { } handleGround(player); - handleDistantRange(player); handleSimulationDistance(player); handleCannonTime(player); handleTacticalSprint(player); @@ -230,12 +223,6 @@ public class PlayerEventHandler { } private static void handleCannonTime(Player player) { - if (player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).cannonFiring > 0) { - player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { - capability.cannonFiring = player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).cannonFiring - 1; - capability.syncPlayerVariables(player); - }); - } if (player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).cannonRecoil > 0) { player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { capability.cannonRecoil = player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).cannonRecoil - 1; @@ -357,27 +344,6 @@ public class PlayerEventHandler { } } - /** - * 望远镜瞄准时显示距离 - */ - private static void handleDistantRange(Player player) { - ItemStack stack = player.getUseItem(); - if (stack.getItem() == Items.SPYGLASS) { - if (player.position().distanceTo((Vec3.atLowerCornerOf(player.level().clip( - new ClipContext(player.getEyePosition(), player.getEyePosition().add(player.getLookAngle().scale(1024)), - ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, player)).getBlockPos()))) <= 512) { - if (!player.level().isClientSide()) - player.displayClientMessage(Component.literal((new DecimalFormat("##.#") - .format(player.position().distanceTo((Vec3.atLowerCornerOf( - player.level().clip(new ClipContext(player.getEyePosition(), player.getEyePosition().add(player.getLookAngle().scale(768)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, player)).getBlockPos())))) - + "M")), true); - } else { - if (player.level().isClientSide()) - player.displayClientMessage(Component.literal("---M"), true); - } - } - } - private static void handleBocekPulling(Player player) { ItemStack mainHandItem = player.getMainHandItem(); CompoundTag tag = mainHandItem.getOrCreateTag(); diff --git a/src/main/java/net/mcreator/superbwarfare/network/ModVariables.java b/src/main/java/net/mcreator/superbwarfare/network/ModVariables.java index 9afa506d3..347a81654 100644 --- a/src/main/java/net/mcreator/superbwarfare/network/ModVariables.java +++ b/src/main/java/net/mcreator/superbwarfare/network/ModVariables.java @@ -73,7 +73,6 @@ public class ModVariables { clone.recoil = original.recoil; clone.recoilHorizon = original.recoilHorizon; clone.firing = original.firing; - clone.cannonFiring = original.cannonFiring; clone.rifleAmmo = original.rifleAmmo; clone.handgunAmmo = original.handgunAmmo; clone.shotgunAmmo = original.shotgunAmmo; @@ -264,7 +263,6 @@ public class ModVariables { public double recoil = 0; public double recoilHorizon = 0; public double firing = 0; - public double cannonFiring = 0; public int cannonRecoil = 0; public int rifleAmmo = 0; @@ -293,7 +291,6 @@ public class ModVariables { nbt.putDouble("recoil", recoil); nbt.putDouble("recoil_horizon", recoilHorizon); nbt.putDouble("firing", firing); - nbt.putDouble("cannonFiring", cannonFiring); nbt.putInt("cannonRecoil", cannonRecoil); nbt.putInt("rifle_ammo", rifleAmmo); nbt.putInt("handgun_ammo", handgunAmmo); @@ -318,7 +315,6 @@ public class ModVariables { recoil = nbt.getDouble("recoil"); recoilHorizon = nbt.getDouble("recoil_horizon"); firing = nbt.getDouble("firing"); - cannonFiring = nbt.getDouble("cannonFiring"); cannonRecoil = nbt.getInt("cannonRecoil"); rifleAmmo = nbt.getInt("rifle_ammo"); handgunAmmo = nbt.getInt("handgun_ammo"); @@ -374,7 +370,6 @@ public class ModVariables { variables.recoil = message.data.recoil; variables.recoilHorizon = message.data.recoilHorizon; variables.firing = message.data.firing; - variables.cannonFiring = message.data.cannonFiring; variables.cannonRecoil = message.data.cannonRecoil; variables.rifleAmmo = message.data.rifleAmmo; variables.handgunAmmo = message.data.handgunAmmo;