优化NBT#PrepareEmptyTime
This commit is contained in:
parent
1862382211
commit
3adbbc266d
3 changed files with 7 additions and 6 deletions
|
@ -548,11 +548,12 @@ public class GunEventHandler {
|
||||||
int prepareLoadTime = GunsTool.getGunIntTag(stack, "PrepareLoadTime", 0);
|
int prepareLoadTime = GunsTool.getGunIntTag(stack, "PrepareLoadTime", 0);
|
||||||
tag.putInt("prepare_load", prepareLoadTime + 1);
|
tag.putInt("prepare_load", prepareLoadTime + 1);
|
||||||
player.getCooldowns().addCooldown(stack.getItem(), prepareLoadTime);
|
player.getCooldowns().addCooldown(stack.getItem(), prepareLoadTime);
|
||||||
} else if (tag.getDouble("prepare_empty") != 0 && tag.getInt("ammo") == 0) {
|
} else if (GunsTool.getGunIntTag(stack, "PrepareEmptyTime", 0) != 0 && tag.getInt("ammo") == 0) {
|
||||||
// 此处判断空仓换弹,如莫辛纳甘
|
// 此处判断空仓换弹,如莫辛纳甘
|
||||||
playGunEmptyPrepareSounds(player);
|
playGunEmptyPrepareSounds(player);
|
||||||
tag.putInt("prepare", (int) tag.getDouble("prepare_empty") + 1);
|
int prepareEmptyTime = GunsTool.getGunIntTag(stack, "PrepareEmptyTime", 0);
|
||||||
player.getCooldowns().addCooldown(stack.getItem(), (int) tag.getDouble("prepare_empty"));
|
tag.putInt("prepare", prepareEmptyTime + 1);
|
||||||
|
player.getCooldowns().addCooldown(stack.getItem(), prepareEmptyTime);
|
||||||
} else {
|
} else {
|
||||||
playGunPrepareReloadSounds(player);
|
playGunPrepareReloadSounds(player);
|
||||||
int prepareTime = GunsTool.getGunIntTag(stack, "PrepareTime", 0);
|
int prepareTime = GunsTool.getGunIntTag(stack, "PrepareTime", 0);
|
||||||
|
@ -772,7 +773,7 @@ public class GunEventHandler {
|
||||||
double shooterHeight = player.getEyePosition().distanceTo((Vec3.atLowerCornerOf(player.level().clip(new ClipContext(player.getEyePosition(), player.getEyePosition().add(new Vec3(0, -1, 0).scale(10)),
|
double shooterHeight = player.getEyePosition().distanceTo((Vec3.atLowerCornerOf(player.level().clip(new ClipContext(player.getEyePosition(), player.getEyePosition().add(new Vec3(0, -1, 0).scale(10)),
|
||||||
ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, player)).getBlockPos())));
|
ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, player)).getBlockPos())));
|
||||||
|
|
||||||
ModUtils.queueServerWork((int) (stack.getOrCreateTag().getDouble("prepare_empty") / 2 + 3 + 1.5 * shooterHeight), () -> {
|
ModUtils.queueServerWork((int) (GunsTool.getGunIntTag(stack, "PrepareEmptyTime", 0) / 2 + 3 + 1.5 * shooterHeight), () -> {
|
||||||
if (stack.is(ModTags.Items.SHOTGUN)) {
|
if (stack.is(ModTags.Items.SHOTGUN)) {
|
||||||
SoundTool.playLocalSound(serverPlayer, ModSounds.SHELL_CASING_SHOTGUN.get(), (float) Math.max(0.75 - 0.12 * shooterHeight, 0), 1);
|
SoundTool.playLocalSound(serverPlayer, ModSounds.SHELL_CASING_SHOTGUN.get(), (float) Math.max(0.75 - 0.12 * shooterHeight, 0), 1);
|
||||||
} else if (stack.is(ModTags.Items.SNIPER_RIFLE)) {
|
} else if (stack.is(ModTags.Items.SNIPER_RIFLE)) {
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class GunsTool {
|
||||||
private static final Set<String> STRING_SET = Set.of("EmptyReloadTime", "FireMode", "Weight", "SoundRadius", "BurstSize", "ProjectileAmount",
|
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",
|
"Spread", "NormalReloadTime", "Headshot", "Semi", "Burst", "Auto", "RecoilX", "RecoilY", "Velocity", "Damage", "BypassesArmor",
|
||||||
"RPM", "Magazine", "MinZoom", "MaxZoom", "CustomZoom", "ExplosionDamage", "ExplosionRadius", "BoltActionTime", "ClipLoad",
|
"RPM", "Magazine", "MinZoom", "MaxZoom", "CustomZoom", "ExplosionDamage", "ExplosionRadius", "BoltActionTime", "ClipLoad",
|
||||||
"PrepareTime", "IterativeTime", "PrepareLoadTime", "FinishTime");
|
"PrepareTime", "IterativeTime", "PrepareLoadTime", "FinishTime", "PrepareEmptyTime");
|
||||||
|
|
||||||
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;
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
"FireMode": 0,
|
"FireMode": 0,
|
||||||
"Semi": 1,
|
"Semi": 1,
|
||||||
"PrepareTime": 29,
|
"PrepareTime": 29,
|
||||||
"prepare_empty": 16,
|
"PrepareEmptyTime": 16,
|
||||||
"IterativeTime": 11,
|
"IterativeTime": 11,
|
||||||
"FinishTime": 18,
|
"FinishTime": 18,
|
||||||
"BypassesArmor": 0.54,
|
"BypassesArmor": 0.54,
|
||||||
|
|
Loading…
Add table
Reference in a new issue