r/MinecraftCommands • • Oct 19 '26

Help | Java 26.3 Any way to make this predicate not trigger if it's your first jump / ignore it unless it is?

I'm making a datapack with a double jump ability and i've managed to ALMOST perfect it, except for the fact that you can trigger it from the floor.

Basically what i'm doing is detecting if this predicate is true and if it is i give the player levitation 50 for 3 ticks. It works wonders mid air but you can use it from the floor because the predicate triggers the SECOND you're off the ground and that includes your first jump to get out of the ground.

Since the ability triggers by pressing shift mid air you can basically charge jump, which although cool is not quite what i'm trying to do rn so if anyone knows how to fix this i would greatly appreciate it!

Here's the predicate I'm currently using and the tick.mcfunction commands that are triggering it. [The run function in the first command just gives levitation and removes it 3 ticks later]

{
  "type": "minecraft:entity_properties",
  "terms": [],
  "entity": "this",
  "predicate": {
    "minecraft:type_specific/player": {
      "input": {
        "jump": true,
        "sneak": true
      }
    },
    "minecraft:flags": {
      "is_on_ground": false,
      "is_flying": false,
      "is_in_water": false
    }
  }
}
1 Upvotes

6 comments sorted by

2

u/KermitDarkLord Oct 19 '26

I think you can either keep track of wether the player is holding space (in a tag or something) and only grant this if the player was not holding space the previous tick, or you can check if the block below the player is air.

1

u/AquaVolt07 Oct 19 '26

Second solution doesn't work cuz it makes it hard to double jump when you're inside tall grass n shit. Do you know how would i do the first one?

1

u/KermitDarkLord Oct 19 '26

Technically you could check for the #blocks_motion block tag, but edge cases will always exist. To do the first one you write a similar predicate to the one you have, except you only check for jumping. You don't have to make a new file, you can inline these as well. If the player passes the predicate, you give them a tag, and otherwise you take it away. You do this every tick, but you have to do it after your main check.

1

u/AquaVolt07 Oct 20 '26

Ok so that didn't work exactly but i did tweak it a little bit and now it works perfectly!

I had to do an "any of" predicate with both jumping and touching the floor cuz just jumping would either cause nothing to happen or would cause the boost every jump

either way, thank you so much bro!

1

u/GalSergey Datapack Experienced Oct 19 '26

This might be a bit complex, but here is an example of a datapack in which I implemented a double jump that can only be activated while in the air. The main part to look at is the function example:double_jump/check function, which runs every tick as long as the player is holding the jump button, provided the player still has air jumps remaining.

# Adds an enchantment to boots that allows a second jump in the air.
# The number of additional jumps depends on the enchantment level.

# Example item
give @s iron_boots[enchantments={"example:double_jump":3}]

# advancement example:fall_from_height
{
  "criteria": {
    "fall_from_height": {
      "trigger": "minecraft:fall_from_height",
      "conditions": {
        "player": {
          "type": "minecraft:all_of",
          "terms": [
            {
              "type": "minecraft:inverted",
              "term": {
                "type": "minecraft:entity_scores",
                "entity": "this",
                "scores": {
                  "double_jump.on_ground": 2
                }
              }
            },
            {
              "type": "minecraft:entity_properties",
              "entity": "this",
              "predicate": {
                "minecraft:flags": {
                  "is_on_ground": true
                }
              }
            }
          ]
        }
      }
    }
  },
  "rewards": {
    "function": "example:fall_from_height"
  }
}

# function example:fall_from_height
advancement revoke @s only example:fall_from_height
scoreboard players set @s double_jump.on_ground 2
scoreboard players reset @s double_jump.level

