[SOLVED]Ahhh!!! I want custom book for enchantment

Started by dreamingdreamer on

Topic category: Help with Minecraft modding (Java Edition)

Joined Sep 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
[SOLVED]Ahhh!!! I want custom book for enchantment
Fri, 10/17/2025 - 12:56 (edited)

I tried writing code with ChatGPT.

But it still shows up as a limited enchantment with ...? in the Enchant Table.

How can I put vanilla enchantments on items?

//custom element
@EventBusSubscriber
public class AllowCustomBookEnchant {
@SubscribeEvent
public static void onEnchantabilityCheck(EnchantmentLevelSetEvent event) {
ItemStack stack = event.getItem();

if (stack.getItem() instanceof BlessedBookItem || stack.getItem() instanceof AdvancedBlessedBookItem) {
event.setEnchantLevel(event.getEnchantLevel());
ItemEnchantments enchantments = stack.getEnchantments();
stack.set(DataComponents.ENCHANTMENTS, enchantments);
}
}
//book.java
public class BlessedBookItem extends Item {
public BlessedBookItem(Item.Properties properties) {
super(properties.stacksTo(1).component(DataComponents.ENCHANTABLE, new Enchantable(7))
.component(DataComponents.ENCHANTMENTS, ItemEnchantments.EMPTY)
.component(DataComponents.REPAIR_COST, 1));
}
public static void addStoredEnchant(ItemStack stack, ItemEnchantments enchants) {
stack.set(DataComponents.ENCHANTMENTS, enchants);
}
public static boolean hasStoredEnchantments(ItemStack stack) {
return stack.has(DataComponents.ENCHANTMENTS);
}
}
Edited by dreamingdreamer on Fri, 10/17/2025 - 12:56
Joined Oct 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
do you change the…
Thu, 10/16/2025 - 00:20

do you change the ItemEnchantments.EMPTY part for the item? also, for the question in your text, custom tools already allow enchants provided they are in the correct enchantable tag (can be seen through the element tags tab on the left (should already default to the enchantable tag of the set item tool type))

Joined Sep 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
hmm...But it doesn't work…
Fri, 10/17/2025 - 12:36

hmm...But it doesn't work... I want to know why it doesn't work.

I've tried many things, but most of them don't work.

Is there any checklist for when an enchantment is marked as "Limited Enchantment"?

Joined Sep 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
ah, I use Mcreator newest…
Fri, 10/17/2025 - 12:46

ah, I use Mcreator newest version, neoforge 21.8.31

... wait, I'll try somethings

Joined Sep 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
... wow... ChatGPT didn't…
Fri, 10/17/2025 - 12:55

... wow... ChatGPT didn't tell me that.(that is element tags)

thank you for your help

Knowledge++