优化NBT#ProjectileAmount

This commit is contained in:
17146 2024-12-24 14:30:10 +08:00
parent 19bc16cb52
commit 54cadb74ac
31 changed files with 15 additions and 43 deletions

View file

@ -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));
}
}
}

View file

@ -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);

View file

@ -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;

View file

@ -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);

View file

@ -6,7 +6,7 @@
"headshot": 1.5,
"velocity": 17,
"mag": 25,
"projectile_amount": 12,
"ProjectileAmount": 12,
"Weight": 7,
"FireMode": 2,
"semi": 1,

View file

@ -6,7 +6,7 @@
"headshot": 1.5,
"velocity": 15,
"mag": 2,
"projectile_amount": 12,
"ProjectileAmount": 12,
"Weight": 1,
"FireMode": 0,
"semi": 1,

View file

@ -8,7 +8,6 @@
"headshot": 2,
"velocity": 44.5,
"mag": 30,
"projectile_amount": 1,
"Weight": 4,
"FireMode": 2,
"semi": 1,

View file

@ -8,7 +8,6 @@
"headshot": 2,
"velocity": 36,
"mag": 30,
"projectile_amount": 1,
"Weight": 5,
"FireMode": 2,
"semi": 1,

View file

@ -7,7 +7,6 @@
"headshot": 2,
"velocity": 40,
"mag": 55,
"projectile_amount": 1,
"Weight": 6,
"FireMode": 2,
"semi": 0,

View file

@ -6,7 +6,6 @@
"headshot": 1.5,
"velocity": 17,
"mag": 17,
"projectile_amount": 1,
"Weight": 1,
"FireMode": 0,
"semi": 1,

View file

@ -6,7 +6,6 @@
"headshot": 1.5,
"velocity": 17,
"mag": 17,
"projectile_amount": 1,
"Weight": 1,
"FireMode": 2,
"semi": 1,

View file

@ -8,7 +8,6 @@
"headshot": 2,
"velocity": 44,
"mag": 30,
"projectile_amount": 1,
"Weight": 4,
"FireMode": 2,
"semi": 1,

View file

@ -6,7 +6,6 @@
"headshot": 3,
"velocity": 38,
"mag": 1,
"projectile_amount": 1,
"Weight": 5,
"FireMode": 0,
"semi": 1,

View file

@ -5,7 +5,6 @@
"damage": 35,
"headshot": 3,
"velocity": 37.75,
"projectile_amount": 1,
"mag": 5,
"bolt_action_time": 22,
"Weight": 5,

View file

@ -6,7 +6,6 @@
"headshot": 1.5,
"velocity": 15,
"mag": 7,
"projectile_amount": 1,
"Weight": 2,
"FireMode": 0,
"semi": 1,

View file

@ -8,7 +8,6 @@
"headshot": 2,
"velocity": 44,
"mag": 30,
"projectile_amount": 1,
"Weight": 4,
"FireMode": 2,
"semi": 1,

View file

@ -6,7 +6,6 @@
"headshot": 2,
"velocity": 43,
"mag": 100,
"projectile_amount": 1,
"Weight": 8,
"FireMode": 2,
"semi": 0,

View file

@ -7,7 +7,7 @@
"velocity": 17,
"mag": 8,
"force_stop_reloading": 1,
"projectile_amount": 12,
"ProjectileAmount": 12,
"Weight": 4,
"FireMode": 0,
"semi": 1,

View file

@ -8,7 +8,6 @@
"damage": 38,
"headshot": 3,
"velocity": 47.2,
"projectile_amount": 1,
"mag": 5,
"bolt_action_time": 18,
"Weight": 7,

View file

@ -7,7 +7,6 @@
"velocity": 38,
"mag": 8,
"force_stop_reloading": 1,
"projectile_amount": 1,
"Weight": 3,
"FireMode": 0,
"semi": 1,

View file

@ -7,7 +7,6 @@
"velocity": 46,
"Weight": 10,
"FireMode": 2,
"projectile_amount": 1,
"BypassesArmor": 0.3,
"SoundRadius": 14,
"rpm": 1200

View file

@ -8,7 +8,6 @@
"headshot": 2.5,
"velocity": 42.5,
"mag": 20,
"projectile_amount": 1,
"Weight": 5,
"FireMode": 0,
"semi": 1,

View file

@ -6,7 +6,6 @@
"damage": 33,
"headshot": 3,
"velocity": 42,
"projectile_amount": 1,
"mag": 5,
"bolt_action_time": 22,
"Weight": 5,

View file

@ -6,7 +6,6 @@
"damage": 140,
"headshot": 3,
"velocity": 36,
"projectile_amount": 1,
"mag": 3,
"bolt_action_time": 37,
"Weight": 10,

View file

@ -8,7 +8,6 @@
"headshot": 2,
"velocity": 46,
"mag": 30,
"projectile_amount": 1,
"Weight": 4,
"FireMode": 2,
"semi": 1,

View file

@ -6,7 +6,6 @@
"headshot": 2,
"velocity": 38,
"mag": 75,
"projectile_amount": 1,
"Weight": 6,
"FireMode": 2,
"semi": 1,

View file

@ -5,7 +5,6 @@
"recoil_y": 0.018,
"damage": 35,
"mag": 5,
"projectile_amount": 1,
"headshot": 3,
"velocity": 70,
"bolt_action_time": 22,

View file

@ -6,7 +6,6 @@
"headshot": 2,
"velocity": 36,
"mag": 20,
"projectile_amount": 1,
"Weight": 4,
"FireMode": 0,
"semi": 1,

View file

@ -7,7 +7,6 @@
"headshot": 2,
"velocity": 42,
"mag": 10,
"projectile_amount": 1,
"Weight": 5,
"FireMode": 0,
"semi": 1,

View file

@ -6,7 +6,6 @@
"headshot": 2,
"velocity": 24,
"mag": 6,
"projectile_amount": 1,
"Weight": 2,
"FireMode": 0,
"semi": 1,

View file

@ -6,7 +6,6 @@
"headshot": 1.5,
"velocity": 16,
"mag": 13,
"projectile_amount": 1,
"Weight": 3,
"FireMode": 2,
"semi": 1,