So, I'm trying to make a harry potter mod where when you shift + right click a stick it transforms into a wand(a custom item). I've created a class for what should the vannila stick do:
package com.rextechnology.rexmod.item.custom;
import com.rextechnology.rexmod.item.ModItems;
import net.minecraft.network.chat.Component;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.Nullable;
import java.util.List;
public class StickItem extends Item {
public StickItem(Properties pProperties) {
super(pProperties);
}
@Override
public void appendHoverText(ItemStack pStack, @Nullable Level pLevel, List<Component> pTooltipComponents, TooltipFlag pIsAdvanced) {
pTooltipComponents.add(Component.literal("§6Shift §6+ §6click to convert to a wand"));
super.appendHoverText(pStack, pLevel, pTooltipComponents, pIsAdvanced);
}
@Override
public InteractionResultHolder<ItemStack> use(Level pLevel, Player pPlayer, InteractionHand pUsedHand) {
if (pPlayer.isShiftKeyDown()) {
pPlayer.setItemInHand(pUsedHand, new ItemStack(ModItems.WAND.get()));
}
return super.use(pLevel, pPlayer, pUsedHand);
}
}
but I dont know how to make this class be used by the vannila stick