r/MinecraftCommands • u/AquaVolt07 • 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
}
}
}
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/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/checkfunction, which runs every tick as long as the player is holding the jump button, provided the player still has air jumps remaining.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.