Minecraft: How to create a function that prevents players from swimming upstream

minecraft-commandsminecraft-java-edition

I'm creating a custom map in Minecraft and came across an idea involving running water as an obstacle. I was wondering if there was a way to create running water that would beat and push the player in the direction of flow as though they were being dragged downstream like white water rapids.

A /tp command that executes if the player is in a flowing water block might do it, but I was wondering if there was anything smoother and more reliable.

Best Answer

Haha! I did it! I created an invisible and silent ghast with the tag "fast_water" using this command:

/summon ghast ~ ~ ~ {NoAI:1,Silent:1,Invulnerable:1,ActiveEffects:[{Id:14,Amplifier:0,Duration:1000000,ShowParticles:0b}],Tags:["fast_water"]}

And I used a series of repeating command blocks to detect if a player was standing in any height of flowing water, then if the conditions were met, teleported the invisible ghast a small space ahead of the player, so that the collision box would force the player downstream! Huzzah!

I only needed this for one direction of flowing water, so I don't need to optimize it for every direction.