修改换弹开始条件

This commit is contained in:
Light_Quanta 2025-04-15 23:31:04 +08:00
parent e44c46dc3b
commit 92c8838613
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959

View file

@ -2,10 +2,8 @@ package com.atsuishio.superbwarfare.network.message.send;
import com.atsuishio.superbwarfare.Mod;
import com.atsuishio.superbwarfare.init.ModAttachments;
import com.atsuishio.superbwarfare.init.ModItems;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.tools.Ammo;
import io.netty.buffer.ByteBuf;
import net.minecraft.network.codec.ByteBufCodecs;
import net.minecraft.network.codec.StreamCodec;
@ -51,20 +49,7 @@ public record ReloadMessage(int msgType) implements CustomPacketPayload {
boolean clipLoad = data.ammo.get() == 0 && gunItem.isClipReload(stack);
// 检查备弹
boolean hasCreativeAmmoBox = player.getInventory().hasAnyMatching(item -> item.is(ModItems.CREATIVE_AMMO_BOX.get()));
if (!hasCreativeAmmoBox) {
var ammoTypeInfo = data.ammoTypeInfo();
if (ammoTypeInfo.type() == GunData.AmmoConsumeType.PLAYER_AMMO) {
var ammoType = Ammo.getType(ammoTypeInfo.value());
assert ammoType != null;
if (ammoType.get(cap) == 0) return;
} else if ((ammoTypeInfo.type() == GunData.AmmoConsumeType.ITEM || ammoTypeInfo.type() == GunData.AmmoConsumeType.TAG) && !data.hasAmmo(player)) {
return;
}
}
if (!data.hasAmmo(player)) return;
if (canReload || clipLoad) {
int magazine = data.magazine();