Started by
Oofeiro
on
Topic category: Help with Minecraft modding (Java Edition)
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
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.
Did you ever figure this out? Trying to make a piece of armor increase my Energy Variable, however it just goes up infinitely. I figure I need to have the event trigger on player tick so that it constantly knows if the Chestplate is equipped or not, but then how do I just make it only apply the +35 to my variable only once and not every tick?
I had a similar problem, all I did was make a player number variable for each equipment slot, and made a procedure so that if the variable was 0 and the armor was in slot, it increased my health by 5 and set the variable to 1 so it wouldn't loop. Then another if block where if the variable is 1 and no armor is in slot, it reduced health by 5 and set the variable back to 0. There's probably a more elegant way of doing it but with this method I never had any issues