How to make items drop from a vanilla entity if the player has a specific enchantment

Started by ZSorcer19 on

Topic category: Help with Minecraft modding (Java Edition)

Joined Jun 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to make items drop from a vanilla entity if the player has a specific enchantment

So I'm trying to make a procedure that checks if the entity killed is a Guardian and if it is then it checks the item in the main-hand of the player for a specific enchantment. If both conditions are true then I want it to drop a custom item. I've tried multiple methods to get it to work and I have yet to find anything that works.

Joined Jun 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
event/target entity is an…
Sun, 06/04/2023 - 20:21

event/target entity is an entity who dies i.e. guardian
Your mistake: your conditions means that when guardian dies his weapon in main-hand must have your enchantment
 
How to fix: Your second condition should be linked to the one who made entity die i.e source entity. You can find source entity in minecraft components. Put it instead of event/target entity in second condition.


(P.s. when doing conditions instead of doing multiple ifdo you can just place blue thing from logic (it has same color as ifdo) and select AND instead of = and with right mouse button do external inputs. Thats will be easier to understand what you doing)

Joined Jun 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thank you so much, it works…
Sun, 06/04/2023 - 20:42

Thank you so much, it works now :D