Started by
Tengrip
on
Topic category: Help with Minecraft modding (Java Edition)
Essentially what i'm attempting to do is create an enchantment that causes a player to turn invisible when no hostile mobs are within a predefined range of the player, There is no global trigger for sneaking so I use "on Player Tick Update" followed by an if statement detecting the enchantment and if the player is sneaking. Essentially what I think is happening is it's causing an infinite loop when I press crouch instantly causing a crash.
Anyone have any ideas or a better way to do this?
idk something like this?
set it as global procedure
you could try building from there.
https://imgur.com/a/RAUosCQ
idk if you even cancel that tho
When you use the update trigger with a potion effect, the effect will stop applying when your negative condition is met.
For example if you check for sneaking then add Speed, if you stop sneaking the Speed effect will no longer be applied. This is why using the effect with a short duration (like 0.5 seconds or so) is ideal for this, because you don't have to program a negative condition like you did. Try only checking for the sneaking, then under that if there is an entity on range, after that apply your effect. You should stop receiving the effect if you are 1: not crouching and 2: There are no entities nearby.
Hope this helps!