优化NBT#Spread

This commit is contained in:
17146 2024-12-24 14:37:43 +08:00
parent 54cadb74ac
commit 4eb52372b1
35 changed files with 44 additions and 44 deletions

View file

@ -231,7 +231,7 @@ public class ClientEventHandler {
// 精准度 // 精准度
float times = (float) Math.min(Minecraft.getInstance().getDeltaFrameTime(), 0.8); float times = (float) Math.min(Minecraft.getInstance().getDeltaFrameTime(), 0.8);
double basicDev = stack.getOrCreateTag().getDouble("spread"); double basicDev = GunsTool.getGunDoubleTag(stack, "Spread");
double walk = isMoving() ? 0.3 * basicDev : 0; double walk = isMoving() ? 0.3 * basicDev : 0;
double sprint = player.isSprinting() ? 0.25 * basicDev : 0; double sprint = player.isSprinting() ? 0.25 * basicDev : 0;
double crouching = player.isCrouching() ? -0.15 * basicDev : 0; double crouching = player.isCrouching() ? -0.15 * basicDev : 0;

View file

@ -11,10 +11,7 @@ import com.atsuishio.superbwarfare.network.ModVariables;
import com.atsuishio.superbwarfare.perk.AmmoPerk; import com.atsuishio.superbwarfare.perk.AmmoPerk;
import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.Perk;
import com.atsuishio.superbwarfare.perk.PerkHelper; import com.atsuishio.superbwarfare.perk.PerkHelper;
import com.atsuishio.superbwarfare.tools.EntityFindUtil; import com.atsuishio.superbwarfare.tools.*;
import com.atsuishio.superbwarfare.tools.ParticleTool;
import com.atsuishio.superbwarfare.tools.SeekTool;
import com.atsuishio.superbwarfare.tools.SoundTool;
import net.minecraft.core.particles.ParticleTypes; import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.FriendlyByteBuf;
@ -336,7 +333,7 @@ public class FireMessage {
int wireLength = PerkHelper.getItemPerkLevel(ModPerks.LONGER_WIRE.get(), stack); int wireLength = PerkHelper.getItemPerkLevel(ModPerks.LONGER_WIRE.get(), stack);
boolean zoom = player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).zoom; boolean zoom = player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).zoom;
double spread = stack.getOrCreateTag().getDouble("spread"); double spread = GunsTool.getGunDoubleTag(stack, "Spread");
Level level = player.level(); Level level = player.level();
if (!level.isClientSide()) { if (!level.isClientSide()) {
@ -369,7 +366,7 @@ public class FireMessage {
if (!stack.getOrCreateTag().getBoolean("reloading")) { if (!stack.getOrCreateTag().getBoolean("reloading")) {
if (!player.getCooldowns().isOnCooldown(stack.getItem()) && stack.getOrCreateTag().getInt("ammo") > 0) { if (!player.getCooldowns().isOnCooldown(stack.getItem()) && stack.getOrCreateTag().getInt("ammo") > 0) {
boolean zoom = player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).zoom; boolean zoom = player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).zoom;
double spread = stack.getOrCreateTag().getDouble("spread"); double spread = GunsTool.getGunDoubleTag(stack, "Spread");
Level level = player.level(); Level level = player.level();
if (!level.isClientSide()) { if (!level.isClientSide()) {
@ -421,7 +418,7 @@ public class FireMessage {
if (!tag.getBoolean("reloading") && !player.getCooldowns().isOnCooldown(stack.getItem()) && tag.getInt("ammo") > 0) { if (!tag.getBoolean("reloading") && !player.getCooldowns().isOnCooldown(stack.getItem()) && tag.getInt("ammo") > 0) {
boolean zoom = player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).zoom; boolean zoom = player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).zoom;
double spread = stack.getOrCreateTag().getDouble("spread"); double spread = GunsTool.getGunDoubleTag(stack, "Spread");
if (!level.isClientSide()) { if (!level.isClientSide()) {
RpgRocketEntity rocketEntity = new RpgRocketEntity(player, level, RpgRocketEntity rocketEntity = new RpgRocketEntity(player, level,

View file

@ -19,6 +19,7 @@ import net.minecraftforge.network.PacketDistributor;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.util.HashMap; import java.util.HashMap;
import java.util.Set;
import java.util.UUID; import java.util.UUID;
@Mod.EventBusSubscriber(modid = ModUtils.MODID) @Mod.EventBusSubscriber(modid = ModUtils.MODID)
@ -52,11 +53,14 @@ public class GunsTool {
} }
} }
// TODO 临时使用移植完毕后删除
private static final Set<String> STRING_SET = Set.of("EmptyReloadTime", "FireMode", "Weight", "SoundRadius", "BurstSize", "ProjectileAmount",
"Spread");
public static void initGun(Level level, ItemStack stack, String location) { public static void initGun(Level level, ItemStack stack, String location) {
if (level.getServer() == null) return; if (level.getServer() == null) return;
gunsData.get(location).forEach((k, v) -> { gunsData.get(location).forEach((k, v) -> {
if (k.equals("EmptyReloadTime") || k.equals("FireMode") || k.equals("Weight") || k.equals("SoundRadius") || k.equals("BurstSize") if (STRING_SET.contains(k)) {
|| k.equals("ProjectileAmount")) {
CompoundTag tag = stack.getOrCreateTag(); CompoundTag tag = stack.getOrCreateTag();
CompoundTag data = tag.getCompound("GunData"); CompoundTag data = tag.getCompound("GunData");
data.putDouble(k, v); data.putDouble(k, v);
@ -70,8 +74,7 @@ public class GunsTool {
public static void initCreativeGun(ItemStack stack, String location) { public static void initCreativeGun(ItemStack stack, String location) {
if (gunsData != null && gunsData.get(location) != null) { if (gunsData != null && gunsData.get(location) != null) {
gunsData.get(location).forEach((k, v) -> { gunsData.get(location).forEach((k, v) -> {
if (k.equals("EmptyReloadTime") || k.equals("FireMode") || k.equals("Weight") || k.equals("SoundRadius") || k.equals("BurstSize") if (STRING_SET.contains(k)) {
|| k.equals("ProjectileAmount")) {
CompoundTag tag = stack.getOrCreateTag(); CompoundTag tag = stack.getOrCreateTag();
CompoundTag data = tag.getCompound("GunData"); CompoundTag data = tag.getCompound("GunData");
data.putDouble(k, v); data.putDouble(k, v);

View file

@ -1,5 +1,5 @@
{ {
"spread": 3.5, "Spread": 3.5,
"recoil_x": 0.006, "recoil_x": 0.006,
"recoil_y": 0.018, "recoil_y": 0.018,
"damage": 2.5, "damage": 2.5,

View file

@ -1,5 +1,5 @@
{ {
"spread": 4, "Spread": 4,
"recoil_x": 0.005, "recoil_x": 0.005,
"recoil_y": 0.026, "recoil_y": 0.026,
"damage": 5, "damage": 5,

View file

@ -1,7 +1,7 @@
{ {
"MinZoom": 1.25, "MinZoom": 1.25,
"MaxZoom": 6, "MaxZoom": 6,
"spread": 3.5, "Spread": 3.5,
"recoil_x": 0.0015, "recoil_x": 0.0015,
"recoil_y": 0.01, "recoil_y": 0.01,
"damage": 7.7, "damage": 7.7,

View file

@ -1,7 +1,7 @@
{ {
"MinZoom": 1.25, "MinZoom": 1.25,
"MaxZoom": 6, "MaxZoom": 6,
"spread": 4, "Spread": 4,
"recoil_x": 0.002, "recoil_x": 0.002,
"recoil_y": 0.012, "recoil_y": 0.012,
"damage": 8.5, "damage": 8.5,

View file

@ -1,6 +1,6 @@
{ {
"CustomZoom": 0.75, "CustomZoom": 0.75,
"spread": 4, "Spread": 4,
"headshot": 2.5, "headshot": 2.5,
"damage": 48, "damage": 48,
"Weight": 3, "Weight": 3,

View file

@ -1,6 +1,6 @@
{ {
"CustomZoom": 0.75, "CustomZoom": 0.75,
"spread": 5, "Spread": 5,
"recoil_x": 0.0018, "recoil_x": 0.0018,
"recoil_y": 0.01, "recoil_y": 0.01,
"damage": 9.5, "damage": 9.5,

View file

@ -1,5 +1,5 @@
{ {
"spread": 2.5, "Spread": 2.5,
"recoil_x": 0.004, "recoil_x": 0.004,
"recoil_y": 0.013, "recoil_y": 0.013,
"damage": 5.5, "damage": 5.5,

View file

@ -1,5 +1,5 @@
{ {
"spread": 2.5, "Spread": 2.5,
"recoil_x": 0.004, "recoil_x": 0.004,
"recoil_y": 0.013, "recoil_y": 0.013,
"damage": 5.5, "damage": 5.5,

View file

@ -1,7 +1,7 @@
{ {
"MinZoom": 1.25, "MinZoom": 1.25,
"MaxZoom": 6, "MaxZoom": 6,
"spread": 3.5, "Spread": 3.5,
"recoil_x": 0.0016, "recoil_x": 0.0016,
"recoil_y": 0.009, "recoil_y": 0.009,
"damage": 7.5, "damage": 7.5,

View file

@ -1,5 +1,5 @@
{ {
"spread": 7, "Spread": 7,
"recoil_x": 0.004, "recoil_x": 0.004,
"recoil_y": 0.04, "recoil_y": 0.04,
"damage": 65, "damage": 65,

View file

@ -1,6 +1,6 @@
{ {
"CustomZoom": 1.75, "CustomZoom": 1.75,
"spread": 5, "Spread": 5,
"zoomSpread": 5, "zoomSpread": 5,
"mag": 1, "mag": 1,
"Weight": 10, "Weight": 10,

View file

@ -1,5 +1,5 @@
{ {
"spread": 5, "Spread": 5,
"recoil_x": 0.002, "recoil_x": 0.002,
"recoil_y": 0.063, "recoil_y": 0.063,
"damage": 35, "damage": 35,

View file

@ -1,5 +1,5 @@
{ {
"spread": 2.5, "Spread": 2.5,
"recoil_x": 0.006, "recoil_x": 0.006,
"recoil_y": 0.018, "recoil_y": 0.018,
"damage": 9.5, "damage": 9.5,

View file

@ -1,7 +1,7 @@
{ {
"MinZoom": 4, "MinZoom": 4,
"MaxZoom": 8, "MaxZoom": 8,
"spread": 4, "Spread": 4,
"recoil_x": 0.0015, "recoil_x": 0.0015,
"recoil_y": 0.011, "recoil_y": 0.011,
"damage": 7, "damage": 7,

View file

@ -1,5 +1,5 @@
{ {
"spread": 5, "Spread": 5,
"recoil_x": 0.004, "recoil_x": 0.004,
"recoil_y": 0.014, "recoil_y": 0.014,
"damage": 9, "damage": 9,

View file

@ -1,5 +1,5 @@
{ {
"spread": 1.5, "Spread": 1.5,
"recoil_x": 0.004, "recoil_x": 0.004,
"recoil_y": 0.023, "recoil_y": 0.023,
"damage": 40, "damage": 40,

View file

@ -1,5 +1,5 @@
{ {
"spread": 3, "Spread": 3,
"recoil_x": 0.009, "recoil_x": 0.009,
"recoil_y": 0.04, "recoil_y": 0.04,
"damage": 3, "damage": 3,

View file

@ -2,7 +2,7 @@
"CustomZoom": 4.75, "CustomZoom": 4.75,
"min_zoom": 4, "min_zoom": 4,
"max_zoom": 8, "max_zoom": 8,
"spread": 6, "Spread": 6,
"recoil_x": 0.007, "recoil_x": 0.007,
"recoil_y": 0.013, "recoil_y": 0.013,
"damage": 38, "damage": 38,

View file

@ -1,5 +1,5 @@
{ {
"spread": 2, "Spread": 2,
"recoil_x": 0.004, "recoil_x": 0.004,
"recoil_y": 0.031, "recoil_y": 0.031,
"damage": 16, "damage": 16,

View file

@ -1,5 +1,5 @@
{ {
"spread": 1.5, "Spread": 1.5,
"recoil_x": 0.003, "recoil_x": 0.003,
"recoil_y": 0.02, "recoil_y": 0.02,
"damage": 8, "damage": 8,

View file

@ -1,7 +1,7 @@
{ {
"MinZoom": 1.25, "MinZoom": 1.25,
"MaxZoom": 6, "MaxZoom": 6,
"spread": 5, "Spread": 5,
"recoil_x": 0.006, "recoil_x": 0.006,
"recoil_y": 0.014, "recoil_y": 0.014,
"damage": 12, "damage": 12,

View file

@ -1,6 +1,6 @@
{ {
"CustomZoom": 2.25, "CustomZoom": 2.25,
"spread": 4.8, "Spread": 4.8,
"recoil_x": 0.002, "recoil_x": 0.002,
"recoil_y": 0.063, "recoil_y": 0.063,
"damage": 33, "damage": 33,

View file

@ -1,6 +1,6 @@
{ {
"CustomZoom": 3.75, "CustomZoom": 3.75,
"spread": 8, "Spread": 8,
"recoil_x": 0.01, "recoil_x": 0.01,
"recoil_y": 0.038, "recoil_y": 0.038,
"damage": 140, "damage": 140,

View file

@ -1,7 +1,7 @@
{ {
"MinZoom": 4, "MinZoom": 4,
"MaxZoom": 8, "MaxZoom": 8,
"spread": 3.7, "Spread": 3.7,
"recoil_x": 0.0013, "recoil_x": 0.0013,
"recoil_y": 0.009, "recoil_y": 0.009,
"damage": 8.25, "damage": 8.25,

View file

@ -1,5 +1,5 @@
{ {
"spread": 5, "Spread": 5,
"recoil_x": 0.008, "recoil_x": 0.008,
"recoil_y": 0.018, "recoil_y": 0.018,
"damage": 200, "damage": 200,

View file

@ -1,5 +1,5 @@
{ {
"spread": 5.5, "Spread": 5.5,
"recoil_x": 0.0018, "recoil_x": 0.0018,
"recoil_y": 0.012, "recoil_y": 0.012,
"damage": 8.75, "damage": 8.75,

View file

@ -1,6 +1,6 @@
{ {
"CustomZoom": 1.75, "CustomZoom": 1.75,
"spread": 6, "Spread": 6,
"recoil_x": 0.007, "recoil_x": 0.007,
"recoil_y": 0.018, "recoil_y": 0.018,
"damage": 35, "damage": 35,

View file

@ -1,5 +1,5 @@
{ {
"spread": 4.5, "Spread": 4.5,
"recoil_x": 0.004, "recoil_x": 0.004,
"recoil_y": 0.015, "recoil_y": 0.015,
"damage": 9.5, "damage": 9.5,

View file

@ -1,6 +1,6 @@
{ {
"CustomZoom": 2.75, "CustomZoom": 2.75,
"spread": 5.5, "Spread": 5.5,
"recoil_x": 0.004, "recoil_x": 0.004,
"recoil_y": 0.009, "recoil_y": 0.009,
"damage": 18, "damage": 18,

View file

@ -1,5 +1,5 @@
{ {
"spread": 2, "Spread": 2,
"recoil_x": 0.0001, "recoil_x": 0.0001,
"recoil_y": 0.002, "recoil_y": 0.002,
"damage": 5, "damage": 5,

View file

@ -1,5 +1,5 @@
{ {
"spread": 3, "Spread": 3,
"recoil_x": 0.005, "recoil_x": 0.005,
"recoil_y": 0.032, "recoil_y": 0.032,
"damage": 19, "damage": 19,

View file

@ -1,5 +1,5 @@
{ {
"spread": 2.3, "Spread": 2.3,
"recoil_x": 0.002, "recoil_x": 0.002,
"recoil_y": 0.007, "recoil_y": 0.007,
"damage": 6, "damage": 6,