优化NBT#BurstSize

This commit is contained in:
17146 2024-12-24 14:17:58 +08:00
parent d26a2b6ee9
commit 19bc16cb52
28 changed files with 17 additions and 29 deletions

View file

@ -328,7 +328,7 @@ public class ClickHandler {
ClientEventHandler.holdFire = true;
}
if (GunsTool.getGunIntTag(stack, "FireMode") == 1 && ClientEventHandler.burstFireSize == 0) {
ClientEventHandler.burstFireSize = (int) stack.getOrCreateTag().getDouble("burst_size");
ClientEventHandler.burstFireSize = GunsTool.getGunIntTag(stack, "BurstSize", 1);
}
}
}

View file

@ -55,7 +55,7 @@ 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")) {
if (k.equals("EmptyReloadTime") || k.equals("FireMode") || k.equals("Weight") || k.equals("SoundRadius") || k.equals("BurstSize")) {
CompoundTag tag = stack.getOrCreateTag();
CompoundTag data = tag.getCompound("GunData");
data.putDouble(k, v);
@ -69,7 +69,7 @@ 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")) {
if (k.equals("EmptyReloadTime") || k.equals("FireMode") || k.equals("Weight") || k.equals("SoundRadius") || k.equals("BurstSize")) {
CompoundTag tag = stack.getOrCreateTag();
CompoundTag data = tag.getCompound("GunData");
data.putDouble(k, v);
@ -141,6 +141,7 @@ public class GunsTool {
tag.putBoolean("is_empty_reloading", false);
}
/* PerkData */
public static void setPerkIntTag(ItemStack stack, String name, int num) {
CompoundTag tag = stack.getOrCreateTag().getCompound("PerkData");
tag.putInt(name, num);
@ -174,6 +175,7 @@ public class GunsTool {
return tag.getBoolean(name);
}
/* Attachments */
public static int getAttachmentType(ItemStack stack, AttachmentType type) {
CompoundTag tag = stack.getOrCreateTag().getCompound("Attachments");
return tag.getInt(type.getName());
@ -197,6 +199,7 @@ public class GunsTool {
}
}
/* GunData */
public static void setGunIntTag(ItemStack stack, String name, int num) {
CompoundTag tag = stack.getOrCreateTag();
var data = tag.getCompound("GunData");
@ -205,8 +208,13 @@ public class GunsTool {
}
public static int getGunIntTag(ItemStack stack, String name) {
return getGunIntTag(stack, name, 0);
}
public static int getGunIntTag(ItemStack stack, String name, int defaultValue) {
CompoundTag tag = stack.getOrCreateTag();
var data = tag.getCompound("GunData");
if (!data.contains(name)) return defaultValue;
return data.getInt(name);
}
@ -218,8 +226,13 @@ public class GunsTool {
}
public static double getGunDoubleTag(ItemStack stack, String name) {
return getGunDoubleTag(stack, name, 0);
}
public static double getGunDoubleTag(ItemStack stack, String name, double defaultValue) {
CompoundTag tag = stack.getOrCreateTag();
var data = tag.getCompound("GunData");
if (!data.contains(name)) return defaultValue;
return data.getDouble(name);
}
}

View file

@ -12,7 +12,6 @@
"semi": 1,
"burst": 0,
"auto": 1,
"burst_size": 1,
"normal_reload_time": 64,
"EmptyReloadTime": 85,
"BypassesArmor": 0.05,

View file

@ -12,7 +12,6 @@
"semi": 1,
"burst": 0,
"auto": 0,
"burst_size": 1,
"normal_reload_time": 66,
"EmptyReloadTime": 83,
"BypassesArmor": 0.01,

View file

@ -14,7 +14,6 @@
"semi": 1,
"burst": 0,
"auto": 1,
"burst_size": 1,
"normal_reload_time": 52,
"EmptyReloadTime": 58,
"BypassesArmor": 0.23,

View file

@ -14,7 +14,6 @@
"semi": 1,
"burst": 0,
"auto": 1,
"burst_size": 1,
"normal_reload_time": 52,
"EmptyReloadTime": 65,
"BypassesArmor": 0.2,

View file

@ -13,7 +13,6 @@
"semi": 0,
"burst": 0,
"auto": 1,
"burst_size": 1,
"normal_reload_time": 73,
"EmptyReloadTime": 95,
"BypassesArmor": 0.25,

View file

@ -12,7 +12,6 @@
"semi": 1,
"burst": 0,
"auto": 0,
"burst_size": 1,
"normal_reload_time": 30,
"EmptyReloadTime": 35,
"BypassesArmor": 0.15,

View file

@ -12,7 +12,6 @@
"semi": 1,
"burst": 0,
"auto": 1,
"burst_size": 1,
"normal_reload_time": 30,
"EmptyReloadTime": 35,
"BypassesArmor": 0.15,

View file

@ -14,7 +14,6 @@
"semi": 1,
"burst": 0,
"auto": 1,
"burst_size": 1,
"normal_reload_time": 56,
"EmptyReloadTime": 64,
"BypassesArmor": 0.25,

View file

@ -12,7 +12,6 @@
"semi": 1,
"burst": 0,
"auto": 0,
"burst_size": 1,
"EmptyReloadTime": 64,
"BypassesArmor": 0.7,
"SoundRadius": 20

View file

@ -13,7 +13,6 @@
"semi": 1,
"burst": 0,
"auto": 0,
"burst_size": 1,
"EmptyReloadTime": 59,
"clipLoad": 1,
"prepare_time": 29,

View file

@ -12,7 +12,6 @@
"semi": 1,
"burst": 0,
"auto": 0,
"burst_size": 1,
"normal_reload_time": 30,
"EmptyReloadTime": 35,
"BypassesArmor": 0.2,

View file

@ -14,7 +14,6 @@
"semi": 1,
"burst": 0,
"auto": 1,
"burst_size": 1,
"normal_reload_time": 56,
"EmptyReloadTime": 64,
"BypassesArmor": 0.25,

View file

@ -12,7 +12,6 @@
"semi": 0,
"burst": 0,
"auto": 1,
"burst_size": 1,
"normal_reload_time": 114,
"EmptyReloadTime": 133,
"BypassesArmor": 0.25,

View file

@ -13,7 +13,6 @@
"semi": 1,
"burst": 0,
"auto": 0,
"burst_size": 1,
"prepare_time": 7,
"prepare_load_time": 36,
"iterative_time": 16,

View file

@ -16,7 +16,6 @@
"semi": 1,
"burst": 0,
"auto": 0,
"burst_size": 1,
"normal_reload_time": 60,
"EmptyReloadTime": 78,
"BypassesArmor": 0.6,

View file

@ -13,7 +13,6 @@
"semi": 1,
"burst": 0,
"auto": 0,
"burst_size": 1,
"prepare_time": 7,
"iterative_time": 16,
"finish_time": 19,

View file

@ -14,7 +14,6 @@
"semi": 1,
"burst": 0,
"auto": 1,
"burst_size": 1,
"normal_reload_time": 54,
"EmptyReloadTime": 71,
"BypassesArmor": 0.4,

View file

@ -14,7 +14,6 @@
"semi": 1,
"burst": 0,
"auto": 0,
"burst_size": 1,
"prepare_time": 29,
"prepare_empty": 16,
"iterative_time": 11,

View file

@ -14,7 +14,6 @@
"semi": 1,
"burst": 0,
"auto": 0,
"burst_size": 1,
"normal_reload_time": 63,
"EmptyReloadTime": 92,
"BypassesArmor": 1,

View file

@ -14,7 +14,6 @@
"semi": 1,
"burst": 0,
"auto": 1,
"burst_size": 1,
"normal_reload_time": 60,
"EmptyReloadTime": 74,
"BypassesArmor": 0.28,

View file

@ -12,7 +12,6 @@
"semi": 1,
"burst": 0,
"auto": 1,
"burst_size": 1,
"normal_reload_time": 73,
"EmptyReloadTime": 95,
"BypassesArmor": 0.23,

View file

@ -14,7 +14,6 @@
"semi": 1,
"burst": 0,
"auto": 0,
"burst_size": 1,
"normal_reload_time": 59,
"EmptyReloadTime": 89,
"BypassesArmor": 0.8,

View file

@ -12,7 +12,6 @@
"semi": 1,
"burst": 0,
"auto": 0,
"burst_size": 1,
"normal_reload_time": 54,
"EmptyReloadTime": 75,
"BypassesArmor": 0.23,

View file

@ -13,7 +13,6 @@
"semi": 1,
"burst": 0,
"auto": 0,
"burst_size": 1,
"normal_reload_time": 56,
"EmptyReloadTime": 70,
"BypassesArmor": 0.45,

View file

@ -12,7 +12,6 @@
"semi": 1,
"burst": 0,
"auto": 0,
"burst_size": 1,
"EmptyReloadTime": 65,
"BypassesArmor": 0.3,
"SoundRadius": 10,

View file

@ -12,7 +12,7 @@
"semi": 1,
"burst": 1,
"auto": 1,
"burst_size": 3,
"BurstSize": 3,
"normal_reload_time": 46,
"EmptyReloadTime": 64,
"BypassesArmor": 0.15,