火炮无人时不判断玩家背包弹药
This commit is contained in:
parent
926b43f32a
commit
f876137e17
2 changed files with 13 additions and 9 deletions
|
@ -395,7 +395,7 @@ public class Mk42Entity extends VehicleEntity implements GeoEntity, CannonEntity
|
|||
|
||||
Level level = player.level();
|
||||
if (level instanceof ServerLevel server) {
|
||||
if (!InventoryTool.hasCreativeAmmoBox(player)) {
|
||||
if (!InventoryTool.hasCreativeAmmoBox(player) && player == getFirstPassenger()) {
|
||||
var ammo = getWeaponIndex(0) == 0 ? ModItems.AP_5_INCHES.get() : ModItems.HE_5_INCHES.get();
|
||||
var ammoCount = InventoryTool.countItem(player.getInventory().items, ammo);
|
||||
|
||||
|
|
|
@ -407,15 +407,19 @@ public class Mle1934Entity extends VehicleEntity implements GeoEntity, CannonEnt
|
|||
Level level = player.level();
|
||||
if (level instanceof ServerLevel server) {
|
||||
int consumed;
|
||||
if (InventoryTool.hasCreativeAmmoBox(player)) {
|
||||
consumed = 2;
|
||||
} else {
|
||||
var ammo = getWeaponIndex(0) == 0 ? ModItems.AP_5_INCHES.get() : ModItems.HE_5_INCHES.get();
|
||||
var ammoCount = InventoryTool.countItem(player.getInventory().items, ammo);
|
||||
if (player == getFirstPassenger()) {
|
||||
if (InventoryTool.hasCreativeAmmoBox(player)) {
|
||||
consumed = 2;
|
||||
} else {
|
||||
var ammo = getWeaponIndex(0) == 0 ? ModItems.AP_5_INCHES.get() : ModItems.HE_5_INCHES.get();
|
||||
var ammoCount = InventoryTool.countItem(player.getInventory().items, ammo);
|
||||
|
||||
// 尝试消耗两发弹药
|
||||
if (ammoCount <= 0) return;
|
||||
consumed = InventoryTool.consumeItem(player.getInventory().items, ammo, 2);
|
||||
// 尝试消耗两发弹药
|
||||
if (ammoCount <= 0) return;
|
||||
consumed = InventoryTool.consumeItem(player.getInventory().items, ammo, 2);
|
||||
}
|
||||
} else {
|
||||
consumed = stack.getCount();
|
||||
}
|
||||
|
||||
if (getFirstPassenger() != getOwner()) {
|
||||
|
|
Loading…
Add table
Reference in a new issue