diff --git a/src/main/java/com/atsuishio/superbwarfare/client/AnimationHelper.java b/src/main/java/com/atsuishio/superbwarfare/client/AnimationHelper.java index 9a1b168c0..69bc18494 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/AnimationHelper.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/AnimationHelper.java @@ -1,8 +1,7 @@ package com.atsuishio.superbwarfare.client; import com.atsuishio.superbwarfare.event.ClientEventHandler; -import com.atsuishio.superbwarfare.tools.GunsTool; -import com.atsuishio.superbwarfare.tools.NBTTool; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import net.minecraft.client.Minecraft; @@ -83,7 +82,8 @@ public class AnimationHelper { } public static void handleReloadShakeAnimation(ItemStack stack, GeoBone main, GeoBone camera, float roll, float pitch) { - if (GunsTool.getGunIntTag(NBTTool.getTag(stack), "ReloadTime") > 0) { + var data = GunData.from(stack); + if (data.reload.time() > 0) { main.setRotX(roll * main.getRotX()); main.setRotY(roll * main.getRotY()); main.setRotZ(roll * main.getRotZ()); diff --git a/src/main/java/com/atsuishio/superbwarfare/client/ClickHandler.java b/src/main/java/com/atsuishio/superbwarfare/client/ClickHandler.java index 15b268862..081317196 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/ClickHandler.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/ClickHandler.java @@ -9,11 +9,10 @@ import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity; import com.atsuishio.superbwarfare.entity.vehicle.base.WeaponVehicleEntity; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.*; -import com.atsuishio.superbwarfare.item.gun.GunData; import com.atsuishio.superbwarfare.item.gun.GunItem; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.network.message.send.*; import com.atsuishio.superbwarfare.perk.PerkHelper; -import com.atsuishio.superbwarfare.tools.GunsTool; import com.atsuishio.superbwarfare.tools.NBTTool; import com.atsuishio.superbwarfare.tools.SeekTool; import com.atsuishio.superbwarfare.tools.TraceTool; @@ -337,16 +336,14 @@ public class ClickHandler { var tag = data.tag(); player.playSound(ModSounds.TRIGGER_CLICK.get(), 1, 1); - if (!gunItem.useBackpackAmmo(stack) && data.ammo() <= 0 && GunsTool.getGunIntTag(tag, "ReloadTime") == 0) { + if (!gunItem.useBackpackAmmo(stack) && data.ammo() <= 0 && data.reload.time() == 0) { if (ReloadConfig.LEFT_CLICK_RELOAD.get()) { PacketDistributor.sendToServer(new ReloadMessage(0)); ClientEventHandler.burstFireAmount = 0; } } else { PacketDistributor.sendToServer(new FireMessage(0)); - if ((!data.reloading() && !data.charging() - && !GunsTool.getGunBooleanTag(tag, "NeedBoltAction") - ) && drawTime < 0.01) { + if ((!data.reloading() && !data.charging() && !data.bolt.needed()) && drawTime < 0.01) { if (data.fireMode() == 1) { if (ClientEventHandler.burstFireAmount == 0) { ClientEventHandler.burstFireAmount = data.burstAmount(); diff --git a/src/main/java/com/atsuishio/superbwarfare/client/PoseTool.java b/src/main/java/com/atsuishio/superbwarfare/client/PoseTool.java index eaffa1f72..10f1657d5 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/PoseTool.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/PoseTool.java @@ -1,7 +1,7 @@ package com.atsuishio.superbwarfare.client; -import com.atsuishio.superbwarfare.item.gun.GunData; import com.atsuishio.superbwarfare.item.gun.GunItem; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import net.minecraft.client.model.HumanoidModel; import net.minecraft.world.InteractionHand; import net.minecraft.world.entity.LivingEntity; diff --git a/src/main/java/com/atsuishio/superbwarfare/client/model/item/AK12ItemModel.java b/src/main/java/com/atsuishio/superbwarfare/client/model/item/AK12ItemModel.java index a94b4b0b0..6093f761e 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/model/item/AK12ItemModel.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/model/item/AK12ItemModel.java @@ -5,7 +5,7 @@ import com.atsuishio.superbwarfare.client.AnimationHelper; import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.item.gun.rifle.AK12Item; import com.atsuishio.superbwarfare.tools.GunsTool; import net.minecraft.client.Minecraft; diff --git a/src/main/java/com/atsuishio/superbwarfare/client/model/item/AK47ItemModel.java b/src/main/java/com/atsuishio/superbwarfare/client/model/item/AK47ItemModel.java index 40f968c56..d613490e7 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/model/item/AK47ItemModel.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/model/item/AK47ItemModel.java @@ -5,7 +5,7 @@ import com.atsuishio.superbwarfare.client.AnimationHelper; import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.item.gun.rifle.AK47Item; import com.atsuishio.superbwarfare.tools.GunsTool; import net.minecraft.client.Minecraft; diff --git a/src/main/java/com/atsuishio/superbwarfare/client/model/item/BocekItemModel.java b/src/main/java/com/atsuishio/superbwarfare/client/model/item/BocekItemModel.java index bbfe71caa..3bd5de1ee 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/model/item/BocekItemModel.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/model/item/BocekItemModel.java @@ -4,7 +4,7 @@ import com.atsuishio.superbwarfare.Mod; import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.item.gun.special.BocekItem; import net.minecraft.client.Minecraft; import net.minecraft.resources.ResourceLocation; diff --git a/src/main/java/com/atsuishio/superbwarfare/client/model/item/DevotionItemModel.java b/src/main/java/com/atsuishio/superbwarfare/client/model/item/DevotionItemModel.java index 98ddba729..5f03e5e6c 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/model/item/DevotionItemModel.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/model/item/DevotionItemModel.java @@ -5,7 +5,7 @@ import com.atsuishio.superbwarfare.client.AnimationHelper; import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.item.gun.machinegun.DevotionItem; import net.minecraft.client.Minecraft; import net.minecraft.resources.ResourceLocation; diff --git a/src/main/java/com/atsuishio/superbwarfare/client/model/item/Glock17ItemModel.java b/src/main/java/com/atsuishio/superbwarfare/client/model/item/Glock17ItemModel.java index 13147889f..2c9a1d3d3 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/model/item/Glock17ItemModel.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/model/item/Glock17ItemModel.java @@ -5,7 +5,7 @@ import com.atsuishio.superbwarfare.client.AnimationHelper; import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.item.gun.handgun.Glock17Item; import com.atsuishio.superbwarfare.tools.GunsTool; import net.minecraft.client.Minecraft; @@ -106,7 +106,7 @@ public class Glock17ItemModel extends GeoModel { var data = GunData.from(stack); var tag = data.tag(); - if (GunsTool.getGunIntTag(tag, "ReloadTime") > 0) { + if (data.reload.time() > 0) { main.setRotX(numR * main.getRotX()); main.setRotY(numR * main.getRotY()); main.setRotZ(numR * main.getRotZ()); diff --git a/src/main/java/com/atsuishio/superbwarfare/client/model/item/Glock18ItemModel.java b/src/main/java/com/atsuishio/superbwarfare/client/model/item/Glock18ItemModel.java index 2115fd928..1f58972ea 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/model/item/Glock18ItemModel.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/model/item/Glock18ItemModel.java @@ -5,7 +5,7 @@ import com.atsuishio.superbwarfare.client.AnimationHelper; import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.item.gun.handgun.Glock18Item; import com.atsuishio.superbwarfare.tools.GunsTool; import net.minecraft.client.Minecraft; @@ -115,7 +115,7 @@ public class Glock18ItemModel extends GeoModel { float numR = (float) (1 - 0.12 * zt); float numP = (float) (1 - 0.68 * zt); - if (GunsTool.getGunIntTag(tag, "ReloadTime") > 0) { + if (data.reload.time() > 0) { main.setRotX(numR * main.getRotX()); main.setRotY(numR * main.getRotY()); main.setRotZ(numR * main.getRotZ()); diff --git a/src/main/java/com/atsuishio/superbwarfare/client/model/item/Hk416ItemModel.java b/src/main/java/com/atsuishio/superbwarfare/client/model/item/Hk416ItemModel.java index 988c73b40..63a60f172 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/model/item/Hk416ItemModel.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/model/item/Hk416ItemModel.java @@ -5,7 +5,7 @@ import com.atsuishio.superbwarfare.client.AnimationHelper; import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.item.gun.rifle.Hk416Item; import com.atsuishio.superbwarfare.tools.GunsTool; import net.minecraft.client.Minecraft; diff --git a/src/main/java/com/atsuishio/superbwarfare/client/model/item/InsidiousItemModel.java b/src/main/java/com/atsuishio/superbwarfare/client/model/item/InsidiousItemModel.java index ad164af60..b13aca589 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/model/item/InsidiousItemModel.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/model/item/InsidiousItemModel.java @@ -5,7 +5,7 @@ import com.atsuishio.superbwarfare.client.AnimationHelper; import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.item.gun.rifle.InsidiousItem; import net.minecraft.client.Minecraft; import net.minecraft.resources.ResourceLocation; diff --git a/src/main/java/com/atsuishio/superbwarfare/client/model/item/JavelinItemModel.java b/src/main/java/com/atsuishio/superbwarfare/client/model/item/JavelinItemModel.java index a6b007525..d7d7face6 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/model/item/JavelinItemModel.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/model/item/JavelinItemModel.java @@ -4,7 +4,7 @@ import com.atsuishio.superbwarfare.Mod; import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.item.gun.launcher.JavelinItem; import net.minecraft.client.Minecraft; import net.minecraft.resources.ResourceLocation; diff --git a/src/main/java/com/atsuishio/superbwarfare/client/model/item/K98ItemModel.java b/src/main/java/com/atsuishio/superbwarfare/client/model/item/K98ItemModel.java index 6dc587277..f92616a53 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/model/item/K98ItemModel.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/model/item/K98ItemModel.java @@ -4,9 +4,8 @@ import com.atsuishio.superbwarfare.Mod; import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.item.gun.sniper.K98Item; -import com.atsuishio.superbwarfare.tools.GunsTool; import net.minecraft.client.Minecraft; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Mth; @@ -109,7 +108,7 @@ public class K98ItemModel extends GeoModel { float numR = (float) (1 - 0.52 * zt); float numP = (float) (1 - 0.58 * zt); - if (GunsTool.getGunIntTag(tag, "ReloadTime") > 0 || data.reloading()) { + if (data.reload.time() > 0 || data.reloading()) { main.setRotX(numR * main.getRotX()); main.setRotY(numR * main.getRotY()); main.setRotZ(numR * main.getRotZ()); diff --git a/src/main/java/com/atsuishio/superbwarfare/client/model/item/M1911ItemModel.java b/src/main/java/com/atsuishio/superbwarfare/client/model/item/M1911ItemModel.java index e394a642c..6e4e414cc 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/model/item/M1911ItemModel.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/model/item/M1911ItemModel.java @@ -5,7 +5,7 @@ import com.atsuishio.superbwarfare.client.AnimationHelper; import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.item.gun.handgun.M1911Item; import com.atsuishio.superbwarfare.tools.GunsTool; import net.minecraft.client.Minecraft; @@ -107,7 +107,7 @@ public class M1911ItemModel extends GeoModel { var data = GunData.from(stack); var tag = data.tag(); - if (GunsTool.getGunIntTag(tag, "ReloadTime") > 0) { + if (data.reload.time() > 0) { main.setRotX(numR * main.getRotX()); main.setRotY(numR * main.getRotY()); main.setRotZ(numR * main.getRotZ()); diff --git a/src/main/java/com/atsuishio/superbwarfare/client/model/item/M4ItemModel.java b/src/main/java/com/atsuishio/superbwarfare/client/model/item/M4ItemModel.java index 8303d53f8..845735cad 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/model/item/M4ItemModel.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/model/item/M4ItemModel.java @@ -5,7 +5,7 @@ import com.atsuishio.superbwarfare.client.AnimationHelper; import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.item.gun.rifle.M4Item; import com.atsuishio.superbwarfare.tools.GunsTool; import com.atsuishio.superbwarfare.tools.NBTTool; diff --git a/src/main/java/com/atsuishio/superbwarfare/client/model/item/M60ItemModel.java b/src/main/java/com/atsuishio/superbwarfare/client/model/item/M60ItemModel.java index 37a0a03d7..db8448969 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/model/item/M60ItemModel.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/model/item/M60ItemModel.java @@ -5,7 +5,7 @@ import com.atsuishio.superbwarfare.client.AnimationHelper; import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.item.gun.machinegun.M60Item; import com.atsuishio.superbwarfare.tools.GunsTool; import net.minecraft.client.Minecraft; @@ -154,7 +154,7 @@ public class M60ItemModel extends GeoModel { AnimationHelper.handleShellsAnimation(getAnimationProcessor(), 1f, 0.45f); GeoBone shell = getAnimationProcessor().getBone("shell"); - if (GunsTool.getGunIntTag(tag, "ReloadTime") > 0) { + if (data.reload.time() > 0) { main.setRotX(numR * main.getRotX()); main.setRotY(numR * main.getRotY()); main.setRotZ(numR * main.getRotZ()); diff --git a/src/main/java/com/atsuishio/superbwarfare/client/model/item/M870ItemModel.java b/src/main/java/com/atsuishio/superbwarfare/client/model/item/M870ItemModel.java index efc04f967..7790783b1 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/model/item/M870ItemModel.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/model/item/M870ItemModel.java @@ -4,7 +4,7 @@ import com.atsuishio.superbwarfare.Mod; import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.item.gun.shotgun.M870Item; import net.minecraft.client.Minecraft; import net.minecraft.resources.ResourceLocation; diff --git a/src/main/java/com/atsuishio/superbwarfare/client/model/item/M98bItemModel.java b/src/main/java/com/atsuishio/superbwarfare/client/model/item/M98bItemModel.java index 5f2caf2b9..e26b1260e 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/model/item/M98bItemModel.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/model/item/M98bItemModel.java @@ -4,9 +4,8 @@ import com.atsuishio.superbwarfare.Mod; import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.item.gun.sniper.M98bItem; -import com.atsuishio.superbwarfare.tools.GunsTool; import net.minecraft.client.Minecraft; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Mth; @@ -108,7 +107,7 @@ public class M98bItemModel extends GeoModel { float numR = (float) (1 - 0.88 * zt); float numP = (float) (1 - 0.68 * zt); - if (GunsTool.getGunIntTag(tag, "ReloadTime") > 0) { + if (data.reload.time() > 0) { main.setRotX(numR * main.getRotX()); main.setRotY(numR * main.getRotY()); main.setRotZ(numR * main.getRotZ()); diff --git a/src/main/java/com/atsuishio/superbwarfare/client/model/item/MarlinItemModel.java b/src/main/java/com/atsuishio/superbwarfare/client/model/item/MarlinItemModel.java index 92abfd48b..cb4c681fa 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/model/item/MarlinItemModel.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/model/item/MarlinItemModel.java @@ -4,7 +4,7 @@ import com.atsuishio.superbwarfare.Mod; import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.item.gun.rifle.MarlinItem; import com.atsuishio.superbwarfare.tools.NBTTool; import net.minecraft.client.Minecraft; diff --git a/src/main/java/com/atsuishio/superbwarfare/client/model/item/MinigunItemModel.java b/src/main/java/com/atsuishio/superbwarfare/client/model/item/MinigunItemModel.java index c42fea38b..968aad83d 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/model/item/MinigunItemModel.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/model/item/MinigunItemModel.java @@ -4,7 +4,7 @@ import com.atsuishio.superbwarfare.Mod; import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.item.gun.machinegun.MinigunItem; import net.minecraft.client.Minecraft; import net.minecraft.resources.ResourceLocation; diff --git a/src/main/java/com/atsuishio/superbwarfare/client/model/item/Mk14ItemModel.java b/src/main/java/com/atsuishio/superbwarfare/client/model/item/Mk14ItemModel.java index 241b775e8..de7e216e5 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/model/item/Mk14ItemModel.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/model/item/Mk14ItemModel.java @@ -5,7 +5,7 @@ import com.atsuishio.superbwarfare.client.AnimationHelper; import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.item.gun.rifle.Mk14Item; import com.atsuishio.superbwarfare.tools.GunsTool; import net.minecraft.client.Minecraft; diff --git a/src/main/java/com/atsuishio/superbwarfare/client/model/item/MosinNagantItemModel.java b/src/main/java/com/atsuishio/superbwarfare/client/model/item/MosinNagantItemModel.java index 5e333ab09..ad60831e9 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/model/item/MosinNagantItemModel.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/model/item/MosinNagantItemModel.java @@ -4,9 +4,8 @@ import com.atsuishio.superbwarfare.Mod; import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.item.gun.sniper.MosinNagantItem; -import com.atsuishio.superbwarfare.tools.GunsTool; import net.minecraft.client.Minecraft; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Mth; @@ -125,7 +124,7 @@ public class MosinNagantItemModel extends GeoModel { float numR = (float) (1 - 0.97 * zt); float numP = (float) (1 - 0.81 * zt); - if (data.reloading() || GunsTool.getGunIntTag(tag, "BoltActionTick") > 0) { + if (data.reloading() || data.bolt.actionTime() > 0) { main.setRotX(numR * main.getRotX()); main.setRotY(numR * main.getRotY()); main.setRotZ(numR * main.getRotZ()); diff --git a/src/main/java/com/atsuishio/superbwarfare/client/model/item/Mp443ItemModel.java b/src/main/java/com/atsuishio/superbwarfare/client/model/item/Mp443ItemModel.java index f838e91ff..394eb5611 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/model/item/Mp443ItemModel.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/model/item/Mp443ItemModel.java @@ -5,7 +5,7 @@ import com.atsuishio.superbwarfare.client.AnimationHelper; import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.item.gun.handgun.Mp443Item; import com.atsuishio.superbwarfare.tools.GunsTool; import net.minecraft.client.Minecraft; @@ -104,7 +104,7 @@ public class Mp443ItemModel extends GeoModel { var data = GunData.from(stack); var tag = data.tag(); - if (GunsTool.getGunIntTag(tag, "ReloadTime") > 0) { + if (data.reload.time() > 0) { main.setRotX(numR * main.getRotX()); main.setRotY(numR * main.getRotY()); main.setRotZ(numR * main.getRotZ()); diff --git a/src/main/java/com/atsuishio/superbwarfare/client/model/item/Ntw20Model.java b/src/main/java/com/atsuishio/superbwarfare/client/model/item/Ntw20Model.java index 4dec8bd68..03b42b830 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/model/item/Ntw20Model.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/model/item/Ntw20Model.java @@ -4,7 +4,7 @@ import com.atsuishio.superbwarfare.Mod; import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.item.gun.heavy.Ntw20Item; import com.atsuishio.superbwarfare.tools.GunsTool; import net.minecraft.client.Minecraft; @@ -164,7 +164,7 @@ public class Ntw20Model extends GeoModel { float numR = (float) (1 - 0.92 * zt); float numP = (float) (1 - 0.88 * zt); - if (GunsTool.getGunIntTag(tag, "ReloadTime") > 0 || GunsTool.getGunIntTag(tag, "BoltActionTick") > 0) { + if (data.reload.time() > 0 || data.bolt.actionTime() > 0) { main.setRotX(numR * main.getRotX()); main.setRotY(numR * main.getRotY()); main.setRotZ(numR * main.getRotZ()); diff --git a/src/main/java/com/atsuishio/superbwarfare/client/model/item/Qbz95ItemModel.java b/src/main/java/com/atsuishio/superbwarfare/client/model/item/Qbz95ItemModel.java index 87da8a874..5b81326cd 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/model/item/Qbz95ItemModel.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/model/item/Qbz95ItemModel.java @@ -5,7 +5,7 @@ import com.atsuishio.superbwarfare.client.AnimationHelper; import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.item.gun.rifle.Qbz95Item; import com.atsuishio.superbwarfare.tools.GunsTool; import com.atsuishio.superbwarfare.tools.NBTTool; @@ -204,7 +204,7 @@ public class Qbz95ItemModel extends GeoModel { lHandRotZ = Mth.lerp(1.5f * times, lHandRotZ, isZooming ? 2.9228f : leftHand.getRotZ()); - if (GunData.from(stack).emptyReloading()) { + if (GunData.from(stack).reload.empty()) { leftHand.setPosX(lHandPosX); leftHand.setPosY(lHandPosY); leftHand.setPosZ(lHandPosZ); diff --git a/src/main/java/com/atsuishio/superbwarfare/client/model/item/RpgItemModel.java b/src/main/java/com/atsuishio/superbwarfare/client/model/item/RpgItemModel.java index 263c8c704..c755ae7cd 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/model/item/RpgItemModel.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/model/item/RpgItemModel.java @@ -5,7 +5,7 @@ import com.atsuishio.superbwarfare.client.AnimationHelper; import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.item.gun.launcher.RpgItem; import com.atsuishio.superbwarfare.tools.GunsTool; import net.minecraft.client.Minecraft; diff --git a/src/main/java/com/atsuishio/superbwarfare/client/model/item/RpkItemModel.java b/src/main/java/com/atsuishio/superbwarfare/client/model/item/RpkItemModel.java index 78f883dc8..43d1d6bfa 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/model/item/RpkItemModel.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/model/item/RpkItemModel.java @@ -5,7 +5,7 @@ import com.atsuishio.superbwarfare.client.AnimationHelper; import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.item.gun.machinegun.RpkItem; import com.atsuishio.superbwarfare.tools.GunsTool; import net.minecraft.client.Minecraft; diff --git a/src/main/java/com/atsuishio/superbwarfare/client/model/item/SecondaryCataclysmModel.java b/src/main/java/com/atsuishio/superbwarfare/client/model/item/SecondaryCataclysmModel.java index ae21bfdad..71f2d8b9f 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/model/item/SecondaryCataclysmModel.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/model/item/SecondaryCataclysmModel.java @@ -4,9 +4,8 @@ import com.atsuishio.superbwarfare.Mod; import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.item.gun.launcher.SecondaryCataclysm; -import com.atsuishio.superbwarfare.tools.GunsTool; import net.minecraft.client.Minecraft; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Mth; @@ -102,7 +101,7 @@ public class SecondaryCataclysmModel extends GeoModel { var data = GunData.from(stack); var tag = data.tag(); - if (GunsTool.getGunIntTag(tag, "ReloadTime") > 0) { + if (data.reload.time() > 0) { main.setRotX(numR * main.getRotX()); main.setRotY(numR * main.getRotY()); main.setRotZ(numR * main.getRotZ()); diff --git a/src/main/java/com/atsuishio/superbwarfare/client/model/item/SentinelItemModel.java b/src/main/java/com/atsuishio/superbwarfare/client/model/item/SentinelItemModel.java index 9ebbf2be0..a264c2ede 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/model/item/SentinelItemModel.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/model/item/SentinelItemModel.java @@ -4,9 +4,8 @@ import com.atsuishio.superbwarfare.Mod; import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.item.gun.sniper.SentinelItem; -import com.atsuishio.superbwarfare.tools.GunsTool; import net.minecraft.client.Minecraft; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Mth; @@ -118,7 +117,7 @@ public class SentinelItemModel extends GeoModel { float numR = (float) (1 - 0.9 * zt); float numP = (float) (1 - 0.98 * zt); - if (GunsTool.getGunIntTag(tag, "ReloadTime") > 0 || data.charging()) { + if (data.reload.time() > 0 || data.charging()) { main.setRotX(numR * main.getRotX()); main.setRotY(numR * main.getRotY()); main.setRotZ(numR * main.getRotZ()); diff --git a/src/main/java/com/atsuishio/superbwarfare/client/model/item/SksItemModel.java b/src/main/java/com/atsuishio/superbwarfare/client/model/item/SksItemModel.java index f349ae4dd..30a123e63 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/model/item/SksItemModel.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/model/item/SksItemModel.java @@ -5,7 +5,7 @@ import com.atsuishio.superbwarfare.client.AnimationHelper; import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.item.gun.rifle.SksItem; import com.atsuishio.superbwarfare.tools.GunsTool; import net.minecraft.client.Minecraft; diff --git a/src/main/java/com/atsuishio/superbwarfare/client/model/item/SvdItemModel.java b/src/main/java/com/atsuishio/superbwarfare/client/model/item/SvdItemModel.java index 888b75c69..82fa2f9b0 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/model/item/SvdItemModel.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/model/item/SvdItemModel.java @@ -5,7 +5,7 @@ import com.atsuishio.superbwarfare.client.AnimationHelper; import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.item.gun.sniper.SvdItem; import com.atsuishio.superbwarfare.tools.GunsTool; import net.minecraft.client.Minecraft; diff --git a/src/main/java/com/atsuishio/superbwarfare/client/model/item/TracheliumItemModel.java b/src/main/java/com/atsuishio/superbwarfare/client/model/item/TracheliumItemModel.java index ffc9fd6ff..c60f7276d 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/model/item/TracheliumItemModel.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/model/item/TracheliumItemModel.java @@ -5,7 +5,7 @@ import com.atsuishio.superbwarfare.client.AnimationHelper; import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.item.gun.handgun.Trachelium; import com.atsuishio.superbwarfare.tools.GunsTool; import com.atsuishio.superbwarfare.tools.NBTTool; @@ -165,7 +165,7 @@ public class TracheliumItemModel extends GeoModel { ammo.setRotZ(60 * Mth.DEG_TO_RAD * (float) ClientEventHandler.revolverWheelPreTime); ammohole.setRotZ(-60 * Mth.DEG_TO_RAD * (float) ClientEventHandler.revolverWheelPreTime); - if (GunData.from(stack).emptyReloading()) { + if (GunData.from(stack).reload.empty()) { lun.setRotZ(0); ammo.setRotZ(0); ammohole.setRotZ(0); diff --git a/src/main/java/com/atsuishio/superbwarfare/client/model/item/VectorItemModel.java b/src/main/java/com/atsuishio/superbwarfare/client/model/item/VectorItemModel.java index 04a56b1c0..c3617951e 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/model/item/VectorItemModel.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/model/item/VectorItemModel.java @@ -5,7 +5,7 @@ import com.atsuishio.superbwarfare.client.AnimationHelper; import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.item.gun.smg.VectorItem; import com.atsuishio.superbwarfare.tools.GunsTool; import net.minecraft.client.Minecraft; diff --git a/src/main/java/com/atsuishio/superbwarfare/client/overlay/AmmoBarOverlay.java b/src/main/java/com/atsuishio/superbwarfare/client/overlay/AmmoBarOverlay.java index b9c9b624d..9c9dbc7eb 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/overlay/AmmoBarOverlay.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/overlay/AmmoBarOverlay.java @@ -9,8 +9,8 @@ import com.atsuishio.superbwarfare.init.ModItems; import com.atsuishio.superbwarfare.init.ModKeyMappings; import com.atsuishio.superbwarfare.init.ModTags; import com.atsuishio.superbwarfare.item.common.ammo.AmmoSupplierItem; -import com.atsuishio.superbwarfare.item.gun.GunData; import com.atsuishio.superbwarfare.item.gun.GunItem; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.tools.AmmoType; import com.atsuishio.superbwarfare.tools.GunsTool; import com.atsuishio.superbwarfare.tools.InventoryTool; diff --git a/src/main/java/com/atsuishio/superbwarfare/client/overlay/JavelinHudOverlay.java b/src/main/java/com/atsuishio/superbwarfare/client/overlay/JavelinHudOverlay.java index 800d50a8b..2cdb13019 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/overlay/JavelinHudOverlay.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/overlay/JavelinHudOverlay.java @@ -6,7 +6,7 @@ import com.atsuishio.superbwarfare.client.RenderHelper; import com.atsuishio.superbwarfare.entity.vehicle.base.ArmedVehicleEntity; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModItems; -import com.atsuishio.superbwarfare.item.gun.GunData; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.tools.EntityFindUtil; import com.atsuishio.superbwarfare.tools.NBTTool; import com.atsuishio.superbwarfare.tools.SeekTool; diff --git a/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/RpkItemRenderer.java b/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/RpkItemRenderer.java index 2d29f8958..db58a2c2f 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/RpkItemRenderer.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/RpkItemRenderer.java @@ -5,7 +5,7 @@ import com.atsuishio.superbwarfare.client.ItemModelHelper; import com.atsuishio.superbwarfare.client.model.item.RpkItemModel; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.item.gun.machinegun.RpkItem; import com.atsuishio.superbwarfare.tools.GunsTool; import com.mojang.blaze3d.vertex.PoseStack; diff --git a/src/main/java/com/atsuishio/superbwarfare/client/tooltip/ClientGunImageTooltip.java b/src/main/java/com/atsuishio/superbwarfare/client/tooltip/ClientGunImageTooltip.java index 138c34236..0d4db2a72 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/tooltip/ClientGunImageTooltip.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/tooltip/ClientGunImageTooltip.java @@ -4,8 +4,8 @@ import com.atsuishio.superbwarfare.client.TooltipTool; import com.atsuishio.superbwarfare.client.tooltip.component.GunImageComponent; import com.atsuishio.superbwarfare.init.ModKeyMappings; import com.atsuishio.superbwarfare.init.ModPerks; -import com.atsuishio.superbwarfare.item.gun.GunData; import com.atsuishio.superbwarfare.item.gun.GunItem; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.perk.AmmoPerk; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; diff --git a/src/main/java/com/atsuishio/superbwarfare/event/ClientEventHandler.java b/src/main/java/com/atsuishio/superbwarfare/event/ClientEventHandler.java index 4ac95f8a8..5020c6da0 100644 --- a/src/main/java/com/atsuishio/superbwarfare/event/ClientEventHandler.java +++ b/src/main/java/com/atsuishio/superbwarfare/event/ClientEventHandler.java @@ -10,8 +10,8 @@ import com.atsuishio.superbwarfare.entity.vehicle.base.MobileVehicleEntity; import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity; import com.atsuishio.superbwarfare.entity.vehicle.base.WeaponVehicleEntity; import com.atsuishio.superbwarfare.init.*; -import com.atsuishio.superbwarfare.item.gun.GunData; import com.atsuishio.superbwarfare.item.gun.GunItem; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.network.message.send.*; import com.atsuishio.superbwarfare.perk.AmmoPerk; import com.atsuishio.superbwarfare.perk.Perk; @@ -311,7 +311,7 @@ public class ClientEventHandler { && !holdFireVehicle && !notInGame() && cap != null && !cap.edit - && !(data.normalReloading() || data.emptyReloading()) + && !(data.reload.normal() || data.reload.empty()) && !data.reloading() && !data.charging() && !player.getCooldowns().isOnCooldown(stack.getItem()) @@ -456,7 +456,7 @@ public class ClientEventHandler { //左轮类 if (clientTimer.getProgress() == 0 && stack.is(ModTags.Items.REVOLVER) && ((holdFire && !tag.getBoolean("DA")) - || (GunsTool.getGunIntTag(tag, "BoltActionTick") < 7 && GunsTool.getGunIntTag(tag, "BoltActionTick") > 2) || tag.getBoolean("canImmediatelyShoot"))) { + || (data.bolt.actionTime() < 7 && data.bolt.actionTime() > 2) || tag.getBoolean("canImmediatelyShoot"))) { revolverPreTime = Mth.clamp(revolverPreTime + 0.3 * times, 0, 1); revolverWheelPreTime = Mth.clamp(revolverWheelPreTime + 0.32 * times, 0, revolverPreTime > 0.7 ? 1 : 0.55); } else if (!tag.getBoolean("DA") && !tag.getBoolean("canImmediatelyShoot")) { @@ -473,12 +473,12 @@ public class ClientEventHandler { && drawTime < 0.01 && cap != null && !cap.edit && !notInGame() - && (!(data.normalReloading() || data.emptyReloading()) + && (!(data.reload.normal() || data.reload.empty()) && !data.reloading() && !data.charging() && data.ammo() > 0 && !player.getCooldowns().isOnCooldown(stack.getItem()) - && !GunsTool.getGunBooleanTag(tag, "NeedBoltAction") + && !data.bolt.needed() && revolverPre(tag)) || (stack.is(ModItems.MINIGUN.get()) && !player.isSprinting() @@ -521,7 +521,7 @@ public class ClientEventHandler { clientTimer.stop(); } - if (stack.getItem() == ModItems.DEVOTION.get() && (data.normalReloading() || data.emptyReloading())) { + if (stack.getItem() == ModItems.DEVOTION.get() && (data.reload.normal() || data.reload.empty())) { customRpm = 0; } @@ -586,8 +586,8 @@ public class ClientEventHandler { } // 判断是否为栓动武器(BoltActionTime > 0),并在开火后给一个需要上膛的状态 - if (data.boltActionTime() > 0 && data.ammo() > (stack.is(ModTags.Items.REVOLVER) ? 0 : 1)) { - GunsTool.setGunBooleanTag(tag, "NeedBoltAction", true); + if (data.bolt.defaultActionTime() > 0 && data.ammo() > (stack.is(ModTags.Items.REVOLVER) ? 0 : 1)) { + data.bolt.markNeeded(); } revolverPreTime = 0; diff --git a/src/main/java/com/atsuishio/superbwarfare/event/ClientMouseHandler.java b/src/main/java/com/atsuishio/superbwarfare/event/ClientMouseHandler.java index 201f9e9d2..887cedc53 100644 --- a/src/main/java/com/atsuishio/superbwarfare/event/ClientMouseHandler.java +++ b/src/main/java/com/atsuishio/superbwarfare/event/ClientMouseHandler.java @@ -7,7 +7,7 @@ import com.atsuishio.superbwarfare.entity.vehicle.base.CannonEntity; import com.atsuishio.superbwarfare.init.ModItems; import com.atsuishio.superbwarfare.init.ModMobEffects; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.tools.NBTTool; import net.minecraft.client.CameraType; import net.minecraft.client.Minecraft; diff --git a/src/main/java/com/atsuishio/superbwarfare/event/GunEventHandler.java b/src/main/java/com/atsuishio/superbwarfare/event/GunEventHandler.java index 29f1fd056..3316608e8 100644 --- a/src/main/java/com/atsuishio/superbwarfare/event/GunEventHandler.java +++ b/src/main/java/com/atsuishio/superbwarfare/event/GunEventHandler.java @@ -9,8 +9,9 @@ import com.atsuishio.superbwarfare.init.ModItems; import com.atsuishio.superbwarfare.init.ModPerks; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; import com.atsuishio.superbwarfare.item.gun.GunItem; +import com.atsuishio.superbwarfare.item.gun.data.GunData; +import com.atsuishio.superbwarfare.item.gun.data.ReloadState; import com.atsuishio.superbwarfare.perk.AmmoPerk; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; @@ -61,23 +62,22 @@ public class GunEventHandler { /** * 拉大栓 */ - private static void handleGunBolt(Player player, GunData gunData) { + private static void handleGunBolt(Player player, GunData data) { ItemStack stack = player.getMainHandItem(); if (stack.is(ModTags.Items.NORMAL_GUN)) { - var tag = gunData.tag(); - var data = gunData.data(); + var tag = data.tag(); - if (GunsTool.getGunIntTag(tag, "BoltActionTick") > 0) { - data.putInt("BoltActionTick", GunsTool.getGunIntTag(tag, "BoltActionTick") - 1); + if (data.bolt.actionTime() > 0) { + data.bolt.reduceActionTime(); } - if (stack.getItem() == ModItems.MARLIN.get() && GunsTool.getGunIntTag(tag, "BoltActionTick") == 9) { + if (stack.getItem() == ModItems.MARLIN.get() && data.bolt.actionTime() == 9) { tag.remove("IsEmpty"); } - if (GunsTool.getGunIntTag(tag, "BoltActionTick") == 1) { - GunsTool.setGunBooleanTag(tag, "NeedBoltAction", false); + if (data.bolt.actionTime() == 1) { + data.bolt.markNeedless(); if (stack.is(ModTags.Items.REVOLVER)) { tag.putBoolean("canImmediatelyShoot", true); } @@ -165,7 +165,7 @@ public class GunEventHandler { if (stack.is(ModTags.Items.REVOLVER)) return; - Mod.queueServerWork((int) (data.boltActionTime() / 2 + 1.5 * shooterHeight), () -> { + Mod.queueServerWork((int) (data.bolt.defaultActionTime() / 2 + 1.5 * shooterHeight), () -> { if (stack.is(ModTags.Items.SHOTGUN)) { SoundTool.playLocalSound(serverPlayer, ModSounds.SHELL_CASING_SHOTGUN.get(), (float) Math.max(0.75 - 0.12 * shooterHeight, 0), 1); } else if (stack.is(ModTags.Items.SNIPER_RIFLE)) { @@ -316,53 +316,51 @@ public class GunEventHandler { var data = gunData.data(); // 启动换弹 - if (GunsTool.getGunBooleanTag(tag, "StartReload")) { + if (gunData.reload.shouldStart()) { NeoForge.EVENT_BUS.post(new ReloadEvent.Pre(player, stack)); if (gunItem.isOpenBolt(stack)) { if (gunData.ammo() == 0) { - data.putInt("ReloadTime", gunData.emptyReloadTime() + 1); - gunData.setReloadState(GunData.ReloadState.EMPTY_RELOADING); + gunData.reload.setTime(gunData.emptyReloadTime() + 1); + gunData.reload.setState(ReloadState.EMPTY_RELOADING); playGunEmptyReloadSounds(player); } else { - data.putInt("ReloadTime", gunData.normalReloadTime() + 1); - gunData.setReloadState(GunData.ReloadState.NORMAL_RELOADING); + gunData.reload.setTime(gunData.normalReloadTime() + 1); + gunData.reload.setState(ReloadState.NORMAL_RELOADING); playGunNormalReloadSounds(player); } } else { - data.putInt("ReloadTime", gunData.emptyReloadTime() + 2); - gunData.setReloadState(GunData.ReloadState.EMPTY_RELOADING); + gunData.reload.setTime(gunData.emptyReloadTime() + 2); + gunData.reload.setState(ReloadState.EMPTY_RELOADING); playGunEmptyReloadSounds(player); } - data.remove("StartReload"); + gunData.reload.markStarted(); } - if (data.getInt("ReloadTime") > 0) { - data.putInt("ReloadTime", data.getInt("ReloadTime") - 1); - } + gunData.reload.reduce(); if (stack.getItem() == ModItems.RPG.get()) { - if (data.getInt("ReloadTime") == 84) { + if (gunData.reload.time() == 84) { tag.remove("IsEmpty"); } - if (data.getInt("ReloadTime") == 9) { + if (gunData.reload.time() == 9) { data.remove("CloseHammer"); } } - if (stack.getItem() == ModItems.MK_14.get() && data.getInt("ReloadTime") == 18) { + if (stack.getItem() == ModItems.MK_14.get() && gunData.reload.time() == 18) { data.remove("HoldOpen"); } - if (stack.getItem() == ModItems.SVD.get() && data.getInt("ReloadTime") == 17) { + if (stack.getItem() == ModItems.SVD.get() && gunData.reload.time() == 17) { data.remove("HoldOpen"); } - if (stack.getItem() == ModItems.SKS.get() && data.getInt("ReloadTime") == 14) { + if (stack.getItem() == ModItems.SKS.get() && gunData.reload.time() == 14) { data.remove("HoldOpen"); } - if (stack.getItem() == ModItems.M_60.get() && data.getInt("ReloadTime") == 55) { + if (stack.getItem() == ModItems.M_60.get() && gunData.reload.time() == 55) { data.remove("HideBulletChain"); } @@ -371,16 +369,16 @@ public class GunEventHandler { || stack.getItem() == ModItems.M_1911.get() || stack.getItem() == ModItems.MP_443.get() ) { - if (data.getInt("ReloadTime") == 9) { + if (gunData.reload.time() == 9) { data.remove("HoldOpen"); } } - if (stack.getItem() == ModItems.QBZ_95.get() && data.getInt("ReloadTime") == 14) { + if (stack.getItem() == ModItems.QBZ_95.get() && gunData.reload.time() == 14) { data.remove("HoldOpen"); } - if (data.getInt("ReloadTime") == 1) { + if (gunData.reload.time() == 1) { if (gunItem.isOpenBolt(stack)) { if (gunData.ammo() == 0) { playGunEmptyReload(player, gunData); @@ -390,7 +388,7 @@ public class GunEventHandler { } else { playGunEmptyReload(player, gunData); } - data.remove("StartReload"); + gunData.reload.markStarted(); } } @@ -413,7 +411,7 @@ public class GunEventHandler { GunsTool.reload(player, stack, gunData, AmmoType.HEAVY, gunItem.hasBulletInBarrel(stack)); } } - gunData.setReloadState(GunData.ReloadState.NOT_RELOADING); + gunData.reload.setState(ReloadState.NOT_RELOADING); NeoForge.EVENT_BUS.post(new ReloadEvent.Post(player, stack)); } @@ -447,7 +445,7 @@ public class GunEventHandler { player.getInventory().clearOrCountMatchingItems(p -> p.getItem() == ModItems.JAVELIN_MISSILE.get(), 1, player.inventoryMenu.getCraftSlots()); } } - gunData.setReloadState(GunData.ReloadState.NOT_RELOADING); + gunData.reload.setState(ReloadState.NOT_RELOADING); NeoForge.EVENT_BUS.post(new ReloadEvent.Post(player, stack)); } @@ -541,8 +539,8 @@ public class GunEventHandler { tag.remove("ForceStop"); tag.remove("Stopped"); - gunData.setReloadStage(1); - gunData.setReloadState(GunData.ReloadState.NORMAL_RELOADING); + gunData.reload.setStage(1); + gunData.reload.setState(ReloadState.NORMAL_RELOADING); tag.remove("StartSingleReload"); } @@ -575,26 +573,26 @@ public class GunEventHandler { } else if (stack.is(ModItems.SECONDARY_CATACLYSM.get()) && gunData.ammo() >= gunData.magazine()) { tag.putBoolean("ForceStartStage3", true); } else { - gunData.setReloadStage(2); + gunData.reload.setStage(2); } } else { if (stack.is(ModItems.SECONDARY_CATACLYSM.get()) && gunData.ammo() >= gunData.magazine()) { tag.putBoolean("ForceStartStage3", true); } else { - gunData.setReloadStage(2); + gunData.reload.setStage(2); } } // 检查备弹 } // 强制停止换弹,进入三阶段 - if (tag.getBoolean("ForceStop") && gunData.getReloadStage() == 2 && tag.getInt("IterativeLoadTime") > 0) { + if (tag.getBoolean("ForceStop") && gunData.reload.stage() == 2 && tag.getInt("IterativeLoadTime") > 0) { tag.putBoolean("Stopped", true); } // 二阶段 if ((tag.getDouble("PrepareTime") == 0 || tag.getDouble("PrepareLoadTime") == 0) - && gunData.getReloadStage() == 2 + && gunData.reload.stage() == 2 && tag.getInt("IterativeLoadTime") == 0 && !tag.getBoolean("Stopped") && gunData.ammo() < gunData.magazine() @@ -635,7 +633,7 @@ public class GunEventHandler { if (tag.getInt("IterativeLoadTime") == 1) { // 装满结束 if (gunData.ammo() >= gunData.magazine()) { - gunData.setReloadStage(3); + gunData.reload.setStage(3); } // 备弹耗尽结束 @@ -644,29 +642,29 @@ public class GunEventHandler { if (capability == null) capability = new PlayerVariable(); if (stack.is(ModTags.Items.USE_SHOTGUN_AMMO) && capability.shotgunAmmo == 0) { - gunData.setReloadStage(3); + gunData.reload.setStage(3); } else if (stack.is(ModTags.Items.USE_SNIPER_AMMO) && capability.sniperAmmo == 0) { - gunData.setReloadStage(3); + gunData.reload.setStage(3); } else if ((stack.is(ModTags.Items.USE_HANDGUN_AMMO) || stack.is(ModTags.Items.SMG)) && capability.handgunAmmo == 0) { - gunData.setReloadStage(3); + gunData.reload.setStage(3); } else if (stack.is(ModTags.Items.USE_RIFLE_AMMO) && capability.rifleAmmo == 0) { - gunData.setReloadStage(3); + gunData.reload.setStage(3); } else if (stack.is(ModTags.Items.USE_HEAVY_AMMO) && capability.heavyAmmo == 0) { - gunData.setReloadStage(3); + gunData.reload.setStage(3); } } // 强制结束 if (tag.getBoolean("Stopped")) { - gunData.setReloadStage(3); + gunData.reload.setStage(3); tag.remove("ForceStop"); tag.remove("Stopped"); } } // 三阶段 - if ((tag.getInt("IterativeLoadTime") == 1 && gunData.getReloadStage() == 3) || tag.getBoolean("ForceStartStage3")) { - gunData.setReloadStage(3); + if ((tag.getInt("IterativeLoadTime") == 1 && gunData.reload.stage() == 3) || tag.getBoolean("ForceStartStage3")) { + gunData.reload.setStage(3); tag.remove("ForceStartStage3"); int finishTime = gunData.finishTime(); tag.putInt("FinishTime", finishTime + 2); @@ -680,11 +678,11 @@ public class GunEventHandler { // 三阶段结束 if (tag.getInt("FinishTime") == 1) { - gunData.setReloadStage(0); - if (gunData.boltActionTime() > 0) { - GunsTool.setGunBooleanTag(tag, "NeedBoltAction", false); + gunData.reload.setStage(0); + if (gunData.bolt.defaultActionTime() > 0) { + gunData.bolt.markNeedless(); } - gunData.setReloadState(GunData.ReloadState.NOT_RELOADING); + gunData.reload.setState(ReloadState.NOT_RELOADING); tag.remove("StartSingleReload"); NeoForge.EVENT_BUS.post(new ReloadEvent.Post(player, stack)); diff --git a/src/main/java/com/atsuishio/superbwarfare/event/LivingEventHandler.java b/src/main/java/com/atsuishio/superbwarfare/event/LivingEventHandler.java index 9892da0ca..a9fb2ebc0 100644 --- a/src/main/java/com/atsuishio/superbwarfare/event/LivingEventHandler.java +++ b/src/main/java/com/atsuishio/superbwarfare/event/LivingEventHandler.java @@ -14,8 +14,9 @@ import com.atsuishio.superbwarfare.entity.vehicle.base.ContainerMobileVehicleEnt import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity; import com.atsuishio.superbwarfare.event.events.PreKillEvent; import com.atsuishio.superbwarfare.init.*; -import com.atsuishio.superbwarfare.item.gun.GunData; import com.atsuishio.superbwarfare.item.gun.GunItem; +import com.atsuishio.superbwarfare.item.gun.data.GunData; +import com.atsuishio.superbwarfare.item.gun.data.ReloadState; import com.atsuishio.superbwarfare.network.message.receive.ClientIndicatorMessage; import com.atsuishio.superbwarfare.network.message.receive.DrawClientMessage; import com.atsuishio.superbwarfare.network.message.receive.PlayerGunKillMessage; @@ -360,19 +361,19 @@ public class LivingEventHandler { oldTag = oldData.tag(); var data = oldData.data(); - if (oldData.boltActionTime() > 0) { - data.putInt("BoltActionTick", 0); + if (oldData.bolt.defaultActionTime() > 0) { + oldData.bolt.setActionTime(0); } - data.putInt("ReloadTime", 0); + oldData.reload.setTime(0); oldTag.put("GunData", data); - oldData.setReloadState(GunData.ReloadState.NOT_RELOADING); + oldData.reload.setState(ReloadState.NOT_RELOADING); if (oldData.iterativeTime() != 0) { oldTag.remove("ForceStop"); oldTag.remove("Stopped"); - oldData.setReloadStage(0); + oldData.reload.setStage(0); oldTag.remove("PrepareTime"); oldTag.remove("PrepareLoadTime"); oldTag.remove("IterativeLoadTime"); @@ -398,20 +399,20 @@ public class LivingEventHandler { player.getPersistentData().putDouble("noRun", 40); newTag.putBoolean("draw", true); - if (newData.boltActionTime() > 0) { - GunsTool.setGunIntTag(newTag, "BoltActionTick", 0); + if (newData.bolt.defaultActionTime() > 0) { + newData.bolt.setActionTime(0); } - newData.setReloadState(GunData.ReloadState.NOT_RELOADING); + newData.reload.setState(ReloadState.NOT_RELOADING); - var data = newTag.getCompound("GunData"); - data.remove("ReloadTime"); + var data = newData.data(); + newData.reload.setTime(0); newTag.put("GunData", data); if (newData.iterativeTime() != 0) { newTag.remove("ForceStop"); newTag.remove("Stopped"); - newData.setReloadStage(0); + newData.reload.setStage(0); newTag.remove("PrepareTime"); newTag.remove("PrepareLoadTime"); newTag.remove("IterativeLoadTime"); diff --git a/src/main/java/com/atsuishio/superbwarfare/event/PlayerEventHandler.java b/src/main/java/com/atsuishio/superbwarfare/event/PlayerEventHandler.java index c599fffd0..ec121bb63 100644 --- a/src/main/java/com/atsuishio/superbwarfare/event/PlayerEventHandler.java +++ b/src/main/java/com/atsuishio/superbwarfare/event/PlayerEventHandler.java @@ -6,8 +6,8 @@ import com.atsuishio.superbwarfare.config.server.MiscConfig; import com.atsuishio.superbwarfare.init.ModItems; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; import com.atsuishio.superbwarfare.item.gun.GunItem; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.tools.*; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; diff --git a/src/main/java/com/atsuishio/superbwarfare/event/ReloadEventHandler.java b/src/main/java/com/atsuishio/superbwarfare/event/ReloadEventHandler.java index 7afd5faab..38099b610 100644 --- a/src/main/java/com/atsuishio/superbwarfare/event/ReloadEventHandler.java +++ b/src/main/java/com/atsuishio/superbwarfare/event/ReloadEventHandler.java @@ -3,7 +3,7 @@ package com.atsuishio.superbwarfare.event; import com.atsuishio.superbwarfare.event.events.ReloadEvent; import com.atsuishio.superbwarfare.init.ModPerks; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.perk.PerkHelper; import com.atsuishio.superbwarfare.tools.GunsTool; import net.minecraft.world.entity.player.Player; diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/GunEvents.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/GunEvents.java index 0151304a5..23a93ce48 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/GunEvents.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/GunEvents.java @@ -2,6 +2,7 @@ package com.atsuishio.superbwarfare.item.gun; import com.atsuishio.superbwarfare.Mod; import com.atsuishio.superbwarfare.init.ModTags; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import net.neoforged.bus.api.SubscribeEvent; import net.neoforged.fml.common.EventBusSubscriber; import net.neoforged.neoforge.event.entity.player.ItemEntityPickupEvent; diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/GunItem.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/GunItem.java index bc95452fc..2698ee49b 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/GunItem.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/GunItem.java @@ -8,6 +8,7 @@ import com.atsuishio.superbwarfare.init.ModItems; import com.atsuishio.superbwarfare.init.ModPerks; import com.atsuishio.superbwarfare.init.ModTags; import com.atsuishio.superbwarfare.item.CustomRendererItem; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; import com.atsuishio.superbwarfare.tools.AmmoType; diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/SpecialFireWeapon.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/SpecialFireWeapon.java index fd6595cf5..22b20e5ac 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/SpecialFireWeapon.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/SpecialFireWeapon.java @@ -1,5 +1,6 @@ package com.atsuishio.superbwarfare.item.gun; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import net.minecraft.world.entity.player.Player; diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/data/Bolt.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/data/Bolt.java new file mode 100644 index 000000000..0e552908d --- /dev/null +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/data/Bolt.java @@ -0,0 +1,47 @@ +package com.atsuishio.superbwarfare.item.gun.data; + +import net.minecraft.nbt.CompoundTag; + +public final class Bolt { + private final CompoundTag data; + private final GunData gunData; + + + Bolt(GunData data) { + this.gunData = data; + this.data = data.data(); + } + + public boolean needed() { + return data.getBoolean("NeedBoltAction"); + } + + public void markNeeded() { + data.putBoolean("NeedBoltAction", true); + } + + public void markNeedless() { + data.remove("NeedBoltAction"); + } + + public int defaultActionTime() { + return (int) gunData.getGunData("BoltActionTime") + gunData.item().getCustomBoltActionTime(gunData.stack()); + } + + public int actionTime() { + return data.getInt("BoltActionTime"); + } + + public void setActionTime(int tick) { + if (tick <= 0) { + data.remove("BoltActionTime"); + } else { + data.putInt("BoltActionTime", tick); + } + } + + public void reduceActionTime() { + setActionTime(actionTime() - 1); + } + +} diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/data/Charge.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/data/Charge.java new file mode 100644 index 000000000..67cbe1318 --- /dev/null +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/data/Charge.java @@ -0,0 +1,43 @@ +package com.atsuishio.superbwarfare.item.gun.data; + +import net.minecraft.nbt.CompoundTag; + +public final class Charge { + private final CompoundTag data; + + Charge(GunData data) { + this.data = data.data(); + } + + public void markStart() { + data.putBoolean("StartCharge", true); + } + + public boolean shouldStartCharge() { + return data.getBoolean("StartCharge"); + } + + public void markStarted() { + data.remove("StartCharge"); + } + + public int time() { + return data.getInt("ChargeTime"); + } + + public void reduce() { + setTime(time() - 1); + } + + public void setTime(int chargeTime) { + if (chargeTime <= 0) { + data.remove("ChargeTime"); + } else { + data.putInt("ChargeTime", chargeTime); + } + } + + public void reset() { + setTime(0); + } +} diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/GunData.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/data/GunData.java similarity index 72% rename from src/main/java/com/atsuishio/superbwarfare/item/gun/GunData.java rename to src/main/java/com/atsuishio/superbwarfare/item/gun/data/GunData.java index 891cc24be..f751b260a 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/GunData.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/data/GunData.java @@ -1,5 +1,6 @@ -package com.atsuishio.superbwarfare.item.gun; +package com.atsuishio.superbwarfare.item.gun.data; +import com.atsuishio.superbwarfare.item.gun.GunItem; import com.atsuishio.superbwarfare.perk.AmmoPerk; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; @@ -49,6 +50,10 @@ public class GunData { } else { perk = tag.getCompound("PerkData"); } + + reload = new Reload(this); + charge = new Charge(this); + bolt = new Bolt(this); } public boolean initialized() { @@ -91,7 +96,7 @@ public class GunData { return perk; } - private double getGunData(String key) { + double getGunData(String key) { return getGunData(key, 0); } @@ -103,7 +108,7 @@ public class GunData { return getGunData("Damage"); } - public double perkDamage() { + public double perkDamageRate() { var perk = PerkHelper.getPerkByType(tag, Perk.Type.AMMO); if (perk instanceof AmmoPerk ammoPerk) { return ammoPerk.damageRate; @@ -112,7 +117,7 @@ public class GunData { } public double damage() { - return (rawDamage() + item.getCustomDamage(stack)) + perkDamage(); + return (rawDamage() + item.getCustomDamage(stack)) * perkDamageRate(); } public double explosionDamage() { @@ -167,24 +172,10 @@ public class GunData { return (int) getGunData("PrepareEmptyTime"); } - public int boltActionTime() { - return (int) getGunData("BoltActionTime") + item.getCustomBoltActionTime(stack); - } - public int finishTime() { return (int) getGunData("FinishTime"); } - public int reloadTime() { - var normalReload = normalReloadTime(); - var emptyReload = emptyReloadTime(); - - if (normalReload == 0) return emptyReload; - if (emptyReload == 0) return normalReload; - - return ammo() < magazine() ? normalReload : emptyReload; - } - public double soundRadius() { return getGunData("SoundRadius", 15) + item.getCustomSoundRadius(stack); } @@ -217,9 +208,6 @@ public class GunData { data.putInt("Ammo", ammo); } - public boolean reloading() { - return getReloadState() != ReloadState.NOT_RELOADING; - } public double defaultZoom() { return getGunData("DefaultZoom", 1.25); @@ -292,88 +280,21 @@ public class GunData { return item.canSwitchScope(stack); } - public enum ReloadState { - NOT_RELOADING, - NORMAL_RELOADING, - EMPTY_RELOADING, + + public final Reload reload; + + public boolean reloading() { + return reload.state() != ReloadState.NOT_RELOADING; } - public ReloadState getReloadState() { - return switch (data.getInt("ReloadState")) { - case 1 -> ReloadState.NORMAL_RELOADING; - case 2 -> ReloadState.EMPTY_RELOADING; - default -> ReloadState.NOT_RELOADING; - }; - } - - public boolean normalReloading() { - return getReloadState() == ReloadState.NORMAL_RELOADING; - } - - public boolean emptyReloading() { - return getReloadState() == ReloadState.EMPTY_RELOADING; - } - - public void setReloadState(ReloadState state) { - if (state == ReloadState.NOT_RELOADING) { - data.remove("ReloadState"); - } else { - data.putInt("ReloadState", state.ordinal()); - } - } - - public int getReloadStage() { - return data.getInt("ReloadStage"); - } - - public void setReloadStage(int stage) { - if (stage == 0) { - data.remove("ReloadStage"); - } else { - data.putInt("ReloadStage", stage); - } - } - - public final Charge charge = new Charge(); - - public class Charge { - public void markStart() { - data.putBoolean("StartCharge", true); - } - - public boolean shouldStartCharge() { - return data.getBoolean("StartCharge"); - } - - public void markStarted() { - data.remove("StartCharge"); - } - - public int time() { - return data.getInt("ChargeTime"); - } - - public void reduce() { - setTime(time() - 1); - } - - public void setTime(int chargeTime) { - if (chargeTime <= 0) { - data.remove("ChargeTime"); - } else { - data.putInt("ChargeTime", chargeTime); - } - } - - public void reset() { - setTime(0); - } - } + public final Charge charge; public boolean charging() { return charge.time() > 0; } + public final Bolt bolt; + public void save() { stack.set(DataComponents.CUSTOM_DATA, CustomData.of(tag)); } diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/data/Reload.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/data/Reload.java new file mode 100644 index 000000000..e1eff37b9 --- /dev/null +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/data/Reload.java @@ -0,0 +1,75 @@ +package com.atsuishio.superbwarfare.item.gun.data; + +import net.minecraft.nbt.CompoundTag; + +public final class Reload { + private final CompoundTag data; + + Reload(GunData data) { + this.data = data.data(); + } + + public ReloadState state() { + return switch (data.getInt("ReloadState")) { + case 1 -> ReloadState.NORMAL_RELOADING; + case 2 -> ReloadState.EMPTY_RELOADING; + default -> ReloadState.NOT_RELOADING; + }; + } + + public boolean normal() { + return state() == ReloadState.NORMAL_RELOADING; + } + + public boolean empty() { + return state() == ReloadState.EMPTY_RELOADING; + } + + public void setState(ReloadState state) { + if (state == ReloadState.NOT_RELOADING) { + data.remove("ReloadState"); + } else { + data.putInt("ReloadState", state.ordinal()); + } + } + + public int stage() { + return data.getInt("ReloadStage"); + } + + public void setStage(int stage) { + if (stage <= 0) { + data.remove("ReloadStage"); + } else { + data.putInt("ReloadStage", stage); + } + } + + public void markStart() { + data.putBoolean("StartReload", true); + } + + public void markStarted() { + data.remove("StartReload"); + } + + public boolean shouldStart() { + return data.getBoolean("StartReload"); + } + + public int time() { + return data.getInt("ReloadTime"); + } + + public void setTime(int time) { + if (time <= 0) { + data.remove("ReloadTime"); + } else { + data.putInt("ReloadTime", time); + } + } + + public void reduce() { + setTime(time() - 1); + } +} diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/data/ReloadState.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/data/ReloadState.java new file mode 100644 index 000000000..b8a1646a9 --- /dev/null +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/data/ReloadState.java @@ -0,0 +1,7 @@ +package com.atsuishio.superbwarfare.item.gun.data; + +public enum ReloadState { + NOT_RELOADING, + NORMAL_RELOADING, + EMPTY_RELOADING, +} diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/handgun/Glock17Item.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/handgun/Glock17Item.java index 35f5460e6..4a3e24743 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/handgun/Glock17Item.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/handgun/Glock17Item.java @@ -5,8 +5,8 @@ import com.atsuishio.superbwarfare.client.renderer.item.Glock17ItemRenderer; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; import com.atsuishio.superbwarfare.item.gun.GunItem; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; import net.minecraft.client.Minecraft; @@ -49,11 +49,11 @@ public class Glock17Item extends GunItem implements GeoItem { ItemStack stack = player.getMainHandItem(); if (!stack.is(ModTags.Items.GUN)) return PlayState.STOP; - if (GunData.from(stack).emptyReloading()) { + if (GunData.from(stack).reload.empty()) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.glock.reload_empty")); } - if (GunData.from(stack).normalReloading()) { + if (GunData.from(stack).reload.normal()) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.glock.reload_normal")); } @@ -69,7 +69,7 @@ public class Glock17Item extends GunItem implements GeoItem { if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("noRun") == 0 - && !(GunData.from(stack).normalReloading() || GunData.from(stack).emptyReloading()) && ClientEventHandler.drawTime < 0.01) { + && !(GunData.from(stack).reload.normal() || GunData.from(stack).reload.empty()) && ClientEventHandler.drawTime < 0.01) { if (player.hasEffect(MobEffects.MOVEMENT_SPEED)) { return event.setAndContinue(RawAnimation.begin().thenLoop("animation.glock.run_fast")); } else { diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/handgun/Glock18Item.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/handgun/Glock18Item.java index 8e080d87c..8385635b1 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/handgun/Glock18Item.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/handgun/Glock18Item.java @@ -6,8 +6,8 @@ import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModPerks; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; import com.atsuishio.superbwarfare.item.gun.GunItem; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; import net.minecraft.client.Minecraft; @@ -50,11 +50,11 @@ public class Glock18Item extends GunItem implements GeoItem { ItemStack stack = player.getMainHandItem(); if (!stack.is(ModTags.Items.GUN)) return PlayState.STOP; - if (GunData.from(stack).emptyReloading()) { + if (GunData.from(stack).reload.empty()) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.glock.reload_empty")); } - if (GunData.from(stack).normalReloading()) { + if (GunData.from(stack).reload.normal()) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.glock.reload_normal")); } @@ -69,7 +69,7 @@ public class Glock18Item extends GunItem implements GeoItem { if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("noRun") == 0 - && !(GunData.from(stack).normalReloading() || GunData.from(stack).emptyReloading()) && ClientEventHandler.drawTime < 0.01) { + && !(GunData.from(stack).reload.normal() || GunData.from(stack).reload.empty()) && ClientEventHandler.drawTime < 0.01) { if (player.hasEffect(MobEffects.MOVEMENT_SPEED)) { return event.setAndContinue(RawAnimation.begin().thenLoop("animation.glock.run_fast")); } else { diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/handgun/M1911Item.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/handgun/M1911Item.java index 4bb9e0239..e6110e216 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/handgun/M1911Item.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/handgun/M1911Item.java @@ -5,8 +5,8 @@ import com.atsuishio.superbwarfare.client.renderer.item.M1911ItemRenderer; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; import com.atsuishio.superbwarfare.item.gun.GunItem; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; import net.minecraft.client.Minecraft; @@ -49,11 +49,11 @@ public class M1911Item extends GunItem implements GeoItem { ItemStack stack = player.getMainHandItem(); if (!stack.is(ModTags.Items.GUN)) return PlayState.STOP; - if (GunData.from(stack).emptyReloading()) { + if (GunData.from(stack).reload.empty()) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.glock.reload_empty")); } - if (GunData.from(stack).normalReloading()) { + if (GunData.from(stack).reload.normal()) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.glock.reload_normal")); } @@ -69,7 +69,7 @@ public class M1911Item extends GunItem implements GeoItem { if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("noRun") == 0 - && !(GunData.from(stack).normalReloading() || GunData.from(stack).emptyReloading()) && ClientEventHandler.drawTime < 0.01) { + && !(GunData.from(stack).reload.normal() || GunData.from(stack).reload.empty()) && ClientEventHandler.drawTime < 0.01) { if (player.hasEffect(MobEffects.MOVEMENT_SPEED)) { return event.setAndContinue(RawAnimation.begin().thenLoop("animation.glock.run_fast")); } else { diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/handgun/Mp443Item.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/handgun/Mp443Item.java index 96a517e50..8ad9a348c 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/handgun/Mp443Item.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/handgun/Mp443Item.java @@ -5,8 +5,8 @@ import com.atsuishio.superbwarfare.client.renderer.item.Mp443ItemRenderer; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; import com.atsuishio.superbwarfare.item.gun.GunItem; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; import net.minecraft.client.Minecraft; @@ -49,11 +49,11 @@ public class Mp443Item extends GunItem implements GeoItem { ItemStack stack = player.getMainHandItem(); if (!stack.is(ModTags.Items.GUN)) return PlayState.STOP; - if (GunData.from(stack).emptyReloading()) { + if (GunData.from(stack).reload.empty()) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.glock.reload_empty")); } - if (GunData.from(stack).normalReloading()) { + if (GunData.from(stack).reload.normal()) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.glock.reload_normal")); } @@ -69,7 +69,7 @@ public class Mp443Item extends GunItem implements GeoItem { if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("noRun") == 0 - && !(GunData.from(stack).normalReloading() || GunData.from(stack).emptyReloading()) && ClientEventHandler.drawTime < 0.01) { + && !(GunData.from(stack).reload.normal() || GunData.from(stack).reload.empty()) && ClientEventHandler.drawTime < 0.01) { if (player.hasEffect(MobEffects.MOVEMENT_SPEED)) { return event.setAndContinue(RawAnimation.begin().thenLoop("animation.glock.run_fast")); } else { diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/handgun/Trachelium.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/handgun/Trachelium.java index 9ad335e80..149c19b75 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/handgun/Trachelium.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/handgun/Trachelium.java @@ -6,8 +6,8 @@ import com.atsuishio.superbwarfare.client.renderer.item.TracheliumItemRenderer; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; import com.atsuishio.superbwarfare.item.gun.GunItem; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; import com.atsuishio.superbwarfare.tools.GunsTool; @@ -111,7 +111,7 @@ public class Trachelium extends GunItem implements GeoItem { boolean stock = GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.STOCK) == 2; boolean grip = GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.GRIP) > 0 || GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.SCOPE) > 0; - if (GunsTool.getGunIntTag(tag, "BoltActionTick") > 0) { + if (data.bolt.actionTime() > 0) { if (stock) { if (grip) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.trachelium.action_stock_grip")); @@ -127,7 +127,7 @@ public class Trachelium extends GunItem implements GeoItem { } } - if (GunData.from(stack).emptyReloading()) { + if (GunData.from(stack).reload.empty()) { if (stock) { if (grip) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.trachelium.reload_stock_grip")); diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/heavy/Ntw20Item.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/heavy/Ntw20Item.java index ac8e5cfa6..263d2717e 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/heavy/Ntw20Item.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/heavy/Ntw20Item.java @@ -7,8 +7,8 @@ import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModRarity; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; import com.atsuishio.superbwarfare.item.gun.GunItem; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; import com.atsuishio.superbwarfare.tools.GunsTool; @@ -59,15 +59,15 @@ public class Ntw20Item extends GunItem implements GeoItem { var data = GunData.from(stack); final var tag = data.tag(); - if (GunsTool.getGunIntTag(tag, "BoltActionTick") > 0) { + if (data.bolt.actionTime() > 0) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ntw_20.shift")); } - if (data.emptyReloading()) { + if (data.reload.empty()) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ntw_20.reload_empty")); } - if (data.normalReloading()) { + if (data.reload.normal()) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ntw_20.reload_normal")); } @@ -84,9 +84,9 @@ public class Ntw20Item extends GunItem implements GeoItem { if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("noRun") == 0 - && !(data.normalReloading() || data.emptyReloading()) + && !(data.reload.normal() || data.reload.empty()) && ClientEventHandler.drawTime < 0.01) { - if (player.hasEffect(MobEffects.MOVEMENT_SPEED) && GunsTool.getGunIntTag(tag, "BoltActionTick") == 0) { + if (player.hasEffect(MobEffects.MOVEMENT_SPEED) && data.bolt.actionTime() == 0) { return event.setAndContinue(RawAnimation.begin().thenLoop("animation.ntw_20.run_fast")); } else { return event.setAndContinue(RawAnimation.begin().thenLoop("animation.ntw_20.run")); diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/launcher/JavelinItem.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/launcher/JavelinItem.java index 7f7a72b5d..ff22aabe5 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/launcher/JavelinItem.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/launcher/JavelinItem.java @@ -9,9 +9,9 @@ import com.atsuishio.superbwarfare.entity.projectile.JavelinMissileEntity; import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.*; -import com.atsuishio.superbwarfare.item.gun.GunData; import com.atsuishio.superbwarfare.item.gun.GunItem; import com.atsuishio.superbwarfare.item.gun.SpecialFireWeapon; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.network.message.receive.ShootClientMessage; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; @@ -77,7 +77,7 @@ public class JavelinItem extends GunItem implements GeoItem, SpecialFireWeapon { ItemStack stack = player.getMainHandItem(); if (!stack.is(ModTags.Items.GUN)) return PlayState.STOP; - if (GunData.from(stack).emptyReloading()) { + if (GunData.from(stack).reload.empty()) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.javelin.reload")); } diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/launcher/M79Item.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/launcher/M79Item.java index c9029bdfa..a3ed327ef 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/launcher/M79Item.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/launcher/M79Item.java @@ -10,9 +10,9 @@ import com.atsuishio.superbwarfare.init.ModItems; import com.atsuishio.superbwarfare.init.ModPerks; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; import com.atsuishio.superbwarfare.item.gun.GunItem; import com.atsuishio.superbwarfare.item.gun.SpecialFireWeapon; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.network.message.receive.ShootClientMessage; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; @@ -76,7 +76,7 @@ public class M79Item extends GunItem implements GeoItem, SpecialFireWeapon { ItemStack stack = player.getMainHandItem(); if (!stack.is(ModTags.Items.GUN)) return PlayState.STOP; - if (GunData.from(stack).emptyReloading()) { + if (GunData.from(stack).reload.empty()) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m79.reload")); } diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/launcher/RpgItem.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/launcher/RpgItem.java index 15e497460..e7c38feb8 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/launcher/RpgItem.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/launcher/RpgItem.java @@ -10,9 +10,9 @@ import com.atsuishio.superbwarfare.init.ModItems; import com.atsuishio.superbwarfare.init.ModPerks; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; import com.atsuishio.superbwarfare.item.gun.GunItem; import com.atsuishio.superbwarfare.item.gun.SpecialFireWeapon; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.network.message.receive.ShootClientMessage; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; @@ -77,7 +77,7 @@ public class RpgItem extends GunItem implements GeoItem, SpecialFireWeapon { if (!stack.is(ModTags.Items.GUN)) return PlayState.STOP; var data = GunData.from(stack); - if (data.emptyReloading()) { + if (data.reload.empty()) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.rpg.reload")); } diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/launcher/SecondaryCataclysm.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/launcher/SecondaryCataclysm.java index a2796c04d..dcd20bc35 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/launcher/SecondaryCataclysm.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/launcher/SecondaryCataclysm.java @@ -8,9 +8,9 @@ import com.atsuishio.superbwarfare.entity.projectile.GunGrenadeEntity; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.*; import com.atsuishio.superbwarfare.item.EnergyStorageItem; -import com.atsuishio.superbwarfare.item.gun.GunData; import com.atsuishio.superbwarfare.item.gun.GunItem; import com.atsuishio.superbwarfare.item.gun.SpecialFireWeapon; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.network.message.receive.ShootClientMessage; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; @@ -90,15 +90,15 @@ public class SecondaryCataclysm extends GunItem implements GeoItem, SpecialFireW var data = GunData.from(stack); final var tag = data.tag(); - if (data.getReloadStage() == 1 && tag.getDouble("PrepareLoadTime") > 0) { + if (data.reload.stage() == 1 && tag.getDouble("PrepareLoadTime") > 0) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.sc.prepare")); } - if (tag.getDouble("LoadIndex") == 0 && data.getReloadStage() == 2) { + if (tag.getDouble("LoadIndex") == 0 && data.reload.stage() == 2) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.sc.iterativeload")); } - if (tag.getDouble("LoadIndex") == 1 && data.getReloadStage() == 2) { + if (tag.getDouble("LoadIndex") == 1 && data.reload.stage() == 2) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.sc.iterativeload2")); } @@ -106,7 +106,7 @@ public class SecondaryCataclysm extends GunItem implements GeoItem, SpecialFireW return event.setAndContinue(RawAnimation.begin().thenPlay("animation.sc.hit")); } - if (data.getReloadStage() == 3) { + if (data.reload.stage() == 3) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.sc.finish")); } @@ -122,10 +122,10 @@ public class SecondaryCataclysm extends GunItem implements GeoItem, SpecialFireW if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("noRun") == 0 - && !data.emptyReloading() - && data.getReloadStage() != 1 - && data.getReloadStage() != 2 - && data.getReloadStage() != 3 + && !data.reload.empty() + && data.reload.stage() != 1 + && data.reload.stage() != 2 + && data.reload.stage() != 3 && ClientEventHandler.drawTime < 0.01 && ClientEventHandler.gunMelee == 0 && !data.reloading() diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/machinegun/DevotionItem.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/machinegun/DevotionItem.java index a0166c5b1..c4347c9f0 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/machinegun/DevotionItem.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/machinegun/DevotionItem.java @@ -6,8 +6,8 @@ import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModPerks; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; import com.atsuishio.superbwarfare.item.gun.GunItem; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; import net.minecraft.client.Minecraft; @@ -50,11 +50,11 @@ public class DevotionItem extends GunItem implements GeoItem { ItemStack stack = player.getMainHandItem(); if (!stack.is(ModTags.Items.GUN)) return PlayState.STOP; - if (GunData.from(stack).emptyReloading()) { + if (GunData.from(stack).reload.empty()) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.devotion.reload_empty")); } - if (GunData.from(stack).normalReloading()) { + if (GunData.from(stack).reload.normal()) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.devotion.reload_normal")); } diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/machinegun/M60Item.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/machinegun/M60Item.java index fb636b797..2ce2c3e76 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/machinegun/M60Item.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/machinegun/M60Item.java @@ -6,8 +6,8 @@ import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModPerks; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; import com.atsuishio.superbwarfare.item.gun.GunItem; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; import com.atsuishio.superbwarfare.tools.GunsTool; @@ -67,11 +67,11 @@ public class M60Item extends GunItem implements GeoItem { ItemStack stack = player.getMainHandItem(); if (!stack.is(ModTags.Items.GUN)) return PlayState.STOP; - if (GunData.from(stack).emptyReloading()) { + if (GunData.from(stack).reload.empty()) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m60.reload")); } - if (GunData.from(stack).normalReloading()) { + if (GunData.from(stack).reload.normal()) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m60.reload2")); } diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/machinegun/MinigunItem.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/machinegun/MinigunItem.java index 3681bbbb8..73f6b233b 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/machinegun/MinigunItem.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/machinegun/MinigunItem.java @@ -7,8 +7,8 @@ import com.atsuishio.superbwarfare.init.ModParticleTypes; import com.atsuishio.superbwarfare.init.ModPerks; import com.atsuishio.superbwarfare.init.ModRarity; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; import com.atsuishio.superbwarfare.item.gun.GunItem; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.tools.NBTTool; import com.atsuishio.superbwarfare.tools.ParticleTool; diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/machinegun/RpkItem.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/machinegun/RpkItem.java index 01577d649..df2d65a51 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/machinegun/RpkItem.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/machinegun/RpkItem.java @@ -7,8 +7,8 @@ import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModPerks; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; import com.atsuishio.superbwarfare.item.gun.GunItem; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; import com.atsuishio.superbwarfare.tools.GunsTool; @@ -62,7 +62,7 @@ public class RpkItem extends GunItem implements GeoItem { boolean drum = GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.MAGAZINE) == 2; boolean grip = GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.GRIP) == 1 || GunsTool.getAttachmentType(stack, GunsTool.AttachmentType.GRIP) == 2; - if (GunData.from(stack).emptyReloading()) { + if (GunData.from(stack).reload.empty()) { if (drum) { if (grip) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ak47.reload_empty_drum_grip")); @@ -78,7 +78,7 @@ public class RpkItem extends GunItem implements GeoItem { } } - if (GunData.from(stack).normalReloading()) { + if (GunData.from(stack).reload.normal()) { if (drum) { if (grip) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ak47.reload_normal_drum_grip")); diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/rifle/AK12Item.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/rifle/AK12Item.java index 1d783ee60..73f0f50b1 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/rifle/AK12Item.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/rifle/AK12Item.java @@ -6,8 +6,8 @@ import com.atsuishio.superbwarfare.client.renderer.item.AK12ItemRenderer; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; import com.atsuishio.superbwarfare.item.gun.GunItem; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; import com.atsuishio.superbwarfare.tools.GunsTool; @@ -62,7 +62,7 @@ public class AK12Item extends GunItem implements GeoItem { boolean drum = GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.MAGAZINE) == 2; boolean grip = GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.GRIP) == 1 || GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.GRIP) == 2; - if (GunData.from(stack).emptyReloading()) { + if (GunData.from(stack).reload.empty()) { if (grip) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ak12.reload_empty_grip")); } else { @@ -70,7 +70,7 @@ public class AK12Item extends GunItem implements GeoItem { } } - if (GunData.from(stack).normalReloading()) { + if (GunData.from(stack).reload.normal()) { if (drum) { if (grip) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ak12.reload_normal_drum_grip")); diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/rifle/AK47Item.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/rifle/AK47Item.java index 5334de66d..79d156906 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/rifle/AK47Item.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/rifle/AK47Item.java @@ -6,8 +6,8 @@ import com.atsuishio.superbwarfare.client.renderer.item.AK47ItemRenderer; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; import com.atsuishio.superbwarfare.item.gun.GunItem; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; import com.atsuishio.superbwarfare.tools.GunsTool; @@ -62,7 +62,7 @@ public class AK47Item extends GunItem implements GeoItem { boolean drum = GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.MAGAZINE) == 2; boolean grip = GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.GRIP) == 1 || GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.GRIP) == 2; - if (GunData.from(stack).emptyReloading()) { + if (GunData.from(stack).reload.empty()) { if (drum) { if (grip) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ak47.reload_empty_drum_grip")); @@ -78,7 +78,7 @@ public class AK47Item extends GunItem implements GeoItem { } } - if (GunData.from(stack).normalReloading()) { + if (GunData.from(stack).reload.normal()) { if (drum) { if (grip) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ak47.reload_normal_drum_grip")); diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/rifle/Hk416Item.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/rifle/Hk416Item.java index a2e0c3303..daafe0070 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/rifle/Hk416Item.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/rifle/Hk416Item.java @@ -6,8 +6,8 @@ import com.atsuishio.superbwarfare.client.renderer.item.Hk416ItemRenderer; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; import com.atsuishio.superbwarfare.item.gun.GunItem; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; import com.atsuishio.superbwarfare.tools.GunsTool; @@ -57,7 +57,7 @@ public class Hk416Item extends GunItem implements GeoItem { boolean drum = GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.MAGAZINE) == 2; boolean grip = GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.GRIP) == 1 || GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.GRIP) == 2; - if (GunData.from(stack).emptyReloading()) { + if (GunData.from(stack).reload.empty()) { if (drum) { if (grip) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m4.reload_empty_drum_grip")); @@ -73,7 +73,7 @@ public class Hk416Item extends GunItem implements GeoItem { } } - if (GunData.from(stack).normalReloading()) { + if (GunData.from(stack).reload.normal()) { if (drum) { if (grip) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m4.reload_normal_drum_grip")); diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/rifle/InsidiousItem.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/rifle/InsidiousItem.java index 50eaa772c..caff736a4 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/rifle/InsidiousItem.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/rifle/InsidiousItem.java @@ -5,8 +5,8 @@ import com.atsuishio.superbwarfare.client.renderer.item.InsidiousItemRenderer; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; import com.atsuishio.superbwarfare.item.gun.GunItem; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; import net.minecraft.client.Minecraft; @@ -51,7 +51,7 @@ public class InsidiousItem extends GunItem implements GeoItem { if (!stack.is(ModTags.Items.GUN)) return PlayState.STOP; var data = GunData.from(stack); - if (data.emptyReloading()) { + if (data.reload.empty()) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.insidious.reload")); } diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/rifle/M4Item.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/rifle/M4Item.java index e2b2f4a6e..510658b5e 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/rifle/M4Item.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/rifle/M4Item.java @@ -6,8 +6,8 @@ import com.atsuishio.superbwarfare.client.renderer.item.M4ItemRenderer; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; import com.atsuishio.superbwarfare.item.gun.GunItem; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; import com.atsuishio.superbwarfare.tools.GunsTool; @@ -58,7 +58,7 @@ public class M4Item extends GunItem implements GeoItem { boolean drum = GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.MAGAZINE) == 2; boolean grip = GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.GRIP) == 1 || GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.GRIP) == 2; - if (data.emptyReloading()) { + if (data.reload.empty()) { if (drum) { if (grip) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m4.reload_empty_drum_grip")); @@ -74,7 +74,7 @@ public class M4Item extends GunItem implements GeoItem { } } - if (data.normalReloading()) { + if (data.reload.normal()) { if (drum) { if (grip) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m4.reload_normal_drum_grip")); diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/rifle/MarlinItem.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/rifle/MarlinItem.java index e5da4c6b2..ee1070198 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/rifle/MarlinItem.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/rifle/MarlinItem.java @@ -5,11 +5,10 @@ import com.atsuishio.superbwarfare.client.renderer.item.MarlinItemRenderer; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; import com.atsuishio.superbwarfare.item.gun.GunItem; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; -import com.atsuishio.superbwarfare.tools.GunsTool; import net.minecraft.client.Minecraft; import net.minecraft.client.player.LocalPlayer; import net.minecraft.resources.ResourceLocation; @@ -52,23 +51,23 @@ public class MarlinItem extends GunItem implements GeoItem { var data = GunData.from(stack); final var tag = data.tag(); - if (GunsTool.getGunIntTag(tag, "BoltActionTick") > 0) { + if (data.bolt.actionTime() > 0) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.marlin.shift")); } - if (data.getReloadStage() == 1 && tag.getDouble("PrepareTime") > 0) { + if (data.reload.stage() == 1 && tag.getDouble("PrepareTime") > 0) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.marlin.prepare")); } - if (tag.getDouble("LoadIndex") == 0 && data.getReloadStage() == 2) { + if (tag.getDouble("LoadIndex") == 0 && data.reload.stage() == 2) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.marlin.iterativeload")); } - if (tag.getDouble("LoadIndex") == 1 && data.getReloadStage() == 2) { + if (tag.getDouble("LoadIndex") == 1 && data.reload.stage() == 2) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.marlin.iterativeload2")); } - if (data.getReloadStage() == 3) { + if (data.reload.stage() == 3) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.marlin.finish")); } diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/rifle/Mk14Item.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/rifle/Mk14Item.java index 4e8f01adf..2494ef528 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/rifle/Mk14Item.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/rifle/Mk14Item.java @@ -6,8 +6,8 @@ import com.atsuishio.superbwarfare.client.renderer.item.Mk14ItemRenderer; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; import com.atsuishio.superbwarfare.item.gun.GunItem; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; import com.atsuishio.superbwarfare.tools.GunsTool; @@ -57,7 +57,7 @@ public class Mk14Item extends GunItem implements GeoItem { boolean drum = GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.MAGAZINE) == 2; boolean grip = GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.GRIP) == 1 || GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.GRIP) == 2; - if (data.emptyReloading()) { + if (data.reload.empty()) { if (drum) { if (grip) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m14.reload_empty_drum_grip")); @@ -73,7 +73,7 @@ public class Mk14Item extends GunItem implements GeoItem { } } - if (data.normalReloading()) { + if (data.reload.normal()) { if (drum) { if (grip) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m14.reload_normal_drum_grip")); diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/rifle/Qbz95Item.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/rifle/Qbz95Item.java index 43f10bc7c..a50792ba0 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/rifle/Qbz95Item.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/rifle/Qbz95Item.java @@ -6,8 +6,8 @@ import com.atsuishio.superbwarfare.client.renderer.item.Qbz95ItemRenderer; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; import com.atsuishio.superbwarfare.item.gun.GunItem; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; import com.atsuishio.superbwarfare.tools.GunsTool; @@ -61,7 +61,7 @@ public class Qbz95Item extends GunItem implements GeoItem { boolean drum = GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.MAGAZINE) == 2; boolean grip = GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.GRIP) == 1 || GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.GRIP) == 2; - if (data.emptyReloading()) { + if (data.reload.empty()) { if (drum) { if (grip) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.qbz95.reload_empty_drum_grip")); @@ -77,7 +77,7 @@ public class Qbz95Item extends GunItem implements GeoItem { } } - if (data.normalReloading()) { + if (data.reload.normal()) { if (drum) { if (grip) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.qbz95.reload_normal_drum_grip")); diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/rifle/SksItem.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/rifle/SksItem.java index 0907c5ce5..26dd3c0f3 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/rifle/SksItem.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/rifle/SksItem.java @@ -5,8 +5,8 @@ import com.atsuishio.superbwarfare.client.renderer.item.SksItemRenderer; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; import com.atsuishio.superbwarfare.item.gun.GunItem; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; import com.atsuishio.superbwarfare.tools.GunsTool; @@ -58,11 +58,11 @@ public class SksItem extends GunItem implements GeoItem { ItemStack stack = player.getMainHandItem(); if (!stack.is(ModTags.Items.GUN)) return PlayState.STOP; - if (GunData.from(stack).emptyReloading()) { + if (GunData.from(stack).reload.empty()) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.sks.reload_empty")); } - if (GunData.from(stack).normalReloading()) { + if (GunData.from(stack).reload.normal()) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.sks.reload_normal")); } diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/shotgun/Aa12Item.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/shotgun/Aa12Item.java index d6516303d..f52ce19cc 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/shotgun/Aa12Item.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/shotgun/Aa12Item.java @@ -8,8 +8,8 @@ import com.atsuishio.superbwarfare.init.ModPerks; import com.atsuishio.superbwarfare.init.ModRarity; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; import com.atsuishio.superbwarfare.item.gun.GunItem; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; import net.minecraft.client.Minecraft; @@ -57,11 +57,11 @@ public class Aa12Item extends GunItem implements GeoItem { if (this.animationProcedure.equals("empty")) { - if (GunData.from(stack).emptyReloading()) { + if (GunData.from(stack).reload.empty()) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.aa12.reload_empty")); } - if (GunData.from(stack).normalReloading()) { + if (GunData.from(stack).reload.normal()) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.aa12.reload_normal")); } diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/shotgun/HomemadeShotgunItem.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/shotgun/HomemadeShotgunItem.java index e076f6030..c5ef485cc 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/shotgun/HomemadeShotgunItem.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/shotgun/HomemadeShotgunItem.java @@ -6,8 +6,8 @@ import com.atsuishio.superbwarfare.client.tooltip.component.ShotgunImageComponen import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; import com.atsuishio.superbwarfare.item.gun.GunItem; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; import net.minecraft.client.Minecraft; @@ -58,11 +58,11 @@ public class HomemadeShotgunItem extends GunItem implements GeoItem { ItemStack stack = player.getMainHandItem(); if (!stack.is(ModTags.Items.GUN)) return PlayState.STOP; - if (GunData.from(stack).emptyReloading()) { + if (GunData.from(stack).reload.empty()) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ab.reload_empty")); } - if (GunData.from(stack).normalReloading()) { + if (GunData.from(stack).reload.normal()) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ab.reload_normal")); } diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/shotgun/M870Item.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/shotgun/M870Item.java index 8fa192e03..47192f84c 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/shotgun/M870Item.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/shotgun/M870Item.java @@ -6,11 +6,10 @@ import com.atsuishio.superbwarfare.client.tooltip.component.ShotgunImageComponen import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; import com.atsuishio.superbwarfare.item.gun.GunItem; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; -import com.atsuishio.superbwarfare.tools.GunsTool; import com.atsuishio.superbwarfare.tools.NBTTool; import net.minecraft.client.Minecraft; import net.minecraft.client.player.LocalPlayer; @@ -57,27 +56,27 @@ public class M870Item extends GunItem implements GeoItem { var data = GunData.from(stack); final var tag = NBTTool.getTag(stack); - if (GunsTool.getGunIntTag(tag, "BoltActionTick") > 0) { + if (data.bolt.actionTime() > 0) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m870.shift")); } - if (data.getReloadStage() == 1 && tag.getDouble("PrepareLoadTime") > 0) { + if (data.reload.stage() == 1 && tag.getDouble("PrepareLoadTime") > 0) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m870.preparealt")); } - if (data.getReloadStage() == 1 && tag.getDouble("PrepareTime") > 0) { + if (data.reload.stage() == 1 && tag.getDouble("PrepareTime") > 0) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m870.prepare")); } - if (tag.getDouble("LoadIndex") == 0 && data.getReloadStage() == 2) { + if (tag.getDouble("LoadIndex") == 0 && data.reload.stage() == 2) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m870.iterativeload")); } - if (tag.getDouble("LoadIndex") == 1 && data.getReloadStage() == 2) { + if (tag.getDouble("LoadIndex") == 1 && data.reload.stage() == 2) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m870.iterativeload2")); } - if (data.getReloadStage() == 3) { + if (data.reload.stage() == 3) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m870.finish")); } diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/smg/VectorItem.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/smg/VectorItem.java index 411654b97..58795b07d 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/smg/VectorItem.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/smg/VectorItem.java @@ -6,8 +6,8 @@ import com.atsuishio.superbwarfare.client.renderer.item.VectorItemRenderer; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; import com.atsuishio.superbwarfare.item.gun.GunItem; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; import com.atsuishio.superbwarfare.tools.GunsTool; @@ -56,7 +56,7 @@ public class VectorItem extends GunItem implements GeoItem { boolean drum = GunsTool.getAttachmentType(tag, GunsTool.AttachmentType.MAGAZINE) == 2; - if (data.emptyReloading()) { + if (data.reload.empty()) { if (drum) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.vec.reload_empty_drum")); } else { @@ -64,7 +64,7 @@ public class VectorItem extends GunItem implements GeoItem { } } - if (data.normalReloading()) { + if (data.reload.normal()) { if (drum) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.vec.reload_normal_drum")); } else { diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/sniper/HuntingRifleItem.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/sniper/HuntingRifleItem.java index 91c7df17a..03d5b574e 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/sniper/HuntingRifleItem.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/sniper/HuntingRifleItem.java @@ -5,8 +5,8 @@ import com.atsuishio.superbwarfare.client.renderer.item.HuntingRifleItemRenderer import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; import com.atsuishio.superbwarfare.item.gun.GunItem; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; import net.minecraft.client.Minecraft; @@ -54,7 +54,7 @@ public class HuntingRifleItem extends GunItem implements GeoItem { ItemStack stack = player.getMainHandItem(); if (!stack.is(ModTags.Items.GUN)) return PlayState.STOP; - if (GunData.from(stack).emptyReloading()) { + if (GunData.from(stack).reload.empty()) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.hunting_rifle.reload")); } diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/sniper/K98Item.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/sniper/K98Item.java index 282c07d61..1a24ac1b7 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/sniper/K98Item.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/sniper/K98Item.java @@ -5,11 +5,10 @@ import com.atsuishio.superbwarfare.client.renderer.item.K98ItemRenderer; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; import com.atsuishio.superbwarfare.item.gun.GunItem; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; -import com.atsuishio.superbwarfare.tools.GunsTool; import net.minecraft.client.Minecraft; import net.minecraft.client.player.LocalPlayer; import net.minecraft.resources.ResourceLocation; @@ -53,27 +52,27 @@ public class K98Item extends GunItem implements GeoItem { var data = GunData.from(stack); final var tag = data.tag(); - if (GunsTool.getGunIntTag(tag, "BoltActionTick") > 0) { + if (data.bolt.actionTime() > 0) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.k98.shift")); } - if (data.getReloadState() == GunData.ReloadState.EMPTY_RELOADING) { + if (data.reload.empty()) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.k98.reload_empty")); } - if (data.getReloadStage() == 1 && tag.getDouble("PrepareTime") > 0) { + if (data.reload.stage() == 1 && tag.getDouble("PrepareTime") > 0) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.k98.prepare")); } - if (tag.getDouble("LoadIndex") == 0 && data.getReloadStage() == 2) { + if (tag.getDouble("LoadIndex") == 0 && data.reload.stage() == 2) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.k98.iterativeload")); } - if (tag.getDouble("LoadIndex") == 1 && data.getReloadStage() == 2) { + if (tag.getDouble("LoadIndex") == 1 && data.reload.stage() == 2) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.k98.iterativeload2")); } - if (data.getReloadStage() == 3) { + if (data.reload.stage() == 3) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.k98.finish")); } @@ -91,14 +90,14 @@ public class K98Item extends GunItem implements GeoItem { if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("noRun") == 0 - && !(data.getReloadState() == GunData.ReloadState.EMPTY_RELOADING) - && data.getReloadStage() != 1 - && data.getReloadStage() != 2 - && data.getReloadStage() != 3 + && !data.reload.empty() + && data.reload.stage() != 1 + && data.reload.stage() != 2 + && data.reload.stage() != 3 && ClientEventHandler.drawTime < 0.01 && !data.reloading() ) { - if (player.hasEffect(MobEffects.MOVEMENT_SPEED) && GunsTool.getGunIntTag(tag, "BoltActionTick") == 0) { + if (player.hasEffect(MobEffects.MOVEMENT_SPEED) && data.bolt.actionTime() == 0) { return event.setAndContinue(RawAnimation.begin().thenLoop("animation.k98.run_fast")); } else { return event.setAndContinue(RawAnimation.begin().thenLoop("animation.k98.run")); diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/sniper/M98bItem.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/sniper/M98bItem.java index 9bad7adc0..eb6b38580 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/sniper/M98bItem.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/sniper/M98bItem.java @@ -5,11 +5,10 @@ import com.atsuishio.superbwarfare.client.renderer.item.M98bItemRenderer; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; import com.atsuishio.superbwarfare.item.gun.GunItem; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; -import com.atsuishio.superbwarfare.tools.GunsTool; import net.minecraft.client.Minecraft; import net.minecraft.client.player.LocalPlayer; import net.minecraft.resources.ResourceLocation; @@ -52,15 +51,15 @@ public class M98bItem extends GunItem implements GeoItem { var data = GunData.from(stack); final var tag = data.tag(); - if (GunsTool.getGunIntTag(tag, "BoltActionTick") > 0) { + if (data.bolt.actionTime() > 0) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m98b.shift")); } - if (data.emptyReloading()) { + if (data.reload.empty()) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m98b.reload_empty")); } - if (data.normalReloading()) { + if (data.reload.normal()) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m98b.reload_normal")); } @@ -77,8 +76,8 @@ public class M98bItem extends GunItem implements GeoItem { if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("noRun") == 0 - && !(data.normalReloading() || data.emptyReloading()) && ClientEventHandler.drawTime < 0.01) { - if (player.hasEffect(MobEffects.MOVEMENT_SPEED) && GunsTool.getGunIntTag(tag, "BoltActionTick") == 0) { + && !(data.reload.normal() || data.reload.empty()) && ClientEventHandler.drawTime < 0.01) { + if (player.hasEffect(MobEffects.MOVEMENT_SPEED) && data.bolt.actionTime() == 0) { return event.setAndContinue(RawAnimation.begin().thenLoop("animation.m98b.run_fast")); } else { return event.setAndContinue(RawAnimation.begin().thenLoop("animation.m98b.run")); diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/sniper/MosinNagantItem.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/sniper/MosinNagantItem.java index 1115fcbe4..5347bbb0f 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/sniper/MosinNagantItem.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/sniper/MosinNagantItem.java @@ -5,11 +5,10 @@ import com.atsuishio.superbwarfare.client.renderer.item.MosinNagantItemRenderer; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; import com.atsuishio.superbwarfare.item.gun.GunItem; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; -import com.atsuishio.superbwarfare.tools.GunsTool; import com.atsuishio.superbwarfare.tools.NBTTool; import net.minecraft.client.Minecraft; import net.minecraft.client.player.LocalPlayer; @@ -53,27 +52,27 @@ public class MosinNagantItem extends GunItem implements GeoItem { var data = GunData.from(stack); final var tag = data.tag(); - if (GunsTool.getGunIntTag(tag, "BoltActionTick") > 0) { + if (data.bolt.actionTime() > 0) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mosin.shift")); } - if (data.getReloadStage() == 1 && data.ammo() == 0) { + if (data.reload.stage() == 1 && data.ammo() == 0) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mosin.prepare_empty")); } - if (data.getReloadStage() == 1 && data.ammo() > 0) { + if (data.reload.stage() == 1 && data.ammo() > 0) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mosin.prepare")); } - if (NBTTool.getTag(stack).getDouble("LoadIndex") == 0 && data.getReloadStage() == 2) { + if (NBTTool.getTag(stack).getDouble("LoadIndex") == 0 && data.reload.stage() == 2) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mosin.iterativeload")); } - if (NBTTool.getTag(stack).getDouble("LoadIndex") == 1 && data.getReloadStage() == 2) { + if (NBTTool.getTag(stack).getDouble("LoadIndex") == 1 && data.reload.stage() == 2) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mosin.iterativeload2")); } - if (data.getReloadStage() == 3) { + if (data.reload.stage() == 3) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mosin.finish")); } @@ -90,14 +89,14 @@ public class MosinNagantItem extends GunItem implements GeoItem { if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("noRun") == 0 - && !(GunData.from(stack).emptyReloading()) - && data.getReloadStage() != 1 - && data.getReloadStage() != 2 - && data.getReloadStage() != 3 + && !(GunData.from(stack).reload.empty()) + && data.reload.stage() != 1 + && data.reload.stage() != 2 + && data.reload.stage() != 3 && ClientEventHandler.drawTime < 0.01 && !data.reloading() ) { - if (player.hasEffect(MobEffects.MOVEMENT_SPEED) && GunsTool.getGunIntTag(tag, "BoltActionTick") == 0) { + if (player.hasEffect(MobEffects.MOVEMENT_SPEED) && data.bolt.actionTime() == 0) { return event.setAndContinue(RawAnimation.begin().thenLoop("animation.mosin.run_fast")); } else { return event.setAndContinue(RawAnimation.begin().thenLoop("animation.mosin.run")); diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/sniper/SentinelItem.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/sniper/SentinelItem.java index bf41dff88..e27f66203 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/sniper/SentinelItem.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/sniper/SentinelItem.java @@ -8,11 +8,10 @@ import com.atsuishio.superbwarfare.init.ModRarity; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; import com.atsuishio.superbwarfare.item.EnergyStorageItem; -import com.atsuishio.superbwarfare.item.gun.GunData; import com.atsuishio.superbwarfare.item.gun.GunItem; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; -import com.atsuishio.superbwarfare.tools.GunsTool; import net.minecraft.client.Minecraft; import net.minecraft.client.player.LocalPlayer; import net.minecraft.resources.ResourceLocation; @@ -76,15 +75,15 @@ public class SentinelItem extends GunItem implements GeoItem, EnergyStorageItem var data = GunData.from(stack); final var tag = data.tag(); - if (GunsTool.getGunIntTag(tag, "BoltActionTick") > 0) { + if (data.bolt.actionTime() > 0) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.sentinel.shift")); } - if (data.emptyReloading()) { + if (data.reload.empty()) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.sentinel.reload_empty")); } - if (data.normalReloading()) { + if (data.reload.normal()) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.sentinel.reload_normal")); } @@ -109,7 +108,7 @@ public class SentinelItem extends GunItem implements GeoItem, EnergyStorageItem && !data.charging() && ClientEventHandler.drawTime < 0.01 ) { - if (player.hasEffect(MobEffects.MOVEMENT_SPEED) && GunsTool.getGunIntTag(tag, "BoltActionTick") == 0) { + if (player.hasEffect(MobEffects.MOVEMENT_SPEED) && data.bolt.actionTime() == 0) { return event.setAndContinue(RawAnimation.begin().thenLoop("animation.sentinel.run_fast")); } else { return event.setAndContinue(RawAnimation.begin().thenLoop("animation.sentinel.run")); diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/sniper/SvdItem.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/sniper/SvdItem.java index a897fb015..0bfd32380 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/sniper/SvdItem.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/sniper/SvdItem.java @@ -6,8 +6,8 @@ import com.atsuishio.superbwarfare.client.renderer.item.SvdItemRenderer; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; import com.atsuishio.superbwarfare.item.gun.GunItem; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; import com.atsuishio.superbwarfare.tools.GunsTool; @@ -52,11 +52,11 @@ public class SvdItem extends GunItem implements GeoItem { ItemStack stack = player.getMainHandItem(); if (!stack.is(ModTags.Items.GUN)) return PlayState.STOP; - if (GunData.from(stack).emptyReloading()) { + if (GunData.from(stack).reload.empty()) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.svd.reload_empty")); } - if (GunData.from(stack).normalReloading()) { + if (GunData.from(stack).reload.normal()) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.svd.reload_normal")); } diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/special/BocekItem.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/special/BocekItem.java index 42f5a33a1..7451fe439 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/special/BocekItem.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/special/BocekItem.java @@ -9,9 +9,9 @@ import com.atsuishio.superbwarfare.init.ModItems; import com.atsuishio.superbwarfare.init.ModPerks; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; import com.atsuishio.superbwarfare.item.gun.GunItem; import com.atsuishio.superbwarfare.item.gun.SpecialFireWeapon; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.network.message.receive.ShootClientMessage; import com.atsuishio.superbwarfare.perk.AmmoPerk; import com.atsuishio.superbwarfare.perk.Perk; diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/special/TaserItem.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/special/TaserItem.java index 448ece622..5b3458fb6 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/special/TaserItem.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/special/TaserItem.java @@ -11,9 +11,9 @@ import com.atsuishio.superbwarfare.init.ModPerks; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; import com.atsuishio.superbwarfare.item.EnergyStorageItem; -import com.atsuishio.superbwarfare.item.gun.GunData; import com.atsuishio.superbwarfare.item.gun.GunItem; import com.atsuishio.superbwarfare.item.gun.SpecialFireWeapon; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.network.message.receive.ShootClientMessage; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; @@ -95,7 +95,7 @@ public class TaserItem extends GunItem implements GeoItem, SpecialFireWeapon, En ItemStack stack = player.getMainHandItem(); if (!stack.is(ModTags.Items.GUN)) return PlayState.STOP; - if (GunData.from(stack).emptyReloading()) { + if (GunData.from(stack).reload.empty()) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.taser.reload")); } diff --git a/src/main/java/com/atsuishio/superbwarfare/menu/ReforgingTableMenu.java b/src/main/java/com/atsuishio/superbwarfare/menu/ReforgingTableMenu.java index 218b83842..6b5bd9251 100644 --- a/src/main/java/com/atsuishio/superbwarfare/menu/ReforgingTableMenu.java +++ b/src/main/java/com/atsuishio/superbwarfare/menu/ReforgingTableMenu.java @@ -4,8 +4,8 @@ import com.atsuishio.superbwarfare.init.ModBlocks; import com.atsuishio.superbwarfare.init.ModMenuTypes; import com.atsuishio.superbwarfare.init.ModTags; import com.atsuishio.superbwarfare.item.PerkItem; -import com.atsuishio.superbwarfare.item.gun.GunData; import com.atsuishio.superbwarfare.item.gun.GunItem; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; import com.atsuishio.superbwarfare.tools.NBTTool; diff --git a/src/main/java/com/atsuishio/superbwarfare/network/message/send/AdjustZoomFovMessage.java b/src/main/java/com/atsuishio/superbwarfare/network/message/send/AdjustZoomFovMessage.java index 55aebbb35..1d65e91d4 100644 --- a/src/main/java/com/atsuishio/superbwarfare/network/message/send/AdjustZoomFovMessage.java +++ b/src/main/java/com/atsuishio/superbwarfare/network/message/send/AdjustZoomFovMessage.java @@ -4,7 +4,7 @@ import com.atsuishio.superbwarfare.Mod; import com.atsuishio.superbwarfare.init.ModItems; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.tools.FormatTool; import com.atsuishio.superbwarfare.tools.GunsTool; import com.atsuishio.superbwarfare.tools.SoundTool; diff --git a/src/main/java/com/atsuishio/superbwarfare/network/message/send/EditMessage.java b/src/main/java/com/atsuishio/superbwarfare/network/message/send/EditMessage.java index 6502710aa..813b0ed0e 100644 --- a/src/main/java/com/atsuishio/superbwarfare/network/message/send/EditMessage.java +++ b/src/main/java/com/atsuishio/superbwarfare/network/message/send/EditMessage.java @@ -3,7 +3,7 @@ package com.atsuishio.superbwarfare.network.message.send; import com.atsuishio.superbwarfare.Mod; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.tools.SoundTool; import io.netty.buffer.ByteBuf; import net.minecraft.nbt.CompoundTag; diff --git a/src/main/java/com/atsuishio/superbwarfare/network/message/send/FireMessage.java b/src/main/java/com/atsuishio/superbwarfare/network/message/send/FireMessage.java index 5caa9575d..bb81d4023 100644 --- a/src/main/java/com/atsuishio/superbwarfare/network/message/send/FireMessage.java +++ b/src/main/java/com/atsuishio/superbwarfare/network/message/send/FireMessage.java @@ -6,8 +6,8 @@ import com.atsuishio.superbwarfare.entity.projectile.ProjectileEntity; import com.atsuishio.superbwarfare.event.GunEventHandler; import com.atsuishio.superbwarfare.init.ModPerks; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; import com.atsuishio.superbwarfare.item.gun.SpecialFireWeapon; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.perk.AmmoPerk; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; @@ -89,18 +89,17 @@ public record FireMessage(int msgType) implements CustomPacketPayload { private static void handleGunBolt(Player player, ItemStack stack) { if (!stack.is(ModTags.Items.GUN)) return; var data = GunData.from(stack); - CompoundTag tag = data.tag(); - if (data.boltActionTime() > 0 + if (data.bolt.defaultActionTime() > 0 && data.ammo() > (stack.is(ModTags.Items.REVOLVER) ? -1 : 0) - && GunsTool.getGunIntTag(tag, "BoltActionTick") == 0 - && !(data.normalReloading() - || data.emptyReloading()) + && data.bolt.actionTime() == 0 + && !(data.reload.normal() + || data.reload.empty()) && !data.reloading() && !data.charging() ) { - if (!player.getCooldowns().isOnCooldown(stack.getItem()) && GunsTool.getGunBooleanTag(tag, "NeedBoltAction")) { - GunsTool.setGunIntTag(tag, "BoltActionTick", data.boltActionTime() + 1); + if (!player.getCooldowns().isOnCooldown(stack.getItem()) && data.bolt.needed()) { + data.bolt.setActionTime(data.bolt.defaultActionTime() + 1); GunEventHandler.playGunBoltSounds(player); } } diff --git a/src/main/java/com/atsuishio/superbwarfare/network/message/send/FireModeMessage.java b/src/main/java/com/atsuishio/superbwarfare/network/message/send/FireModeMessage.java index 6fa649b22..579c40c8e 100644 --- a/src/main/java/com/atsuishio/superbwarfare/network/message/send/FireModeMessage.java +++ b/src/main/java/com/atsuishio/superbwarfare/network/message/send/FireModeMessage.java @@ -3,9 +3,8 @@ package com.atsuishio.superbwarfare.network.message.send; import com.atsuishio.superbwarfare.Mod; import com.atsuishio.superbwarfare.init.ModItems; import com.atsuishio.superbwarfare.init.ModSounds; -import com.atsuishio.superbwarfare.item.gun.GunData; import com.atsuishio.superbwarfare.item.gun.GunItem; -import com.atsuishio.superbwarfare.tools.GunsTool; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.tools.SoundTool; import io.netty.buffer.ByteBuf; import net.minecraft.network.codec.ByteBufCodecs; @@ -89,7 +88,7 @@ public record FireModeMessage(int msgType) implements CustomPacketPayload { if (stack.getItem() == ModItems.SENTINEL.get() && !player.isSpectator() && !(player.getCooldowns().isOnCooldown(stack.getItem())) - && GunsTool.getGunIntTag(tag, "ReloadTime") == 0 + && data.reload.time() == 0 && !data.charging() ) { for (var cell : player.getInventory().items) { @@ -110,11 +109,10 @@ public record FireModeMessage(int msgType) implements CustomPacketPayload { } } - if (stack.getItem() == ModItems.TRACHELIUM.get() && !GunsTool.getGunBooleanTag(tag, "NeedBoltAction")) { + if (stack.getItem() == ModItems.TRACHELIUM.get() && !data.bolt.needed()) { tag.putBoolean("DA", !tag.getBoolean("DA")); - data.save(); if (!tag.getBoolean("canImmediatelyShoot")) { - GunsTool.setGunBooleanTag(tag, "NeedBoltAction", true); + data.bolt.markNeeded(); } } diff --git a/src/main/java/com/atsuishio/superbwarfare/network/message/send/ReloadMessage.java b/src/main/java/com/atsuishio/superbwarfare/network/message/send/ReloadMessage.java index 81f52c63e..a1263d9b2 100644 --- a/src/main/java/com/atsuishio/superbwarfare/network/message/send/ReloadMessage.java +++ b/src/main/java/com/atsuishio/superbwarfare/network/message/send/ReloadMessage.java @@ -4,8 +4,8 @@ import com.atsuishio.superbwarfare.Mod; import com.atsuishio.superbwarfare.capability.ModCapabilities; import com.atsuishio.superbwarfare.init.ModItems; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; import com.atsuishio.superbwarfare.item.gun.GunItem; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.tools.GunsTool; import io.netty.buffer.ByteBuf; import net.minecraft.network.codec.ByteBufCodecs; @@ -46,8 +46,8 @@ public record ReloadMessage(int msgType) implements CustomPacketPayload { if (!player.isSpectator() && !data.charging() && !data.reloading() - && GunsTool.getGunIntTag(tag, "ReloadTime") == 0 - && GunsTool.getGunIntTag(tag, "BoltActionTick") == 0 + && data.reload.time() == 0 + && data.bolt.actionTime() == 0 ) { boolean canSingleReload = gunItem.isIterativeReload(stack); boolean canReload = gunItem.isMagazineReload(stack) && !gunItem.isClipReload(stack); @@ -76,19 +76,11 @@ public record ReloadMessage(int msgType) implements CustomPacketPayload { if (canReload || clipLoad) { int magazine = data.magazine(); + var extra = (gunItem.isOpenBolt(stack) && gunItem.hasBulletInBarrel(stack)) ? 1 : 0; + var maxAmmo = magazine + extra; - if (gunItem.isOpenBolt(stack)) { - if (gunItem.hasBulletInBarrel(stack)) { - if (data.ammo() < magazine + 1) { - GunsTool.setGunBooleanTag(tag, "StartReload", true); - } - } else { - if (data.ammo() < magazine) { - GunsTool.setGunBooleanTag(tag, "StartReload", true); - } - } - } else if (data.ammo() < magazine) { - GunsTool.setGunBooleanTag(tag, "StartReload", true); + if (data.ammo() < maxAmmo) { + data.reload.markStart(); } return; } diff --git a/src/main/java/com/atsuishio/superbwarfare/network/message/send/SensitivityMessage.java b/src/main/java/com/atsuishio/superbwarfare/network/message/send/SensitivityMessage.java index 22741cc15..7425e3c3f 100644 --- a/src/main/java/com/atsuishio/superbwarfare/network/message/send/SensitivityMessage.java +++ b/src/main/java/com/atsuishio/superbwarfare/network/message/send/SensitivityMessage.java @@ -2,7 +2,7 @@ package com.atsuishio.superbwarfare.network.message.send; import com.atsuishio.superbwarfare.Mod; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import io.netty.buffer.ByteBuf; import net.minecraft.network.chat.Component; import net.minecraft.network.codec.ByteBufCodecs; diff --git a/src/main/java/com/atsuishio/superbwarfare/network/message/send/ShootMessage.java b/src/main/java/com/atsuishio/superbwarfare/network/message/send/ShootMessage.java index 79af6cbb4..a4a8eb7e7 100644 --- a/src/main/java/com/atsuishio/superbwarfare/network/message/send/ShootMessage.java +++ b/src/main/java/com/atsuishio/superbwarfare/network/message/send/ShootMessage.java @@ -7,7 +7,7 @@ import com.atsuishio.superbwarfare.init.ModItems; import com.atsuishio.superbwarfare.init.ModPerks; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.perk.AmmoPerk; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; @@ -61,8 +61,8 @@ public record ShootMessage(double spread) implements CustomPacketPayload { } // 判断是否为栓动武器(BoltActionTime > 0),并在开火后给一个需要上膛的状态 - if (data.boltActionTime() > 0 && data.ammo() > (stack.is(ModTags.Items.REVOLVER) ? 0 : 1)) { - GunsTool.setGunBooleanTag(tag, "NeedBoltAction", true); + if (data.bolt.defaultActionTime() > 0 && data.ammo() > (stack.is(ModTags.Items.REVOLVER) ? 0 : 1)) { + data.bolt.markNeeded(); } data.setAmmo(data.ammo() - 1); diff --git a/src/main/java/com/atsuishio/superbwarfare/network/message/send/SwitchScopeMessage.java b/src/main/java/com/atsuishio/superbwarfare/network/message/send/SwitchScopeMessage.java index c3be8aa68..9b8f2d443 100644 --- a/src/main/java/com/atsuishio/superbwarfare/network/message/send/SwitchScopeMessage.java +++ b/src/main/java/com/atsuishio/superbwarfare/network/message/send/SwitchScopeMessage.java @@ -2,7 +2,7 @@ package com.atsuishio.superbwarfare.network.message.send; import com.atsuishio.superbwarfare.Mod; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import io.netty.buffer.ByteBuf; import net.minecraft.network.codec.ByteBufCodecs; import net.minecraft.network.codec.StreamCodec; diff --git a/src/main/java/com/atsuishio/superbwarfare/network/message/send/ZoomMessage.java b/src/main/java/com/atsuishio/superbwarfare/network/message/send/ZoomMessage.java index 3f82d0ba3..22cdff11a 100644 --- a/src/main/java/com/atsuishio/superbwarfare/network/message/send/ZoomMessage.java +++ b/src/main/java/com/atsuishio/superbwarfare/network/message/send/ZoomMessage.java @@ -6,7 +6,7 @@ import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity; import com.atsuishio.superbwarfare.entity.vehicle.base.WeaponVehicleEntity; import com.atsuishio.superbwarfare.init.ModItems; import com.atsuishio.superbwarfare.init.ModSounds; -import com.atsuishio.superbwarfare.item.gun.GunData; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.tools.SoundTool; import io.netty.buffer.ByteBuf; import net.minecraft.network.codec.ByteBufCodecs; diff --git a/src/main/java/com/atsuishio/superbwarfare/perk/PerkHelper.java b/src/main/java/com/atsuishio/superbwarfare/perk/PerkHelper.java index 6c0d9a081..14bda3d70 100644 --- a/src/main/java/com/atsuishio/superbwarfare/perk/PerkHelper.java +++ b/src/main/java/com/atsuishio/superbwarfare/perk/PerkHelper.java @@ -3,7 +3,7 @@ package com.atsuishio.superbwarfare.perk; import com.atsuishio.superbwarfare.init.ModItems; import com.atsuishio.superbwarfare.init.ModPerks; import com.atsuishio.superbwarfare.item.PerkItem; -import com.atsuishio.superbwarfare.item.gun.GunData; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Mth; diff --git a/src/main/java/com/atsuishio/superbwarfare/tools/GunsTool.java b/src/main/java/com/atsuishio/superbwarfare/tools/GunsTool.java index 62411292e..e980a501b 100644 --- a/src/main/java/com/atsuishio/superbwarfare/tools/GunsTool.java +++ b/src/main/java/com/atsuishio/superbwarfare/tools/GunsTool.java @@ -3,7 +3,8 @@ package com.atsuishio.superbwarfare.tools; import com.atsuishio.superbwarfare.Mod; import com.atsuishio.superbwarfare.capability.ModCapabilities; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.GunData; +import com.atsuishio.superbwarfare.item.gun.data.GunData; +import com.atsuishio.superbwarfare.item.gun.data.ReloadState; import com.atsuishio.superbwarfare.network.message.receive.GunsDataMessage; import com.google.gson.stream.JsonReader; import net.minecraft.nbt.CompoundTag; @@ -92,8 +93,8 @@ public class GunsTool { int ammoToAdd = mag - ammo + (extraOne ? 1 : 0); // 空仓换弹的栓动武器应该在换弹后取消待上膛标记 - if (ammo == 0 && gunData.boltActionTime() > 0 && !stack.is(ModTags.Items.REVOLVER)) { - data.putBoolean("NeedBoltAction", false); + if (ammo == 0 && gunData.bolt.defaultActionTime() > 0 && !stack.is(ModTags.Items.REVOLVER)) { + gunData.bolt.markNeedless(); } var capability = player.getCapability(ModCapabilities.PLAYER_VARIABLE); @@ -109,7 +110,7 @@ public class GunsTool { int needToAdd = ammo + Math.min(ammoToAdd, playerAmmo); gunData.setAmmo(needToAdd); - gunData.setReloadState(GunData.ReloadState.NOT_RELOADING); + gunData.reload.setState(ReloadState.NOT_RELOADING); } /* PerkData */