Remove then add an item after hitting a mob

Started by aedryN on

Topic category: Help with MCreator software

Joined Aug 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Remove then add an item after hitting a mob
Fri, 12/01/2023 - 03:06 (edited)

Hey everyone!

So basically I have two items in my mod: Uncharged ukulele and Charged ukulele (its icon is an ukulele with some blue effects). 
That is how I want it to work: you take a charged ukulele in your hand -> you hit a mob with it -> charged ukulele is removed from your inventory -> uncharged ukulele is added to your inventory.

I really need your help. I watched some tutorials, but can't figure out how to create this feature properly. In my code I tried to target a player who hits a mob with a tool.

https://imgur.com/T9bG250

CODE^

UPD: anyone here?
 

Edited by aedryN on Fri, 12/01/2023 - 03:06
Joined Oct 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
If entity has 1 in inventory…
Fri, 12/01/2023 - 12:24

If entity has 1 in inventory, give 2. If entity has 2 in inventory, give. When you want it to switch, call the procedure. 

Joined Aug 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thanks for your answer!…
Sat, 12/02/2023 - 01:30

Thanks for your answer! Unfortunately, the procedure for source entity won't compile no matter what. What am I doing wrong? 

I even tried to copy a global trigger procedure from a guide on youtube, but it seems like every time I target a source entity the code simply doesn't compile/work. I even tried to clear all Gradle caches and regenerate the code, but nothing worked for me :(

https://imgur.com/d9N0Abc
ERROR^