2

I am using a repeat command to simulate water breathing with particles, but the particles don't look realistic when the player is swimming with crtl activated, when the player is in walk position it Works perfectly but I didn't find any relative position with x y and z to make it good for both at the same time

The command that I'm using:

/execute as @a at @s run execute if block ~ ~2 ~ water run execute if score aguaa aguaa < 80 constante run particle minecraft:bubble_column_up ~ ~1.8 ~ 0 0 0 0.1 5 force

enter image description here

  • 1
    You need to provide the commands you're currently using before we can really help you. – MBraedley Jan 7 at 19:13
  • /execute as @a at @s run execute if block ~ ~2 ~ water run execute if score aguaa aguaa < 80 constante run particle minecraft:bubble_column_up ~ ~1.8 ~ 0 0 0 0.1 5 force – D3T0NA Jan 7 at 19:49
  • @D3T0NA That doesn't differentiate between walk-swimming and proper swimming. – Fabian Röling Jan 7 at 19:51
  • i don´t know how to differentiate that, that´s the problem here, if i knew how to i would have 2 commands ready to display the particle – D3T0NA Jan 7 at 19:53
3

/execute anchored eyes can do this (and it seems to be the only way to detect when a player is swimming).
This command does something at the nearest player's head position, which is properly adjusted to swimming, crawling, elytra and sneaking:

/execute as @p at @s anchored eyes run <command>

Now the trick: The anchor only works with the rotationally relative coordinates (^ ^ ^), not with the axis relative coordinates (~ ~ ~), so if you don't use those coordinates in your "<command>" part anyway, you need to align it like this:

/execute as @p at @s anchored eyes positioned ^ ^ ^ run <command>

The "as" part is also needed, because the anchor needs an entity reference to know the eye height.

| improve this answer | |
  • It worked perfectly thank you. – D3T0NA Jan 7 at 20:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.