Hi, so I am having trouble with some code. I made a custom pickaxe which extends off the pickaxe class, and I want it to give the player haste while they hold it. There is no obvious override methods that I can find and I need some help thank you.
Here is the code I have so far:
import net.minecraft.ChatFormatting;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.*;
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.Nullable;
import java.util.List;
public class DwarvenPickaxeItem extends PickaxeItem {
public DwarvenPickaxeItem(Tier tier, int attackmodifier, float speed, Properties properties) {
super(tier, attackmodifier, speed, properties);
}
@Override
public void appendHoverText(ItemStack stack, @Nullable Level level, List<Component> components, TooltipFlag flag) {
if(Screen.hasShiftDown()) {
components.add(Component.literal("A pickaxe which has been masterfully crafted by the hands of a Dwarf, making it especially good at mining with speed").withStyle(ChatFormatting.YELLOW).withStyle(ChatFormatting.ITALIC));
}
else {
components.add(Component.literal("Hold SHIFT for more info.").withStyle(ChatFormatting.YELLOW).withStyle(ChatFormatting.ITALIC));
}
super.appendHoverText(stack, level, components, flag);
}
}