From 6594313b6d8a03168646b29b3600317ac9dfcb3d Mon Sep 17 00:00:00 2001 From: Light_Quanta Date: Mon, 14 Apr 2025 21:52:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=95=E5=8F=91=E8=A3=85=E5=A1=AB=E6=97=B6?= =?UTF-8?q?=E6=AD=A3=E7=A1=AE=E6=B6=88=E8=80=97=E5=BC=B9=E8=8D=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../superbwarfare/event/GunEventHandler.java | 24 +------------------ 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/src/main/java/com/atsuishio/superbwarfare/event/GunEventHandler.java b/src/main/java/com/atsuishio/superbwarfare/event/GunEventHandler.java index b074670bc..901c993eb 100644 --- a/src/main/java/com/atsuishio/superbwarfare/event/GunEventHandler.java +++ b/src/main/java/com/atsuishio/superbwarfare/event/GunEventHandler.java @@ -16,10 +16,8 @@ import com.atsuishio.superbwarfare.tools.InventoryTool; import com.atsuishio.superbwarfare.tools.SoundTool; import net.minecraft.core.Holder; import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; -import net.minecraft.tags.ItemTags; import net.minecraft.world.effect.MobEffect; import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.entity.player.Player; @@ -575,27 +573,7 @@ public class GunEventHandler { if (!InventoryTool.hasCreativeAmmoBox(player)) { var cap = player.getData(ModAttachments.PLAYER_VARIABLE); - - var ammoTypeInfo = data.ammoTypeInfo(); - switch (ammoTypeInfo.type()) { - case PLAYER_AMMO -> { - var type = AmmoType.getType(ammoTypeInfo.value()); - assert type != null; - - type.add(cap, -1); - } - case ITEM -> player.getInventory().clearOrCountMatchingItems( - p -> p.getItem().toString().equals(ammoTypeInfo.value()), - 1, - player.inventoryMenu.getCraftSlots() - ); - case TAG -> player.getInventory().clearOrCountMatchingItems( - p -> p.is(ItemTags.create(ResourceLocation.parse(ammoTypeInfo.value()))), - 1, - player.inventoryMenu.getCraftSlots() - ); - } - + data.consumeAmmo(player, 1); player.setData(ModAttachments.PLAYER_VARIABLE, cap); } }