diff --git a/src/main/java/com/atsuishio/superbwarfare/client/tooltip/ClientShotgunImageTooltip.java b/src/main/java/com/atsuishio/superbwarfare/client/tooltip/ClientShotgunImageTooltip.java index 1e4be0632..715e7f973 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/tooltip/ClientShotgunImageTooltip.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/tooltip/ClientShotgunImageTooltip.java @@ -1,11 +1,12 @@ package com.atsuishio.superbwarfare.client.tooltip; +import com.atsuishio.superbwarfare.client.tooltip.component.GunImageComponent; import com.atsuishio.superbwarfare.perk.AmmoPerk; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; +import com.atsuishio.superbwarfare.tools.GunsTool; import com.atsuishio.superbwarfare.tools.ItemNBTTool; import com.atsuishio.superbwarfare.tools.TooltipTool; -import com.atsuishio.superbwarfare.client.tooltip.component.GunImageComponent; import net.minecraft.ChatFormatting; import net.minecraft.network.chat.Component; @@ -27,7 +28,7 @@ public class ClientShotgunImageTooltip extends ClientGunImageTooltip { } if (slug) { - double damage = ItemNBTTool.getDouble(stack, "damage", 0) * ItemNBTTool.getDouble(stack, "projectile_amount", 0) * TooltipTool.perkDamage(stack); + double damage = ItemNBTTool.getDouble(stack, "damage", 0) * GunsTool.getGunIntTag(stack, "ProjectileAmount", 1) * TooltipTool.perkDamage(stack); return Component.translatable("des.superbwarfare.tips.damage").withStyle(ChatFormatting.GRAY) .append(Component.literal("").withStyle(ChatFormatting.RESET)) .append(Component.literal(new DecimalFormat("##.#").format(damage) + (TooltipTool.heBullet(stack) ? " + " + new DecimalFormat("##.#") @@ -36,7 +37,7 @@ public class ClientShotgunImageTooltip extends ClientGunImageTooltip { double damage = ItemNBTTool.getDouble(stack, "damage", 0) * TooltipTool.perkDamage(stack); return Component.translatable("des.superbwarfare.tips.damage").withStyle(ChatFormatting.GRAY) .append(Component.literal("").withStyle(ChatFormatting.RESET)) - .append(Component.literal(new DecimalFormat("##.#").format(damage) + " * " + new DecimalFormat("##").format(ItemNBTTool.getDouble(stack, "projectile_amount", 0))).withStyle(ChatFormatting.GREEN)); + .append(Component.literal(new DecimalFormat("##.#").format(damage) + " * " + new DecimalFormat("##").format(GunsTool.getGunIntTag(stack, "ProjectileAmount", 1))).withStyle(ChatFormatting.GREEN)); } } } diff --git a/src/main/java/com/atsuishio/superbwarfare/event/GunEventHandler.java b/src/main/java/com/atsuishio/superbwarfare/event/GunEventHandler.java index 9bc0f3c5e..fa8ea1170 100644 --- a/src/main/java/com/atsuishio/superbwarfare/event/GunEventHandler.java +++ b/src/main/java/com/atsuishio/superbwarfare/event/GunEventHandler.java @@ -188,7 +188,7 @@ public class GunEventHandler { float headshot = (float) heldItem.getOrCreateTag().getDouble("headshot"); float damage = (float) (heldItem.getOrCreateTag().getDouble("damage") + heldItem.getOrCreateTag().getDouble("sentinelChargeDamage")) * (float) perkDamage(heldItem); float velocity = (float) ((heldItem.getOrCreateTag().getDouble("velocity") + heldItem.getOrCreateTag().getDouble("CustomVelocity")) * perkSpeed(heldItem)); - int projectileAmount = (int) heldItem.getOrCreateTag().getDouble("projectile_amount"); + int projectileAmount = GunsTool.getGunIntTag(heldItem, "ProjectileAmount", 1); float bypassArmorRate = (float) heldItem.getOrCreateTag().getDouble("BypassesArmor"); boolean zoom = player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).zoom; var perk = PerkHelper.getPerkByType(heldItem, Perk.Type.AMMO); diff --git a/src/main/java/com/atsuishio/superbwarfare/network/message/ShootMessage.java b/src/main/java/com/atsuishio/superbwarfare/network/message/ShootMessage.java index 66cbfccc6..8bb649a60 100644 --- a/src/main/java/com/atsuishio/superbwarfare/network/message/ShootMessage.java +++ b/src/main/java/com/atsuishio/superbwarfare/network/message/ShootMessage.java @@ -60,7 +60,7 @@ public class ShootMessage { ItemStack stack = player.getMainHandItem(); if (stack.is(ModTags.Items.NORMAL_GUN)) { - int projectileAmount = (int) stack.getOrCreateTag().getDouble("projectile_amount"); + int projectileAmount = GunsTool.getGunIntTag(stack, "ProjectileAmount", 1); if (stack.getOrCreateTag().getInt("ammo") > 0) { // 空仓挂机 @@ -72,9 +72,7 @@ public class ShootMessage { stack.getOrCreateTag().putBoolean("canImmediatelyShoot", false); } - /* - 判断是否为栓动武器(bolt_action_time > 0),并在开火后给一个需要上膛的状态 - */ + // 判断是否为栓动武器(bolt_action_time > 0),并在开火后给一个需要上膛的状态 if (stack.getOrCreateTag().getDouble("bolt_action_time") > 0 && stack.getOrCreateTag().getInt("ammo") > (stack.is(ModTags.Items.REVOLVER) ? 0 : 1)) { stack.getOrCreateTag().putBoolean("need_bolt_action", true); } @@ -112,8 +110,6 @@ public class ShootMessage { } else if (stack.is(ModItems.MINIGUN.get())) { var tag = stack.getOrCreateTag(); - int projectileAmount = (int) tag.getDouble("projectile_amount"); - if ((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).rifleAmmo > 0 || player.getInventory().hasAnyMatching(s -> s.is(ModItems.CREATIVE_AMMO_BOX.get()))) { tag.putDouble("heat", (tag.getDouble("heat") + 0.1)); @@ -139,10 +135,7 @@ public class ShootMessage { } } - for (int index0 = 0; index0 < (perk instanceof AmmoPerk ammoPerk && ammoPerk.slug ? 1 : projectileAmount); index0++) { - GunEventHandler.gunShoot(player, spared); - } - + GunEventHandler.gunShoot(player, spared); if (!player.getInventory().hasAnyMatching(s -> s.is(ModItems.CREATIVE_AMMO_BOX.get()))) { player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { capability.rifleAmmo = player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).rifleAmmo - 1; diff --git a/src/main/java/com/atsuishio/superbwarfare/tools/GunsTool.java b/src/main/java/com/atsuishio/superbwarfare/tools/GunsTool.java index 9d12df377..4f5c07b91 100644 --- a/src/main/java/com/atsuishio/superbwarfare/tools/GunsTool.java +++ b/src/main/java/com/atsuishio/superbwarfare/tools/GunsTool.java @@ -55,7 +55,8 @@ public class GunsTool { public static void initGun(Level level, ItemStack stack, String location) { if (level.getServer() == null) return; gunsData.get(location).forEach((k, v) -> { - if (k.equals("EmptyReloadTime") || k.equals("FireMode") || k.equals("Weight") || k.equals("SoundRadius") || k.equals("BurstSize")) { + if (k.equals("EmptyReloadTime") || k.equals("FireMode") || k.equals("Weight") || k.equals("SoundRadius") || k.equals("BurstSize") + || k.equals("ProjectileAmount")) { CompoundTag tag = stack.getOrCreateTag(); CompoundTag data = tag.getCompound("GunData"); data.putDouble(k, v); @@ -69,7 +70,8 @@ public class GunsTool { public static void initCreativeGun(ItemStack stack, String location) { if (gunsData != null && gunsData.get(location) != null) { gunsData.get(location).forEach((k, v) -> { - if (k.equals("EmptyReloadTime") || k.equals("FireMode") || k.equals("Weight") || k.equals("SoundRadius") || k.equals("BurstSize")) { + if (k.equals("EmptyReloadTime") || k.equals("FireMode") || k.equals("Weight") || k.equals("SoundRadius") || k.equals("BurstSize") + || k.equals("ProjectileAmount")) { CompoundTag tag = stack.getOrCreateTag(); CompoundTag data = tag.getCompound("GunData"); data.putDouble(k, v); diff --git a/src/main/resources/data/superbwarfare/guns/aa_12.json b/src/main/resources/data/superbwarfare/guns/aa_12.json index 2ce889973..e51f4cc0d 100644 --- a/src/main/resources/data/superbwarfare/guns/aa_12.json +++ b/src/main/resources/data/superbwarfare/guns/aa_12.json @@ -6,7 +6,7 @@ "headshot": 1.5, "velocity": 17, "mag": 25, - "projectile_amount": 12, + "ProjectileAmount": 12, "Weight": 7, "FireMode": 2, "semi": 1, diff --git a/src/main/resources/data/superbwarfare/guns/abekiri.json b/src/main/resources/data/superbwarfare/guns/abekiri.json index d0ddfc7f5..1359b66bc 100644 --- a/src/main/resources/data/superbwarfare/guns/abekiri.json +++ b/src/main/resources/data/superbwarfare/guns/abekiri.json @@ -6,7 +6,7 @@ "headshot": 1.5, "velocity": 15, "mag": 2, - "projectile_amount": 12, + "ProjectileAmount": 12, "Weight": 1, "FireMode": 0, "semi": 1, diff --git a/src/main/resources/data/superbwarfare/guns/ak_12.json b/src/main/resources/data/superbwarfare/guns/ak_12.json index 2aaff6355..e8944fcc8 100644 --- a/src/main/resources/data/superbwarfare/guns/ak_12.json +++ b/src/main/resources/data/superbwarfare/guns/ak_12.json @@ -8,7 +8,6 @@ "headshot": 2, "velocity": 44.5, "mag": 30, - "projectile_amount": 1, "Weight": 4, "FireMode": 2, "semi": 1, diff --git a/src/main/resources/data/superbwarfare/guns/ak_47.json b/src/main/resources/data/superbwarfare/guns/ak_47.json index 3d854291f..de68a9966 100644 --- a/src/main/resources/data/superbwarfare/guns/ak_47.json +++ b/src/main/resources/data/superbwarfare/guns/ak_47.json @@ -8,7 +8,6 @@ "headshot": 2, "velocity": 36, "mag": 30, - "projectile_amount": 1, "Weight": 5, "FireMode": 2, "semi": 1, diff --git a/src/main/resources/data/superbwarfare/guns/devotion.json b/src/main/resources/data/superbwarfare/guns/devotion.json index 3afe5c40e..ca7679c5e 100644 --- a/src/main/resources/data/superbwarfare/guns/devotion.json +++ b/src/main/resources/data/superbwarfare/guns/devotion.json @@ -7,7 +7,6 @@ "headshot": 2, "velocity": 40, "mag": 55, - "projectile_amount": 1, "Weight": 6, "FireMode": 2, "semi": 0, diff --git a/src/main/resources/data/superbwarfare/guns/glock_17.json b/src/main/resources/data/superbwarfare/guns/glock_17.json index ed533c971..99346d226 100644 --- a/src/main/resources/data/superbwarfare/guns/glock_17.json +++ b/src/main/resources/data/superbwarfare/guns/glock_17.json @@ -6,7 +6,6 @@ "headshot": 1.5, "velocity": 17, "mag": 17, - "projectile_amount": 1, "Weight": 1, "FireMode": 0, "semi": 1, diff --git a/src/main/resources/data/superbwarfare/guns/glock_18.json b/src/main/resources/data/superbwarfare/guns/glock_18.json index d29f465dd..9857ba182 100644 --- a/src/main/resources/data/superbwarfare/guns/glock_18.json +++ b/src/main/resources/data/superbwarfare/guns/glock_18.json @@ -6,7 +6,6 @@ "headshot": 1.5, "velocity": 17, "mag": 17, - "projectile_amount": 1, "Weight": 1, "FireMode": 2, "semi": 1, diff --git a/src/main/resources/data/superbwarfare/guns/hk_416.json b/src/main/resources/data/superbwarfare/guns/hk_416.json index 044f837d1..dd06b5ff6 100644 --- a/src/main/resources/data/superbwarfare/guns/hk_416.json +++ b/src/main/resources/data/superbwarfare/guns/hk_416.json @@ -8,7 +8,6 @@ "headshot": 2, "velocity": 44, "mag": 30, - "projectile_amount": 1, "Weight": 4, "FireMode": 2, "semi": 1, diff --git a/src/main/resources/data/superbwarfare/guns/hunting_rifle.json b/src/main/resources/data/superbwarfare/guns/hunting_rifle.json index 8f211a5d8..bcecbcad0 100644 --- a/src/main/resources/data/superbwarfare/guns/hunting_rifle.json +++ b/src/main/resources/data/superbwarfare/guns/hunting_rifle.json @@ -6,7 +6,6 @@ "headshot": 3, "velocity": 38, "mag": 1, - "projectile_amount": 1, "Weight": 5, "FireMode": 0, "semi": 1, diff --git a/src/main/resources/data/superbwarfare/guns/k_98.json b/src/main/resources/data/superbwarfare/guns/k_98.json index dcd0a2013..0f32b113a 100644 --- a/src/main/resources/data/superbwarfare/guns/k_98.json +++ b/src/main/resources/data/superbwarfare/guns/k_98.json @@ -5,7 +5,6 @@ "damage": 35, "headshot": 3, "velocity": 37.75, - "projectile_amount": 1, "mag": 5, "bolt_action_time": 22, "Weight": 5, diff --git a/src/main/resources/data/superbwarfare/guns/m_1911.json b/src/main/resources/data/superbwarfare/guns/m_1911.json index 314250735..56d1e927f 100644 --- a/src/main/resources/data/superbwarfare/guns/m_1911.json +++ b/src/main/resources/data/superbwarfare/guns/m_1911.json @@ -6,7 +6,6 @@ "headshot": 1.5, "velocity": 15, "mag": 7, - "projectile_amount": 1, "Weight": 2, "FireMode": 0, "semi": 1, diff --git a/src/main/resources/data/superbwarfare/guns/m_4.json b/src/main/resources/data/superbwarfare/guns/m_4.json index 339a9f472..710d72f84 100644 --- a/src/main/resources/data/superbwarfare/guns/m_4.json +++ b/src/main/resources/data/superbwarfare/guns/m_4.json @@ -8,7 +8,6 @@ "headshot": 2, "velocity": 44, "mag": 30, - "projectile_amount": 1, "Weight": 4, "FireMode": 2, "semi": 1, diff --git a/src/main/resources/data/superbwarfare/guns/m_60.json b/src/main/resources/data/superbwarfare/guns/m_60.json index a47b398c3..d81985660 100644 --- a/src/main/resources/data/superbwarfare/guns/m_60.json +++ b/src/main/resources/data/superbwarfare/guns/m_60.json @@ -6,7 +6,6 @@ "headshot": 2, "velocity": 43, "mag": 100, - "projectile_amount": 1, "Weight": 8, "FireMode": 2, "semi": 0, diff --git a/src/main/resources/data/superbwarfare/guns/m_870.json b/src/main/resources/data/superbwarfare/guns/m_870.json index 61fb6f40c..5771ab3ed 100644 --- a/src/main/resources/data/superbwarfare/guns/m_870.json +++ b/src/main/resources/data/superbwarfare/guns/m_870.json @@ -7,7 +7,7 @@ "velocity": 17, "mag": 8, "force_stop_reloading": 1, - "projectile_amount": 12, + "ProjectileAmount": 12, "Weight": 4, "FireMode": 0, "semi": 1, diff --git a/src/main/resources/data/superbwarfare/guns/m_98b.json b/src/main/resources/data/superbwarfare/guns/m_98b.json index bd237cfe3..d60bec3a5 100644 --- a/src/main/resources/data/superbwarfare/guns/m_98b.json +++ b/src/main/resources/data/superbwarfare/guns/m_98b.json @@ -8,7 +8,6 @@ "damage": 38, "headshot": 3, "velocity": 47.2, - "projectile_amount": 1, "mag": 5, "bolt_action_time": 18, "Weight": 7, diff --git a/src/main/resources/data/superbwarfare/guns/marlin.json b/src/main/resources/data/superbwarfare/guns/marlin.json index 60cedb3d4..39e1df3b1 100644 --- a/src/main/resources/data/superbwarfare/guns/marlin.json +++ b/src/main/resources/data/superbwarfare/guns/marlin.json @@ -7,7 +7,6 @@ "velocity": 38, "mag": 8, "force_stop_reloading": 1, - "projectile_amount": 1, "Weight": 3, "FireMode": 0, "semi": 1, diff --git a/src/main/resources/data/superbwarfare/guns/minigun.json b/src/main/resources/data/superbwarfare/guns/minigun.json index ff81167e7..1927bb919 100644 --- a/src/main/resources/data/superbwarfare/guns/minigun.json +++ b/src/main/resources/data/superbwarfare/guns/minigun.json @@ -7,7 +7,6 @@ "velocity": 46, "Weight": 10, "FireMode": 2, - "projectile_amount": 1, "BypassesArmor": 0.3, "SoundRadius": 14, "rpm": 1200 diff --git a/src/main/resources/data/superbwarfare/guns/mk_14.json b/src/main/resources/data/superbwarfare/guns/mk_14.json index 328c06d60..a4eefeb72 100644 --- a/src/main/resources/data/superbwarfare/guns/mk_14.json +++ b/src/main/resources/data/superbwarfare/guns/mk_14.json @@ -8,7 +8,6 @@ "headshot": 2.5, "velocity": 42.5, "mag": 20, - "projectile_amount": 1, "Weight": 5, "FireMode": 0, "semi": 1, diff --git a/src/main/resources/data/superbwarfare/guns/mosin_nagant.json b/src/main/resources/data/superbwarfare/guns/mosin_nagant.json index 583a8ba7f..ba30203ad 100644 --- a/src/main/resources/data/superbwarfare/guns/mosin_nagant.json +++ b/src/main/resources/data/superbwarfare/guns/mosin_nagant.json @@ -6,7 +6,6 @@ "damage": 33, "headshot": 3, "velocity": 42, - "projectile_amount": 1, "mag": 5, "bolt_action_time": 22, "Weight": 5, diff --git a/src/main/resources/data/superbwarfare/guns/ntw_20.json b/src/main/resources/data/superbwarfare/guns/ntw_20.json index 8f9f9e7f8..baecf11d9 100644 --- a/src/main/resources/data/superbwarfare/guns/ntw_20.json +++ b/src/main/resources/data/superbwarfare/guns/ntw_20.json @@ -6,7 +6,6 @@ "damage": 140, "headshot": 3, "velocity": 36, - "projectile_amount": 1, "mag": 3, "bolt_action_time": 37, "Weight": 10, diff --git a/src/main/resources/data/superbwarfare/guns/qbz_95.json b/src/main/resources/data/superbwarfare/guns/qbz_95.json index f34a27750..3c68bfaa3 100644 --- a/src/main/resources/data/superbwarfare/guns/qbz_95.json +++ b/src/main/resources/data/superbwarfare/guns/qbz_95.json @@ -8,7 +8,6 @@ "headshot": 2, "velocity": 46, "mag": 30, - "projectile_amount": 1, "Weight": 4, "FireMode": 2, "semi": 1, diff --git a/src/main/resources/data/superbwarfare/guns/rpk.json b/src/main/resources/data/superbwarfare/guns/rpk.json index a5a824b5e..03a408508 100644 --- a/src/main/resources/data/superbwarfare/guns/rpk.json +++ b/src/main/resources/data/superbwarfare/guns/rpk.json @@ -6,7 +6,6 @@ "headshot": 2, "velocity": 38, "mag": 75, - "projectile_amount": 1, "Weight": 6, "FireMode": 2, "semi": 1, diff --git a/src/main/resources/data/superbwarfare/guns/sentinel.json b/src/main/resources/data/superbwarfare/guns/sentinel.json index ce89d78da..538c495c6 100644 --- a/src/main/resources/data/superbwarfare/guns/sentinel.json +++ b/src/main/resources/data/superbwarfare/guns/sentinel.json @@ -5,7 +5,6 @@ "recoil_y": 0.018, "damage": 35, "mag": 5, - "projectile_amount": 1, "headshot": 3, "velocity": 70, "bolt_action_time": 22, diff --git a/src/main/resources/data/superbwarfare/guns/sks.json b/src/main/resources/data/superbwarfare/guns/sks.json index 92e0dcc85..d1765fbdd 100644 --- a/src/main/resources/data/superbwarfare/guns/sks.json +++ b/src/main/resources/data/superbwarfare/guns/sks.json @@ -6,7 +6,6 @@ "headshot": 2, "velocity": 36, "mag": 20, - "projectile_amount": 1, "Weight": 4, "FireMode": 0, "semi": 1, diff --git a/src/main/resources/data/superbwarfare/guns/svd.json b/src/main/resources/data/superbwarfare/guns/svd.json index d8e1660cb..20c3fee72 100644 --- a/src/main/resources/data/superbwarfare/guns/svd.json +++ b/src/main/resources/data/superbwarfare/guns/svd.json @@ -7,7 +7,6 @@ "headshot": 2, "velocity": 42, "mag": 10, - "projectile_amount": 1, "Weight": 5, "FireMode": 0, "semi": 1, diff --git a/src/main/resources/data/superbwarfare/guns/trachelium.json b/src/main/resources/data/superbwarfare/guns/trachelium.json index cf868fd55..55bd90b8b 100644 --- a/src/main/resources/data/superbwarfare/guns/trachelium.json +++ b/src/main/resources/data/superbwarfare/guns/trachelium.json @@ -6,7 +6,6 @@ "headshot": 2, "velocity": 24, "mag": 6, - "projectile_amount": 1, "Weight": 2, "FireMode": 0, "semi": 1, diff --git a/src/main/resources/data/superbwarfare/guns/vector.json b/src/main/resources/data/superbwarfare/guns/vector.json index b984f0845..05d635059 100644 --- a/src/main/resources/data/superbwarfare/guns/vector.json +++ b/src/main/resources/data/superbwarfare/guns/vector.json @@ -6,7 +6,6 @@ "headshot": 1.5, "velocity": 16, "mag": 13, - "projectile_amount": 1, "Weight": 3, "FireMode": 2, "semi": 1,