Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hello there, I have been trying to give the player an enchanted book but I realized that if I enchant the book, it is technically not an enchanted book so it does not work in an anvil. I am kind of new to forge modding so if anyone can please explain how to enchant an enchanted book so that it works in an anvil, that would be great!

Code:

ItemStack unbreak = new ItemStack(Items.ENCHANTED_BOOK);
unbreak.enchant(Enchantments.UNBREAKING, 2);
player.addItem(unbreak);

Thanks

i have no idea how you have an enchanted book that isn't and enchanted book.

anyway, there are mods that show you item's nbt. use one in creative mode to see what you want and compare it to what you have.

  • Author
6 hours ago, MFMods said:

i have no idea how you have an enchanted book that isn't and enchanted book.

By that I mean I have an "enchanted_book" item that has the enchantment as if it were the weapon instead of the item containing the enchantment. ex: a sharpness 5 "enchanted_book" would normally be able to enchant a sword but instead it just does more damageif you attack using the book.

 

6 hours ago, MFMods said:

anyway, there are mods that show you item's nbt. use one in creative mode to see what you want and compare it to what you have.

Alright, I will try that, thanks

Edited by Casa Nuestra

well, i learned something about minecraft today.

anyway, just use EnchantedBookItem.addEnchantment() for books.

how am i so incredibly knowledgeable? well i just placed a cursor on Items.ENCHANTED_BOOK, hit alt+F7 (search for references) and found one occurrence with the answer.

edit: oh and start with book book, not the enchanted book.

Edited by MFMods

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.