Started by
Cadgam
on
Topic category: Help with Minecraft modding (Java Edition)
I'm having trouble with my food item. It applies effects to the player 10 seconds after it is consumed, and then additional effects occur when the initial effects wear off. This happens a total of four times. However, the issue is that when the player dies, the effects continue to trigger even after their designated wait periods.
Create a new Procedure and set its Trigger to "On player tick update", in the procedure add a If Not "Is Event/target entity Alive" Do "Remove specific potion effect from Event/target entity" Then you can specify the effects to remove. Or if you would like all effects to be removed, use "Clear all potion effects of Event/target entity". You can also add any logic to reverse any non potion effects here as well. Oh and also in your Procedure that adds the Effects (Especially the delayed effects) Make a If "Is Event/target entity Alive" before applying the effects So you make sure the Player isn't dead before applying the Effect, then you can break out of the Loop and make None of the effects happen if the Player was found Dead during any of those steps. (Hope this makes sense lol)
This makes sense, but the potion effects with the delay (I'm using wait x ticks on the server side) still occur after I die. The check is only at the start of the effects so if I die while they are still active and haven't yet run out, the check will fail because I will likely have already respawned. (Sorry for the late response but I needed to go to bed early)
Hmm didn't think of that, Well in that case you can create a new "Logic" type variable in the variables tab and set it too "Player Persistent" Call it something like "CanEffectsActivate" And set it by default to "True". Then when you use the potion or item, make it instantly set this Variable to False at the top of the Procedure, Then in your new Procedure that checks for the Players death/Respawn, set this new variable to "True". Now lastly, Make a Check in your Potion Procedure for if the New Variable Value is = to False before Giving the player effects (Also do the same check after each Wait procedure block) And the very end you can set it back to "True". That should do the trick! :)
It worked, thank you!