修复了怪物猎人perk导致无法发射子弹的问题

This commit is contained in:
17146 2024-11-20 23:05:44 +08:00
parent c5cddcc814
commit 085cd68344
3 changed files with 10 additions and 20 deletions

View file

@ -156,7 +156,7 @@ public class GunEventHandler {
if (sound1p != null && player instanceof ServerPlayer serverPlayer) {
SoundTool.playLocalSound(serverPlayer, sound1p, 2f, 1f);
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())));
if (stack.is(ModTags.Items.REVOLVER)) return;
@ -167,7 +167,7 @@ public class GunEventHandler {
} else if (stack.is(ModTags.Items.SNIPER_RIFLE)) {
SoundTool.playLocalSound(serverPlayer, ModSounds.SHELL_CASING_50CAL.get(), (float) Math.max(1 - 0.15 * shooterHeight, 0), 1);
} else {
SoundTool.playLocalSound(serverPlayer,ModSounds.SHELL_CASING_NORMAL.get(), (float) Math.max(1.5 - 0.2 * shooterHeight, 0), 1);
SoundTool.playLocalSound(serverPlayer, ModSounds.SHELL_CASING_NORMAL.get(), (float) Math.max(1.5 - 0.2 * shooterHeight, 0), 1);
}
});
}
@ -231,7 +231,7 @@ public class GunEventHandler {
var dmgPerk = PerkHelper.getPerkByType(heldItem, Perk.Type.DAMAGE);
if (dmgPerk == ModPerks.MONSTER_HUNTER.get()) {
int level = PerkHelper.getItemPerkLevel(perk, heldItem);
int level = PerkHelper.getItemPerkLevel(dmgPerk, heldItem);
projectile.monsterMultiple(0.1f + 0.1f * level);
}
@ -717,7 +717,7 @@ public class GunEventHandler {
if (sound1p != null && player instanceof ServerPlayer serverPlayer) {
SoundTool.playLocalSound(serverPlayer, sound1p, 10f, 1f);
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())));
ModUtils.queueServerWork((int) (stack.getOrCreateTag().getDouble("prepare_empty") / 2 + 3 + 1.5 * shooterHeight), () -> {
@ -726,7 +726,7 @@ public class GunEventHandler {
} else if (stack.is(ModTags.Items.SNIPER_RIFLE)) {
SoundTool.playLocalSound(serverPlayer, ModSounds.SHELL_CASING_50CAL.get(), (float) Math.max(1 - 0.15 * shooterHeight, 0), 1);
} else {
SoundTool.playLocalSound(serverPlayer,ModSounds.SHELL_CASING_NORMAL.get(), (float) Math.max(1.5 - 0.2 * shooterHeight, 0), 1);
SoundTool.playLocalSound(serverPlayer, ModSounds.SHELL_CASING_NORMAL.get(), (float) Math.max(1.5 - 0.2 * shooterHeight, 0), 1);
}
});
}
@ -747,7 +747,7 @@ public class GunEventHandler {
if (sound1p != null && player instanceof ServerPlayer serverPlayer) {
SoundTool.playLocalSound(serverPlayer, sound1p, 10f, 1f);
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())));
ModUtils.queueServerWork((int) (8 + 1.5 * shooterHeight), () -> {
@ -756,7 +756,7 @@ public class GunEventHandler {
} else if (stack.is(ModTags.Items.SNIPER_RIFLE)) {
SoundTool.playLocalSound(serverPlayer, ModSounds.SHELL_CASING_50CAL.get(), (float) Math.max(1 - 0.15 * shooterHeight, 0), 1);
} else {
SoundTool.playLocalSound(serverPlayer,ModSounds.SHELL_CASING_NORMAL.get(), (float) Math.max(1.5 - 0.2 * shooterHeight, 0), 1);
SoundTool.playLocalSound(serverPlayer, ModSounds.SHELL_CASING_NORMAL.get(), (float) Math.max(1.5 - 0.2 * shooterHeight, 0), 1);
}
});
}
@ -794,12 +794,12 @@ public class GunEventHandler {
if (sound1p != null && player instanceof ServerPlayer serverPlayer) {
SoundTool.playLocalSound(serverPlayer, sound1p, 10f, 1f);
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())));
if (stack.is(ModItems.MARLIN.get())) {
ModUtils.queueServerWork((int) (5 + 1.5 * shooterHeight), () -> {
SoundTool.playLocalSound(serverPlayer,ModSounds.SHELL_CASING_NORMAL.get(), (float) Math.max(1.5 - 0.2 * shooterHeight, 0), 1);
SoundTool.playLocalSound(serverPlayer, ModSounds.SHELL_CASING_NORMAL.get(), (float) Math.max(1.5 - 0.2 * shooterHeight, 0), 1);
});
}
}

View file

@ -133,7 +133,6 @@ public class FireMessage {
tag.putBoolean("Seeking", true);
tag.putInt("SeekTime", 0);
}
}
if (tag.getDouble("prepare") == 0 && tag.getBoolean("reloading") && tag.getInt("ammo") > 0) {
@ -190,15 +189,12 @@ public class FireMessage {
if (stack.getOrCreateTag().getDouble("power") >= 6) {
stack.getOrCreateTag().putDouble("speed", stack.getOrCreateTag().getDouble("power"));
if ((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).zoom) {
spawnBullet(player);
spawnFakeArrow(player);
SoundTool.playLocalSound(player, ModSounds.BOCEK_ZOOM_FIRE_1P.get(), 10, 1);
player.playSound(ModSounds.BOCEK_ZOOM_FIRE_3P.get(), 2, 1);
} else {
for (int index0 = 0; index0 < (perk instanceof AmmoPerk ammoPerk && ammoPerk.slug ? 1 : 10); index0++) {
spawnBullet(player);
}
@ -249,7 +245,6 @@ public class FireMessage {
double damage;
boolean zoom = player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).zoom;
float spread;
if ((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).zoom) {
@ -265,7 +260,6 @@ public class FireMessage {
.headShot(headshot)
.zoom(zoom);
if (perk instanceof AmmoPerk ammoPerk) {
int level = PerkHelper.getItemPerkLevel(perk, heldItem);

View file

@ -64,15 +64,11 @@ public class ShootMessage {
int projectileAmount = (int) stack.getOrCreateTag().getDouble("projectile_amount");
if (stack.getOrCreateTag().getInt("ammo") > 0) {
/*
空仓挂机
*/
// 空仓挂机
if (stack.getOrCreateTag().getInt("ammo") == 1) {
stack.getOrCreateTag().putBoolean("HoldOpen", true);
}
if (stack.is(ModTags.Items.REVOLVER)) {
stack.getOrCreateTag().putBoolean("canImmediatelyShoot", false);
}