修复装弹只消耗狙击弹药的问题

This commit is contained in:
Light_Quanta 2024-05-12 17:39:15 +08:00
parent afc495eda6
commit 72e4b0ac12
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959

View file

@ -27,7 +27,14 @@ public class GunReload {
}).orElse(0d);
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.sniperAmmo = Math.max(0, playerAmmo - ammoToAdd);
var newAmmoCount = Math.max(0, playerAmmo - ammoToAdd);
switch (type) {
case RIFLE -> capability.rifleAmmo = newAmmoCount;
case HANDGUN -> capability.handgunAmmo = newAmmoCount;
case SHOTGUN -> capability.shotgunAmmo = newAmmoCount;
case SNIPER -> capability.sniperAmmo = newAmmoCount;
}
capability.syncPlayerVariables(entity);
});
tag.putDouble("ammo", ammo + Math.min(ammoToAdd, playerAmmo));