Heal entity when player right clicks it with a specific item

Started by SeriousMANBOT on Thu, 09/24/2020 - 15:13

Topic category: Help with modding (Java Edition)

Last seen on 21:57, 15. Oct 2020
Joined Mar 2019
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Heal entity when player right clicks it with a specific item
Thu, 09/24/2020 - 15:13

I am making a dinosaur mod. One of them is tameable right now, with raw chicken.

I've made it so that right clicking the mob with raw chicken in my mainhand removes the item from my inventory, but I cant figure out how to make it heal the entity. If anyone knows how and can help, I'd greatly appreciate it.

Last seen on 15:08, 30. Oct 2020
Joined Jun 2019
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
In terms of taming, as well…
Thu, 09/24/2020 - 15:58

In terms of taming, as well as breeding for that matter. I think it automatically sets the taming item to heal the mob.
But, if not, and in more general terms, while editing the entity, under "Triggers" there should be a spot that says "When right clicked on entity". Should be in the center of the screen
 

Simply make a procedure that checks if the item in the main hand of the player is the right item, then have it heal the entity. Probably by giving it instant_health for a short second. Use "Source Entity" as the player and "Event/Target Entity" as the entity being right clicked. 

Last seen on 21:57, 15. Oct 2020
Joined Mar 2019
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
I use version 2020.2 so…
Thu, 09/24/2020 - 16:17

I use version 2020.2 so there's no "Source Entity" for me

Is there any other way?

either way thank you for the help

Last seen on 15:08, 30. Oct 2020
Joined Jun 2019
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Hm, Not too sure if I know a…
Thu, 09/24/2020 - 17:12

Hm, Not too sure if I know a way then. You could possibly use a couple of the "Execute command" procedure blocks in the world management section. With commands like

execute as entity @p[limit=1,nbt={SelectedItem:{id:"minecraft:chicken",Count:1b}}] run clear @s chicken 1 | to remove a raw chicken from the player.

And

execute if entity @p[limit=1,nbt={SelectedItem:{id:"minecraft:chicken",Count:1b}}] run effect give @e[distance=0..0.01] instant_health 20 1

To heal the entity if the closest player is holding raw chicken when right clicked (Though, this would also allow for another player to be holding chicken and then a different player could activate it for them)

Im not exactly sure how well this would work, if at all. But I think it might.
I also mightve made mistakes in those commands themselves, but yeah. I think the way to go with this may be command based.

Last seen on 21:57, 15. Oct 2020
Joined Mar 2019
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
thank you both, although the…
Mon, 09/28/2020 - 19:01

thank you both, although the commands are for 1.14+ and my mods are for 1.12.2

I'll see if I can use both of your advice