Help, if statement with "current health of" block

Started by NitrogenBubbles on Sun, 05/23/2021 - 05:02

Topic category: Help with modding (Java Edition)

Last seen on 23:15, 23. May 2021
Joined Apr 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Help, if statement with "current health of" block
Sun, 05/23/2021 - 05:02

I have been trying to set up a procedure that gives you a potion effect for an infinite amount of time until you lose half of your health (The procedure also makes use of the Health Boost potion effect, essentially giving you the health boost & jump boost potion effects then the idea is that you lose both once you run out of all of the health you gained from the Health Boost.)

I have been trying to use an if statement with the "current health of" block, if the current health of the player is equal to or less than 20 the if statement is triggered.

The log doesn't appear in console when the player has 20 or less health, and the player doesn't lose the potion effects either.

I don't know why it isn't working, anyone care to enlighten me?

My procedure is below.

My Procedure

 

Last seen on 23:52, 19. Jul 2021
Joined Apr 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
I think I may be able to…
Sun, 05/23/2021 - 05:10

I think I may be able to help, though I need to ask a few questions first. 

1. What would be calling upon the procedure? Armour, an item in the player's inventory? Have to know specifics like this because even though you would think MCreator automatically only calls upon the procedure when applied to those, you still need to add checks for whatever item is causing the procedure.

2. Is there a reason you have the potion effects set to 999999? If the procedure is for armour or an item in the inventory, it will be called every tick so you don't need to set the numbers so high, about 25 ticks for both will do the trick.

Last seen on 23:15, 23. May 2021
Joined Apr 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
it is not for armor or an…
Sun, 05/23/2021 - 05:20

it is not for armor or an item in the inventory, it is for a food item that you eat, and the procedure is called when you eat the food item.

Last seen on 23:52, 19. Jul 2021
Joined Apr 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Ah, okay. The issue here is…
Sun, 05/23/2021 - 07:29

Ah, okay. The issue here is that since the procedure isn't going to be called for every single tick, it's not checking what the player's health is. It only checks what their health is when they eat the food item, because that's when the procedure is called.

Last seen on 23:15, 23. May 2021
Joined Apr 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
That makes a lot of sense…
Sun, 05/23/2021 - 10:03

That makes a lot of sense... I hadn't even considered that. Do you know how I might go about fixing this? maybe with another procedure that references this one? 

Last seen on 23:52, 19. Jul 2021
Joined Apr 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
I'm not entirely sure,…
Sun, 05/23/2021 - 23:04

I'm not entirely sure, unfortunately, as I'm fairly new to MCreator myself. But you would definitely need a health-check procedure running every tick.