Create custom enchant or item description?

Hello. I want to spawn something like magic wand. So let it be a simple stick with “Magic wand” label and custom “Magic power” enchantment, that does nothing - just text.
With first I have no problem, but I’m stuck on custom enchantment creation. I found no way to show any custom text instead of exnchantment.

It possible to implement this only on server-side plugin? Or there are have another way to “sign” item?
I saw similar in “Roguelike Dungeons” forge mod - enchanted sticks and swords with… em… something like “description” below the label: “Warm to touch” for example.

p.s.
Sorry for my english
I’m not english speaking :c

Thank everyone for help

To add descriptions to your items, you can offer them the lore value:

ItemStack itemStack = ItemStack.of(ItemTypes.STICK, 1);
List<Text> lore = Lists.newArrayList(Text.of(TextColors.LIGHT_PURPLE, "This wand emits pure magic."));
itemStack.offer(Keys.ITEM_LORE, lore);
1 Like

Enchantment lore is automatically added to the lore of the item when it has custom enchantments on it. You can emulate the enchantment lore effect by adding regular text with TextColors.GRAY to the lore of the item. However, this can be used with any text.

2 Likes

Thank you, it solves problem with descriptions. Didn’t know about ITEM_LORE key.
Custom enchantments question is still actual.

So how can I add custom enchantment? In example, I implement Enchantment interface in new class, then create ItemEnchantment with this class and offer it to item stack. This item (stick) wont stack with regular sticks, but I cant see any enchantment lore on item. What I’m doing wrong?

Someone correct me if I’m wrong, but I don’t think you can implement your own enchantments. What you could do, is convince the player the item was enchanted by adding a line of lore styled exactly the same as enchantments.

Ok. I think, lore may be enough. But it would be nice to add a visual effect of enchantment - and I don’t need an enchantments. Have a way to do this?

upd
No, it’s not possible with Sponge api for now.
Sad.

You could use Keys.HIDE_ENCHANTMENTS and apply an enchantment which would not affect the item at all (eg. infinity to item which is not a bow). The disadvantage of this approach is, that it’s not easy to display the rest of the enchantments the item could have.

1 Like

Oh, it’s great! It’s very good solution, 'cause I dont need to display real enchantments at all. Thank you!