Fixed all in one tools not having damage.

This commit is contained in:
Flanks255 2024-10-19 17:08:46 -05:00
parent b5cb343492
commit 9a418c1c6d

View file

@ -3,10 +3,14 @@ package de.ellpeck.actuallyadditions.mod.items;
import de.ellpeck.actuallyadditions.api.ActuallyTags; import de.ellpeck.actuallyadditions.api.ActuallyTags;
import net.minecraft.core.component.DataComponents; import net.minecraft.core.component.DataComponents;
import net.minecraft.world.InteractionResult; import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.EquipmentSlotGroup;
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.item.DiggerItem; import net.minecraft.world.item.DiggerItem;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items; import net.minecraft.world.item.Items;
import net.minecraft.world.item.Tier; import net.minecraft.world.item.Tier;
import net.minecraft.world.item.component.ItemAttributeModifiers;
import net.minecraft.world.item.context.UseOnContext; import net.minecraft.world.item.context.UseOnContext;
import net.neoforged.neoforge.common.ItemAbilities; import net.neoforged.neoforge.common.ItemAbilities;
import net.neoforged.neoforge.common.ItemAbility; import net.neoforged.neoforge.common.ItemAbility;
@ -27,17 +31,22 @@ public class AllInOneTool extends DiggerItem {
); );
public AllInOneTool(Tier tier) { public AllInOneTool(Tier tier) {
super( super(tier,
/* 4.0f, ActuallyTags.Blocks.MINEABLE_WITH_AIO,
-2f,*/
tier,
ActuallyTags.Blocks.MINEABLE_WITH_AIO,
new Properties() new Properties()
.durability(tier.getUses() * 4) .durability(tier.getUses() * 4)
.component(DataComponents.TOOL, tier.createToolProperties(ActuallyTags.Blocks.MINEABLE_WITH_AIO)) .component(DataComponents.TOOL, tier.createToolProperties(ActuallyTags.Blocks.MINEABLE_WITH_AIO))
.attributes(createAttributes())
); );
} }
private static ItemAttributeModifiers createAttributes() {
ItemAttributeModifiers.Builder builder = ItemAttributeModifiers.builder();
builder.add(Attributes.ATTACK_DAMAGE, new AttributeModifier(BASE_ATTACK_DAMAGE_ID,4.0f, AttributeModifier.Operation.ADD_VALUE), EquipmentSlotGroup.MAINHAND);
builder.add(Attributes.ATTACK_SPEED, new AttributeModifier(BASE_ATTACK_SPEED_ID, -2.0f, AttributeModifier.Operation.ADD_VALUE), EquipmentSlotGroup.MAINHAND);
return builder.build();
}
@Override @Override
public boolean canPerformAction(@Nonnull ItemStack stack, @Nonnull ItemAbility toolAction) { public boolean canPerformAction(@Nonnull ItemStack stack, @Nonnull ItemAbility toolAction) {
if (ACTIONS.contains(toolAction)) if (ACTIONS.contains(toolAction))