I need a way to detect a player crouching while flying with a set of elytras.
I want to create a custom set of wings with a special ability that refreshes every ten seconds for a custom elytra racing minigame that my friends and I can play. I want the trigger of this special effect to be the player holding shift. Is that possible?
All you have to do is create a scoreboard, and then test for any player that has held sneak!
To create the scoreboard type /scoreboard objectives add <OBJECTIVE_NAME> mincraft.custom:minecraft.sneak_time. Where it says "<OBJECTIVE NAME>" you can put anything there, like "elytrasneak" or anything else. This scoreboard will add a score of 1 every game tick (20 times a second, so it will add 20 "score"/second) to any player holding sneak. To test for a player you can use this command /execute if entity @a[scores={OBJECTIVE_NAME=1..} run <COMMAND>. This command will run any command you put in the "<COMMAND> part on players that have sneaked, pretty much at all. The ".." after the one just tests for any number 1 or greater on the scoreboard. If you are looking for a specific time sneaked, like 1 second, or 20 ticks, then you would just change the "1.." to "20".
If you have any more questions, or if you are still confused DM me or just reply here! Hope I could help!
EDIT: These commands will only work in 1.13+, if you are looking for older versions, I can give you those as well.
But that wouldn't only work for shifting while in the air flying with elytra. If you use that method then if a player sneaks on the ground it will trigger. If you add additional checks for if the player is flying, then it would still activate if they had previously shifted on the ground. Also, if the player held shift during the cooldown timer, then the effect would happen as soon as that cooldown timer ended if they had shifted long enough.
Edit: Also, that objective criteria isn't vanilla. What is it?
I got into chiptune music composition.
You can listen to them on my Youtube channel : https://www.youtube.com/channel/UCjWYbJGk7nvNDbnCvMlZGkw
Descriptions are in french, you'd just need some google translation copy-paste...
Also made some more or less complicated datapacks, shared here (planetminecraft).
But that wouldn't only work for shifting while in the air flying with elytra. If you use that method then if a player sneaks on the ground it will trigger. If you add additional checks for if the player is flying, then it would still activate if they had previously shifted on the ground. Also, if the player held shift during the cooldown timer, then the effect would happen as soon as that cooldown timer ended if they had shifted long enough.
Edit: Also, that objective criteria isn't vanilla. What is it?
The criteria is vanilla, I'm not sure what you mean. And I did test my method, and it will detect if you are sneaking while flying with an elytra. There are ways to make it so it only counts up when you are flying with an eltrya, but that would get slightly complicated, so I won't type out all the commands here, but you would use tags, and some other scoreboard objectives to detect this. You can also use tags for the cooldown timer. You might need an advanced knowledge of commands to do this, but it definitly can be done, especially in 1.13+.
The Meaning of Life, the Universe, and Everything.
Location:
Quebec
Join Date:
6/29/2014
Posts:
50
Minecraft:
Avarthar
Member Details
All that would be needed to allow the ability through flying only would be making a check for the block under the player.
If the block under the player is not air, then the other function would simply not run. (You could also make it check for the two (or the number you want) blocks under the player if you want to make sure he is in the air before he uses that. And then the hardest part would be to detect if the player has an elytra currently equiped.
(You can even put both conditions in the same command checking to make it run better and have only one command to change and only one scoreboard if using Mr_Moose_ method.)
I would post the commands (even if pretty simple or easily achievable through a few researches.), but I don't have access to my game currently ^^'.
Rollback Post to RevisionRollBack
Most of my replies are boring at best, but you cannot say I did not try. Just like this signature for example.
To check for the elytra equipped by adding this to the data tags that you're checking when executing the effect:
nbt={Inventory:[{Slot:102b,id:"minecraft:elytra"}]}
I got into chiptune music composition.
You can listen to them on my Youtube channel : https://www.youtube.com/channel/UCjWYbJGk7nvNDbnCvMlZGkw
Descriptions are in french, you'd just need some google translation copy-paste...
Also made some more or less complicated datapacks, shared here (planetminecraft).
I want to create a custom set of wings with a special ability that refreshes every ten seconds for a custom elytra racing minigame that my friends and I can play. I want the trigger of this special effect to be the player holding shift. Is that possible?
Lol I see "Custom set of wings"...
So just replace "execute as @a[scores={Sneak=1..},nbt={FallFlying:1b}] run say I sneak while flying!!!" by :
execute as @a[scores={Sneak=1..},nbt={FallFlying:1b,Inventory:[{Slot:102b,id:"minecraft:elytra",tag:{Powered:1}}]}] run say I sneak while flying!!!
It will only work if you have equipped an elytra with the "Powered:1" tag, which you can obtain with this command :
/give @a minecraft:elytra{Powered:1}
Rollback Post to RevisionRollBack
I got into chiptune music composition.
You can listen to them on my Youtube channel : https://www.youtube.com/channel/UCjWYbJGk7nvNDbnCvMlZGkw
Descriptions are in french, you'd just need some google translation copy-paste...
Also made some more or less complicated datapacks, shared here (planetminecraft).
I need a way to detect a player crouching while flying with a set of elytras.
I want to create a custom set of wings with a special ability that refreshes every ten seconds for a custom elytra racing minigame that my friends and I can play. I want the trigger of this special effect to be the player holding shift. Is that possible?
There does not seem to be any metadata the game could check to see if a player is sneaking, so in vanilla I do not think this would be possible.
Check out my mod! You can find it on CurseForge here:
https://www.curseforge.com/minecraft/mc-mods/the-spookjams-mod
This is quite easy actually!
All you have to do is create a scoreboard, and then test for any player that has held sneak!
To create the scoreboard type /scoreboard objectives add <OBJECTIVE_NAME> mincraft.custom:minecraft.sneak_time. Where it says "<OBJECTIVE NAME>" you can put anything there, like "elytrasneak" or anything else. This scoreboard will add a score of 1 every game tick (20 times a second, so it will add 20 "score"/second) to any player holding sneak. To test for a player you can use this command /execute if entity @a[scores={OBJECTIVE_NAME=1..} run <COMMAND>. This command will run any command you put in the "<COMMAND> part on players that have sneaked, pretty much at all. The ".." after the one just tests for any number 1 or greater on the scoreboard. If you are looking for a specific time sneaked, like 1 second, or 20 ticks, then you would just change the "1.." to "20".
If you have any more questions, or if you are still confused DM me or just reply here! Hope I could help!
EDIT: These commands will only work in 1.13+, if you are looking for older versions, I can give you those as well.
But that wouldn't only work for shifting while in the air flying with elytra. If you use that method then if a player sneaks on the ground it will trigger. If you add additional checks for if the player is flying, then it would still activate if they had previously shifted on the ground. Also, if the player held shift during the cooldown timer, then the effect would happen as soon as that cooldown timer ended if they had shifted long enough.
Edit: Also, that objective criteria isn't vanilla. What is it?
Check out my mod! You can find it on CurseForge here:
https://www.curseforge.com/minecraft/mc-mods/the-spookjams-mod
You only have to make an always-reset to the sneak objective : Put these events in order as a game loop :
-execute as @e[scores={sneakingscore=1..,elytraflyingscore=1..}] run [event]
-scoreboard players reset @a[scores={sneakingscore=1..}] sneakingscore
-scoreboard players reset @a[scores={elytraflyingscore=1..}] elytraflyingscore
I got into chiptune music composition.
You can listen to them on my Youtube channel :
https://www.youtube.com/channel/UCjWYbJGk7nvNDbnCvMlZGkw
Descriptions are in french, you'd just need some google translation copy-paste...
Also made some more or less complicated datapacks, shared here (planetminecraft).
The criteria is vanilla, I'm not sure what you mean. And I did test my method, and it will detect if you are sneaking while flying with an elytra. There are ways to make it so it only counts up when you are flying with an eltrya, but that would get slightly complicated, so I won't type out all the commands here, but you would use tags, and some other scoreboard objectives to detect this. You can also use tags for the cooldown timer. You might need an advanced knowledge of commands to do this, but it definitly can be done, especially in 1.13+.
All that would be needed to allow the ability through flying only would be making a check for the block under the player.
If the block under the player is not air, then the other function would simply not run. (You could also make it check for the two (or the number you want) blocks under the player if you want to make sure he is in the air before he uses that. And then the hardest part would be to detect if the player has an elytra currently equiped.
(You can even put both conditions in the same command checking to make it run better and have only one command to change and only one scoreboard if using Mr_Moose_ method.)
I would post the commands (even if pretty simple or easily achievable through a few researches.), but I don't have access to my game currently ^^'.
Most of my replies are boring at best, but you cannot say I did not try. Just like this signature for example.
To check for the elytra equipped by adding this to the data tags that you're checking when executing the effect:
nbt={Inventory:[{Slot:102b,id:"minecraft:elytra"}]}
Check out my mod! You can find it on CurseForge here:
https://www.curseforge.com/minecraft/mc-mods/the-spookjams-mod
Yeah but that's not the thing geoc1de is searching :
Anyway here's the answer, it's quite easy :
First, add a sneak objective :
/scoreboard objectives add Sneak minecraft.custom:minecraft.sneak_time
Then, run these 2 commands as tick loop, the first before the second (important!)
execute as @a[scores={Sneak=1..},nbt={FallFlying:1b}] run say I sneak while flying!!!
scoreboard players reset @a[scores={Sneak=1..}] Sneak
I got into chiptune music composition.
You can listen to them on my Youtube channel :
https://www.youtube.com/channel/UCjWYbJGk7nvNDbnCvMlZGkw
Descriptions are in french, you'd just need some google translation copy-paste...
Also made some more or less complicated datapacks, shared here (planetminecraft).
Lol I see "Custom set of wings"...
So just replace "execute as @a[scores={Sneak=1..},nbt={FallFlying:1b}] run say I sneak while flying!!!" by :
execute as @a[scores={Sneak=1..},nbt={FallFlying:1b,Inventory:[{Slot:102b,id:"minecraft:elytra",tag:{Powered:1}}]}] run say I sneak while flying!!!
It will only work if you have equipped an elytra with the "Powered:1" tag, which you can obtain with this command :
/give @a minecraft:elytra{Powered:1}
I got into chiptune music composition.
You can listen to them on my Youtube channel :
https://www.youtube.com/channel/UCjWYbJGk7nvNDbnCvMlZGkw
Descriptions are in french, you'd just need some google translation copy-paste...
Also made some more or less complicated datapacks, shared here (planetminecraft).
Did some testing around and got everything to work now, thanks