调整治疗弹匣附魔的效果

This commit is contained in:
17146 2024-07-31 18:46:50 +08:00
parent 1a8ee5d446
commit 2181c46060
3 changed files with 16 additions and 6 deletions

View file

@ -817,12 +817,18 @@ public class GunEventHandler {
}
private static void handleHealClip(Player player, ItemStack stack) {
int healClipLevel = EnchantmentHelper.getTagEnchantmentLevel(ModEnchantments.HEAL_CLIP.get(), stack);
if (healClipLevel == 0) {
healClipLevel = 1;
}
int time = stack.getOrCreateTag().getInt("HealClipTime");
if (time > 0) {
player.heal(player.getMaxHealth() * .6f);
player.heal(12.0f * (0.8f + 0.2f * healClipLevel));
List<Player> players = player.level().getEntitiesOfClass(Player.class, player.getBoundingBox().inflate(5))
.stream().filter(p -> p.isAlliedTo(player)).toList();
players.forEach(p -> p.heal(p.getMaxHealth() * .3f));
int finalHealClipLevel = healClipLevel;
players.forEach(p -> p.heal(6.0f * (0.8f + 0.2f * finalHealClipLevel)));
stack.getOrCreateTag().putInt("HealClipTime", 0);
}

View file

@ -269,9 +269,9 @@ public class LivingEventHandler {
return;
}
int level = EnchantmentHelper.getTagEnchantmentLevel(ModEnchantments.HEAL_CLIP.get(), stack);
if (level != 0) {
stack.getOrCreateTag().putInt("HealClipTime", 80 + level * 20);
int healClipLevel = EnchantmentHelper.getTagEnchantmentLevel(ModEnchantments.HEAL_CLIP.get(), stack);
if (healClipLevel != 0) {
stack.getOrCreateTag().putInt("HealClipTime", 80 + healClipLevel * 20);
}
}
}

View file

@ -87,9 +87,13 @@ public abstract class GunItem extends Item {
itemstack.getOrCreateTag().putDouble("flash_time", (itemstack.getOrCreateTag().getDouble("flash_time") - 1));
}
if (itemstack.getOrCreateTag().contains("HealClipTime")) {
if (itemstack.getOrCreateTag().getInt("HealClipTime") > 0) {
itemstack.getOrCreateTag().putInt("HealClipTime", Math.max(0, itemstack.getOrCreateTag().getInt("HealClipTime") - 1));
}
if (itemstack.getOrCreateTag().getInt("KillClipTime") > 0) {
itemstack.getOrCreateTag().putInt("KillClipTime", Math.max(0, itemstack.getOrCreateTag().getInt("KillClipTime") - 1));
}
}
}