So, mind helping me please? I need something like that but inversed. If zombie looks at player command happens, i tried inversing it but it didn''t work.
First off, thank you! These tutorials help tremendously for anyone trying to teach themselves how to make datapacks like myself. Secondly, I used this to make a sort of teleportation staff, to instantly tp the player to the block they're looking at, so if anyone is wondering what else this can be used for there are a lot of options
Seriously these type of RU-vidrs should at least be noticed for actually making us learn something and their effort on it. Thanks man I've watched a lot of your command block tutorials and other videos it really helps me 👌.
I was aware of raycasting but not the first method, which gave me an idea for something I was thinking for a few hours... After doing simple logic I came to the realization the distance written there (0.3 in the video) is actually detecting whether the target is in a range within(approximately) 180x degrees(where x is the distance) from your forward vector. Also supporting by Cloud Wolf saying that putting a value of 1 detects if it's in anywhere you're looking(not quite true due to changing FOV but is true to normal fov. Also not accurate on the Y axis). Using this method I managed to test if a target is visible to a specific player, by first running this command with a distance value of 1, and if true, running a raycast facing that target that stops upon a non-passable block to see if it the sight is clear. Just thought I'd point it out if anyone ever wants to use this idea
Great video, as a datapack developer I can see a lot of potential with raycasting, especially when wrapped within proper function protection. I've had this video saved to watch for a while, thanks for the info!
This only works on the nearest entity, and only on one entity at a time. You can make it work for multiple players and multiple entities with this command: execute as @e at @a anchored eyes facing entity @s eyes anchored feet positioned ^ ^ ^1 rotated as @p positioned ^ ^ ^-1 if entity @p[distance=..0.3] run effect give @s glowing 10 10 true This basically turns the calculation around, so it's not the player checking what singular entity they're looking at, but each entity is checking whether or not they're in a player's central vision. I wish there was a good way to do something about the angle being too narrow when near a player and too wide when far from a player, but I guess you'd just have to run it a couple of times with different distance ranges on the first @s, and vary how wide the angle is allowed to be. That could get pretty laggy pretty fast (this is already a little laggy I imagine, but it could be made better by just putting a distance limit on that first @s so it stops checking entities that are too far away)
At the cost of accuracy you can alternate between two look functions with a larger range for the selector arguments using distance parameters in only one of them, while the other only checks for air. It decreases the number of selector arguments used. Also, if you’re using effects, no one will notice if the effect goes on for a few extra game ticks to keep the look function calls spaced out longer and the calls lighter.
make a block face the player? i mean there r 4 directions u can just face the player use a 4d snap then give approximate /setblocks based on the rotation of it
You can make an armor stand wear a block. /summon armor_stand ~ ~ ~ {Invisible:1,ArmorItems:[{},{},{},{id:"minecraft:observer",Count:1}],HandItems:[{},{}]} Then add a repeating command block to make the armor stand look at you. /execute as @e[type=minecraft:armor_stand] at @s facing entity @p eyes run tp @s ~ ~ ~ ~ ~
@@hydra9070 i mean it just depends on ur system but u can always check if player's rotation is between certain ranges and then do a setblock based on that (it would b 4 checks/setblocks)
I watched this video a year ago, having no clue what any of this meant. Today after learning command blocks better, finally get how it works, and it is genius.
Thank you for the amazing tutorial! I have a question: If i use this command some blocks away from the command block it won't work, can you tell me why and how can I solve it? I tried to modify the distance but in that case the command activated also if I wasn't looking directly into the mob.
I’m getting back into map making after a long break and old world editors like MCEdit seem to not be working for the latest versions. Are there any editors that did even half of what MCEdit did? Also in your tutorials for data packs, I’m interested in how you would automate some of these processes, for example how would one convert an actual build in a Minecraft world into a structure for a data pack?
Teorik Redstone'cu like a structure file can be made with structure blocks as for Mc edit idk if any new things exist that y I made a nifty item structure saver datapack that lets u move super large structures between worlds
Hey I was confused when you could change the @e to any entity you want and does this work with custom mobs and if you can cand you send me the first command line in the description but just specifically for a sheep so I could edit it? also amazing videos you have helped me alot!
Hi I loved your video but that don't solve my problem. I just want run a command when a player of a team look at a player of an another team. i've try to change you command but i've failed. (/execute if entity @a[team=a] anchored eyes facing entity @a[team=b] eyes run say YES) sry for the fault i'm not english but i'm looking for a solution everywere.
not sure if this will be read but to fix the hitbox issue just run another adjacent command that detects for feet instead of eyes. kinda sucks you cant use both commands at once but it is what it is
can anyone explain why this doesn't work with a custom entity? (raycast method) summon zombie ~ ~ ~ {Silent:1b,DeathLootTable:"scp:empty",PersistenceRequired:1b,CanPickUpLoot:0b,Health:100f,IsBaby:0b,CanBreakDoors:0b,Tags:["scp_173"],CustomName:'{"text":"SCP-173","color":"yellow","italic":false}',ArmorItems:[{},{},{},{id:"minecraft:emerald",Count:1b,tag:{CustomModelData:173,peanut:1b}}],ArmorDropChances:[0.085F,0.085F,0.085F,-327.670F],Attributes:[{Name:"generic.max_health",Base:100},{Name:"generic.follow_range",Base:32},{Name:"generic.knockback_resistance",Base:0.8},{Name:"generic.movement_speed",Base:0.8},{Name:"generic.attack_damage",Base:100},{Name:"generic.attack_knockback",Base:0.1},{Name:"zombie.spawn_reinforcements",Base:0}]} all other mobs glow when looked at, except this one edit: nbt on a mob breaks it, is there a workaround?
If you added a youtube "super thanks" to your page, I would given you some moolah for this awesome tutorial. I don't do patreon stuff, but I do use google play credit cash.
hey is it possible to use the function technique but use say 7 chain command blocks instead of the function if you only want the range to be 7 blocks or less? great vid!
Purple Pumpkin no u can’t use raycasting in command blocks maybe u could try to hardcode it all but that would be a lot and a mess and u would b able to reach through walls
I know for the single command version, expanding the hitbox of the entity/block you wish to look at was addressed, for doing ray casting with the datapack version you made, which was much more accurate, how can you do a similar thing with that?
THIS IS AMAZING; I was hoping to ask you if this works on bedrock edition? and if not, would this work on a player and how would I make it so that when the player is looked at the player is frozen in position? pleas help me thank you!
Gonna tell you, i did not know how i could replace items in the containers for my data pack, so the item I want OUT of the game and replaced by another without millions of lines of commands, but ray helped me a ton, I just check for all the containers player looks at and if the container has that item I want to replace is being replaced immediately, before player can even see the change in the block Tho, it still sucks I need to check for one slot at the time, so just a chest need 27 lines for each slot
@@ToughDialga007 the item u can find with an array search and edit it’s .tag, .Count, and .id it would be more efficient that way too but u can only do 1 at a time
Hi! great video, but i need some help, is there any way to make the look line wider? Like make it so that it works if its even in view? I'm trying to make a mob that only moves when out of sight. Thanks in advance. EDIT: By the way, for the command block method, not the raycast.
U can first detect the entity then start at the player and face the entity (execute facing) and check positioned ^ ^ ^1 if block air repeatedly until u arrive at the entity and if there was all air then it’s tru but this method requires either slow tp approach to go dynamically along the line or 1 command for each possible distance the entity was. Ie my detect command was a range of 3 blocks if that’s true I know it’s around 3 blocks away so use my special command that does positioned ^ ^ ^1 3 times before it looks for the entity
Hello CloudWolf, Here is a request: There are 10 cows which have the scores 1 to 10, and there are 10 parrots which also have the scores 1 to 10, how do i teleport all the parrots to the cows with the same scores? (1->1, 2->2,...,10->10)
dan boyicac that’s my entity linker command/datapack/vid u just doe execute as @e at @s as @e if score @s id = @e[sort=nearest,limit=1] id run tp @s ~ ~ ~ also addd specification you @e for better effficiency
I tried this raycasting method for the first time, I had my own tick-based ones but not an instant one. I ran the exact same "hitbox" detection command... And it worked.. with an offset of a block. By the way the glow I can tell it goes over the hitbox accurately, but it detects it only when I look one block to the negative Z from them. I have no idea why... Even when I made it practically identical to yours it seems that it only detects a mob when I look one block to the negative Z from it
I dont understand anything in the command block section... so the command executes as the player at the eyes. but then facing entity... does that mean it executes at the entity's eyes? and then the anchored feet... what? so it anchores at my feet and moves 1 block infront of it... move what exactly? then it rotates to where my rotation is and then positioned ^ ^ ^-1?????? I dont get it...
It moves towards the entity then facing like the player it goes backwards. If doing those two things ends up close to the player then it is in the FOv specified. Ex: entity behind player. U move 1 block towards that entity. Then facing the way the player is u go backwards 1, this nets u 2 blocks behind the player (if the player faces opposite) which would not put u within the 0.6 blocks ex: entity direction looking at. Move towards it 1 block. Facing same direction, move backwards 1 block. U will be where u started which is at the player so ur in the distance selector
Okay I tried to use the datapack version to be accurate. But I don't want entities to glow, I want to teleport the player that looks at that entity to somewhere. So how do I change the selector in `execute as *@e*[dx=0] positioned ~-0.99 ~-0.99 ~-0.99 if entity @s[dx=0] run effect give @s glowing 1 1 true` this command from @e to the player that executes it? Probably Cloud Wolf won't see this
I know you said not to comment about this, but unfortunately I still don't get the closing thought. For a multiplayer setting, if /execute as @a at @s anchored eyes run function test:start is run every tick, won't every player have the 'this' tag? If so, how will each ray be able to distinguish which is their sender? Is this the wrong way to do it? Thanks!
Pi E as long Asu don’t do @a inside another sub function the game will need to play all subfunctions including the ray for each player 1 at a time in order so by the time player B starts raycasting player A already got the tag raycastedand removed the tag
i doubt you will see this, but how do you make it so the raycasting ignores blocks that you can still right click something through ex. mushrooms, vines, slabs, etc.?
damn I got the block version working, so satisfying too bad the conical nature of detection makes the long range accuracy drop edit: and the sensitivity value can't be smaller than 0.1 apparently
@@glezisbauk4732 idk, if it works in single player but not on a server it means ur messing something up inbetween cause i use this stuff all the time on my servers
I can't figure out how to use the raycasting in command blocks, could someone help me? I'm trying to make a lightning rod that summons lightning at the place where the player is looking