Sneak function on player tick update

Started by Tengrip on

Topic category: Help with modding (Java Edition)

Last seen on 18:34, 12. Jun 2021
Joined May 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Sneak function on player tick update

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?

Procedure Block

Last seen on 04:13, 6. May 2023
Joined Aug 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
idk something like this? set…
Sat, 07/03/2021 - 23:55

idk something like this?

set it as global procedure

you could try building from there.

https://imgur.com/a/RAUosCQ

Last seen on 04:13, 6. May 2023
Joined Aug 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
idk if you even cancel that…
Sat, 07/03/2021 - 23:55

idk if you even cancel that tho

Last seen on 14:48, 19. Apr 2024
Joined Feb 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
When you use the update…
Sun, 01/14/2024 - 01:29

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!