使波赛克正确消耗弹药

This commit is contained in:
Light_Quanta 2025-04-14 22:04:43 +08:00
parent 6594313b6d
commit 2daffca47b
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959

View file

@ -23,7 +23,10 @@ import net.minecraft.sounds.SoundSource;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.tooltip.TooltipComponent; import net.minecraft.world.inventory.tooltip.TooltipComponent;
import net.minecraft.world.item.*; import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemDisplayContext;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Rarity;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.neoforged.neoforge.network.PacketDistributor; import net.neoforged.neoforge.network.PacketDistributor;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -178,8 +181,8 @@ public class BocekItem extends GunItem implements GeoItem, ReleaseSpecialWeapon
player.getCooldowns().addCooldown(stack.getItem(), 7); player.getCooldowns().addCooldown(stack.getItem(), 7);
GunsTool.setGunIntTag(tag, "ArrowEmpty", 7); GunsTool.setGunIntTag(tag, "ArrowEmpty", 7);
if (!InventoryTool.hasCreativeAmmoBox(player) && !player.isCreative()) { if (!InventoryTool.hasCreativeAmmoBox(player)) {
player.getInventory().clearOrCountMatchingItems(p -> Items.ARROW == p.getItem(), 1, player.inventoryMenu.getCraftSlots()); data.consumeAmmo(player, 1);
} }
} }
} }