创造模式不再消耗任何弹药

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

View file

@ -8,6 +8,7 @@ import com.atsuishio.superbwarfare.perk.AmmoPerk;
import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.Perk;
import com.atsuishio.superbwarfare.tools.AmmoType; import com.atsuishio.superbwarfare.tools.AmmoType;
import com.atsuishio.superbwarfare.tools.GunsTool; import com.atsuishio.superbwarfare.tools.GunsTool;
import com.atsuishio.superbwarfare.tools.InventoryTool;
import net.minecraft.core.component.DataComponents; import net.minecraft.core.component.DataComponents;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
@ -304,6 +305,8 @@ public class GunData {
} }
public int countAmmo(Player player) { public int countAmmo(Player player) {
if (player.isCreative() || InventoryTool.hasCreativeAmmoBox(player)) return Integer.MAX_VALUE;
var info = ammoTypeInfo(); var info = ammoTypeInfo();
return switch (info.type()) { return switch (info.type()) {
case PLAYER_AMMO -> { case PLAYER_AMMO -> {
@ -327,6 +330,8 @@ public class GunData {
} }
public void consumeAmmo(Player player, int count) { public void consumeAmmo(Player player, int count) {
if (player.isCreative() || InventoryTool.hasCreativeAmmoBox(player)) return;
var info = ammoTypeInfo(); var info = ammoTypeInfo();
switch (info.type()) { switch (info.type()) {
case PLAYER_AMMO -> { case PLAYER_AMMO -> {