How to use Interaction Entities in Minecraft
HTML-код
- Опубликовано: 26 авг 2024
- A quick tutorial on how to use interaction entities using both command blocks and datapacks.
Command Blocks:
execute as @e[type=interaction] on attacker run say left
execute as @e[type=interaction] on target run say right
bonus
execute as @e[type=interaction] if data entity @s attack run say I was left clicked
execute as @e[type=interaction] if data entity @s interaction run say I was right clicked
execute as @e[type=interaction] run data remove entity @s attack
execute as @e[type=interaction] run data remove entity @s interaction
Latest Version (1.19.4)
📦 Download: www.dropbox.co...
🔵 Discord & Other Links: linktr.ee/Clou...
💻 Website: cloudwolfyt.gi...
This will be actually incredible for creating minigames in minecraft, considering the size of it can be fully customized. Great addition to 1.20!
It's actually 1.19.4, so even sooner than 1.20 people can use it
@@trashcaster well thats fantastic
To get the entity that got clicked in command block, you can do :
execute as @e[type=minecraft:interaction,distance=..6] at @s on attacker as @e[type=minecraft:interaction,distance=...1] run ...
Yeah u can do it by moving positioning around but I prefer the method with less @e selectors especially since u can optionally maintain the player and the entity’s location and selection at all times
@@Cl0udWolf Of course ^^ It's just the shortest way with the command blocks 👍🏻
@@SozoKa sort of, tho with command blocks u can just do execute as @e[type=interactor] if data entity @s attack run ...
@@Cl0udWolf bruh 😭😂
Just a heads-up, you're able to completely skip searching for which interaction entity was interacted with by using a predicate. use "entity properties" and check that the nbt is equal to "{interaction:{}}" for right clicks and "{attack:{}}" for left clicks. Then, in the code that runs after getting the advancement, start it with
"execute at @s as @n[type=minecraft:interaction,predicate={name of your predicate}] run tag @s add interaction"
Now, you will only need to check the entity that has the tag "interaction" and it will be the one you interacted with (Just make sure to remove the tag at the end of the function)
crazy that we're both in the comment section of a video a year old at roughly the same time lmao
i dont fully understand what youre saying here though. what would the code be in the predicate?
@@fullwoodenshovelfromminecr2365 I recommend using Misode's predicate generator. It shows you all the things you can do in a predicate.
For this one, you need to set the predicate to "entity properties" (it should be this by default, otherwise it's the drop-down next to "single"). One of the text boxes under it will be for nbt, and that's where you need to put {interaction{}}. Basically, this will make the predicate true as long as the interaction entity has any interaction data at all. Just make sure the function that checks for this also runs a data remove command to delete the interaction data
@@fullwoodenshovelfromminecr2365 if you still care, in a datapack you can create a condition known as a predicate which is a type of .json file that goes in a predicate folder. so that code is a condition that gets checked when a command asks for it.
So in his case he is using an advancement that triggers a function that follows:
"execute at @s" to make sure that function happens on the activating player's position
"as @n" to target the nearest entity that fits the criteria in brackets
"[type=minecraft:interaction, predicate={predicate name}]" this makes sure that only an entity that is an interaction entity, AND has a predicate defined in the predicate folder of a datapack that passes its check (in this case it is looking for an entity that has the data of {interaction:{}}) and followed up by the resto of the command to do whatever you want to that entity.
Alternately you could use a similar command "execute as @s as @n[type=minecraft:interaction, nbt={interaction:{}}]" the issue with this is that if there are a LOT of interactions nearby it has to check all their nbt data until it finds the correct one. to even further bring down the range of testable entities (if you plan on using a lot) you may want to try using "execute as @s positioned ^ ^ ^3 as @n[type=minecraft:interaction, nbt={interaction:{}},distance=..6]" this puts the location of command at 3 blocks in front of you, and only checks interactions within 6 blocks of that.
I'm personally planning to use this in an adventure map I'm working on where I have stuff like force field generators to smash and multi-button control consoles to interact with, this is all very exciting stuff.
You're a legend, thanks for all these useful video's
This makes a lot of sense. Thank you!
also, I personally would use scoreboards for this one where in tick function I would save the attack/interaction into a scoreboard, and when no one touches it, it is blank, after attack/interaction, the scoreboard value will go to 1
that seems both less efficient and more complicated
@@Cl0udWolf I guess since it is just like how you would use carrot on a stick for click detection except the score is in the interaction entity and not the player
but I wish they can just add click detection that's something like this:
/execute as @a if entity @s click right run ...
Thanks for your contribution. I think it is very helpful for my inspiration when coding things in MC
the command block placing is mad sus
🤨
Nah bro you're just weird
5:40 Found a good use of the new return command here! Instead of having all subsequent commands run from an if statement or making a whole new function for them, you can just say the following and then all code thereafter can run freely as the clicked interaction
_execute if score __#bool__ test matches 0 run return 0_
I’m using this for my tardis. I’m on my 8th iteration with this one going to be the most advanced since the vanity of the tardis will look spectacular with item frames with maps and making survival friendly. I’m using this for the door function where it’ll detect if the player who is trying to open the door has a tardis key before opening the door if they have a key
Got to start playing MC again, this might be usefull in combination with display items for in-game shop rooms
Can we also add tags to these hitboxes so that way when we have multiple, we can tell the command to remove data of the hitboxes with only that tag?
they are still entities, so yes of course we can add tags to them
Perhaps using this in conjunction with the bypass would allow for 20Hz left click detection?
Imagine you have three of this interaction entities, how i can make them do different commands? Like first one to run say comand, second one to run playsound and etc.
Use tags
Noice
Hey CloudWolf , im wondering if theres an easy toggle for something like this (like im left clicking once and it shows an message and left clicking again it will delete the message) , do i need to make this with an scorebaord or is there an other better way? And can i define the player (without the advancement) that clicked the interaction and tp it to somewhere?
is there a way to do it on entities such as frogs
the interaction entity is just not working at all, for me the commands do not work and clicking on the interaction entity doesn't do anything. Even with the chain command blocks the interaction entity does not work. Do you know what to do?
I am trying to find a way to give a player special powers while wearing different trims... this feels like the way to go, but it's tricky because the entity blocks you from attacking or interacting with anything behind it. So, you can't have it floating in front of you at all times. I could put it at the very end of your reach, so you can interact with things between you and it, but then you wouldn't be able to use these powers in tight spaces... hmm...
use like clickable items or sneaking or something
@CloudWolfMinecraft yeah, maybe, but I'm trying to get it to work without gating it behind holding items. Sorta breaks immersion.
I might make these powers only work if you have an empty hand. That way it won't interfere with shooting a bow or swinging a sword, but you can attack and interact with this entity floating on top of your head any time you're not holding anything. And if you want to mine dirt and don't have a shovel, just mine it with more dirt, or your pickaxe or something.
Idk, I'm still brainstorming this. I think it can work, I just gotta be clever about it!
1.19.4 is live!! ^^
What causes the interaction entity to not be viable on a per-tick basis? Does it have some sort of cooldown?
same as with carrot on a stick, it is rate limited to 5Hz unless u spam click it with ur mouse, then it can be up to 20Hz but that is even worse behavior to me
@@Cl0udWolf oh, so the problem is with continuously holding the button?
@@antekacki8753 yes but i would argue having inconsistent is worse than if it were consistently slow for most cases. also it blocks all other interactions both left and right
i made a separate video explaining why it is not a good click detection method for most cases
Hey can you please do a tutorial explaining and teaching us how to use the block interaction entities? Lots of cool values but what do they all mean
This is interaction entity
@@Cl0udWolf Interestingly if you have the interaction width to 100 and height to 100 it wont detect right click to that range.
@@Cl0udWolf but he's saying about block display I think
Genius :)
Hi, can I translate your video for my auditory
So i have a situation where I have two interaction entites, and when i hold a specific item in my offhand and right click something happens, but I only want it to work with one interaction entity, how would I do that?
U can’t. Interaction entities r hierarchical and cannot be ignored. The closest to the player while being in reach and clicked on will trigger
@@Cl0udWolf so then could i make it so that if others interact with it, nothing happens? Like if the don't have a certain tag when they click on it nothing happens
@@bloosix no. i made a separate video explaining why the interaction entity is not a click detection entity
@@Cl0udWolf Alr, thank you. You've been very helpful so i appreciate it
Question, rn I am making a kit pvp thing and I want to be able to detect when a player left clicks while still being able to attack other players
cant with this or any method
@@Cl0udWolf oh ok, dang it why can’t they just add a left click and right click scoreboard objective
ayo that command block shape kinda sus
bro said sus
Hi, is there any way to specify which interaction I'm attacking? for example by putting "type":"minecraft:interaction", [tag]
yes
@@Sakupenny how?
@@benjaminnicro8775 just summon a interaction with a tag then put @e[type=interaction, tag=the tag you added to the interaction]
Hi Cloud Wolf. I want to get a player with the same name as an armour stand's name. Is it possible to do that?
it could be possible but it would be not very efficient and finding a better way to accomplish a similar task would be ideal
Does this work on bedrock on nintendo switch
bro made a pen** 💀
bruh
I bet they are not adding this to bedrock😢