#how do i add an enchantment to an item from the start?

6 messages · Page 1 of 1 (latest)

brittle meadow
tiny drift
#

you need to get the entry from the worlds dynamic registry manager probably

brittle meadow
tiny drift
#

check how the enchant command does it

brittle meadow
# tiny drift 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);
}
tiny drift
#

use the creative tab item event