From 7e5b24617d08e2feaf0e596b6616cb7893c2101d Mon Sep 17 00:00:00 2001 From: Light_Quanta Date: Fri, 11 Apr 2025 14:44:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96GunData=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../superbwarfare/client/ClickHandler.java | 6 +- .../superbwarfare/client/ItemModelHelper.java | 4 +- .../client/model/item/AK12ItemModel.java | 2 +- .../client/model/item/AK47ItemModel.java | 2 +- .../client/model/item/Glock18ItemModel.java | 2 +- .../client/model/item/Hk416ItemModel.java | 4 +- .../client/model/item/K98ItemModel.java | 2 +- .../client/model/item/M4ItemModel.java | 2 +- .../client/model/item/M60ItemModel.java | 2 +- .../client/model/item/MarlinItemModel.java | 2 +- .../client/model/item/Mk14ItemModel.java | 2 +- .../model/item/MosinNagantItemModel.java | 2 +- .../client/model/item/Ntw20Model.java | 4 +- .../client/model/item/Qbz95ItemModel.java | 2 +- .../client/model/item/RpgItemModel.java | 2 +- .../client/model/item/RpkItemModel.java | 2 +- .../client/model/item/SentinelItemModel.java | 4 +- .../client/model/item/SvdItemModel.java | 2 +- .../model/item/TracheliumItemModel.java | 4 +- .../client/model/item/VectorItemModel.java | 4 +- .../client/overlay/AmmoBarOverlay.java | 10 +- .../client/overlay/JavelinHudOverlay.java | 2 +- .../renderer/item/AK12ItemRenderer.java | 3 +- .../renderer/item/AK47ItemRenderer.java | 3 +- .../renderer/item/Aa12ItemRenderer.java | 2 +- .../renderer/item/BocekItemRenderer.java | 2 +- .../renderer/item/Hk416ItemRenderer.java | 2 +- .../renderer/item/InsidiousItemRenderer.java | 3 +- .../client/renderer/item/M4ItemRenderer.java | 2 +- .../renderer/item/Mk14ItemRenderer.java | 3 +- .../client/renderer/item/Ntw20Renderer.java | 3 +- .../renderer/item/Qbz95ItemRenderer.java | 3 +- .../client/renderer/item/RpgItemRenderer.java | 2 +- .../client/renderer/item/RpkItemRenderer.java | 3 +- .../client/renderer/item/SvdItemRenderer.java | 3 +- .../renderer/item/TracheliumItemRenderer.java | 2 +- .../renderer/item/VectorItemRenderer.java | 3 +- .../client/tooltip/ClientGunImageTooltip.java | 6 +- .../event/ClientEventHandler.java | 26 +-- .../superbwarfare/event/GunEventHandler.java | 70 +++---- .../event/LivingEventHandler.java | 56 +++--- .../event/PlayerEventHandler.java | 24 +-- .../superbwarfare/item/gun/GunItem.java | 10 +- .../superbwarfare/item/gun/data/Bolt.java | 47 ----- .../superbwarfare/item/gun/data/Charge.java | 15 -- .../superbwarfare/item/gun/data/GunData.java | 186 +++++------------- .../gun/data/{ => subdata}/Attachment.java | 6 +- .../item/gun/data/subdata/Bolt.java | 16 ++ .../item/gun/data/subdata/Charge.java | 19 ++ .../item/gun/data/{ => subdata}/Perks.java | 5 +- .../item/gun/data/{ => subdata}/Reload.java | 21 +- .../gun/data/{ => value}/AttachmentType.java | 2 +- .../item/gun/data/value/BooleanValue.java | 38 ++++ .../item/gun/data/value/DoubleValue.java | 38 ++++ .../item/gun/data/value/IntValue.java | 38 ++++ .../gun/data/{ => value}/ReloadState.java | 2 +- .../item/gun/data/{ => value}/Starter.java | 7 +- .../item/gun/data/{ => value}/Timer.java | 7 +- .../item/gun/handgun/Trachelium.java | 6 +- .../item/gun/heavy/Ntw20Item.java | 6 +- .../item/gun/launcher/JavelinItem.java | 6 +- .../item/gun/launcher/M79Item.java | 6 +- .../item/gun/launcher/RpgItem.java | 20 +- .../item/gun/launcher/SecondaryCataclysm.java | 10 +- .../item/gun/machinegun/M60Item.java | 2 +- .../item/gun/machinegun/RpkItem.java | 2 +- .../item/gun/rifle/AK12Item.java | 2 +- .../item/gun/rifle/AK47Item.java | 2 +- .../item/gun/rifle/Hk416Item.java | 2 +- .../superbwarfare/item/gun/rifle/M4Item.java | 2 +- .../item/gun/rifle/MarlinItem.java | 6 +- .../item/gun/rifle/Mk14Item.java | 2 +- .../item/gun/rifle/Qbz95Item.java | 2 +- .../superbwarfare/item/gun/rifle/SksItem.java | 2 +- .../item/gun/shotgun/M870Item.java | 6 +- .../item/gun/smg/VectorItem.java | 2 +- .../item/gun/sniper/K98Item.java | 8 +- .../item/gun/sniper/M98bItem.java | 4 +- .../item/gun/sniper/MosinNagantItem.java | 12 +- .../item/gun/sniper/SentinelItem.java | 4 +- .../item/gun/sniper/SvdItem.java | 2 +- .../item/gun/special/BocekItem.java | 2 +- .../item/gun/special/TaserItem.java | 6 +- .../menu/ReforgingTableMenu.java | 12 +- .../network/message/send/EditMessage.java | 2 +- .../network/message/send/FireMessage.java | 14 +- .../network/message/send/FireModeMessage.java | 22 +-- .../network/message/send/ReloadMessage.java | 12 +- .../network/message/send/ShootMessage.java | 16 +- .../superbwarfare/tools/GunsTool.java | 10 +- 90 files changed, 479 insertions(+), 479 deletions(-) delete mode 100644 src/main/java/com/atsuishio/superbwarfare/item/gun/data/Bolt.java delete mode 100644 src/main/java/com/atsuishio/superbwarfare/item/gun/data/Charge.java rename src/main/java/com/atsuishio/superbwarfare/item/gun/data/{ => subdata}/Attachment.java (62%) create mode 100644 src/main/java/com/atsuishio/superbwarfare/item/gun/data/subdata/Bolt.java create mode 100644 src/main/java/com/atsuishio/superbwarfare/item/gun/data/subdata/Charge.java rename src/main/java/com/atsuishio/superbwarfare/item/gun/data/{ => subdata}/Perks.java (96%) rename src/main/java/com/atsuishio/superbwarfare/item/gun/data/{ => subdata}/Reload.java (77%) rename src/main/java/com/atsuishio/superbwarfare/item/gun/data/{ => value}/AttachmentType.java (83%) create mode 100644 src/main/java/com/atsuishio/superbwarfare/item/gun/data/value/BooleanValue.java create mode 100644 src/main/java/com/atsuishio/superbwarfare/item/gun/data/value/DoubleValue.java create mode 100644 src/main/java/com/atsuishio/superbwarfare/item/gun/data/value/IntValue.java rename src/main/java/com/atsuishio/superbwarfare/item/gun/data/{ => value}/ReloadState.java (61%) rename src/main/java/com/atsuishio/superbwarfare/item/gun/data/{ => value}/Starter.java (83%) rename src/main/java/com/atsuishio/superbwarfare/item/gun/data/{ => value}/Timer.java (79%) diff --git a/src/main/java/com/atsuishio/superbwarfare/client/ClickHandler.java b/src/main/java/com/atsuishio/superbwarfare/client/ClickHandler.java index 120fe799b..d7958184a 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/ClickHandler.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/ClickHandler.java @@ -337,7 +337,7 @@ public class ClickHandler { handTimer = 0; } - if (!gunItem.useBackpackAmmo(stack) && data.ammo() <= 0 && data.reload.time() == 0) { + if (!gunItem.useBackpackAmmo(stack) && data.ammo.get() <= 0 && data.reload.time() == 0) { if (ReloadConfig.LEFT_CLICK_RELOAD.get()) { PacketDistributor.sendToServer(new ReloadMessage(0)); ClientEventHandler.burstFireAmount = 0; @@ -346,10 +346,10 @@ public class ClickHandler { PacketDistributor.sendToServer(new FireMessage(0, handTimer, zoom)); if ((!data.reloading() && !data.charging() - && !data.bolt.needed()) + && !data.bolt.needed.get()) && drawTime < 0.01 ) { - if (data.fireMode() == 1) { + if (data.fireMode.get() == 1) { if (ClientEventHandler.burstFireAmount == 0) { ClientEventHandler.burstFireAmount = data.burstAmount(); } diff --git a/src/main/java/com/atsuishio/superbwarfare/client/ItemModelHelper.java b/src/main/java/com/atsuishio/superbwarfare/client/ItemModelHelper.java index b917ed8cd..8449c0a64 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/ItemModelHelper.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/ItemModelHelper.java @@ -1,8 +1,8 @@ package com.atsuishio.superbwarfare.client; -import com.atsuishio.superbwarfare.item.gun.data.Attachment; -import com.atsuishio.superbwarfare.item.gun.data.AttachmentType; import com.atsuishio.superbwarfare.item.gun.data.GunData; +import com.atsuishio.superbwarfare.item.gun.data.subdata.Attachment; +import com.atsuishio.superbwarfare.item.gun.data.value.AttachmentType; import net.minecraft.world.item.ItemStack; import software.bernie.geckolib.cache.object.GeoBone; 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 b600a315b..14e24942e 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,8 +5,8 @@ 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.data.AttachmentType; import com.atsuishio.superbwarfare.item.gun.data.GunData; +import com.atsuishio.superbwarfare.item.gun.data.value.AttachmentType; import com.atsuishio.superbwarfare.item.gun.rifle.AK12Item; import net.minecraft.client.Minecraft; import net.minecraft.resources.ResourceLocation; 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 3bf2e9dd7..f3e426007 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,8 +5,8 @@ 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.data.AttachmentType; import com.atsuishio.superbwarfare.item.gun.data.GunData; +import com.atsuishio.superbwarfare.item.gun.data.value.AttachmentType; import com.atsuishio.superbwarfare.item.gun.rifle.AK47Item; import net.minecraft.client.Minecraft; import net.minecraft.resources.ResourceLocation; 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 1f58972ea..35ef18480 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 @@ -49,7 +49,7 @@ public class Glock18ItemModel extends GeoModel { var data = GunData.from(stack); var tag = data.tag(); - int mode = data.fireMode(); + int mode = data.fireMode.get(); if (mode == 0) { switch_.setRotX(35 * Mth.DEG_TO_RAD); } 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 25ad1855d..fcf3d327c 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,8 +5,8 @@ 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.data.AttachmentType; import com.atsuishio.superbwarfare.item.gun.data.GunData; +import com.atsuishio.superbwarfare.item.gun.data.value.AttachmentType; import com.atsuishio.superbwarfare.item.gun.rifle.Hk416Item; import net.minecraft.client.Minecraft; import net.minecraft.resources.ResourceLocation; @@ -152,7 +152,7 @@ public class Hk416ItemModel extends GeoModel { l.setRotX(rotXBipod * Mth.DEG_TO_RAD); r.setRotX(rotXBipod * Mth.DEG_TO_RAD); - int mode = data.fireMode(); + int mode = data.fireMode.get(); kuaimanji.setRotX(mode == 2 ? 90 * Mth.DEG_TO_RAD : 0); 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 40259809f..9b3be5ba5 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 @@ -44,7 +44,7 @@ public class K98ItemModel extends GeoModel { if (!stack.is(ModTags.Items.GUN)) return; var data = GunData.from(stack); - if (data.reload.prepareTimer.get() > 11 && data.ammo() == 1) { + if (data.reload.prepareTimer.get() > 11 && data.ammo.get() == 1) { clip.setScaleX(0); clip.setScaleY(0); clip.setScaleZ(0); 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 7b04b93fb..a2d779e90 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,8 +5,8 @@ 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.data.AttachmentType; import com.atsuishio.superbwarfare.item.gun.data.GunData; +import com.atsuishio.superbwarfare.item.gun.data.value.AttachmentType; import com.atsuishio.superbwarfare.item.gun.rifle.M4Item; import com.atsuishio.superbwarfare.tools.NBTTool; import net.minecraft.client.Minecraft; 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 db8448969..133690e25 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 @@ -61,7 +61,7 @@ public class M60ItemModel extends GeoModel { var data = GunData.from(stack); var tag = data.tag(); - int ammo = data.ammo(); + int ammo = data.ammo.get(); boolean flag = GunsTool.getGunBooleanTag(tag, "HideBulletChain"); if (ammo < 5 && flag) { 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 794b4c342..8fb607eb8 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 @@ -83,7 +83,7 @@ public class MarlinItemModel extends GeoModel { CrossHairOverlay.gunRot = shen.getRotZ(); - if (GunData.from(stack).isEmpty()) { + if (GunData.from(stack).isEmpty.get()) { jichui.setRotX(-0.52f); } 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 12906536c..1477c3721 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,8 +5,8 @@ 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.data.AttachmentType; import com.atsuishio.superbwarfare.item.gun.data.GunData; +import com.atsuishio.superbwarfare.item.gun.data.value.AttachmentType; import com.atsuishio.superbwarfare.item.gun.rifle.Mk14Item; import net.minecraft.client.Minecraft; import net.minecraft.resources.ResourceLocation; 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 1d42e3cbc..044fecc5d 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 @@ -121,7 +121,7 @@ public class MosinNagantItemModel extends GeoModel { float numR = (float) (1 - 0.97 * zt); float numP = (float) (1 - 0.81 * zt); - if (data.reloading() || data.bolt.actionTime() > 0) { + if (data.reloading() || data.bolt.actionTimer.get() > 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 aa8aca215..9a1f50278 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,8 +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.data.AttachmentType; import com.atsuishio.superbwarfare.item.gun.data.GunData; +import com.atsuishio.superbwarfare.item.gun.data.value.AttachmentType; import com.atsuishio.superbwarfare.item.gun.heavy.Ntw20Item; import net.minecraft.client.Minecraft; import net.minecraft.resources.ResourceLocation; @@ -157,7 +157,7 @@ public class Ntw20Model extends GeoModel { float numR = (float) (1 - 0.92 * zt); float numP = (float) (1 - 0.88 * zt); - if (data.reload.time() > 0 || data.bolt.actionTime() > 0) { + if (data.reload.time() > 0 || data.bolt.actionTimer.get() > 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 cd54ca7f1..c9b686d91 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,8 +5,8 @@ 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.data.AttachmentType; import com.atsuishio.superbwarfare.item.gun.data.GunData; +import com.atsuishio.superbwarfare.item.gun.data.value.AttachmentType; import com.atsuishio.superbwarfare.item.gun.rifle.Qbz95Item; import com.atsuishio.superbwarfare.tools.GunsTool; import net.minecraft.client.Minecraft; 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 22cf8d1db..31809d9e7 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 @@ -45,7 +45,7 @@ public class RpgItemModel extends GeoModel { if (!stack.is(ModTags.Items.GUN)) return; var data = GunData.from(stack); - if (data.closeHammer()) { + if (data.closeHammer.get()) { hammer.setRotX(-90 * Mth.DEG_TO_RAD); } 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 160601e56..dcca391ab 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,8 +5,8 @@ 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.data.AttachmentType; import com.atsuishio.superbwarfare.item.gun.data.GunData; +import com.atsuishio.superbwarfare.item.gun.data.value.AttachmentType; import com.atsuishio.superbwarfare.item.gun.machinegun.RpkItem; import net.minecraft.client.Minecraft; import net.minecraft.resources.ResourceLocation; 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 1e80ed2ff..399eb73de 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 @@ -104,8 +104,8 @@ public class SentinelItemModel extends GeoModel { root.setRotY((float) (0.2f * movePosX + Mth.DEG_TO_RAD * 300 * ClientEventHandler.drawTime + Mth.DEG_TO_RAD * turnRotY)); root.setRotZ((float) (0.2f * movePosX + moveRotZ + Mth.DEG_TO_RAD * 90 * ClientEventHandler.drawTime + 2.7f * mph + Mth.DEG_TO_RAD * turnRotZ)); - if (data.ammo() <= 5) { - ammo.setScaleX((float) data.ammo() / 5); + if (data.ammo.get() <= 5) { + ammo.setScaleX((float) data.ammo.get() / 5); } GeoBone camera = getAnimationProcessor().getBone("camera"); 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 b11b5c742..64fba7e1b 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,8 +5,8 @@ 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.data.AttachmentType; import com.atsuishio.superbwarfare.item.gun.data.GunData; +import com.atsuishio.superbwarfare.item.gun.data.value.AttachmentType; 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 3d21f9096..e31e15e74 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,8 +5,8 @@ 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.data.AttachmentType; import com.atsuishio.superbwarfare.item.gun.data.GunData; +import com.atsuishio.superbwarfare.item.gun.data.value.AttachmentType; import com.atsuishio.superbwarfare.item.gun.handgun.Trachelium; import com.atsuishio.superbwarfare.tools.NBTTool; import net.minecraft.client.Minecraft; @@ -169,7 +169,7 @@ public class TracheliumItemModel extends GeoModel { GeoBone root = getAnimationProcessor().getBone("root"); root.setPosX((float) (movePosX + 20 * ClientEventHandler.drawTime + 9.3f * mph)); root.setPosY((float) (swayY + movePosY - 40 * ClientEventHandler.drawTime - 2f * vY)); - root.setPosZ(!GunData.from(stack).DA() && !GunData.from(stack).canImmediatelyShoot() ? 0.2f * (float) ClientEventHandler.revolverPreTime : 0); + root.setPosZ(!GunData.from(stack).DA.get() && !GunData.from(stack).canImmediatelyShoot.get() ? 0.2f * (float) ClientEventHandler.revolverPreTime : 0); root.setRotX((float) ((swayX - Mth.DEG_TO_RAD * 60 * ClientEventHandler.drawTime + Mth.DEG_TO_RAD * turnRotX - 0.15f * vY))); root.setRotY((float) (0.2f * movePosX + Mth.DEG_TO_RAD * 300 * ClientEventHandler.drawTime + Mth.DEG_TO_RAD * turnRotY)); root.setRotZ((float) (0.2f * movePosX + moveRotZ + Mth.DEG_TO_RAD * 90 * ClientEventHandler.drawTime + 2.7f * mph + Mth.DEG_TO_RAD * turnRotZ)); 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 d81ec0b86..23ab7b653 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,8 +5,8 @@ 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.data.AttachmentType; import com.atsuishio.superbwarfare.item.gun.data.GunData; +import com.atsuishio.superbwarfare.item.gun.data.value.AttachmentType; import com.atsuishio.superbwarfare.item.gun.smg.VectorItem; import net.minecraft.client.Minecraft; import net.minecraft.resources.ResourceLocation; @@ -57,7 +57,7 @@ public class VectorItemModel extends GeoModel { var data = GunData.from(stack); var tag = data.tag(); - int mode = data.fireMode(); + int mode = data.fireMode.get(); if (mode == 0) { kmj.setRotX(-120 * Mth.DEG_TO_RAD); } 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 a4732bc33..e27293b2d 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/overlay/AmmoBarOverlay.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/overlay/AmmoBarOverlay.java @@ -52,10 +52,10 @@ public class AmmoBarOverlay implements LayeredDraw.Layer { } if (stack.getItem() == ModItems.BOCEK.get()) { - return GunData.from(stack).maxAmmo(); + return GunData.from(stack).maxAmmo.get(); } - return GunData.from(stack).ammo(); + return GunData.from(stack).ammo.get(); } private static String getPlayerAmmoCount(Player player) { @@ -69,7 +69,7 @@ public class AmmoBarOverlay implements LayeredDraw.Layer { if (!hasCreativeAmmo()) { var data = GunData.from(stack); if (stack.is(ModTags.Items.LAUNCHER) || stack.getItem() == ModItems.TASER.get()) { - return "" + data.maxAmmo(); + return "" + data.maxAmmo.get(); } if (stack.is(ModTags.Items.USE_RIFLE_AMMO)) { return "" + cap.rifleAmmo; @@ -175,7 +175,7 @@ public class AmmoBarOverlay implements LayeredDraw.Layer { } else { guiGraphics.drawString( Minecraft.getInstance().font, - data.DA() ? Component.translatable("des.superbwarfare.revolver.sa").withStyle(ChatFormatting.BOLD) : Component.translatable("des.superbwarfare.revolver.da").withStyle(ChatFormatting.BOLD), + data.DA.get() ? Component.translatable("des.superbwarfare.revolver.sa").withStyle(ChatFormatting.BOLD) : Component.translatable("des.superbwarfare.revolver.da").withStyle(ChatFormatting.BOLD), w - 96, h - 20, 0xFFFFFF, @@ -262,7 +262,7 @@ public class AmmoBarOverlay implements LayeredDraw.Layer { } private static ResourceLocation getFireMode(GunData data) { - return switch (data.fireMode()) { + return switch (data.fireMode.get()) { case 1 -> BURST; case 2 -> AUTO; default -> SEMI; 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 471073e14..16616cb50 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/overlay/JavelinHudOverlay.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/overlay/JavelinHudOverlay.java @@ -82,7 +82,7 @@ public class JavelinHudOverlay implements LayeredDraw.Layer { float j1 = l + j; preciseBlit(guiGraphics, Mod.loc("textures/screens/javelin/javelin_hud.png"), k, l, 0, 0.0F, i, j, i, j); preciseBlit(guiGraphics, Mod.loc(tag.getBoolean("TopMode") ? "textures/screens/javelin/top.png" : "textures/screens/javelin/dir.png"), k, l, 0, 0.0F, i, j, i, j); - preciseBlit(guiGraphics, Mod.loc(data.ammo() > 0 ? "textures/screens/javelin/missile_green.png" : "textures/screens/javelin/missile_red.png"), k, l, 0, 0.0F, i, j, i, j); + preciseBlit(guiGraphics, Mod.loc(data.ammo.get() > 0 ? "textures/screens/javelin/missile_green.png" : "textures/screens/javelin/missile_red.png"), k, l, 0, 0.0F, i, j, i, j); if (tag.getInt("SeekTime") > 1 && tag.getInt("SeekTime") < 20) { preciseBlit(guiGraphics, Mod.loc("textures/screens/javelin/seek.png"), k, l, 0, 0.0F, i, j, i, j); } diff --git a/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/AK12ItemRenderer.java b/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/AK12ItemRenderer.java index bb32a3e68..25c7af39d 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/AK12ItemRenderer.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/AK12ItemRenderer.java @@ -5,10 +5,9 @@ import com.atsuishio.superbwarfare.client.ItemModelHelper; import com.atsuishio.superbwarfare.client.model.item.AK12ItemModel; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.data.AttachmentType; import com.atsuishio.superbwarfare.item.gun.data.GunData; +import com.atsuishio.superbwarfare.item.gun.data.value.AttachmentType; import com.atsuishio.superbwarfare.item.gun.rifle.AK12Item; -import com.atsuishio.superbwarfare.tools.NBTTool; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import net.minecraft.client.Minecraft; diff --git a/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/AK47ItemRenderer.java b/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/AK47ItemRenderer.java index 69a0fce32..00488f3de 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/AK47ItemRenderer.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/AK47ItemRenderer.java @@ -5,10 +5,9 @@ import com.atsuishio.superbwarfare.client.ItemModelHelper; import com.atsuishio.superbwarfare.client.model.item.AK47ItemModel; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.data.AttachmentType; import com.atsuishio.superbwarfare.item.gun.data.GunData; +import com.atsuishio.superbwarfare.item.gun.data.value.AttachmentType; import com.atsuishio.superbwarfare.item.gun.rifle.AK47Item; -import com.atsuishio.superbwarfare.tools.NBTTool; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import net.minecraft.client.Minecraft; diff --git a/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/Aa12ItemRenderer.java b/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/Aa12ItemRenderer.java index c2b6dbaa9..f75603d23 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/Aa12ItemRenderer.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/Aa12ItemRenderer.java @@ -5,8 +5,8 @@ import com.atsuishio.superbwarfare.client.ItemModelHelper; import com.atsuishio.superbwarfare.client.model.item.Aa12ItemModel; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.data.AttachmentType; import com.atsuishio.superbwarfare.item.gun.data.GunData; +import com.atsuishio.superbwarfare.item.gun.data.value.AttachmentType; import com.atsuishio.superbwarfare.item.gun.shotgun.Aa12Item; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; diff --git a/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/BocekItemRenderer.java b/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/BocekItemRenderer.java index fffb67d8e..bd5a0d1da 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/BocekItemRenderer.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/BocekItemRenderer.java @@ -91,7 +91,7 @@ public class BocekItemRenderer extends GeoItemRenderer { } if (name.equals("jian")) { - bone.setHidden(GunData.from(itemStack).maxAmmo() == 0); + bone.setHidden(GunData.from(itemStack).maxAmmo.get() == 0); } if (renderingArms) { diff --git a/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/Hk416ItemRenderer.java b/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/Hk416ItemRenderer.java index 06d82668d..cb34f7b35 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/Hk416ItemRenderer.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/Hk416ItemRenderer.java @@ -5,8 +5,8 @@ import com.atsuishio.superbwarfare.client.ItemModelHelper; import com.atsuishio.superbwarfare.client.model.item.Hk416ItemModel; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.data.AttachmentType; import com.atsuishio.superbwarfare.item.gun.data.GunData; +import com.atsuishio.superbwarfare.item.gun.data.value.AttachmentType; import com.atsuishio.superbwarfare.item.gun.rifle.Hk416Item; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; diff --git a/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/InsidiousItemRenderer.java b/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/InsidiousItemRenderer.java index 573f26a39..b28359e4e 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/InsidiousItemRenderer.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/InsidiousItemRenderer.java @@ -4,10 +4,9 @@ import com.atsuishio.superbwarfare.client.AnimationHelper; import com.atsuishio.superbwarfare.client.model.item.InsidiousItemModel; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.data.AttachmentType; import com.atsuishio.superbwarfare.item.gun.data.GunData; +import com.atsuishio.superbwarfare.item.gun.data.value.AttachmentType; import com.atsuishio.superbwarfare.item.gun.rifle.InsidiousItem; -import com.atsuishio.superbwarfare.tools.NBTTool; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import net.minecraft.client.Minecraft; diff --git a/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/M4ItemRenderer.java b/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/M4ItemRenderer.java index 7bc794b19..24c247154 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/M4ItemRenderer.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/M4ItemRenderer.java @@ -5,8 +5,8 @@ import com.atsuishio.superbwarfare.client.ItemModelHelper; import com.atsuishio.superbwarfare.client.model.item.M4ItemModel; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.data.AttachmentType; import com.atsuishio.superbwarfare.item.gun.data.GunData; +import com.atsuishio.superbwarfare.item.gun.data.value.AttachmentType; import com.atsuishio.superbwarfare.item.gun.rifle.M4Item; import com.atsuishio.superbwarfare.tools.NBTTool; import com.mojang.blaze3d.vertex.PoseStack; diff --git a/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/Mk14ItemRenderer.java b/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/Mk14ItemRenderer.java index 0da67cce3..9a7bcbcdb 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/Mk14ItemRenderer.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/Mk14ItemRenderer.java @@ -5,10 +5,9 @@ import com.atsuishio.superbwarfare.client.ItemModelHelper; import com.atsuishio.superbwarfare.client.model.item.Mk14ItemModel; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.data.AttachmentType; import com.atsuishio.superbwarfare.item.gun.data.GunData; +import com.atsuishio.superbwarfare.item.gun.data.value.AttachmentType; import com.atsuishio.superbwarfare.item.gun.rifle.Mk14Item; -import com.atsuishio.superbwarfare.tools.NBTTool; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import net.minecraft.client.Minecraft; diff --git a/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/Ntw20Renderer.java b/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/Ntw20Renderer.java index f136f388b..70566ef0f 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/Ntw20Renderer.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/Ntw20Renderer.java @@ -5,10 +5,9 @@ import com.atsuishio.superbwarfare.client.ItemModelHelper; import com.atsuishio.superbwarfare.client.model.item.Ntw20Model; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.data.AttachmentType; import com.atsuishio.superbwarfare.item.gun.data.GunData; +import com.atsuishio.superbwarfare.item.gun.data.value.AttachmentType; import com.atsuishio.superbwarfare.item.gun.heavy.Ntw20Item; -import com.atsuishio.superbwarfare.tools.NBTTool; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import net.minecraft.client.Minecraft; diff --git a/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/Qbz95ItemRenderer.java b/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/Qbz95ItemRenderer.java index 95c1287f2..455751e78 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/Qbz95ItemRenderer.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/Qbz95ItemRenderer.java @@ -5,10 +5,9 @@ import com.atsuishio.superbwarfare.client.ItemModelHelper; import com.atsuishio.superbwarfare.client.model.item.Qbz95ItemModel; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.data.AttachmentType; import com.atsuishio.superbwarfare.item.gun.data.GunData; +import com.atsuishio.superbwarfare.item.gun.data.value.AttachmentType; import com.atsuishio.superbwarfare.item.gun.rifle.Qbz95Item; -import com.atsuishio.superbwarfare.tools.NBTTool; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import net.minecraft.client.Minecraft; diff --git a/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/RpgItemRenderer.java b/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/RpgItemRenderer.java index b0316c223..26d07d5e9 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/RpgItemRenderer.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/RpgItemRenderer.java @@ -78,7 +78,7 @@ public class RpgItemRenderer extends GeoItemRenderer { if (!itemStack.is(ModTags.Items.GUN)) return; if (name.equals("Rockets")) { - bone.setHidden(GunData.from(itemStack).isEmpty()); + bone.setHidden(GunData.from(itemStack).isEmpty.get()); } if (name.equals("flare")) { 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 c6a0f04dc..84bd5e552 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,10 +5,9 @@ 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.data.AttachmentType; import com.atsuishio.superbwarfare.item.gun.data.GunData; +import com.atsuishio.superbwarfare.item.gun.data.value.AttachmentType; import com.atsuishio.superbwarfare.item.gun.machinegun.RpkItem; -import com.atsuishio.superbwarfare.tools.GunsTool; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import net.minecraft.client.Minecraft; diff --git a/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/SvdItemRenderer.java b/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/SvdItemRenderer.java index 1c5e27782..66316f00d 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/SvdItemRenderer.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/SvdItemRenderer.java @@ -5,10 +5,9 @@ import com.atsuishio.superbwarfare.client.ItemModelHelper; import com.atsuishio.superbwarfare.client.model.item.SvdItemModel; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.data.AttachmentType; import com.atsuishio.superbwarfare.item.gun.data.GunData; +import com.atsuishio.superbwarfare.item.gun.data.value.AttachmentType; import com.atsuishio.superbwarfare.item.gun.sniper.SvdItem; -import com.atsuishio.superbwarfare.tools.NBTTool; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import net.minecraft.client.Minecraft; diff --git a/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/TracheliumItemRenderer.java b/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/TracheliumItemRenderer.java index e0eec64cd..ebe611c10 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/TracheliumItemRenderer.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/TracheliumItemRenderer.java @@ -5,8 +5,8 @@ import com.atsuishio.superbwarfare.client.ItemModelHelper; import com.atsuishio.superbwarfare.client.model.item.TracheliumItemModel; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.data.AttachmentType; import com.atsuishio.superbwarfare.item.gun.data.GunData; +import com.atsuishio.superbwarfare.item.gun.data.value.AttachmentType; import com.atsuishio.superbwarfare.item.gun.handgun.Trachelium; import com.atsuishio.superbwarfare.tools.NBTTool; import com.mojang.blaze3d.vertex.PoseStack; diff --git a/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/VectorItemRenderer.java b/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/VectorItemRenderer.java index 40270bacb..211919a7d 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/VectorItemRenderer.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/renderer/item/VectorItemRenderer.java @@ -5,10 +5,9 @@ import com.atsuishio.superbwarfare.client.ItemModelHelper; import com.atsuishio.superbwarfare.client.model.item.VectorItemModel; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.ModTags; -import com.atsuishio.superbwarfare.item.gun.data.AttachmentType; import com.atsuishio.superbwarfare.item.gun.data.GunData; +import com.atsuishio.superbwarfare.item.gun.data.value.AttachmentType; import com.atsuishio.superbwarfare.item.gun.smg.VectorItem; -import com.atsuishio.superbwarfare.tools.NBTTool; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import net.minecraft.client.Minecraft; 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 b93ffc299..6e23cb6b9 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/tooltip/ClientGunImageTooltip.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/tooltip/ClientGunImageTooltip.java @@ -124,8 +124,8 @@ public class ClientGunImageTooltip implements ClientTooltipComponent { * 获取武器等级文本组件 */ protected Component getLevelComponent() { - int level = data.level(); - double rate = data.exp() / (20 * Math.pow(level, 2) + 160 * level + 20); + int level = data.level.get(); + double rate = data.exp.get() / (20 * Math.pow(level, 2) + 160 * level + 20); ChatFormatting formatting; if (level < 10) { @@ -151,7 +151,7 @@ public class ClientGunImageTooltip implements ClientTooltipComponent { * 获取武器强化点数文本组件 */ protected Component getUpgradePointComponent() { - int upgradePoint = Mth.floor(data.upgradePoint()); + int upgradePoint = Mth.floor(data.upgradePoint.get()); return Component.translatable("des.superbwarfare.guns.upgrade_point").withStyle(ChatFormatting.GRAY) .append(Component.literal("").withStyle(ChatFormatting.RESET)) .append(Component.literal(String.valueOf(upgradePoint)).withStyle(ChatFormatting.WHITE).withStyle(ChatFormatting.BOLD)); diff --git a/src/main/java/com/atsuishio/superbwarfare/event/ClientEventHandler.java b/src/main/java/com/atsuishio/superbwarfare/event/ClientEventHandler.java index 49639d017..7a12b988a 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.VehicleEntity; import com.atsuishio.superbwarfare.entity.vehicle.base.WeaponVehicleEntity; import com.atsuishio.superbwarfare.init.*; import com.atsuishio.superbwarfare.item.gun.GunItem; -import com.atsuishio.superbwarfare.item.gun.data.AttachmentType; import com.atsuishio.superbwarfare.item.gun.data.GunData; +import com.atsuishio.superbwarfare.item.gun.data.value.AttachmentType; import com.atsuishio.superbwarfare.network.message.send.*; import com.atsuishio.superbwarfare.perk.AmmoPerk; import com.atsuishio.superbwarfare.perk.Perk; @@ -200,7 +200,7 @@ public class ClientEventHandler { ItemStack stack = player.getMainHandItem(); if (!stack.is(ModTags.Items.REVOLVER)) { return true; - } else if (stack.is(ModTags.Items.REVOLVER) && (data.DA() || data.canImmediatelyShoot())) { + } else if (stack.is(ModTags.Items.REVOLVER) && (data.DA.get() || data.canImmediatelyShoot.get())) { return true; } else { return revolverPreTime >= 1; @@ -489,7 +489,7 @@ public class ClientEventHandler { final var tag = data.tag(); var perk = data.perk.get(Perk.Type.AMMO); - int mode = data.fireMode(); + int mode = data.fireMode.get(); // 精准度 float times = (float) Math.min(Minecraft.getInstance().getTimer().getRealtimeDeltaTicks(), 0.8); @@ -548,11 +548,11 @@ public class ClientEventHandler { int cooldown = (int) (1000 / rps); //左轮类 - if (clientTimer.getProgress() == 0 && stack.is(ModTags.Items.REVOLVER) && ((holdFire && !data.DA()) - || (data.bolt.actionTime() < 7 && data.bolt.actionTime() > 2) || data.canImmediatelyShoot())) { + if (clientTimer.getProgress() == 0 && stack.is(ModTags.Items.REVOLVER) && ((holdFire && !data.DA.get()) + || (data.bolt.actionTimer.get() < 7 && data.bolt.actionTimer.get() > 2) || data.canImmediatelyShoot.get())) { 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 (!data.DA() && !data.canImmediatelyShoot()) { + } else if (!data.DA.get() && !data.canImmediatelyShoot.get()) { revolverPreTime = Mth.clamp(revolverPreTime - 1.2 * times, 0, 1); } @@ -569,9 +569,9 @@ public class ClientEventHandler { && (!(data.reload.normal() || data.reload.empty()) && !data.reloading() && !data.charging() - && data.ammo() > 0 + && data.ammo.get() > 0 && !player.getCooldowns().isOnCooldown(stack.getItem()) - && !data.bolt.needed() + && !data.bolt.needed.get() && revolverPre(data)) || (stack.is(ModItems.MINIGUN.get()) && !player.isSprinting() @@ -646,14 +646,14 @@ public class ClientEventHandler { ItemStack stack = player.getMainHandItem(); var data = GunData.from(stack); if (stack.is(ModTags.Items.NORMAL_GUN)) { - if (data.ammo() > 0) { - int mode = data.fireMode(); + if (data.ammo.get() > 0) { + int mode = data.fireMode.get(); if (mode != 2) { holdFire = false; } if (mode == 1) { - if (data.ammo() == 1) { + if (data.ammo.get() == 1) { burstFireAmount = 1; } if (burstFireAmount == 1) { @@ -679,8 +679,8 @@ public class ClientEventHandler { } // 判断是否为栓动武器(BoltActionTime > 0),并在开火后给一个需要上膛的状态 - if (data.bolt.defaultActionTime() > 0 && data.ammo() > (stack.is(ModTags.Items.REVOLVER) ? 0 : 1)) { - data.bolt.markNeeded(); + if (data.defaultActionTime() > 0 && data.ammo.get() > (stack.is(ModTags.Items.REVOLVER) ? 0 : 1)) { + data.bolt.needed.set(true); } revolverPreTime = 0; diff --git a/src/main/java/com/atsuishio/superbwarfare/event/GunEventHandler.java b/src/main/java/com/atsuishio/superbwarfare/event/GunEventHandler.java index 4eeb25e4c..daa9e6303 100644 --- a/src/main/java/com/atsuishio/superbwarfare/event/GunEventHandler.java +++ b/src/main/java/com/atsuishio/superbwarfare/event/GunEventHandler.java @@ -5,9 +5,9 @@ import com.atsuishio.superbwarfare.entity.projectile.ProjectileEntity; import com.atsuishio.superbwarfare.event.events.ReloadEvent; import com.atsuishio.superbwarfare.init.*; import com.atsuishio.superbwarfare.item.gun.GunItem; -import com.atsuishio.superbwarfare.item.gun.data.AttachmentType; import com.atsuishio.superbwarfare.item.gun.data.GunData; -import com.atsuishio.superbwarfare.item.gun.data.ReloadState; +import com.atsuishio.superbwarfare.item.gun.data.value.AttachmentType; +import com.atsuishio.superbwarfare.item.gun.data.value.ReloadState; import com.atsuishio.superbwarfare.perk.AmmoPerk; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.tools.AmmoType; @@ -60,18 +60,18 @@ public class GunEventHandler { var stack = data.stack(); if (stack.is(ModTags.Items.NORMAL_GUN)) { - if (data.bolt.actionTime() > 0) { - data.bolt.reduceActionTime(); + if (data.bolt.actionTimer.get() > 0) { + data.bolt.actionTimer.reduce(); } - if (stack.getItem() == ModItems.MARLIN.get() && data.bolt.actionTime() == 9) { - data.setIsEmpty(false); + if (stack.getItem() == ModItems.MARLIN.get() && data.bolt.actionTimer.get() == 9) { + data.isEmpty.set(false); } - if (data.bolt.actionTime() == 1) { - data.bolt.markNeedless(); + if (data.bolt.actionTimer.get() == 1) { + data.bolt.needed.set(false); if (stack.is(ModTags.Items.REVOLVER)) { - data.setCanImmediatelyShoot(true); + data.canImmediatelyShoot.set(true); } } } @@ -156,7 +156,7 @@ public class GunEventHandler { if (stack.is(ModTags.Items.REVOLVER)) return; - Mod.queueServerWork((int) (data.bolt.defaultActionTime() / 2 + 1.5 * shooterHeight), () -> { + Mod.queueServerWork((int) (data.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)) { @@ -270,7 +270,7 @@ public class GunEventHandler { NeoForge.EVENT_BUS.post(new ReloadEvent.Pre(player, stack)); if (gunItem.isOpenBolt(stack)) { - if (gun.ammo() == 0) { + if (gun.ammo.get() == 0) { reload.setTime(gun.defaultEmptyReloadTime() + 1); reload.setState(ReloadState.EMPTY_RELOADING); playGunEmptyReloadSounds(player); @@ -295,7 +295,7 @@ public class GunEventHandler { if (reload.time() == 1) { if (gunItem.isOpenBolt(stack)) { - if (gun.ammo() == 0) { + if (gun.ammo.get() == 0) { playGunEmptyReload(player, gun); } else { playGunNormalReload(player, gun); @@ -312,7 +312,7 @@ public class GunEventHandler { var gunItem = gunData.item(); if (player.getInventory().hasAnyMatching(item -> item.is(ModItems.CREATIVE_AMMO_BOX.get()))) { - gunData.setAmmo(gunData.magazine() + (gunItem.hasBulletInBarrel(stack) ? 1 : 0)); + gunData.ammo.set(gunData.magazine() + (gunItem.hasBulletInBarrel(stack) ? 1 : 0)); } else { if (stack.is(ModTags.Items.USE_SHOTGUN_AMMO)) { GunsTool.reload(player, stack, gunData, AmmoType.SHOTGUN, gunItem.hasBulletInBarrel(stack)); @@ -334,7 +334,7 @@ public class GunEventHandler { ItemStack stack = data.stack(); if (player.getInventory().hasAnyMatching(item -> item.is(ModItems.CREATIVE_AMMO_BOX.get()))) { - data.setAmmo(data.magazine()); + data.ammo.set(data.magazine()); } else { if (stack.is(ModTags.Items.USE_SHOTGUN_AMMO)) { GunsTool.reload(player, stack, data, AmmoType.SHOTGUN); @@ -348,7 +348,7 @@ public class GunEventHandler { GunsTool.reload(player, stack, data, AmmoType.HEAVY); } else if (data.item().getCustomAmmoItem() != null) { var ammoItem = data.item().getCustomAmmoItem(); - data.setAmmo(1); + data.ammo.set(1); player.getInventory().clearOrCountMatchingItems(p -> p.getItem() == ammoItem, 1, player.inventoryMenu.getCraftSlots()); } } @@ -414,13 +414,13 @@ public class GunEventHandler { if (reload.singleReloadStarter.start()) { NeoForge.EVENT_BUS.post(new ReloadEvent.Pre(player, stack)); - if ((data.defaultPrepareLoadTime() != 0 && data.ammo() == 0) || stack.is(ModItems.SECONDARY_CATACLYSM.get())) { + if ((data.defaultPrepareLoadTime() != 0 && data.ammo.get() == 0) || stack.is(ModItems.SECONDARY_CATACLYSM.get())) { // 此处判断空仓换弹的时候,是否在准备阶段就需要装填一发,如M870 playGunPrepareLoadReloadSounds(player); int prepareLoadTime = data.defaultPrepareLoadTime(); reload.prepareLoadTimer.set(prepareLoadTime + 1); player.getCooldowns().addCooldown(stack.getItem(), prepareLoadTime); - } else if (data.defaultPrepareEmptyTime() != 0 && data.ammo() == 0) { + } else if (data.defaultPrepareEmptyTime() != 0 && data.ammo.get() == 0) { // 此处判断空仓换弹,如莫辛纳甘 playGunEmptyPrepareSounds(player); int prepareEmptyTime = data.defaultPrepareEmptyTime(); @@ -433,8 +433,8 @@ public class GunEventHandler { player.getCooldowns().addCooldown(stack.getItem(), prepareTime); } - data.setForceStop(false); - data.setStopped(false); + data.forceStop.set(false); + data.stopped.set(false); reload.setStage(1); reload.setState(ReloadState.NORMAL_RELOADING); } @@ -457,15 +457,15 @@ public class GunEventHandler { || stack.is(ModTags.Items.USE_HANDGUN_AMMO) && capability.handgunAmmo == 0 || stack.is(ModTags.Items.USE_RIFLE_AMMO) && capability.rifleAmmo == 0 || stack.is(ModTags.Items.USE_HEAVY_AMMO) && capability.heavyAmmo == 0 - || stack.is(ModTags.Items.LAUNCHER) && data.maxAmmo() == 0 - || stack.is(ModItems.SECONDARY_CATACLYSM.get()) && data.ammo() >= data.magazine() + || stack.is(ModTags.Items.LAUNCHER) && data.maxAmmo.get() == 0 + || stack.is(ModItems.SECONDARY_CATACLYSM.get()) && data.ammo.get() >= data.magazine() ) { reload.stage3Starter.markStart(); } else { reload.setStage(2); } } else { - if (stack.is(ModItems.SECONDARY_CATACLYSM.get()) && data.ammo() >= data.magazine()) { + if (stack.is(ModItems.SECONDARY_CATACLYSM.get()) && data.ammo.get() >= data.magazine()) { reload.stage3Starter.markStart(); } else { reload.setStage(2); @@ -475,23 +475,23 @@ public class GunEventHandler { } // 强制停止换弹,进入三阶段 - if (data.forceStop() && reload.stage() == 2 && reload.iterativeLoadTimer.get() > 0) { - data.setForceStop(true); + if (data.forceStop.get() && reload.stage() == 2 && reload.iterativeLoadTimer.get() > 0) { + data.forceStop.set(true); } // 二阶段 if ((reload.prepareTimer.get() == 0 || reload.iterativeLoadTimer.get() == 0) && reload.stage() == 2 && reload.iterativeLoadTimer.get() == 0 - && !data.stopped() - && data.ammo() < data.magazine() + && !data.stopped.get() + && data.ammo.get() < data.magazine() ) { playGunLoopReloadSounds(player); int iterativeTime = data.defaultIterativeTime(); reload.iterativeLoadTimer.set(iterativeTime); player.getCooldowns().addCooldown(stack.getItem(), iterativeTime); // 动画播放nbt - data.setLoadIndex(data.loadIndex() == 1 ? 0 : 1); + data.loadIndex.set(data.loadIndex.get() == 1 ? 0 : 1); } // 装填 @@ -515,7 +515,7 @@ public class GunEventHandler { // 二阶段结束 if (reload.iterativeLoadTimer.get() == 1) { // 装满结束 - if (data.ammo() >= data.magazine()) { + if (data.ammo.get() >= data.magazine()) { reload.setStage(3); } @@ -537,10 +537,10 @@ public class GunEventHandler { } // 强制结束 - if (data.stopped()) { + if (data.stopped.get()) { reload.setStage(3); - data.setStopped(false); - data.setForceStop(false); + data.stopped.set(false); + data.forceStop.set(false); } } @@ -557,14 +557,14 @@ public class GunEventHandler { } if (stack.getItem() == ModItems.MARLIN.get() && reload.finishTimer.get() == 10) { - data.setIsEmpty(false); + data.isEmpty.set(false); } // 三阶段结束 if (reload.finishTimer.get() == 1) { reload.setStage(0); - if (data.bolt.defaultActionTime() > 0) { - data.bolt.markNeedless(); + if (data.defaultActionTime() > 0) { + data.bolt.needed.set(false); } reload.setState(ReloadState.NOT_RELOADING); reload.singleReloadStarter.finish(); @@ -574,7 +574,7 @@ public class GunEventHandler { } public static void singleLoad(Player player, GunData data) { - data.setAmmo(data.ammo() + 1); + data.ammo.set(data.ammo.get() + 1); if (!InventoryTool.hasCreativeAmmoBox(player)) { var cap = player.getData(ModAttachments.PLAYER_VARIABLE); diff --git a/src/main/java/com/atsuishio/superbwarfare/event/LivingEventHandler.java b/src/main/java/com/atsuishio/superbwarfare/event/LivingEventHandler.java index a334a25f1..3b9cec5f2 100644 --- a/src/main/java/com/atsuishio/superbwarfare/event/LivingEventHandler.java +++ b/src/main/java/com/atsuishio/superbwarfare/event/LivingEventHandler.java @@ -16,7 +16,7 @@ import com.atsuishio.superbwarfare.init.*; import com.atsuishio.superbwarfare.item.common.ammo.box.AmmoBoxInfo; 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.item.gun.data.value.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; @@ -218,14 +218,14 @@ public class LivingEventHandler { // 先处理发射器类武器或高爆弹的爆炸伤害 if (source.is(ModDamageTypes.PROJECTILE_BOOM)) { if (stack.is(ModTags.Items.LAUNCHER) || data.perk.getLevel(ModPerks.HE_BULLET) > 0) { - data.setExp(data.exp() + amount); + data.exp.set(data.exp.get() + amount); } } // 再判断是不是枪械能造成的伤害 if (!DamageTypeTool.isGunDamage(source)) return; - data.setExp(data.exp() + amount); + data.exp.set(data.exp.get() + amount); data.save(); } @@ -243,27 +243,27 @@ public class LivingEventHandler { // 先处理发射器类武器或高爆弹的爆炸伤害 if (source.is(ModDamageTypes.PROJECTILE_BOOM)) { if (stack.is(ModTags.Items.LAUNCHER) || data.perk.getLevel(ModPerks.HE_BULLET) > 0) { - data.setExp(data.exp() + amount); + data.exp.set(data.exp.get() + amount); } } // 再判断是不是枪械能造成的伤害 if (DamageTypeTool.isGunDamage(source)) { - data.setExp(data.exp() + amount); + data.exp.set(data.exp.get() + amount); } // 提升武器等级 - int level = data.level(); - double exp = data.exp(); + int level = data.level.get(); + double exp = data.exp.get(); double upgradeExpNeeded = 20 * Math.pow(level, 2) + 160 * level + 20; while (exp >= upgradeExpNeeded) { exp -= upgradeExpNeeded; - level = data.level() + 1; + level = data.level.get() + 1; upgradeExpNeeded = 20 * Math.pow(level, 2) + 160 * level + 20; - data.setExp(exp); - data.setLevel(level); - data.setUpgradePoint(data.upgradePoint() + 0.5); + data.exp.set(exp); + data.level.set(level); + data.upgradePoint.set(data.upgradePoint.get() + 0.5); } data.save(); } @@ -277,17 +277,17 @@ public class LivingEventHandler { if (event.getEntity() instanceof TargetEntity) return; var data = GunData.from(stack); - int level = data.level(); - double exp = data.exp(); + int level = data.level.get(); + double exp = data.exp.get(); double upgradeExpNeeded = 20 * Math.pow(level, 2) + 160 * level + 20; while (exp >= upgradeExpNeeded) { exp -= upgradeExpNeeded; - level = data.level() + 1; + level = data.level.get() + 1; upgradeExpNeeded = 20 * Math.pow(level, 2) + 160 * level + 20; - data.setExp(exp); - data.setLevel(level); - data.setUpgradePoint(data.upgradePoint() + 0.5); + data.exp.set(exp); + data.level.set(level); + data.upgradePoint.set(data.upgradePoint.get() + 0.5); } data.save(); } @@ -357,8 +357,8 @@ public class LivingEventHandler { var oldData = GunData.from(oldStack); - if (oldData.bolt.defaultActionTime() > 0) { - oldData.bolt.setActionTime(0); + if (oldData.defaultActionTime() > 0) { + oldData.bolt.actionTimer.reset(); } oldData.reload.setTime(0); @@ -366,8 +366,8 @@ public class LivingEventHandler { oldData.reload.setState(ReloadState.NOT_RELOADING); if (oldData.defaultIterativeTime() != 0) { - oldData.setStopped(false); - oldData.setForceStop(false); + oldData.stopped.set(false); + oldData.forceStop.set(false); oldData.reload.setStage(0); oldData.reload.prepareTimer.reset(); oldData.reload.prepareLoadTimer.reset(); @@ -393,16 +393,16 @@ public class LivingEventHandler { newTag = newData.tag(); newTag.putBoolean("draw", true); - if (newData.bolt.defaultActionTime() > 0) { - newData.bolt.setActionTime(0); + if (newData.defaultActionTime() > 0) { + newData.bolt.actionTimer.reset(); } newData.reload.setState(ReloadState.NOT_RELOADING); newData.reload.reloadTimer.reset(); if (newData.defaultIterativeTime() != 0) { - newData.setForceStop(false); - newData.setStopped(false); + newData.forceStop.set(false); + newData.stopped.set(false); newData.reload.setStage(0); newData.reload.prepareTimer.reset(); newData.reload.prepareLoadTimer.reset(); @@ -643,7 +643,7 @@ public class LivingEventHandler { var cap = player.getData(ModAttachments.PLAYER_VARIABLE).watch(); int mag = data.magazine(); - int ammo = data.ammo(); + int ammo = data.ammo.get(); int ammoReload = (int) Math.min(mag, mag * rate); int ammoNeed = Math.min(mag - ammo, ammoReload); @@ -656,7 +656,7 @@ public class LivingEventHandler { } else { cap.rifleAmmo -= ammoFinal; } - data.setAmmo(Math.min(mag, ammo + ammoFinal)); + data.ammo.set(Math.min(mag, ammo + ammoFinal)); } else if (stack.is(ModTags.Items.USE_HANDGUN_AMMO)) { int ammoFinal = Math.min(cap.handgunAmmo, ammoNeed); if (flag) { @@ -664,7 +664,7 @@ public class LivingEventHandler { } else { cap.handgunAmmo -= ammoFinal; } - data.setAmmo(Math.min(mag, ammo + ammoFinal)); + data.ammo.set(Math.min(mag, ammo + ammoFinal)); } data.save(); player.setData(ModAttachments.PLAYER_VARIABLE, cap); diff --git a/src/main/java/com/atsuishio/superbwarfare/event/PlayerEventHandler.java b/src/main/java/com/atsuishio/superbwarfare/event/PlayerEventHandler.java index e22ad26b5..d8433bc63 100644 --- a/src/main/java/com/atsuishio/superbwarfare/event/PlayerEventHandler.java +++ b/src/main/java/com/atsuishio/superbwarfare/event/PlayerEventHandler.java @@ -84,8 +84,8 @@ public class PlayerEventHandler { var data = GunData.from(stack); - if ((stack.is(ModItems.RPG.get()) || stack.is(ModItems.BOCEK.get())) && data.ammo() == 1) { - data.setIsEmpty(false); + if ((stack.is(ModItems.RPG.get()) || stack.is(ModItems.BOCEK.get())) && data.ammo.get() == 1) { + data.isEmpty.set(false); } } @@ -123,24 +123,24 @@ public class PlayerEventHandler { GunsTool.reload(player, stack, data, AmmoType.HEAVY); } - if (stack.getItem() == ModItems.TASER.get() && data.maxAmmo() > 0 && data.ammo() == 0) { - data.setAmmo(1); + if (stack.getItem() == ModItems.TASER.get() && data.maxAmmo.get() > 0 && data.ammo.get() == 0) { + data.ammo.set(1); player.getInventory().clearOrCountMatchingItems(p -> p.getItem() == ModItems.TASER_ELECTRODE.get(), 1, player.inventoryMenu.getCraftSlots()); } - if (stack.getItem() == ModItems.M_79.get() && data.maxAmmo() > 0 && data.ammo() == 0) { - data.setAmmo(1); + if (stack.getItem() == ModItems.M_79.get() && data.maxAmmo.get() > 0 && data.ammo.get() == 0) { + data.ammo.set(1); player.getInventory().clearOrCountMatchingItems(p -> p.getItem() == ModItems.GRENADE_40MM.get(), 1, player.inventoryMenu.getCraftSlots()); } - if (stack.getItem() == ModItems.RPG.get() && data.maxAmmo() > 0 && data.ammo() == 0) { - data.setAmmo(1); + if (stack.getItem() == ModItems.RPG.get() && data.maxAmmo.get() > 0 && data.ammo.get() == 0) { + data.ammo.set(1); player.getInventory().clearOrCountMatchingItems(p -> p.getItem() == ModItems.ROCKET.get(), 1, player.inventoryMenu.getCraftSlots()); } - if (stack.getItem() == ModItems.JAVELIN.get() && data.maxAmmo() > 0 && data.ammo() == 0) { - data.setAmmo(1); + if (stack.getItem() == ModItems.JAVELIN.get() && data.maxAmmo.get() > 0 && data.ammo.get() == 0) { + data.ammo.set(1); player.getInventory().clearOrCountMatchingItems(p -> p.getItem() == ModItems.JAVELIN_MISSILE.get(), 1, player.inventoryMenu.getCraftSlots()); } } else { - data.setAmmo(data.magazine()); + data.ammo.set(data.magazine()); } GunsTool.setGunBooleanTag(tag, "HoldOpen", false); data.save(); @@ -192,7 +192,7 @@ public class PlayerEventHandler { ItemStack output = left.copy(); var data = GunData.from(output); - data.setUpgradePoint(data.upgradePoint() + 1); + data.upgradePoint.set(data.upgradePoint.get() + 1); data.save(); event.setOutput(output); 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 03b834780..0cf5dbccc 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/GunItem.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/GunItem.java @@ -8,8 +8,8 @@ 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.AttachmentType; import com.atsuishio.superbwarfare.item.gun.data.GunData; +import com.atsuishio.superbwarfare.item.gun.data.value.AttachmentType; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.tools.AmmoType; import net.minecraft.client.model.HumanoidModel; @@ -70,14 +70,14 @@ public abstract class GunItem extends Item implements CustomRendererItem { if (!data.initialized()) { data.initialize(); if (level.getServer() != null && entity instanceof Player player && player.isCreative()) { - data.setAmmo(data.magazine()); + data.ammo.set(data.magazine()); } } tag.putBoolean("draw", false); handleGunPerks(data); var hasBulletInBarrel = gunItem.hasBulletInBarrel(stack); - var ammoCount = data.ammo(); + var ammoCount = data.ammo.get(); var magazine = data.magazine(); if ((hasBulletInBarrel && ammoCount > magazine + 1) || (!hasBulletInBarrel && ammoCount > magazine)) { @@ -97,7 +97,7 @@ public abstract class GunItem extends Item implements CustomRendererItem { } entity.setData(ModAttachments.PLAYER_VARIABLE, capability); capability.sync(entity); - data.setAmmo(magazine + (hasBulletInBarrel ? 1 : 0)); + data.ammo.set(magazine + (hasBulletInBarrel ? 1 : 0)); } data.save(); } @@ -185,7 +185,7 @@ public abstract class GunItem extends Item implements CustomRendererItem { tag.remove("FourthTimesCharmCount"); int mag = data.magazine(); - data.setAmmo(Math.min(mag, data.ammo() + 2)); + data.ammo.set(Math.min(mag, data.ammo.get() + 2)); } } 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 deleted file mode 100644 index 0e552908d..000000000 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/data/Bolt.java +++ /dev/null @@ -1,47 +0,0 @@ -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 deleted file mode 100644 index 6d9bfab02..000000000 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/data/Charge.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.atsuishio.superbwarfare.item.gun.data; - -public final class Charge { - public final Timer timer; - public final Starter starter; - - Charge(GunData data) { - this.timer = new Timer(data.data(), "Charge"); - this.starter = new Starter(data.data(), "Charge"); - } - - public int time() { - return timer.get(); - } -} diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/data/GunData.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/data/GunData.java index 6f12e31dd..415fa70ca 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/data/GunData.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/data/GunData.java @@ -1,6 +1,8 @@ package com.atsuishio.superbwarfare.item.gun.data; import com.atsuishio.superbwarfare.item.gun.GunItem; +import com.atsuishio.superbwarfare.item.gun.data.subdata.*; +import com.atsuishio.superbwarfare.item.gun.data.value.*; import com.atsuishio.superbwarfare.perk.AmmoPerk; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.tools.GunsTool; @@ -15,13 +17,13 @@ import java.util.UUID; import java.util.WeakHashMap; public class GunData { - private final ItemStack stack; - private final GunItem item; - private final CompoundTag tag; - private final CompoundTag data; - private final CompoundTag perkTag; - private final CompoundTag attachmentTag; - private final String id; + public final ItemStack stack; + public final GunItem item; + public final CompoundTag tag; + public final CompoundTag data; + public final CompoundTag perkTag; + public final CompoundTag attachmentTag; + public final String id; private static final WeakHashMap dataCache = new WeakHashMap<>(); @@ -29,6 +31,7 @@ public class GunData { if (!(stack.getItem() instanceof GunItem gunItem)) { throw new IllegalArgumentException("stack is not GunItem!"); } + this.item = gunItem; this.stack = stack; var id = stack.getDescriptionId(); @@ -46,6 +49,21 @@ public class GunData { bolt = new Bolt(this); attachment = new Attachment(this); perk = new Perks(this); + + ammo = new IntValue(data, "Ammo"); + fireMode = new IntValue(data, "FireMode", (int) getGunData("FireMode")); + level = new IntValue(data, "Level"); + exp = new DoubleValue(data, "Exp"); + upgradePoint = new DoubleValue(data, "UpgradePoint"); + + canImmediatelyShoot = new BooleanValue(data, "CanImmediatelyShoot"); + DA = new BooleanValue(data, "DA"); + isEmpty = new BooleanValue(data, "IsEmpty"); + closeHammer = new BooleanValue(data, "CloseHammer"); + stopped = new BooleanValue(data, "Stopped"); + forceStop = new BooleanValue(data, "ForceStop"); + loadIndex = new IntValue(data, "LoadIndex"); + maxAmmo = new IntValue(data, "MaxAmmo"); } private CompoundTag getOrPut(String name) { @@ -107,6 +125,9 @@ public class GunData { return getGunData(key, 0); } + + // 枪械本体属性开始 + private double getGunData(String key, double defaultValue) { return GunsTool.gunsData.getOrDefault(id, new HashMap<>()).getOrDefault(key, defaultValue); } @@ -183,6 +204,10 @@ public class GunData { return (int) getGunData("FinishTime"); } + public int defaultActionTime() { + return (int) getGunData("BoltActionTime") + item.getCustomBoltActionTime(stack()); + } + public double soundRadius() { return getGunData("SoundRadius", 15) + item.getCustomSoundRadius(stack); } @@ -207,14 +232,6 @@ public class GunData { return item.getCustomWeight(stack); } - public int ammo() { - return data.getInt("Ammo"); - } - - public void setAmmo(int ammo) { - data.putInt("Ammo", ammo); - } - public double defaultZoom() { return getGunData("DefaultZoom", 1.25); @@ -244,40 +261,15 @@ public class GunData { return (int) getGunData("BurstAmount"); } - public int fireMode() { - if (data.contains("FireMode")) { - return data.getInt("FireMode"); - } - return (int) getGunData("FireMode"); - } - public void setFireMode(int fireMode) { - data.putInt("FireMode", fireMode); - } + // 可持久化属性开始 - public int level() { - return data.getInt("Level"); - } - public void setLevel(int level) { - data.putInt("Level", level); - } - - public double exp() { - return data.getDouble("Exp"); - } - - public void setExp(double exp) { - data.putDouble("Exp", exp); - } - - public double upgradePoint() { - return data.getDouble("UpgradePoint"); - } - - public void setUpgradePoint(double upgradePoint) { - data.putDouble("UpgradePoint", upgradePoint); - } + public final IntValue ammo; + public final IntValue fireMode; + public final IntValue level; + public final DoubleValue exp; + public final DoubleValue upgradePoint; public boolean canAdjustZoom() { return item.canAdjustZoom(stack); @@ -300,101 +292,17 @@ public class GunData { return charge.time() > 0; } - public boolean canImmediatelyShoot() { - return data.getBoolean("CanImmediatelyShoot"); - } + public final BooleanValue canImmediatelyShoot; + public final BooleanValue DA; + public final BooleanValue isEmpty; + public final BooleanValue closeHammer; + public final BooleanValue stopped; + public final BooleanValue forceStop; + public final IntValue loadIndex; + public final IntValue maxAmmo; - public void setCanImmediatelyShoot(boolean value) { - if (!value) { - data.remove("CanImmediatelyShoot"); - } else { - data.putBoolean("CanImmediatelyShoot", true); - } - } - public boolean DA() { - return data.getBoolean("DA"); - } - - public void setDA(boolean value) { - if (!value) { - data.remove("DA"); - } else { - data.putBoolean("DA", true); - } - } - - public boolean isEmpty() { - return data.getBoolean("IsEmpty"); - } - - public void setIsEmpty(boolean value) { - if (!value) { - data.remove("IsEmpty"); - } else { - data.putBoolean("IsEmpty", true); - } - } - - public boolean closeHammer() { - return data.getBoolean("CloseHammer"); - } - - public void setCloseHammer(boolean value) { - if (!value) { - data.remove("CloseHammer"); - } else { - data.putBoolean("CloseHammer", true); - } - } - - public boolean stopped() { - return data.getBoolean("Stopped"); - } - - public void setStopped(boolean value) { - if (!value) { - data.remove("Stopped"); - } else { - data.putBoolean("Stopped", true); - } - } - - public boolean forceStop() { - return data.getBoolean("ForceStop"); - } - - public void setForceStop(boolean value) { - if (!value) { - data.remove("ForceStop"); - } else { - data.putBoolean("ForceStop", true); - } - } - - public int loadIndex() { - return data.getInt("LoadIndex"); - } - - public void setLoadIndex(int value) { - if (value == 0) { - data.remove("LoadIndex"); - return; - } - data.putInt("LoadIndex", value); - } - - public int maxAmmo() { - return data.getInt("MaxAmmo"); - } - - public void setMaxAmmo(int value) { - if (value == 0) { - data.remove("MaxAmmo"); - return; - } - data.putInt("MaxAmmo", value); - } + // 其他子级属性 public final Bolt bolt; public final Attachment attachment; diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/data/Attachment.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/data/subdata/Attachment.java similarity index 62% rename from src/main/java/com/atsuishio/superbwarfare/item/gun/data/Attachment.java rename to src/main/java/com/atsuishio/superbwarfare/item/gun/data/subdata/Attachment.java index 01b957f6d..1fe2cc393 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/data/Attachment.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/data/subdata/Attachment.java @@ -1,11 +1,13 @@ -package com.atsuishio.superbwarfare.item.gun.data; +package com.atsuishio.superbwarfare.item.gun.data.subdata; +import com.atsuishio.superbwarfare.item.gun.data.GunData; +import com.atsuishio.superbwarfare.item.gun.data.value.AttachmentType; import net.minecraft.nbt.CompoundTag; public final class Attachment { private final CompoundTag attachment; - Attachment(GunData gun) { + public Attachment(GunData gun) { this.attachment = gun.attachment(); } diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/data/subdata/Bolt.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/data/subdata/Bolt.java new file mode 100644 index 000000000..8d9c759eb --- /dev/null +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/data/subdata/Bolt.java @@ -0,0 +1,16 @@ +package com.atsuishio.superbwarfare.item.gun.data.subdata; + +import com.atsuishio.superbwarfare.item.gun.data.GunData; +import com.atsuishio.superbwarfare.item.gun.data.value.BooleanValue; +import com.atsuishio.superbwarfare.item.gun.data.value.Timer; + +public final class Bolt { + + public Bolt(GunData data) { + needed = new BooleanValue(data.data(), "NeedBoltAction"); + actionTimer = new Timer(data.data(), "BoltActionTime"); + } + + public final BooleanValue needed; + public final Timer actionTimer; +} diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/data/subdata/Charge.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/data/subdata/Charge.java new file mode 100644 index 000000000..7db73d88f --- /dev/null +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/data/subdata/Charge.java @@ -0,0 +1,19 @@ +package com.atsuishio.superbwarfare.item.gun.data.subdata; + +import com.atsuishio.superbwarfare.item.gun.data.GunData; +import com.atsuishio.superbwarfare.item.gun.data.value.Starter; +import com.atsuishio.superbwarfare.item.gun.data.value.Timer; + +public final class Charge { + public final Timer timer; + public final Starter starter; + + public Charge(GunData data) { + this.timer = new Timer(data.data(), "Charge"); + this.starter = new Starter(data.data(), "Charge"); + } + + public int time() { + return timer.get(); + } +} diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/data/Perks.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/data/subdata/Perks.java similarity index 96% rename from src/main/java/com/atsuishio/superbwarfare/item/gun/data/Perks.java rename to src/main/java/com/atsuishio/superbwarfare/item/gun/data/subdata/Perks.java index 01ed9203c..300d43b2f 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/data/Perks.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/data/subdata/Perks.java @@ -1,7 +1,8 @@ -package com.atsuishio.superbwarfare.item.gun.data; +package com.atsuishio.superbwarfare.item.gun.data.subdata; import com.atsuishio.superbwarfare.init.ModPerks; import com.atsuishio.superbwarfare.item.PerkItem; +import com.atsuishio.superbwarfare.item.gun.data.GunData; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkInstance; import net.minecraft.nbt.CompoundTag; @@ -13,7 +14,7 @@ import java.util.ArrayList; public final class Perks { private final CompoundTag perks; - Perks(GunData gun) { + public Perks(GunData gun) { this.perks = gun.perk(); } diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/data/Reload.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/data/subdata/Reload.java similarity index 77% rename from src/main/java/com/atsuishio/superbwarfare/item/gun/data/Reload.java rename to src/main/java/com/atsuishio/superbwarfare/item/gun/data/subdata/Reload.java index b5af55d41..03f4f9e94 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/data/Reload.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/data/subdata/Reload.java @@ -1,5 +1,10 @@ -package com.atsuishio.superbwarfare.item.gun.data; +package com.atsuishio.superbwarfare.item.gun.data.subdata; +import com.atsuishio.superbwarfare.item.gun.data.GunData; +import com.atsuishio.superbwarfare.item.gun.data.value.IntValue; +import com.atsuishio.superbwarfare.item.gun.data.value.ReloadState; +import com.atsuishio.superbwarfare.item.gun.data.value.Starter; +import com.atsuishio.superbwarfare.item.gun.data.value.Timer; import net.minecraft.nbt.CompoundTag; public final class Reload { @@ -15,7 +20,7 @@ public final class Reload { public final Starter singleReloadStarter; public final Starter stage3Starter; - Reload(GunData data) { + public Reload(GunData data) { this.data = data.data(); reloadTimer = new Timer(this.data, "Reload"); @@ -27,6 +32,8 @@ public final class Reload { reloadStarter = new Starter(this.data, "Reload"); singleReloadStarter = new Starter(this.data, "SingleReload"); stage3Starter = new Starter(this.data, "Stage3Forcefully"); + + stage = new IntValue(this.data, "ReloadStage"); } public ReloadState state() { @@ -53,16 +60,14 @@ public final class Reload { } } + public final IntValue stage; + public int stage() { - return data.getInt("ReloadStage"); + return stage.get(); } public void setStage(int stage) { - if (stage <= 0) { - data.remove("ReloadStage"); - } else { - data.putInt("ReloadStage", stage); - } + this.stage.set(stage); } diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/data/AttachmentType.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/data/value/AttachmentType.java similarity index 83% rename from src/main/java/com/atsuishio/superbwarfare/item/gun/data/AttachmentType.java rename to src/main/java/com/atsuishio/superbwarfare/item/gun/data/value/AttachmentType.java index 4cc5c6e9e..742563929 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/data/AttachmentType.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/data/value/AttachmentType.java @@ -1,4 +1,4 @@ -package com.atsuishio.superbwarfare.item.gun.data; +package com.atsuishio.superbwarfare.item.gun.data.value; public enum AttachmentType { SCOPE("Scope"), diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/data/value/BooleanValue.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/data/value/BooleanValue.java new file mode 100644 index 000000000..8fd072370 --- /dev/null +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/data/value/BooleanValue.java @@ -0,0 +1,38 @@ +package com.atsuishio.superbwarfare.item.gun.data.value; + +import net.minecraft.nbt.CompoundTag; + +public class BooleanValue { + private final CompoundTag tag; + private final String name; + private final boolean defaultValue; + + public BooleanValue(CompoundTag tag, String name, boolean defaultValue) { + this.tag = tag; + this.name = name; + this.defaultValue = defaultValue; + } + + public BooleanValue(CompoundTag tag, String name) { + this(tag, name, false); + } + + public boolean get() { + if (tag.contains(name)) { + return tag.getBoolean(name); + } + return defaultValue; + } + + public void set(boolean value) { + if (value == defaultValue) { + tag.remove(name); + } else { + tag.putBoolean(name, value); + } + } + + public void reset() { + set(defaultValue); + } +} diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/data/value/DoubleValue.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/data/value/DoubleValue.java new file mode 100644 index 000000000..34909411b --- /dev/null +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/data/value/DoubleValue.java @@ -0,0 +1,38 @@ +package com.atsuishio.superbwarfare.item.gun.data.value; + +import net.minecraft.nbt.CompoundTag; + +public class DoubleValue { + private final CompoundTag tag; + private final String name; + private final double defaultValue; + + public DoubleValue(CompoundTag tag, String name, double defaultValue) { + this.tag = tag; + this.name = name; + this.defaultValue = defaultValue; + } + + public DoubleValue(CompoundTag tag, String name) { + this(tag, name, 0); + } + + public double get() { + if (tag.contains(name)) { + return tag.getDouble(name); + } + return defaultValue; + } + + public void set(double value) { + if (value == defaultValue) { + tag.remove(name); + } else { + tag.putDouble(name, value); + } + } + + public void reset() { + set(defaultValue); + } +} diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/data/value/IntValue.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/data/value/IntValue.java new file mode 100644 index 000000000..b09dc4b87 --- /dev/null +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/data/value/IntValue.java @@ -0,0 +1,38 @@ +package com.atsuishio.superbwarfare.item.gun.data.value; + +import net.minecraft.nbt.CompoundTag; + +public class IntValue { + private final CompoundTag tag; + private final String name; + private final int defaultValue; + + public IntValue(CompoundTag tag, String name, int defaultValue) { + this.tag = tag; + this.name = name; + this.defaultValue = defaultValue; + } + + public IntValue(CompoundTag tag, String name) { + this(tag, name, 0); + } + + public int get() { + if (tag.contains(name)) { + return tag.getInt(name); + } + return defaultValue; + } + + public void set(int value) { + if (value == defaultValue) { + tag.remove(name); + } else { + tag.putInt(name, value); + } + } + + public void reset() { + set(defaultValue); + } +} diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/data/ReloadState.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/data/value/ReloadState.java similarity index 61% rename from src/main/java/com/atsuishio/superbwarfare/item/gun/data/ReloadState.java rename to src/main/java/com/atsuishio/superbwarfare/item/gun/data/value/ReloadState.java index b8a1646a9..c5ff69a80 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/data/ReloadState.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/data/value/ReloadState.java @@ -1,4 +1,4 @@ -package com.atsuishio.superbwarfare.item.gun.data; +package com.atsuishio.superbwarfare.item.gun.data.value; public enum ReloadState { NOT_RELOADING, diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/data/Starter.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/data/value/Starter.java similarity index 83% rename from src/main/java/com/atsuishio/superbwarfare/item/gun/data/Starter.java rename to src/main/java/com/atsuishio/superbwarfare/item/gun/data/value/Starter.java index 3163bf871..2c939eaf0 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/data/Starter.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/data/value/Starter.java @@ -1,12 +1,15 @@ -package com.atsuishio.superbwarfare.item.gun.data; +package com.atsuishio.superbwarfare.item.gun.data.value; import net.minecraft.nbt.CompoundTag; +/** + * 标记某种状态是否应该开始 + */ public class Starter { private final CompoundTag tag; private final String name; - Starter(CompoundTag tag, String name) { + public Starter(CompoundTag tag, String name) { this.tag = tag; this.name = "Start" + name; } diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/data/Timer.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/data/value/Timer.java similarity index 79% rename from src/main/java/com/atsuishio/superbwarfare/item/gun/data/Timer.java rename to src/main/java/com/atsuishio/superbwarfare/item/gun/data/value/Timer.java index 7537c0274..c21f6614e 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/data/Timer.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/data/value/Timer.java @@ -1,12 +1,15 @@ -package com.atsuishio.superbwarfare.item.gun.data; +package com.atsuishio.superbwarfare.item.gun.data.value; import net.minecraft.nbt.CompoundTag; +/** + * 针对一种状态的计时器 + */ public class Timer { private final CompoundTag tag; public final String name; - Timer(CompoundTag tag, String name) { + public Timer(CompoundTag tag, String name) { this.tag = tag; this.name = name + "Time"; } 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 d5688e9a5..e95da87f8 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 @@ -7,8 +7,8 @@ import com.atsuishio.superbwarfare.init.ModAttachments; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; import com.atsuishio.superbwarfare.item.gun.GunItem; -import com.atsuishio.superbwarfare.item.gun.data.AttachmentType; import com.atsuishio.superbwarfare.item.gun.data.GunData; +import com.atsuishio.superbwarfare.item.gun.data.value.AttachmentType; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; import com.atsuishio.superbwarfare.tools.NBTTool; @@ -108,7 +108,7 @@ public class Trachelium extends GunItem implements GeoItem { boolean stock = data.attachment.get(AttachmentType.STOCK) == 2; boolean grip = data.attachment.get(AttachmentType.GRIP) > 0 || data.attachment.get(AttachmentType.SCOPE) > 0; - if (data.bolt.actionTime() > 0) { + if (data.bolt.actionTimer.get() > 0) { if (stock) { if (grip) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.trachelium.action_stock_grip")); @@ -248,7 +248,7 @@ public class Trachelium extends GunItem implements GeoItem { @Override public int getCustomBoltActionTime(ItemStack stack) { - return GunData.from(stack).DA() ? 12 : 0; + return GunData.from(stack).DA.get() ? 12 : 0; } @Override 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 0e933c365..0548adac6 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 @@ -8,8 +8,8 @@ import com.atsuishio.superbwarfare.init.ModEnumExtensions; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; import com.atsuishio.superbwarfare.item.gun.GunItem; -import com.atsuishio.superbwarfare.item.gun.data.AttachmentType; import com.atsuishio.superbwarfare.item.gun.data.GunData; +import com.atsuishio.superbwarfare.item.gun.data.value.AttachmentType; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; import com.atsuishio.superbwarfare.tools.GunsTool; @@ -58,7 +58,7 @@ public class Ntw20Item extends GunItem implements GeoItem { if (!stack.is(ModTags.Items.GUN)) return PlayState.STOP; var data = GunData.from(stack); - if (data.bolt.actionTime() > 0) { + if (data.bolt.actionTimer.get() > 0) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ntw_20.shift")); } @@ -84,7 +84,7 @@ public class Ntw20Item extends GunItem implements GeoItem { && ClientEventHandler.cantSprint == 0 && !(data.reload.normal() || data.reload.empty()) && ClientEventHandler.drawTime < 0.01) { - if (ClientEventHandler.tacticalSprint && data.bolt.actionTime() == 0) { + if (ClientEventHandler.tacticalSprint && data.bolt.actionTimer.get() == 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 15352ae5b..761f30962 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 @@ -136,7 +136,7 @@ public class JavelinItem extends GunItem implements GeoItem, SpecialFireWeapon { final var tag = data.tag(); if (entity instanceof Player player && selected) { - data.setMaxAmmo(getAmmoCount(player)); + data.maxAmmo.set(getAmmoCount(player)); if (tag.getBoolean("Seeking")) { @@ -288,7 +288,7 @@ public class JavelinItem extends GunItem implements GeoItem, SpecialFireWeapon { } player.getCooldowns().addCooldown(stack.getItem(), 10); - data.setAmmo(data.ammo() - 1); + data.ammo.set(data.ammo.get() - 1); data.save(); } @@ -309,7 +309,7 @@ public class JavelinItem extends GunItem implements GeoItem, SpecialFireWeapon { public void fireOnPress(Player player, final GunData data, boolean zoom) { var tag = data.tag(); - if (!zoom || data.ammo() <= 0) return; + if (!zoom || data.ammo.get() <= 0) return; Entity seekingEntity = SeekTool.seekEntity(player, player.level(), 512, 8); 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 364cd8e5b..ddea57799 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 @@ -127,7 +127,7 @@ public class M79Item extends GunItem implements GeoItem, SpecialFireWeapon { super.inventoryTick(stack, world, entity, slot, selected); if (entity instanceof Player player) { var data = GunData.from(stack); - data.setMaxAmmo(getAmmoCount(player)); + data.maxAmmo.set(getAmmoCount(player)); data.save(); } } @@ -170,7 +170,7 @@ public class M79Item extends GunItem implements GeoItem, SpecialFireWeapon { public void fireOnPress(Player player, final GunData data, boolean zoom) { if (data.reloading()) return; ItemStack stack = data.stack(); - if (player.getCooldowns().isOnCooldown(stack.getItem()) || data.ammo() <= 0) return; + if (player.getCooldowns().isOnCooldown(stack.getItem()) || data.ammo.get() <= 0) return; double spread = data.spread(); @@ -218,7 +218,7 @@ public class M79Item extends GunItem implements GeoItem, SpecialFireWeapon { } player.getCooldowns().addCooldown(stack.getItem(), 2); - data.setAmmo(data.ammo() - 1); + data.ammo.set(data.ammo.get() - 1); } @Override 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 d15c48616..8e8715e29 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 @@ -137,13 +137,13 @@ public class RpgItem extends GunItem implements GeoItem, SpecialFireWeapon { if (tag.getBoolean("draw")) { tag.putBoolean("draw", false); - if (data.ammo() == 0) { - data.setIsEmpty(true); + if (data.ammo.get() == 0) { + data.isEmpty.set(true); } } if (entity instanceof Player player) { - data.setMaxAmmo(getAmmoCount(player)); + data.maxAmmo.set(getAmmoCount(player)); } data.save(); @@ -186,7 +186,7 @@ public class RpgItem extends GunItem implements GeoItem, SpecialFireWeapon { if (data.reloading() || player.getCooldowns().isOnCooldown(stack.getItem()) - || data.ammo() <= 0 + || data.ammo.get() <= 0 ) return; double spread = data.spread(); @@ -237,21 +237,21 @@ public class RpgItem extends GunItem implements GeoItem, SpecialFireWeapon { PacketDistributor.sendToPlayer(serverPlayer, new ShootClientMessage(10)); } - if (data.ammo() == 1) { - data.setIsEmpty(true); - data.setCloseHammer(true); + if (data.ammo.get() == 1) { + data.isEmpty.set(true); + data.closeHammer.set(true); } player.getCooldowns().addCooldown(stack.getItem(), 10); - data.setAmmo(data.ammo() - 1); + data.ammo.set(data.ammo.get() - 1); } @Override public void addReloadTimeBehavior(Map> behaviors) { super.addReloadTimeBehavior(behaviors); - behaviors.put(84, data -> data.setIsEmpty(false)); - behaviors.put(9, data -> data.setCloseHammer(false)); + behaviors.put(84, data -> data.isEmpty.set(false)); + behaviors.put(9, data -> data.closeHammer.set(false)); } @Override 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 40a3c32f2..78b220760 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 @@ -91,11 +91,11 @@ public class SecondaryCataclysm extends GunItem implements GeoItem, SpecialFireW return event.setAndContinue(RawAnimation.begin().thenPlay("animation.sc.prepare")); } - if (data.loadIndex() == 0 && data.reload.stage() == 2) { + if (data.loadIndex.get() == 0 && data.reload.stage() == 2) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.sc.iterativeload")); } - if (data.loadIndex() == 1 && data.reload.stage() == 2) { + if (data.loadIndex.get() == 1 && data.reload.stage() == 2) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.sc.iterativeload2")); } @@ -178,7 +178,7 @@ public class SecondaryCataclysm extends GunItem implements GeoItem, SpecialFireW if (entity instanceof Player player) { var data = GunData.from(stack); - data.setMaxAmmo(getAmmoCount(player)); + data.maxAmmo.set(getAmmoCount(player)); data.save(); } @@ -268,7 +268,7 @@ public class SecondaryCataclysm extends GunItem implements GeoItem, SpecialFireW public void fireOnPress(Player player, final GunData data, boolean zoom) { if (data.reloading()) return; ItemStack stack = data.stack(); - if (player.getCooldowns().isOnCooldown(stack.getItem()) || data.ammo() <= 0) return; + if (player.getCooldowns().isOnCooldown(stack.getItem()) || data.ammo.get() <= 0) return; double spread = data.spread(); @@ -334,7 +334,7 @@ public class SecondaryCataclysm extends GunItem implements GeoItem, SpecialFireW PacketDistributor.sendToPlayer(serverPlayer, new ShootClientMessage(10)); } - data.setAmmo(data.ammo() - 1); + data.ammo.set(data.ammo.get() - 1); player.getCooldowns().addCooldown(stack.getItem(), 6); } 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 d2989bd2b..aabe24f3d 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 @@ -113,7 +113,7 @@ public class M60Item extends GunItem implements GeoItem { if (tag.getBoolean("draw")) { tag.putBoolean("draw", false); - if (data.ammo() <= 5) { + if (data.ammo.get() <= 5) { GunsTool.setGunBooleanTag(tag, "HideBulletChain", true); } data.save(); 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 232364015..9cce27c08 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 @@ -8,8 +8,8 @@ import com.atsuishio.superbwarfare.init.ModPerks; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; import com.atsuishio.superbwarfare.item.gun.GunItem; -import com.atsuishio.superbwarfare.item.gun.data.AttachmentType; import com.atsuishio.superbwarfare.item.gun.data.GunData; +import com.atsuishio.superbwarfare.item.gun.data.value.AttachmentType; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; import com.atsuishio.superbwarfare.tools.GunsTool; 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 0b51c53ff..75082a2c7 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 @@ -7,8 +7,8 @@ import com.atsuishio.superbwarfare.init.ModAttachments; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; import com.atsuishio.superbwarfare.item.gun.GunItem; -import com.atsuishio.superbwarfare.item.gun.data.AttachmentType; import com.atsuishio.superbwarfare.item.gun.data.GunData; +import com.atsuishio.superbwarfare.item.gun.data.value.AttachmentType; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; import com.atsuishio.superbwarfare.tools.GunsTool; 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 067494589..b3023152a 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 @@ -7,8 +7,8 @@ import com.atsuishio.superbwarfare.init.ModAttachments; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; import com.atsuishio.superbwarfare.item.gun.GunItem; -import com.atsuishio.superbwarfare.item.gun.data.AttachmentType; import com.atsuishio.superbwarfare.item.gun.data.GunData; +import com.atsuishio.superbwarfare.item.gun.data.value.AttachmentType; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; import com.atsuishio.superbwarfare.tools.GunsTool; 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 62f0a9c4f..7f541d121 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 @@ -7,8 +7,8 @@ import com.atsuishio.superbwarfare.init.ModAttachments; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; import com.atsuishio.superbwarfare.item.gun.GunItem; -import com.atsuishio.superbwarfare.item.gun.data.AttachmentType; import com.atsuishio.superbwarfare.item.gun.data.GunData; +import com.atsuishio.superbwarfare.item.gun.data.value.AttachmentType; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; import com.atsuishio.superbwarfare.tools.GunsTool; 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 c5464ed36..29d30ff87 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 @@ -7,8 +7,8 @@ import com.atsuishio.superbwarfare.init.ModAttachments; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; import com.atsuishio.superbwarfare.item.gun.GunItem; -import com.atsuishio.superbwarfare.item.gun.data.AttachmentType; import com.atsuishio.superbwarfare.item.gun.data.GunData; +import com.atsuishio.superbwarfare.item.gun.data.value.AttachmentType; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; import com.atsuishio.superbwarfare.tools.GunsTool; 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 d5695cb12..078d5be45 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 @@ -49,7 +49,7 @@ public class MarlinItem extends GunItem implements GeoItem { if (!stack.is(ModTags.Items.GUN)) return PlayState.STOP; var data = GunData.from(stack); - if (data.bolt.actionTime() > 0) { + if (data.bolt.actionTimer.get() > 0) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.marlin.shift")); } @@ -57,11 +57,11 @@ public class MarlinItem extends GunItem implements GeoItem { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.marlin.prepare")); } - if (data.loadIndex() == 0 && data.reload.stage() == 2) { + if (data.loadIndex.get() == 0 && data.reload.stage() == 2) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.marlin.iterativeload")); } - if (data.loadIndex() == 1 && data.reload.stage() == 2) { + if (data.loadIndex.get() == 1 && data.reload.stage() == 2) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.marlin.iterativeload2")); } 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 edf96b8dc..e53430556 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 @@ -7,8 +7,8 @@ import com.atsuishio.superbwarfare.init.ModAttachments; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; import com.atsuishio.superbwarfare.item.gun.GunItem; -import com.atsuishio.superbwarfare.item.gun.data.AttachmentType; import com.atsuishio.superbwarfare.item.gun.data.GunData; +import com.atsuishio.superbwarfare.item.gun.data.value.AttachmentType; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; import com.atsuishio.superbwarfare.tools.GunsTool; 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 11b26cca8..667156c20 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 @@ -7,8 +7,8 @@ import com.atsuishio.superbwarfare.init.ModAttachments; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; import com.atsuishio.superbwarfare.item.gun.GunItem; -import com.atsuishio.superbwarfare.item.gun.data.AttachmentType; import com.atsuishio.superbwarfare.item.gun.data.GunData; +import com.atsuishio.superbwarfare.item.gun.data.value.AttachmentType; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; import com.atsuishio.superbwarfare.tools.GunsTool; 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 fbdcdcec2..c0d660354 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 @@ -97,7 +97,7 @@ public class SksItem extends GunItem implements GeoItem { if (tag.getBoolean("draw")) { tag.putBoolean("draw", false); - if (data.ammo() == 0) { + if (data.ammo.get() == 0) { GunsTool.setGunBooleanTag(tag, "HoldOpen", true); } data.save(); 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 d42177169..38f68ecda 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 @@ -53,7 +53,7 @@ public class M870Item extends GunItem implements GeoItem { if (!stack.is(ModTags.Items.GUN)) return PlayState.STOP; var data = GunData.from(stack); - if (data.bolt.actionTime() > 0) { + if (data.bolt.actionTimer.get() > 0) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m870.shift")); } @@ -65,11 +65,11 @@ public class M870Item extends GunItem implements GeoItem { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m870.prepare")); } - if (data.loadIndex() == 0 && data.reload.stage() == 2) { + if (data.loadIndex.get() == 0 && data.reload.stage() == 2) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m870.iterativeload")); } - if (data.loadIndex() == 1 && data.reload.stage() == 2) { + if (data.loadIndex.get() == 1 && data.reload.stage() == 2) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m870.iterativeload2")); } 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 6768050c6..daeb61485 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 @@ -7,8 +7,8 @@ import com.atsuishio.superbwarfare.init.ModAttachments; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; import com.atsuishio.superbwarfare.item.gun.GunItem; -import com.atsuishio.superbwarfare.item.gun.data.AttachmentType; import com.atsuishio.superbwarfare.item.gun.data.GunData; +import com.atsuishio.superbwarfare.item.gun.data.value.AttachmentType; 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/item/gun/sniper/K98Item.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/sniper/K98Item.java index 2403f7df5..d33e40091 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 @@ -50,7 +50,7 @@ public class K98Item extends GunItem implements GeoItem { if (!stack.is(ModTags.Items.GUN)) return PlayState.STOP; var data = GunData.from(stack); - if (data.bolt.actionTime() > 0) { + if (data.bolt.actionTimer.get() > 0) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.k98.shift")); } @@ -62,11 +62,11 @@ public class K98Item extends GunItem implements GeoItem { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.k98.prepare")); } - if (data.loadIndex() == 0 && data.reload.stage() == 2) { + if (data.loadIndex.get() == 0 && data.reload.stage() == 2) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.k98.iterativeload")); } - if (data.loadIndex() == 1 && data.reload.stage() == 2) { + if (data.loadIndex.get() == 1 && data.reload.stage() == 2) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.k98.iterativeload2")); } @@ -94,7 +94,7 @@ public class K98Item extends GunItem implements GeoItem { && ClientEventHandler.drawTime < 0.01 && !data.reloading() ) { - if (ClientEventHandler.tacticalSprint && data.bolt.actionTime() == 0) { + if (ClientEventHandler.tacticalSprint && data.bolt.actionTimer.get() == 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 3d86f5aa7..499beaa1a 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 @@ -49,7 +49,7 @@ public class M98bItem extends GunItem implements GeoItem { if (!stack.is(ModTags.Items.GUN)) return PlayState.STOP; var data = GunData.from(stack); - if (data.bolt.actionTime() > 0) { + if (data.bolt.actionTimer.get() > 0) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m98b.shift")); } @@ -74,7 +74,7 @@ public class M98bItem extends GunItem implements GeoItem { if (player.isSprinting() && player.onGround() && ClientEventHandler.cantSprint == 0 && !(data.reload.normal() || data.reload.empty()) && ClientEventHandler.drawTime < 0.01) { - if (ClientEventHandler.tacticalSprint && data.bolt.actionTime() == 0) { + if (ClientEventHandler.tacticalSprint && data.bolt.actionTimer.get() == 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 3a7058454..33dea673d 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 @@ -49,23 +49,23 @@ public class MosinNagantItem extends GunItem implements GeoItem { if (!stack.is(ModTags.Items.GUN)) return PlayState.STOP; var data = GunData.from(stack); - if (data.bolt.actionTime() > 0) { + if (data.bolt.actionTimer.get() > 0) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mosin.shift")); } - if (data.reload.stage() == 1 && data.ammo() == 0) { + if (data.reload.stage() == 1 && data.ammo.get() == 0) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mosin.prepare_empty")); } - if (data.reload.stage() == 1 && data.ammo() > 0) { + if (data.reload.stage() == 1 && data.ammo.get() > 0) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mosin.prepare")); } - if (data.loadIndex() == 0 && data.reload.stage() == 2) { + if (data.loadIndex.get() == 0 && data.reload.stage() == 2) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mosin.iterativeload")); } - if (data.loadIndex() == 1 && data.reload.stage() == 2) { + if (data.loadIndex.get() == 1 && data.reload.stage() == 2) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mosin.iterativeload2")); } @@ -92,7 +92,7 @@ public class MosinNagantItem extends GunItem implements GeoItem { && ClientEventHandler.drawTime < 0.01 && !data.reloading() ) { - if (ClientEventHandler.tacticalSprint && data.bolt.actionTime() == 0) { + if (ClientEventHandler.tacticalSprint && data.bolt.actionTimer.get() == 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 4925aafee..c73de4fe7 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 @@ -73,7 +73,7 @@ public class SentinelItem extends GunItem implements GeoItem, EnergyStorageItem if (!stack.is(ModTags.Items.GUN)) return PlayState.STOP; var data = GunData.from(stack); - if (data.bolt.actionTime() > 0) { + if (data.bolt.actionTimer.get() > 0) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.sentinel.shift")); } @@ -105,7 +105,7 @@ public class SentinelItem extends GunItem implements GeoItem, EnergyStorageItem && !data.charging() && ClientEventHandler.drawTime < 0.01 ) { - if (ClientEventHandler.tacticalSprint && data.bolt.actionTime() == 0) { + if (ClientEventHandler.tacticalSprint && data.bolt.actionTimer.get() == 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 089162777..37ff838c2 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 @@ -7,8 +7,8 @@ import com.atsuishio.superbwarfare.init.ModAttachments; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; import com.atsuishio.superbwarfare.item.gun.GunItem; -import com.atsuishio.superbwarfare.item.gun.data.AttachmentType; import com.atsuishio.superbwarfare.item.gun.data.GunData; +import com.atsuishio.superbwarfare.item.gun.data.value.AttachmentType; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; import com.atsuishio.superbwarfare.tools.GunsTool; 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 3767c591c..907becc96 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 @@ -117,7 +117,7 @@ public class BocekItem extends GunItem implements GeoItem, SpecialFireWeapon { var data = GunData.from(stack); final var tag = data.tag(); if (entity instanceof Player player) { - data.setMaxAmmo(getAmmoCount(player)); + data.maxAmmo.set(getAmmoCount(player)); data.save(); } 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 55116f4a1..806515a48 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 @@ -146,7 +146,7 @@ public class TaserItem extends GunItem implements GeoItem, SpecialFireWeapon, En var data = GunData.from(stack); if (entity instanceof Player player) { - data.setMaxAmmo(getAmmoCount(player)); + data.maxAmmo.set(getAmmoCount(player)); data.save(); } @@ -228,7 +228,7 @@ public class TaserItem extends GunItem implements GeoItem, SpecialFireWeapon, En var hasEnoughEnergy = energyStorage != null && energyStorage.getEnergyStored() >= 400 + 100 * perkLevel; if (player.getCooldowns().isOnCooldown(stack.getItem()) - || data.ammo() <= 0 + || data.ammo.get() <= 0 || !hasEnoughEnergy ) return; @@ -256,7 +256,7 @@ public class TaserItem extends GunItem implements GeoItem, SpecialFireWeapon, En PacketDistributor.sendToPlayer(serverPlayer, new ShootClientMessage(10)); } - data.setAmmo(data.ammo() - 1); + data.ammo.set(data.ammo.get() - 1); data.tag().putBoolean("shoot", true); energyStorage.extractEnergy(400 + 100 * perkLevel, false); } diff --git a/src/main/java/com/atsuishio/superbwarfare/menu/ReforgingTableMenu.java b/src/main/java/com/atsuishio/superbwarfare/menu/ReforgingTableMenu.java index 6810708a3..8eb9b81d4 100644 --- a/src/main/java/com/atsuishio/superbwarfare/menu/ReforgingTableMenu.java +++ b/src/main/java/com/atsuishio/superbwarfare/menu/ReforgingTableMenu.java @@ -209,13 +209,13 @@ public class ReforgingTableMenu extends AbstractContainerMenu { } var data = GunData.from(stack); - double oldPoint = data.upgradePoint(); + double oldPoint = data.upgradePoint.get(); int point = (int) oldPoint; int newPoint = this.upgradePoint.get(); int delta = newPoint - point; if (delta != 0) { - data.setUpgradePoint(oldPoint + delta); + data.upgradePoint.set(oldPoint + delta); data.save(); } } @@ -292,7 +292,7 @@ public class ReforgingTableMenu extends AbstractContainerMenu { int level = inputData.perk.getLevel(perkItem); if (level <= 0) { - this.upgradePoint.set((int) inputData.upgradePoint()); + this.upgradePoint.set((int) inputData.upgradePoint.get()); return; } @@ -300,8 +300,8 @@ public class ReforgingTableMenu extends AbstractContainerMenu { var outputData = GunData.from(output); outputData.perk.remove(perkItem.getPerk()); - inputData.setUpgradePoint(Math.min(MAX_UPGRADE_POINT, level - 1 + inputData.upgradePoint())); - this.upgradePoint.set((int) inputData.upgradePoint()); + inputData.upgradePoint.set(Math.min(MAX_UPGRADE_POINT, level - 1 + inputData.upgradePoint.get())); + this.upgradePoint.set((int) inputData.upgradePoint.get()); outputData.save(); inputData.save(); @@ -336,7 +336,7 @@ public class ReforgingTableMenu extends AbstractContainerMenu { if (!(stack.getItem() instanceof GunItem)) return; var data = GunData.from(stack); - int point = (int) data.upgradePoint(); + int point = (int) data.upgradePoint.get(); this.upgradePoint.set(Mth.clamp(point, 0, MAX_UPGRADE_POINT)); for (var type : Perk.Type.values()) { 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 7b29088c6..89d1a4204 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,8 +3,8 @@ 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.data.AttachmentType; import com.atsuishio.superbwarfare.item.gun.data.GunData; +import com.atsuishio.superbwarfare.item.gun.data.value.AttachmentType; 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/network/message/send/FireMessage.java b/src/main/java/com/atsuishio/superbwarfare/network/message/send/FireMessage.java index 54d44d0ea..c4282e5a3 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 @@ -55,8 +55,8 @@ public record FireMessage(int msgType, double power, boolean zoom) implements Cu var cap = player.getData(ModAttachments.PLAYER_VARIABLE).watch(); if (type == 0) { - if (data.reload.prepareTimer.get() == 0 && data.reloading() && data.ammo() > 0) { - data.setForceStop(true); + if (data.reload.prepareTimer.get() == 0 && data.reloading() && data.ammo.get() > 0) { + data.forceStop.set(true); } cap.edit = false; @@ -82,16 +82,16 @@ public record FireMessage(int msgType, double power, boolean zoom) implements Cu if (!stack.is(ModTags.Items.GUN)) return; var data = GunData.from(stack); - if (data.bolt.defaultActionTime() > 0 - && data.ammo() > (stack.is(ModTags.Items.REVOLVER) ? -1 : 0) - && data.bolt.actionTime() == 0 + if (data.defaultActionTime() > 0 + && data.ammo.get() > (stack.is(ModTags.Items.REVOLVER) ? -1 : 0) + && data.bolt.actionTimer.get() == 0 && !(data.reload.normal() || data.reload.empty()) && !data.reloading() && !data.charging() ) { - if (!player.getCooldowns().isOnCooldown(stack.getItem()) && data.bolt.needed()) { - data.bolt.setActionTime(data.bolt.defaultActionTime() + 1); + if (!player.getCooldowns().isOnCooldown(stack.getItem()) && data.bolt.needed.get()) { + data.bolt.actionTimer.set(data.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 b2425a64b..2cc85435b 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 @@ -35,20 +35,20 @@ public record FireModeMessage(int msgType) implements CustomPacketPayload { if (stack.getItem() instanceof GunItem gunItem) { var data = GunData.from(stack); var tag = data.tag(); - int fireMode = data.fireMode(); + int fireMode = data.fireMode.get(); int mode = gunItem.getAvailableFireModes(); mode &= 0b111; if (fireMode == 0) { if ((mode & 2) != 0) { - data.setFireMode(1); + data.fireMode.set(1); playChangeModeSound(player); data.save(); return; } if ((mode & 4) != 0) { - data.setFireMode(2); + data.fireMode.set(2); playChangeModeSound(player); data.save(); return; @@ -57,13 +57,13 @@ public record FireModeMessage(int msgType) implements CustomPacketPayload { if (fireMode == 1) { if ((mode & 4) != 0) { - data.setFireMode(2); + data.fireMode.set(2); playChangeModeSound(player); data.save(); return; } if ((mode & 1) != 0) { - data.setFireMode(0); + data.fireMode.set(0); playChangeModeSound(player); data.save(); return; @@ -72,13 +72,13 @@ public record FireModeMessage(int msgType) implements CustomPacketPayload { if (fireMode == 2) { if ((mode & 1) != 0) { - data.setFireMode(0); + data.fireMode.set(0); playChangeModeSound(player); data.save(); return; } if ((mode & 2) != 0) { - data.setFireMode(1); + data.fireMode.set(1); playChangeModeSound(player); data.save(); return; @@ -109,10 +109,10 @@ public record FireModeMessage(int msgType) implements CustomPacketPayload { } } - if (stack.getItem() == ModItems.TRACHELIUM.get() && !data.bolt.needed()) { - data.setDA(!data.DA()); - if (!data.canImmediatelyShoot()) { - data.bolt.markNeeded(); + if (stack.getItem() == ModItems.TRACHELIUM.get() && !data.bolt.needed.get()) { + data.DA.set(!data.DA.get()); + if (!data.canImmediatelyShoot.get()) { + data.bolt.needed.set(true); } } 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 ebf3c4f0c..72b60cde7 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 @@ -44,11 +44,11 @@ public record ReloadMessage(int msgType) implements CustomPacketPayload { && !data.charging() && !data.reloading() && data.reload.time() == 0 - && data.bolt.actionTime() == 0 + && data.bolt.actionTimer.get() == 0 ) { boolean canSingleReload = gunItem.isIterativeReload(stack); boolean canReload = gunItem.isMagazineReload(stack) && !gunItem.isClipReload(stack); - boolean clipLoad = data.ammo() == 0 && gunItem.isClipReload(stack); + boolean clipLoad = data.ammo.get() == 0 && gunItem.isClipReload(stack); // 检查备弹 boolean hasCreativeAmmoBox = player.getInventory().hasAnyMatching(item -> item.is(ModItems.CREATIVE_AMMO_BOX.get())); @@ -64,9 +64,9 @@ public record ReloadMessage(int msgType) implements CustomPacketPayload { return; } else if (stack.is(ModTags.Items.USE_HEAVY_AMMO) && cap.heavyAmmo == 0) { return; - } else if (stack.getItem() == ModItems.TASER.get() && data.maxAmmo() == 0) { + } else if (stack.getItem() == ModItems.TASER.get() && data.maxAmmo.get() == 0) { return; - } else if (stack.is(ModTags.Items.LAUNCHER) && data.maxAmmo() == 0) { + } else if (stack.is(ModTags.Items.LAUNCHER) && data.maxAmmo.get() == 0) { return; } } @@ -76,13 +76,13 @@ public record ReloadMessage(int msgType) implements CustomPacketPayload { var extra = (gunItem.isOpenBolt(stack) && gunItem.hasBulletInBarrel(stack)) ? 1 : 0; var maxAmmo = magazine + extra; - if (data.ammo() < maxAmmo) { + if (data.ammo.get() < maxAmmo) { data.reload.reloadStarter.markStart(); } return; } - if (canSingleReload && data.ammo() < data.magazine()) { + if (canSingleReload && data.ammo.get() < data.magazine()) { data.reload.singleReloadStarter.markStart(); } data.save(); 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 89f65ddff..970ea2914 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 @@ -47,25 +47,25 @@ public record ShootMessage(double spread, boolean zoom) implements CustomPacketP if (stack.is(ModTags.Items.NORMAL_GUN)) { int projectileAmount = data.projectileAmount(); - if (data.ammo() > 0) { + if (data.ammo.get() > 0) { // 空仓挂机 - if (data.ammo() == 1) { + if (data.ammo.get() == 1) { GunsTool.setGunBooleanTag(tag, "HoldOpen", true); } if (stack.is(ModTags.Items.REVOLVER)) { - data.setCanImmediatelyShoot(false); + data.canImmediatelyShoot.set(true); } // 判断是否为栓动武器(BoltActionTime > 0),并在开火后给一个需要上膛的状态 - if (data.bolt.defaultActionTime() > 0 && data.ammo() > (stack.is(ModTags.Items.REVOLVER) ? 0 : 1)) { - data.bolt.markNeeded(); + if (data.defaultActionTime() > 0 && data.ammo.get() > (stack.is(ModTags.Items.REVOLVER) ? 0 : 1)) { + data.bolt.needed.set(true); } - data.setAmmo(data.ammo() - 1); - data.setIsEmpty(true); + data.ammo.set(data.ammo.get() - 1); + data.isEmpty.set(true); - if (stack.getItem() == ModItems.M_60.get() && data.ammo() <= 5) { + if (stack.getItem() == ModItems.M_60.get() && data.ammo.get() <= 5) { GunsTool.setGunBooleanTag(tag, "HideBulletChain", true); } diff --git a/src/main/java/com/atsuishio/superbwarfare/tools/GunsTool.java b/src/main/java/com/atsuishio/superbwarfare/tools/GunsTool.java index c16cec6ef..11b0fe171 100644 --- a/src/main/java/com/atsuishio/superbwarfare/tools/GunsTool.java +++ b/src/main/java/com/atsuishio/superbwarfare/tools/GunsTool.java @@ -4,7 +4,7 @@ import com.atsuishio.superbwarfare.Mod; import com.atsuishio.superbwarfare.init.ModAttachments; import com.atsuishio.superbwarfare.init.ModTags; import com.atsuishio.superbwarfare.item.gun.data.GunData; -import com.atsuishio.superbwarfare.item.gun.data.ReloadState; +import com.atsuishio.superbwarfare.item.gun.data.value.ReloadState; import com.atsuishio.superbwarfare.network.message.receive.GunsDataMessage; import com.google.gson.stream.JsonReader; import net.minecraft.nbt.CompoundTag; @@ -80,12 +80,12 @@ public class GunsTool { public static void reload(Player player, ItemStack stack, GunData data, AmmoType type, boolean extraOne) { int mag = data.magazine(); - int ammo = data.ammo(); + int ammo = data.ammo.get(); int ammoToAdd = mag - ammo + (extraOne ? 1 : 0); // 空仓换弹的栓动武器应该在换弹后取消待上膛标记 - if (ammo == 0 && data.bolt.defaultActionTime() > 0 && !stack.is(ModTags.Items.REVOLVER)) { - data.bolt.markNeedless(); + if (ammo == 0 && data.defaultActionTime() > 0 && !stack.is(ModTags.Items.REVOLVER)) { + data.bolt.needed.set(false); } var capability = player.getData(ModAttachments.PLAYER_VARIABLE).watch(); @@ -99,7 +99,7 @@ public class GunsTool { int needToAdd = ammo + Math.min(ammoToAdd, playerAmmo); - data.setAmmo(needToAdd); + data.ammo.set(needToAdd); data.reload.setState(ReloadState.NOT_RELOADING); }