How to make a treasure enchantement only go on certain items

Started by DarkParty on

Topic category: Help with Minecraft modding (Java Edition)

Joined Apr 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to make a treasure enchantement only go on certain items

So I am trying to make an enchantments mod, but when an enchantment is a treasure enchantment, you can apply the book to like literally anything, which I do not want to be the case. But it seems like you can only specify what items are enchantable on an enchanting table.

Joined Apr 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I realize that the question…
Tue, 12/23/2025 - 18:26

I realize that the question may be a little unclear XD. I am wonder how to make it so that you can only apply an enchante book of a custom enchantment to certain items.

 

Joined Apr 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I think that enchantments…
Tue, 12/23/2025 - 18:59

I think that enchantments can normally only be applied to certain items in an anvil. However I'm also pretty sure that creative mode bypasses that limit. If your testing has been in creative mode, try it in survival, it might work as intended (not applying to the wrong items) in survival mode.

I could be mistaken though.

Joined Nov 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Here are some "creative"…
Tue, 12/23/2025 - 19:23

Here are some "creative" solutions I could think of from the top of my head, They may not be ideal but they'll "work":

  1. Don't use the anvil to enchant the item

    Make a procedure that when a player R-clicks with the book in off hand, it checks (with an if-statement) if the player is holding the particular book; it'll apply the enchantment to the item while removing some of the players XP

    Make sure that when the player clicks the anvil it will cancel the event.

  2. Use a temporary fake anvil, that transfers an amount of damage  

    Have it so that when the player R-clicks the anvil with the book, it'll replace the anvil with a block that looks similar to it (possibly with the book visually on it) 

    When you R-Click the fake anvil with the sword it takes some XP, enchants the sword, and places back the old anvil with some additional damage added onto it.

     

Its fine if you don't like these ideas but hopefully they'll help you come up with a better one.

Joined Apr 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
It was the creative mode …
Tue, 12/23/2025 - 19:31

It was the creative mode @catnip. Thx!

Joined Apr 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I'm glad I was able to help.
Tue, 12/23/2025 - 22:02

I'm glad I was able to help.