Is there a way to stop levitation 254 from shooting you into the air when landing?

Solution 1:

Update in 19w37a (for 1.15): Levitation 254 simply works now, I was not able to reproduce the bouncing behaviour. So the solution below is only useful for older versions. I'll keep it in the 1.12 syntax unless someone requests me to update it.


I have no real solution to stop the bouncing (and I don't think there is one), but it can be detected when a player is first off the ground and then on the ground again. And it's possible to give the player a lot of downwards momentum to force him back to the ground, again with negative levitation. I don't exactly know why this works and doesn't produce an endless loop of bounces, but it works and that's all that matters. Of course it looks very ridiculous when a player elegantly glides to the ground and then suddenly does a very high and very quick jump and is then pushed back on the ground. But this is just a workaround. I think a true fix won't come for a long time if you don't write your own mod, because it's a bug in an unsupported feature (effect level above 4).

Setup:

/scoreboard objectives add antiJump dummy

Loop:

execute @a[score_antiJump_min=0,score_antiJump=0] ~ ~ ~ detect ~ ~-.1 ~ air 0 scoreboard players set @s antiJump 1
scoreboard players add @a[score_antiJump_min=1] antiJump 1
execute @a ~ ~ ~ detect ~ ~-.1 ~ air 0 scoreboard players set @s antiJump 1
effect @a[score_antiJump_min=2,score_antiJump=2] levitation 0
effect @a[score_antiJump_min=2,score_antiJump=2] levitation 1 128
scoreboard players set @a[score_antiJump_min=9] antiJump 0
effect @a[score_antiJump=0] levitation 1000000 254

This gives every player on the ground by default the state of 0. When they are in the air (there's an air block 0.1 blocks below them), they get state 1. When they are then on the ground again, they get a high negative levitation effect (128) that pushes them down against the bouncing so that they still fly about 5 blocks up, but they are back on the ground after only 0.4 seconds. Also their state starts ticking up. When it reaches 9, it's reset to 0 and they get the levitation effect 254 again.

This system only checks for air below the player, no other small blocks (like slab, carpet, chests, etc.), but I tested it and it actually works just as well with them. The only exception is if you build really big towers out of blocks without a hitbox (signs, banners, buttons, ...) and the player falls right through it. Then he can actually still bounce up the regular height. To solve that, you can just duplicate all the execute detect commands (keeping the order) with standing_sign or similar instead of air or you can set the 9 in the second last command to a higher number, but that could, if it's too high, prevent players from jumping for a while after they were bounced.

This system is almost unnoticable when walking/jumping around normally. There are some movements with stairs or water that behave differently than you would expect, but they should be pretty rare. I first made a system where a block would be set on top of the player to keep him from going up, but that was very unelegant in comparison to this one and had much potential for unwanted side effects. This system shouldn't have that. It's not perfect, but it's (to my knowledge) the best that can be done with commands.