修复创造弹药盒重生不换弹BUG

This commit is contained in:
Atsuihsio 2024-10-19 02:39:39 +08:00
parent 58e5ab348a
commit 11eafdd7f6
2 changed files with 42 additions and 33 deletions

View file

@ -520,8 +520,6 @@ public class ClientEventHandler {
randomShell[1] = (0.2 + (Math.random() - 0.5));
randomShell[2] = (0.7 + (Math.random() - 0.5));
Minecraft.getInstance().player.getPersistentData().putDouble("noRun", 20);
float gunRecoilY = (float) tag.getDouble("recoil_y") * 10;
recoilY = (float) (2 * Math.random() - 1) * gunRecoilY;

View file

@ -197,9 +197,9 @@ public class PlayerEventHandler {
* 判断玩家是否在奔跑
*/
private static void handlePlayerSprint(Player player) {
// if (player.getMainHandItem().getOrCreateTag().getInt("flash_time") > 0 || player.getMainHandItem().getOrCreateTag().getInt("fire_animation") > 0) {
// player.getPersistentData().putDouble("noRun", 20);
// }
if (player.getMainHandItem().getOrCreateTag().getInt("flash_time") > 0 || player.getMainHandItem().getOrCreateTag().getInt("fire_animation") > 0) {
player.getPersistentData().putDouble("noRun", 40);
}
if ((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).holdFire) {
player.getPersistentData().putDouble("noRun", 10);
@ -299,8 +299,16 @@ public class PlayerEventHandler {
private static void handleRespawnReload(Player player) {
if (!GameplayConfig.RESPAWN_RELOAD.get()) return;
int count = 0;
for (var inv : player.getInventory().items) {
if (inv.is(ModItems.CREATIVE_AMMO_BOX.get())) {
count++;
}
}
for (ItemStack stack : player.getInventory().items) {
if (stack.is(ModTags.Items.GUN)) {
if (count == 0) {
var cap = player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables());
if (stack.is(ModTags.Items.USE_SHOTGUN_AMMO) && cap.shotgunAmmo > 0) {
@ -331,6 +339,9 @@ public class PlayerEventHandler {
stack.getOrCreateTag().putInt("ammo", 1);
player.getInventory().clearOrCountMatchingItems(p -> p.getItem() == ModItems.JAVELIN_MISSILE.get(), 1, player.inventoryMenu.getCraftSlots());
}
} else {
stack.getOrCreateTag().putInt("ammo", stack.getOrCreateTag().getInt("mag") + stack.getOrCreateTag().getInt("customMag"));
}
}
}
}