修复后坐力小概率神秘消失的bug,统一手臂颜色

This commit is contained in:
Atsuihsio 2024-07-13 01:34:03 +08:00
parent 93ecbb22a0
commit d208f9e8ab
26 changed files with 32 additions and 38 deletions

View file

@ -161,6 +161,9 @@ public class GunEventHandler {
for (int index0 = 0; index0 < (int) stack.getOrCreateTag().getDouble("projectile_amount"); index0++) { for (int index0 = 0; index0 < (int) stack.getOrCreateTag().getDouble("projectile_amount"); index0++) {
gunShoot(player); gunShoot(player);
} }
stack.getOrCreateTag().putBoolean("shoot",true);
} }
/* /*
@ -230,6 +233,8 @@ public class GunEventHandler {
} }
} }
stack.getOrCreateTag().putBoolean("shoot",true);
for (int index0 = 0; index0 < (int) stack.getOrCreateTag().getDouble("projectile_amount"); index0++) { for (int index0 = 0; index0 < (int) stack.getOrCreateTag().getDouble("projectile_amount"); index0++) {
gunShoot(player); gunShoot(player);
} }
@ -320,12 +325,6 @@ public class GunEventHandler {
public static void gunShoot(Player player) { public static void gunShoot(Player player) {
ItemStack heldItem = player.getMainHandItem(); ItemStack heldItem = player.getMainHandItem();
player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.recoilHorizon = 2 * Math.random() - 1;
capability.recoil = 0.1;
capability.firing = 1;
capability.syncPlayerVariables(player);
});
if (!player.level().isClientSide()) { if (!player.level().isClientSide()) {
float headshot = (float) heldItem.getOrCreateTag().getDouble("headshot"); float headshot = (float) heldItem.getOrCreateTag().getDouble("headshot");
@ -786,5 +785,4 @@ public class GunEventHandler {
tag.putBoolean("sentinel_is_charging", false); tag.putBoolean("sentinel_is_charging", false);
} }
} }
} }

View file

@ -294,6 +294,16 @@ public class PlayerEventHandler {
Runnable recoilRunnable = () -> { Runnable recoilRunnable = () -> {
while (recoilTimer[0] < recoilDuration) { while (recoilTimer[0] < recoilDuration) {
if (tag.getBoolean("shoot")) {
player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.recoilHorizon = 2 * Math.random() - 1;
capability.recoil = 0.1;
capability.firing = 1;
capability.syncPlayerVariables(player);
});
tag.putBoolean("shoot",false);
}
/* /*
开火动画计时器 开火动画计时器
*/ */
@ -355,6 +365,12 @@ public class PlayerEventHandler {
player.yRotO = player.getYRot(); player.yRotO = player.getYRot();
} }
double finalRecoil = recoil;
player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(c -> {
c.recoil = finalRecoil;
c.syncPlayerVariables(player);
});
/* /*
计算散布 计算散布
*/ */
@ -407,13 +423,6 @@ public class PlayerEventHandler {
player.getAttribute(TargetModAttributes.SPREAD.get()).setBaseValue(0); player.getAttribute(TargetModAttributes.SPREAD.get()).setBaseValue(0);
} }
double finalRecoil = recoil;
player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(c -> {
c.recoil = finalRecoil;
c.syncPlayerVariables(player);
});
recoilTimer[0]++; recoilTimer[0]++;
try { try {
Thread.sleep(sleepTime); Thread.sleep(sleepTime);

View file

@ -172,6 +172,9 @@ public class FireMessage {
player.playSound(TargetModSounds.BOCEK_ZOOM_FIRE_3P.get(), 2, 1); player.playSound(TargetModSounds.BOCEK_ZOOM_FIRE_3P.get(), 2, 1);
} }
} else { } else {
stack.getOrCreateTag().putBoolean("shoot",true);
for (int index0 = 0; index0 < 10; index0++) { for (int index0 = 0; index0 < 10; index0++) {
spawnBullet(player); spawnBullet(player);
} }
@ -201,12 +204,6 @@ public class FireMessage {
private static void spawnBullet(Player player) { private static void spawnBullet(Player player) {
ItemStack heldItem = player.getMainHandItem(); ItemStack heldItem = player.getMainHandItem();
player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.recoilHorizon = Math.random() < 0.5 ? -1 : 1;
capability.recoil = 0.1;
capability.firing = 1;
capability.syncPlayerVariables(player);
});
if (player.level().isClientSide()) return; if (player.level().isClientSide()) return;
@ -240,12 +237,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
&& ItemNBTTool.getInt(stack, "Power", 1200) > 400) { && ItemNBTTool.getInt(stack, "Power", 1200) > 400) {
player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.recoilHorizon = Math.random() < 0.5 ? -1 : 1;
capability.recoil = 0.1;
capability.firing = 1;
capability.syncPlayerVariables(player);
});
player.getCooldowns().addCooldown(stack.getItem(), 5); player.getCooldowns().addCooldown(stack.getItem(), 5);
if (player instanceof ServerPlayer serverPlayer) { if (player instanceof ServerPlayer serverPlayer) {
@ -266,6 +258,8 @@ public class FireMessage {
level.addFreshEntity(taserBulletProjectile); level.addFreshEntity(taserBulletProjectile);
} }
stack.getOrCreateTag().putBoolean("shoot",true);
stack.getOrCreateTag().putInt("fire_animation", 4); stack.getOrCreateTag().putInt("fire_animation", 4);
stack.getOrCreateTag().putInt("ammo", (stack.getOrCreateTag().getInt("ammo") - 1)); stack.getOrCreateTag().putInt("ammo", (stack.getOrCreateTag().getInt("ammo") - 1));
ItemNBTTool.setInt(stack, "Power", ItemNBTTool.getInt(stack, "Power", 1200) - 400); ItemNBTTool.setInt(stack, "Power", ItemNBTTool.getInt(stack, "Power", 1200) - 400);
@ -279,12 +273,6 @@ public class FireMessage {
ItemStack stack = player.getMainHandItem(); ItemStack stack = player.getMainHandItem();
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) {
player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.recoilHorizon = Math.random() < 0.5 ? -1 : 1;
capability.recoil = 0.1;
capability.firing = 1;
capability.syncPlayerVariables(player);
});
Level level = player.level(); Level level = player.level();
if (!level.isClientSide()) { if (!level.isClientSide()) {
@ -313,6 +301,9 @@ public class FireMessage {
serverPlayer.level().playSound(null, serverPlayer.getOnPos(), TargetModSounds.M_79_FAR.get(), SoundSource.PLAYERS, 6, 1); serverPlayer.level().playSound(null, serverPlayer.getOnPos(), TargetModSounds.M_79_FAR.get(), SoundSource.PLAYERS, 6, 1);
serverPlayer.level().playSound(null, serverPlayer.getOnPos(), TargetModSounds.M_79_VERYFAR.get(), SoundSource.PLAYERS, 12, 1); serverPlayer.level().playSound(null, serverPlayer.getOnPos(), TargetModSounds.M_79_VERYFAR.get(), SoundSource.PLAYERS, 12, 1);
} }
stack.getOrCreateTag().putBoolean("shoot",true);
stack.getOrCreateTag().putInt("fire_animation", 2); stack.getOrCreateTag().putInt("fire_animation", 2);
stack.getOrCreateTag().putInt("ammo", (stack.getOrCreateTag().getInt("ammo") - 1)); stack.getOrCreateTag().putInt("ammo", (stack.getOrCreateTag().getInt("ammo") - 1));
} }
@ -327,12 +318,6 @@ public class FireMessage {
CompoundTag tag = mainHandItem.getOrCreateTag(); CompoundTag tag = mainHandItem.getOrCreateTag();
if (!tag.getBoolean("reloading") && !player.getCooldowns().isOnCooldown(mainHandItem.getItem()) && tag.getInt("ammo") > 0) { if (!tag.getBoolean("reloading") && !player.getCooldowns().isOnCooldown(mainHandItem.getItem()) && tag.getInt("ammo") > 0) {
player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.recoilHorizon = Math.random() < 0.5 ? -1 : 1;
capability.recoil = 0.1;
capability.firing = 1;
capability.syncPlayerVariables(player);
});
if (!level.isClientSide()) { if (!level.isClientSide()) {
int monsterMultiple = EnchantmentHelper.getTagEnchantmentLevel(TargetModEnchantments.MONSTER_HUNTER.get(), mainHandItem); int monsterMultiple = EnchantmentHelper.getTagEnchantmentLevel(TargetModEnchantments.MONSTER_HUNTER.get(), mainHandItem);
@ -366,6 +351,8 @@ public class FireMessage {
serverPlayer.level().playSound(null, serverPlayer.getOnPos(), TargetModSounds.RPG_VERYFAR.get(), SoundSource.PLAYERS, 16, 1); serverPlayer.level().playSound(null, serverPlayer.getOnPos(), TargetModSounds.RPG_VERYFAR.get(), SoundSource.PLAYERS, 16, 1);
} }
tag.putBoolean("shoot",true);
tag.putInt("fire_animation", 2); tag.putInt("fire_animation", 2);
tag.putInt("ammo", tag.getInt("ammo") - 1); tag.putInt("ammo", tag.getInt("ammo") - 1);
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 77 KiB

After

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 168 KiB

After

Width:  |  Height:  |  Size: 168 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 130 KiB

After

Width:  |  Height:  |  Size: 130 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 142 KiB

After

Width:  |  Height:  |  Size: 142 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 KiB

After

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 36 KiB