Armor increases a value infinitely

Started by Oofeiro on

Topic category: Help with modding (Java Edition)

Last seen on 00:32, 26. Jul 2024
Joined Nov 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Armor increases a value infinitely
Sat, 11/04/2023 - 03:13 (edited)

Hello! I'm having a problem with modding!

I'm currently trying to make an armor that makes it so when you wear a full set of it, a value is multiplied by 1.5. I coded the effects for it and when i tested in Minecraft, the value was being increased by 50% INFINITELY. It went from mininum to maximum in an instant! 

 

I tried to find a way to limit the increasing value to just 1 multiplication, but i couldn't.

Also i think the biggest problem is the global trigger "On player tick update".

 

Can you guys help me with this? Here's the procedure: https://ibb.co/nP77wJb

 

Edited by Oofeiro on Sat, 11/04/2023 - 03:13
Last seen on 20:37, 26. Jul 2024
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Yes, you're correct, the…
Sat, 11/04/2023 - 16:57

Yes, you're correct, the problem is that running this on player update tick means it's multiplying the variable twenty times every second.

You could add a cap on the number variable by adding an additional condition where you first check that the variable is less than or equal to the maximum value. An easier approach though might be to just change it to a logic variable. If the player's wearing the full set, the logic variable should be true; otherwise, set the logic variable to false; then just refer to that when determining whether or not to set the value to 0, (if it's false), or 1.5, (if it's true.) Unless you need to be able to set this to more than two values, which could get a bit more complicated.

But yeah, you need to add a condition of some sort so it doesn't increase infinitely. You also probably want to add an 'else' condition that resets the variable to zero, otherwise if the player puts on a full set of armor and takes it off, the variable won't reset.