Skip to content

Commit

Permalink
Treat Elementium Axe as weapon for durability damage
Browse files Browse the repository at this point in the history
Fixes #4492 by reducing the durability damage from attacking with an elementium axe from 2 to 1, since it's primarily intended as a weapon.
  • Loading branch information
TheRealWormbo committed Mar 22, 2024
1 parent af3beeb commit f0db5fb
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
Expand All @@ -20,6 +21,8 @@
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;

import org.jetbrains.annotations.NotNull;

import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.common.annotations.SoftImplement;
import vazkii.botania.common.item.equipment.tool.manasteel.ManasteelAxeItem;
Expand Down Expand Up @@ -63,4 +66,12 @@ public boolean canApplyAtEnchantingTable(ItemStack stack, Enchantment enchantmen

}

// [VanillaCopy] modified from DiggerItem::hurtEnemy, actually same as SwordItem::hurtEnemy
@Override
public boolean hurtEnemy(ItemStack stack, @NotNull LivingEntity target, @NotNull LivingEntity attacker) {
// only do 1 durability damage, since this is primarily a weapon
stack.hurtAndBreak(1, attacker, living -> living.broadcastBreakEvent(EquipmentSlot.MAINHAND));
return true;
}

}

0 comments on commit f0db5fb

Please sign in to comment.