Minecraft /execute if PREDICATE [1.19] Command Tutorial
Вставка
- Опубліковано 10 лют 2025
- Learn how to use predicates in this Minecraft predicate tutorial for 1.19/1.18/1.17/1.16. If you've ever wondered what /execute if predicate is, then this video is for you! Predicates are a more advanced datapack feature that let you detect very specific things. It could be the answer to How to detect light levels, y level, NBT tags, or even how to detect rain! Predicates are a super useful part of any datapack or command block project!
Predicate generator: misode.github....
My datapack tutorial: • How to Make a Datapack...
Predicate list: minecraft.game...
===l o n k s===
My Discord Server [ / discord ]
My Twitch [ / legitimoose ]
My Editor [ / ciara_millinery ]
Italian captions provided by KooriKitsune38!
In this Minecraft predicate tutorial, you'll learn how to use predicates in Minecraft, and how predicates work in datapacks (data packs) and how to detect things in Minecraft 1.16! People always ask how to detect people falling into the void in bedwars, and this is one way to do it! Predicates are super useful to detect light levels, detect rain, detect when a player is sneaking, or detect items in hand. There are so many different uses, and when used in combination with other execute subcommands like /execute if score, and /execute in general, you can do some great things! Predicates are a relatively recent addition to Minecraft, and this tutorial is completely up to date in Minecraft 1.16 (and 1.17!)
Great videos, thank you. Wondering if its possible to use predicates to compare two entities. For example to see if a player is within a cube area around a named armorstand. Not using spherical range but rather see if the player is within a cube volume. I see the location with min and max values but not sure if they can be applied in game in this way.
Hmm, it's certainly an interesting idea! I don't _think_ you could, but I also couldn't completely rule it out without trying. If you find out that it's possible in some way, let me know!
@@Legitimoose well here you go.. predicate is as follows. you can change the distance range to whatever. Below the predicate definition is an example call to it.
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"distance": {
"x": {
"min": 0,
"max": 10
},
"y": {
"min": 0,
"max": 10
},
"z": {
"min": 0,
"max": 10
}
}
}
}
in my world I use an armorstand at spawn to hold many variables as scores and tags. so this example calls the distance check from me the player to that armorstand called "variables"
execute as @p at @e[name=variables] if predicate sbox:cubedistance run say nearby
@@GameMaker04 YOOOO WHAT I honestly didn't know quite how distance would work but that makes so much sense now that I see it! That is actually awesome, thank you.
EDIT: pinned because i think people might find this useful, and I totally glossed over it in the video!
you could use the dx selector
@@Coco-vz6eb and the dy and dz
Reminder for anyone coding in 1.21+ : The file he named "predicates" in the video must now be renamed to "predicate" and the same must be done with the "functions" file, renaming it to "function". Just a format change they made recently. Also the pack format number for 1.21.3 is "48" while the pack format number for the new 1.21.4 is "61".
LIFE SAVER
I spent half an hour trying to figure out why my predicate didn't show up and even Minecraft Wiki says it's supposed to be "predicates". THANK YOU SO MUCH!!
I hate this change from mojang, every time i deside to make a datapack i always spend like 15 minutes just figuring out how this thing is named on this version
man, I wish I knew about this before I made a billion scoreboards...
Same
F 😔
At least you know now ; )
Same
Same…
just found your channel a few days ago and subscribed right away. Great content/personality and i love that someone else out there covers commands/data packs (something i’ve wanted to get into!)
Welcome aboard!
Because I was bored, i did the math at 5:30.
from what was on the screen, he showed 7 samples. {9,8,8,6,7,10,10}
add the array and you get 58.
then you get the average: 58/7 = 8.2857
divide the average from the total number of players: 8.2857/16 = ~0.51
so to anyone who asked the question of "Is it really a 50/50 chance?"
Yes, yes is.
the hero we need, but not the one we deserve.
thanks for the high quality comment lmao
Witchcraft language
LETS GOOO HOMESTUCKFAN GOT THE MOST (tied with colonel sand, hotdog and eggnog)
Bro, realized you're only 4k, you deserve way more than that
Thanks! I'm gettin' there >;)
4 months later HE HAS 4x MORE SUBSCRIBERS
@@degamersspelen6468 ikr
@@degamersspelen6468 bro I would think he has 379k subs
3 years ago the only commands i knew were /gamemode 1
same
3 years ago I didnt know about commands
now im a command PRO
Man I'm binge watching your videos.. i, as a programmer, love this kind of stuff.. and not knowing Java I'm grateful that I can just use commands blocks so thank you:)
For those that would like to know. When it comes to the performance of NBT selectors vs predicates in @a selectors. Predicates are up to 10x faster than going nbt={...}, so if you need to check NBT of a player predicates are the best option for selectors
What about @e?
@@elrtohruhvd same thing, @a is pretty much just @e[type=player]
I didn't realize how useful predicate was until now, feel blessed.
Same
MY GOD THIS IS GAME CHANGING THANK YOU!!!
Thank you SO much, not that anyone asked I’m making an origins-inspired realm for me and my friends to play on! I have made several origins already with just command blocks but I got stuck with detecting if a player on a certain team was below y = 0 and giving said player a certain effect. I can comfortably say that this tutorial has given me the knowledge required to finish my Warden Origin! Many many thanks and a happy new years!
This video and that predicate generator just changed how I do commands FOREVER!! You are amazing, your videos are real helpful!
THANK YUO FOR UPLOADING!!! YOU HAVE HELPED ME SO MUCH
You're welcome! :D
Finally someone who calls it Jason rather than jay s ON
Of course ;^)
Wanted to say thank you, using your videos I managed to create my own simple datapack for what I wanted to do. They were interesting, entertaining and very informative.
Thanks ! Your videos are really helpful ! I will try to make a security system to alert a player if another player enters a restricted area
Whenever im trying to work out complex command stuff i know legitimoose has got my back! Thanks man, ill try figure this out haha
I want to say thank you for making this tutorial and explaining how all this works, I've been trying to randomize some attributes for certain mobs and this video helped clear up how I can go about doing that.
this video saved me so so SO much trouble for my cool little JJK world im planning on working on for java
If any of you are starting to go through the comments, wondering why in the world it isn't working for you on 1.21, don't worry I have your solution. Minecraft changed the folder naming conventions for data packs in 1.21 for some reason, so instead of naming your folders "functions" or "predicates", don't make it plural. The path should be .../predicate/detect_sneak.json.
as always, amazing video! one day you'll get to 100k and probably even 1mil!
Dude honestly u are so underrated like u should at least have 1mil subs u are fun to hear and ur tutorials are amazing like making me just happy to hear u are honestly the best youtuber I’ve ever seen think Iam kidding no literally u I love u
:O thanks so much! I'm glad you like them!
@@Legitimoose omg u replied Iam gonna cry thank u so much!
@@Legitimoose wow I saw what I typed and wow English XD
@@justchillaxe2750 language is hard i cant judge ;)
@@Legitimoose Ye true lol
Dude, amazing video. Just incredible. Like for real, some of the best videos on this platform. Amazingly well put together, well edited, and funny.
Thanks so much! I'm glad you appreciate what I'm doin here ;^)
I needed this
same
@@Elm0oo it's a miracle!
lol its the first comment
Hello there, first of all: this video was very helpfull. The only thing I can't find anywhere is how to use the position predicate (so when someone stand at a certain position, a block spawns for example). I know it's been a very a long time since you posted this video, but it's worth a try :)
Thx man me and my best friend are making a channel to teach people how to make command weapons and command item battles with my best friend and I'll put credits on some of the videos of you
ohhhh i miss the old wiki. please bring it back!
This is awesome and super useful !!!!
I have Been looking since a long time that how did I select player's on a wide area this helped me a lot 😊
Dude your channel is so good
thanks! :D
this dude is an absolute legend
Love your channel!
I was using two command blocks to test for sneaking, now I can use one 🤯
FINALLY, I already feel I will spam this
Thx for the tutorial :D
You're welcome!
This one is very helpfull!
The vid is 8 minutes long you commented 51 minutes ago and the vid was posted 52 minutes ago
@Chicken Nugget I guess you’re right lol
@Chicken Nugget that is the reason haha
Super Helpful ❤❤
I hope you make more minecraft tutorial
that DTL music gives me life
"When should you use a predicate, well, when you want to do something only a predicate can do", yeah, no shit sherlock, that's why I'm watching.
Love your videos though, I watch the tutorials over again for fun that's how good they are.
Another truly epic video
Useful video. Question. Did you do any videos on tags. Not the tag command. That's different. What I mean is that minecraft has tags for things like beds. #minecraft:beds is a json file that has a list of the different kinds of beds. I can then use the clear command to clear all beds from the inventory, for instance, by using that tag. They can also be used in crafting recipes. Like the crafting recipe for making a crafting table uses a tag to refer to any type of plank. That works fine for any tags already built into minecraft. But can I create my own tags for lets say concrete powder? I tried it, and the game ignores any tag I try to create. Is it impossible to add my own tags? Or am I just doing wrong? What folder do they need to be stored in, etc. And I noticed a replace true or false option in some of them. I have no clue what that means or why one might use it. I have already done some work with resource packs and datapacks. But I'm still a bit of newbie at both.
thx u legit mouse
>:(
@@Legitimoose XD
exactly what I needed, thank you
This man needs a million subs
omfg how did i lived without knowing the random one, ITS SO FUCKING COOL WTF
Merry Christmas!!!
This is a legendary Command ✌️👌
Im barely 2 minutes in and this already useful
the first part would have been useful a few months ago
5:50 ARE YOU SERIOUS
I LITERALLY NEEDED THIS INFO like a few days ago, guess im gonna re write it
please remember me when you get famous 😰 JK, good video, too hi of IQ speech for me but it has a good vibe to it.
i wil neva forget u 😘
How to check item in water to change into another item? you so great at explain I love it!
i came here for the command tech knowledge
i left after vibing to the drawn to life OST for 8 minutes and 19 seconds
Create a tutorial java tutorial? Pleaseeee, like how u making a buckit plugins for u streamer tournament?
Thank you polaroid with beachy waves
Thanks fort the tutorial
All we need now is to have a simpler way to make custom crafting recipes using command blocks in the crafting table, then command blocks will be more popular than datapacks and mods
Thanks keep up the great work. You are so under-subbed.
Thanks :D
Hey Legitimoose, I was wondering if you could make a tutorial about enemy aggro and stuff about making mobs attack each other of a specific player, as it would make a great video idea AND it would help me in my medium scale project, in which mobs fight alongside players for victory, there being 2-4 teams!
If you read this message, you should know that your videos have such high quality and entertainment that you are my favorite Minecraft coding UA-camr!
simply perfect
I am trying to make a data pack where you can hear birds but I want more complex like different birds for each biome and different times of day but how would I do that?
I wish I had a way to find all these fancy background songs you use like a link to a doc or a spot in the description with the titles
that's a good idea i should do that eventually. my background music is a trade secret but it must be shared
THANK YOU
Fundy: Literally makes you trip when you walk and spits out your inventory
Hello LegitMoose, i have a question. Can i do commands or trigers with mentions, example: "trigger ban (set) Gamer1337", i just don't want to use cheats on our server with friends and only some of commands will be working. Also i've come up with idea that every played gets theyr own tags, and when you type trigger ban, list of player comes up in a chat by tags, when you click on player, well, it bans them. Sorry for bad english, i'm russian
Hi! You can't use mentions like you said (the general term is "arguments") and you also can't run ban, or op commands from a command block or datapack sadly. I do think this is possible though! You'd just have to come up with another way to choose players (@p, or setting a scoreboard or something). I think your idea with the tags could be possible in some form too! If you have any more questions feel free to ask! (and your english is good!)
@@Legitimoose i was kinda predicting that, i thought there would be some kind of "not straight" answer like we are doing custom commands with trigger, but thx for double aprouving. I really hope they add custom commands in datapacks in json, like custom crafting recepie. Thx for your tutorials, i was interested in datapacks and i started learning. When i wrote some "code" i saw that you can write predicate after execute, i didn't bother until this tutorial came out, they actually make everything easier. Your tutorials are the best, everyone quiting datapacks or just bad at explaining, but you're making everything fun and easy to understand. Thx man, subscribe, bell and like! Keep making them, i would like to see things i don't know.
hello i am now a notification in your phone hello moose
You sound like Wilbur Soot. Anyway, I'm a new subscriber! Yey!
Haha that's a new one. Welcome aboard! I _do_ like wilbur, but most people say I sound like technoblade ;^)
drawn to life 2 music :)
you are the best
Hey, I had a question:
I'm looking at making a hide and seek minigame and was looking for the format for detecting a tag in NBT for a predicate. Would appreciate since I can't seem to work it out or find it anywhere. Would even go so far as to appreciate a video on NBT, NBT paths, and editing NBT in the future if you'd be interested in that as well. Thanks for the tutorials man!
"Ive been legitimoose..."
then who is the new legitimoose...
legitermoose
@@Legitimoose :0
Great video. I'm looking to use the /execute command to try and add airships to the game - sort of like Archimedes Ships but way, way less sophisticated. Any ideas on how I might be able to do this using, say, retextured donkeys with levitation/slow falling effects?
Love the content! I seem to be having an issue with detecting lore on an item with the predicate file, any suggestions?
hey nice video! Can you make a video about /tag? That would be awesome
Thanks for the idea! It's goin' on the list!
@@Legitimoose Yes! Ive been waiting for that for so long. Thx for the reply, truly awesome
@@Legitimoose Can you also do one where a Predicate triggers when a entity (e.g. an egg) hits another entity (e.g. a villager)
When will /data command arrive
Cause if you explain it I might be able to understand it more / Also Merry Christmas (Eve) depending on your time zone
Bro really just called JSON files difficult to write smh my head
Nah but in all seriousness thanks. This was a really helpful tutorial!
U da man
Edit:do u know stuff about bedrock edition?
Question: Could you detect something such as whether a player is holding the right-click button or something like that?
Yes
@@deathdanger076 how?
@@zasharan2 with scoreboards, you can detect if a player is using a carrot on a stick. Give that a custom texture and make it unbreakable.. voila
is there a way for if i hit an entity with an item it aplies a potion effect?
life saver
5:40 I always used command like
/execute at @a positioned ~ 0 ~ run tp @a[dx=0,dz=0,dy=59] 0 0 0
for y level check
Everyone: *Watchin The Video*
Me: "HE SPELLED /SCOREBOARD WRONG IN THE BACKGROUND"
1:58 where is that music from? Is it Chocobo Tales? It feels super familiar
If I wanted to check, for example, if a player shot a an arrow (which i could check with a scoreboard) AND they are holding a certain item, how would i do that?
How do you make randomization like a dice? For example if you wanted a 33% chance to get nausea, a 33% chance to get levitation, and a 33% chance to get jump boost, how would you do it? I think the normal method would treat those independently, and would have a chance of none of them happening, or multiple of them happening at the same time.
please remember me when u get famous
Hola buenas ¿Podrías dar un ejemplo de un predicate que detecte cuando un jugador entra a un mundo por primera ves?
Hey legitermoose could you make a custom advancement tutorial? I have been looking for one on youtube but I can't seem to find one, and its very confusing
I love you
Nice video and thank you! Also can you send me a link with the npc mod? i cant find it.
These videos have been so imformitive! Thank you. Okay, so I know this video is old, but is it possible for a predicate to be an nbt? I'm trying to create my own nametag Easter egg, like giving an entity a certain name causes something else to happen, ie Jeb_ makes a sheep's wool fade between colors. I'm new to making datapacks so yeah. My logic is that once the nbt "CustomName" is set to a certain name it'll change the nbt "CollarColor" to a certain color. I've done my best to put that in a regular function, but couldn't get it to work. There's a space for nbts in the predicate generator but when I copied the code into the .json file it didn't have correct syntax. It's obvious I don't know what I'm doing lol, so any help would be appreciated.
i need 2 things
buildable structure (portal or certain block placed) that will run special command that will be activated if player nearby. for example if build cube 9x9 of diamonds it will kill any players in distance 9.
other thing is only underground nether portals. is it possible to prevent them from spawning higher than 60. and working higher than 60?
Can you do right click detection with any item? Some ppl won’t be able to install the server resource pack so everyone walking around with carrots on a stick would look weird. I had this idea with invisible armorstands floating in front of the player and detecting if an item was given do some stuff and give it back but I had no idea how to execute it.
Too bad I'm challenging myself to build a bossfight without using data packs, I'm starting to go crazy now
Hello Mr. LegitiMoose, how would I detect a specific entity getting hit by another specific entity? How would I use the "direct_entity" under (damage types) predicate for this if I could? Thanks a million. Happy Holidays!
Nice video! One question, would it be theoretically be possible with this command to check if a player has a certain potion effect on him? I'm playing on a server with different teams who all should have different potion effects that obviously get lost when they die. So would it be possible to give them the effect back if they don't have it?
Yes, it would absolutely be possible. Potion effects are stored as NBT data on the player, so you could detect it like that! I think that it would be easier however, if you added the effect constantly (every tick or something), then they would get it as soon as they respawn. It wouldn't be as _optimized_ but I don't think it would be any worse than the alternative. Good luck with whichever way you choose!
@@Legitimoose thank you very much! I'll be testing this out, but since we run a modded server I might rather go for the more optimized version.
I’m fairly new to using commands/command blocks. If I want to test out a wither skeleton farm in a creative world before building it in survival and I need to spawn proof the fortress with pressure plates, can a predicate help me with that? I basically need to test nether bricks to see if they have an air block above them, and if so, replace the air with a pressure plate. Nothing I’ve tried has worked yet, and using
/fill x y z x y z minecraft:stone_pressure_plate replace minecraft:air
just leaves big stacks of pressure plates everywhere that shouldn’t be possible. I’m completely stumped but I really don’t want to manually place pressure plates in a 256x256 area to spawn proof it all.
im a bit late, but you could do /fill sand on the top of the farm and then do /fill stone_pressure_plate replace sand, no need for predicates
if you want to detect the y lvl there is much better way to do that the way is:@e[y=-1,dy=60] and
hotdog had like 80% win rate
challenge: Make A In-Game Event like The Single Command Block of the world Destroying Creating Chaos And An Epic Black Hole Appears And Swoops The Players In It Going To Another Dimention meeting A Boss Then Defeating It Then Returning To Its Static State, I know That Sounds Crazy But It Worths A While
and needs EPIC Music ,(and can get u some subs :) )
I have a question that's not really related to this, but is it possible to set nbt values based on players? For example, if I do
/summon armor_stand ~ ~ ~ {Team:playerTeam}
is there some way to make it so that the team that the armor stand joins is the same team the player executing the command is on?
Hi! It should totally be possible! If team is stored as NBT on the player, then you could copy it over using /execute store (which is a bit too complicated for me to type out from memory here) but I bet it can be done! Look into /execute store if you haven't already, and good luck!
@@Legitimoose ok, thank you so much!