2

As part of a datapack-powered PvP map we want to apply slowness to players. Sadly we have run into the issue where slowness does not affect sprint-jumping speed, meaning even players with slowness 100 do not have a difficult time catching up with people running at normal speed.

We have tried some very drastic measures:

  • Applying the slowness potion effect
  • Changing the player's movement speed attribute
  • Giving players jump boost 200 to disable their jump ability

Sadly none of these solutions got rid of the speed boost players get from sprint-jumping. We considered disabling their sprint, but Java edition lacking a /hunger command we found this impossible.

Is there a way to stop players from sprint-jumping, or otherwise make them actually slower?

1 Answer 1

3

I have figured out a way to counterbalance the effect of jumping but will involve predicates which could only be done with datapacks. Edit: Just saw you are already using datapacks, nevermind

First create a scoreboard /scoreboard objectives add Jump custom:jump

Now create a predicate JSON called "is_sprinting" with the following code:

{
    "condition": "minecraft:entity_properties",
    "entity": "this",
    "predicate": {
      "type": "minecraft:player",
      "flags": {
        "is_sprinting": true
      }
    }
  }

This predicate would output a true if the player is sprinting.

So collectively, you can use execute as @a[predicate=namespace:is_sprinting,scores={Jump=1}] at @s run tp @s ~ ~-0.65~ So that those who are jump sprinting would be teleported to the ground, shutting them from jumping. (They can still jump, but as if the gravity is tripled, and their jump sprinting is slower than just sprinting.)

However, "Jump" would increase by 1 every time you jump, therefore in your tick.mcfunction you must reset it at the end. execute as @a[scores={Jump=1..}] run scoreboard players reset @s Jump

0.65 is the optimum value for teleportation, and 0.7 would tp them underground which is not what you want.

I tried it out myself and it works, hoepfully it works for you as well.

5
  • Will try it out as soon as I get the chance!
    – Jeroen
    Commented Dec 20, 2021 at 3:40
  • Do you happen to also know if there is a way to detect players sprinting? That way we can only disable jumping while sprinting, and that would be the perfect solution!
    – Jeroen
    Commented Dec 20, 2021 at 18:35
  • 1
    As I have stated above, we can create a predicate containing the above code. The predicate is a boolean value and would output True shall the player sprint, which is a simple and fast and effective sprint detection.
    – hfanatic
    Commented Dec 21, 2021 at 6:56
  • Also, I don't think that the sprint jump speed boost can be completely removed but the method serves the sole purpose of reducing it as much as possible.
    – hfanatic
    Commented Dec 21, 2021 at 6:57
  • My bad, I skimmed over your comment the first time. Haven't had the chance to test it out myself yet, but a friend told me he got this to work, so I am accepting it as the answer. :)
    – Jeroen
    Commented Dec 21, 2021 at 8:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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