优化NBT#IterativeTime

This commit is contained in:
17146 2024-12-24 16:54:38 +08:00
parent 9eb8961faf
commit 27f8ab9230
8 changed files with 11 additions and 10 deletions

View file

@ -614,8 +614,9 @@ public class GunEventHandler {
&& tag.getInt("ammo") < GunsTool.getGunIntTag(stack, "Magazine", 0) + tag.getInt("customMag")) {
playGunLoopReloadSounds(player);
tag.putDouble("iterative", (int) tag.getDouble("iterative_time"));
player.getCooldowns().addCooldown(stack.getItem(), (int) tag.getDouble("iterative_time"));
int iterativeTime = GunsTool.getGunIntTag(stack, "IterativeTime", 0);
tag.putDouble("iterative", iterativeTime);
player.getCooldowns().addCooldown(stack.getItem(), iterativeTime);
// 动画播放nbt
if (tag.getDouble("load_index") == 1) {
tag.putDouble("load_index", 0);

View file

@ -341,7 +341,7 @@ public class LivingEventHandler {
oldTags.putBoolean("is_normal_reloading", false);
oldTags.putBoolean("is_empty_reloading", false);
if (oldTags.getDouble("iterative_time") != 0) {
if (GunsTool.getGunIntTag(oldStack, "IterativeTime", 0) != 0) {
oldTags.putBoolean("force_stop", false);
oldTags.putBoolean("stop", false);
oldTags.putInt("reload_stage", 0);
@ -376,7 +376,7 @@ public class LivingEventHandler {
data.putInt("ReloadTime", 0);
newStack.addTagElement("GunData", data);
if (newStack.getOrCreateTag().getDouble("iterative_time") != 0) {
if (GunsTool.getGunIntTag(newStack, "IterativeTime", 0) != 0) {
newStack.getOrCreateTag().putBoolean("force_stop", false);
newStack.getOrCreateTag().putBoolean("stop", false);
newStack.getOrCreateTag().putInt("reload_stage", 0);

View file

@ -63,7 +63,7 @@ public class ReloadMessage {
) {
CompoundTag tag = stack.getOrCreateTag();
boolean canSingleReload = tag.getDouble("iterative_time") != 0;
boolean canSingleReload = GunsTool.getGunIntTag(stack, "IterativeTime", 0) != 0;
boolean canReload = (GunsTool.getGunIntTag(stack, "NormalReloadTime") != 0 || GunsTool.getGunIntTag(stack, "EmptyReloadTime") != 0)
&& GunsTool.getGunIntTag(stack, "ClipLoad", 0) != 1;
boolean clipLoad = tag.getInt("ammo") == 0 && GunsTool.getGunIntTag(stack, "ClipLoad", 0) == 1;

View file

@ -57,7 +57,7 @@ public class GunsTool {
private static final Set<String> STRING_SET = Set.of("EmptyReloadTime", "FireMode", "Weight", "SoundRadius", "BurstSize", "ProjectileAmount",
"Spread", "NormalReloadTime", "Headshot", "Semi", "Burst", "Auto", "RecoilX", "RecoilY", "Velocity", "Damage", "BypassesArmor",
"RPM", "Magazine", "MinZoom", "MaxZoom", "CustomZoom", "ExplosionDamage", "ExplosionRadius", "BoltActionTime", "ClipLoad",
"PrepareTime");
"PrepareTime", "IterativeTime");
public static void initGun(Level level, ItemStack stack, String location) {
if (level.getServer() == null) return;

View file

@ -13,7 +13,7 @@
"EmptyReloadTime": 59,
"ClipLoad": 1,
"PrepareTime": 29,
"iterative_time": 11,
"IterativeTime": 11,
"finish_time": 18,
"BypassesArmor": 0.5,
"SoundRadius": 18

View file

@ -13,7 +13,7 @@
"Semi": 1,
"PrepareTime": 7,
"prepare_load_time": 36,
"iterative_time": 16,
"IterativeTime": 16,
"finish_time": 12,
"BypassesArmor": 0.05,
"SoundRadius": 16,

View file

@ -11,7 +11,7 @@
"FireMode": 0,
"Semi": 1,
"PrepareTime": 7,
"iterative_time": 16,
"IterativeTime": 16,
"finish_time": 19,
"BypassesArmor": 0.3,
"SoundRadius": 15,

View file

@ -13,7 +13,7 @@
"Semi": 1,
"PrepareTime": 29,
"prepare_empty": 16,
"iterative_time": 11,
"IterativeTime": 11,
"finish_time": 18,
"BypassesArmor": 0.54,
"SoundRadius": 18