Check If Ranged Item Is Enchanted On Hit?

Started by trevor050 on

Topic category: Help with modding (Java Edition)

Last seen on 22:08, 17. Oct 2023
Joined Feb 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Check If Ranged Item Is Enchanted On Hit?

So I have a ranged throwable that can have an enchantment. When my ranged item collides with an entity I want it to:

 

Check if the throwable has the enchantment, apply an effect to the entity it hits. The issue is that provided itemstack is the only way I know how to check if an item has an enchantment but its a part of "When Projectile Hits Living Entity". So how could I do this?

Last seen on 16:02, 15. Apr 2024
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You could try converting the…
Mon, 10/16/2023 - 12:12

You could try converting the entity into an itemstack entity with one of the conversion functions? I'm honestly not sure how you'd do this with a throwable item. 

...If you want some weirder workarounds though, when the player throws the item, you could give it an infinite potion effect if it's enchanted, (like unluck), and then do something different in your procedure if the throwable entity has unluck. (You would likely need to code in a custom throw event though, firing a projectile when the entity right clicks your item, as I'm not sure the built in trigger would support this.)