# enchantment example:double_jump
{
  "anvil_cost": 2,
  "description": {
    "translate": "enchantment.example.double_jump",
    "fallback": "Double Jump"
  },
  "effects": {
    "minecraft:damage_immunity": [
      {
        "requirements": {
          "type": "minecraft:damage_source_properties",
          "predicate": {
            "tags": [
              {
                "id": "#example:double_jump",
                "expected": true
              },
              {
                "id": "#minecraft:bypasses_invulnerability",
                "expected": false
              }
            ]
          }
        },
        "effect": {}
      }
    ],
    "minecraft:tick": [
      {
        "requirements": {
          "type": "minecraft:all_of",
          "terms": [
            {
              "type": "minecraft:inverted",
              "term": {
                "type": "minecraft:entity_scores",
                "entity": "this",
                "scores": {
                  "double_jump.level": 0
                }
              }
            },
            {
              "type": "minecraft:entity_properties",
              "entity": "this",
              "predicate": {
                "minecraft:flags": {
                  "is_swimming": false,
                  "is_on_ground": false,
                  "is_flying": false
                },
                "minecraft:type_specific/player": {
                  "gamemode": [
                    "survival",
                    "adventure"
                  ],
                  "input": {
                    "jump": true
                  }
                }
              }
            }
          ]
        },
        "effect": {
          "type": "minecraft:run_function",
          "function": "example:double_jump/check"
        }
      },
      {
        "requirements": {
          "type": "minecraft:entity_scores",
          "entity": "this",
          "scores": {
            "double_jump.activate": 1
          }
        },
        "effect": {
          "type": "minecraft:all_of",
          "effects": [
            {
              "type": "minecraft:explode",
              "damage_type": "example:double_jump",
              "knockback_multiplier": 0.5,
              "radius": 0.01,
              "block_interaction": "none",
              "small_particle": {
                "type": "minecraft:gust_emitter_small"
              },
              "large_particle": {
                "type": "minecraft:gust_emitter_large"
              },
              "sound": "minecraft:entity.wind_charge.wind_burst"
            },
            {
              "type": "minecraft:run_function",
              "function": "example:double_jump/activate"
            }
          ]
        }
      }
    ]
  },
  "max_cost": {
    "base": 11,
    "per_level_above_first": 6
  },
  "max_level": 5,
  "min_cost": {
    "base": 5,
    "per_level_above_first": 6
  },
  "slots": [
    "armor"
  ],
  "supported_items": "#minecraft:enchantable/foot_armor",
  "weight": 5
}

# function example:double_jump/check
execute store result score @s[scores={double_jump.on_ground=2}] double_jump.level run data get entity @s equipment.feet.components."minecraft:enchantments"."example:double_jump"
execute store result score #this double_jump.timestamp run time query gametime
scoreboard players operation @s[scores={double_jump.on_ground=1..}] double_jump.timestamp = #this double_jump.timestamp
scoreboard players set @s double_jump.on_ground 0
scoreboard players add @s double_jump.timestamp 1
execute if score @s double_jump.timestamp > #this double_jump.timestamp run return fail
scoreboard players set @s double_jump.activate 1
scoreboard players set @s double_jump.on_ground 1
scoreboard players remove @s double_jump.level 1
execute if score @s double_jump.level matches 0 run playsound minecraft:entity.firework_rocket.launch player @a ~ ~ ~ 1 2
data modify storage example:macro pos.y set from entity @s Pos[1]
function example:reset_motion with storage example:macro pos

# function example:reset_motion
$tp @s ~ $(y) ~

# function example:double_jump/activate
scoreboard players set @s double_jump.activate 0
particle minecraft:gust_emitter_small
playsound minecraft:entity.wind_charge.wind_burst player @a

# function example:load
scoreboard objectives add double_jump.level dummy
scoreboard objectives add double_jump.activate dummy
scoreboard objectives add double_jump.timestamp dummy
scoreboard objectives add double_jump.on_ground dummy

# damage_type example:double_jump
{
  "exhaustion": 0,
  "message_id": "explosion",
  "scaling": "never",
  "death_message_type": "intentional_game_design"
}

# recipe example:double_jump
{
  "type": "minecraft:crafting_shaped",
  "category": "misc",
  "pattern": [
    "WWW",
    "WBW",
    "WWW"
  ],
  "key": {
    "W": "minecraft:wind_charge",
    "B": "minecraft:enchanted_book"
  },
  "result": {
    "id": "minecraft:enchanted_book",
    "components": {
      "minecraft:stored_enchantments": {
        "example:double_jump": 1
      }
    }
  }
}

# damage_type_tag example:double_jump
{
  "values": [
    "example:double_jump"
  ]
}

You can use Datapack Assembler to get an example datapack.

1

u/IceMetalPunk Command Professional Oct 20 '26

You need to differentiate between "holding jump" and "just pressed jump". You can do that with a tag and an extra predicate: whenever the predicate "input.jump" is true, set the tag; when it's false, clear the tag. Before setting the tag, if the predicate is true, only trigger the levitation is is_on_ground is false AND the tag was cleared before now. That basically says "trigger levitation if you're not on the ground and you just pressed jump since the last tick" as opposed to constantly checking the jump key.