Sword That when i hit a mob it gives the player food point

Started by CookiesZININHO on

Topic category: Help with MCreator software

Joined Jul 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Sword That when i hit a mob it gives the player food point

I tried to make a sword that when it hits a mob it gives food points to the player, but I couldn't, can someone help me?here's how i'm trying to do it

Joined Mar 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
trigger: on attack if …
Tue, 07/11/2023 - 23:06

trigger: on attack

if (source entity) is sub type of player

  if item in main hand of (source entity) is (item)

    set food saturation of (source entity) to (get food saturation level of (event/target entity) + 5)

Joined Jul 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I didn't find where this…
Thu, 07/13/2023 - 02:39


I didn't find where this trigger "on attack" is, sorry, can you show me please?I looked around here but I didn't find it

Joined Jul 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I also couldn't find the "…
Thu, 07/13/2023 - 03:01


I also couldn't find the " if item in main hand of (source entity) is (item)", sorry, can you help me find it please?

Joined Jul 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I tried to do it this way…
Thu, 07/13/2023 - 03:14
I tried to do it this way but it didn't work
 

Ícone "Verificada pela comunidade"


Joined Jul 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I noticed that it was…
Thu, 07/13/2023 - 03:20
I noticed that it was different from what you had said and I fixed it, but it still didn't worksorry for the inconvenience
Joined Mar 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
maybe swap where the sword…
Thu, 07/13/2023 - 22:38

maybe swap where the sword and the item in main-hand is.

Joined Jul 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I tried it too, but it didn…
Fri, 07/14/2023 - 00:23
I tried it too, but it didn't work
Joined Jul 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Your Issue is, that you use …
Thu, 07/20/2023 - 10:54

Your Issue is, that you use "the set food saturation" block (saturation is like an invisible parameter that decides how long it takes to lower the first piece of the hunger bar) What you want to use is the "set food level of" block that actually adds hunger to your bar. Otherwise it should work with all the entity blocks being "source entity".

 

Another maybe code efficient way of achieving your goal is to go to your custom Item, then triggers and add the procedure to "when living entity is hit with item". The procedure can look like this:

 

and you can add the procedure here:

If you cant see the images in this text, rightclick it and open in a new tab.