Help! I'm trying to make a potion enchant an item if you use it instead of drinking it but I can't figure it out

Started by Purrpy on Thu, 07/29/2021 - 23:56

Topic category: Help with modding (Java Edition)

Last seen on 00:24, 3. Sep 2021
Joined Jul 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Help! I'm trying to make a potion enchant an item if you use it instead of drinking it but I can't figure it out
Thu, 07/29/2021 - 23:57 (edited)

I'm trying to make a special speed potion that, if you right click on a block instead of drinking it, it'll give Quick Charge 1 to any crossbow in your inventory. The thing is, I can't figure out how to target the crossbow. I tried putting a crossbow in the section for the enchantment instead of "Provided Itemstack" but it just doesn't do anything. How do you enchant a specific item instead of the item that's causing the enchanting to happen?

 

Edited by Purrpy on Thu, 07/29/2021 - 23:57
Last seen on 01:21, 14. Sep 2021
Joined Jul 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
When you use the potion, set…
Sun, 08/22/2021 - 23:36

When you use the potion, set some variable (player persistent or entity nbt) to true. Then, make an "On player tick update procedure". Inside that, check if that variable is true and if the item in the main hand is a crossbow. If that is true, then add the enchantment to item in main hand and set variable to false. 

So: the potion is used, but nothing happens yet. The player then puts a crossbow in his or her hand and BOOM it's enchanted!