#how do i add an enchantment to an item from the start?
6 messages · Page 1 of 1 (latest)
you need to get the entry from the worlds dynamic registry manager probably
ahh...can you please tell me what to do?
check how the enchant command does it
OK maybe like this but i want this item has enchant at a start i mean you can see enchantment on creative tab
@Override
public void onCraftByPlayer(ItemStack stack, World world, PlayerEntity player) {
super.onCraftByPlayer(stack, world, player);
var registry = world.getRegistryManager().get(RegistryKeys.ENCHANTMENT);
var mendingEntry = registry.entryOf(Enchantments.MENDING);
stack.addEnchantment(mendingEntry, 1);
}
use the creative tab item event