Arqade Asked by DoomdiggerII on May 11, 2021
I’m interested in negating fall damage with command blocks by giving players Resistance as they’re falling. How can I use /testfor
to tell whether a player is on the ground or in the air?
Let's make an objective to track this, and call it 'ground'.
/scoreboard objectives add ground dummy
This command needs to be executed only once.
Then, on a fast clock, run
/scoreboard players set @a ground 1
and
/execute @a ~ ~ ~ detect ~ ~-1 ~ air scoreboard set @p ground 0
in that order.
The first command sets all player to 'being on the ground', and the second command sets those who are in the air to not be on the ground.
To affect players in the air, use @a[score_ground_min=0]
To affect players on the ground, use
@a[score_ground=1]
Answered by xornob on May 11, 2021
Try this:
testfor <player> {OnGround:1b}
Tests for specified player on the ground, then make a comparator to a NOT gate (Block with a redstone torch on it)
Answered by Light7 on May 11, 2021
testing if in air:
execute @a[parameters] ~ ~ ~ detect ~ ~-1 ~ air 0 <command>
testing if on ground:
scoreboard objectives add onGround dummy
scoreboard players set @a onGround 1 {onGround:1b}
execute @a[score_onGround_min=1] ~ ~ ~ <command>
scoreboard players set @a[score_onGround_min=1] onGround 1
Answered by Xefer on May 11, 2021
You only need 1 command: hook this up to a redstone clock:
/execute @a ~ ~ ~ detect ~ ~-3 ~ air 0 effect @p jump_boost 1 255 true
It gives them infinite jump boost whilst in the air which prevents fall damage (they can still take fire damage, wither, etc)
Answered by Guest on May 11, 2021
/execute at @a if block ~ ~-3 ~ air run effect give @a minecraft:slow_falling 1 1
I'm using this for 1.16.5 and it works in just one line (the effect can be different)
Answered by Shamwig on May 11, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP