2

Already found similar posts like (How to execute a command relative to an entity), but those are some years old already and very outdated, what would be the new way to use the execute command relative (e.g. slightly behind) an entity? I'd guess it something with at @s[z=.5] or using the positioned tag, but neither of those worked yet. This is what I would like to accomplish, so that only in the right get stop the run command when they are in range, not both on the right and the left.

entity and detection radius

This is the actual detection range, where it detects the armor stand behind an infront of it. new detection range

And this would be the new detection range, where it only stops my execute command, when theres an armor stand in front of it. New detection range

All in all what I need is a way to reposition the anchor of the distance=0.5..1 tag, so that it's not the entity itself but rather e.g. +0.5 in the z coordinate

3
  • What am I seeing in that image? The last sentence is pretty confusing. So you want to do something behind someone, no matter how they are rotated? – Fabian Röling Apr 8 '20 at 18:52
  • I don't really know what to search for for a good duplicate target, but maybe this helps: gaming.stackexchange.com/a/362486/171580 The solution is, if I guess your question correctly, "local coordinates": minecraft.gamepedia.com/Commands#Tilde_and_caret_notation Maybe positioned ^ ^ ^-.5? – Fabian Röling Apr 8 '20 at 19:07
  • I added some more pictures to show precisely what I mean. Couldn't explain it better, but I got 4 repeating command blocks for each direction n,s,w,e. That's why it doesn't matter how they are rotated. Only the anchor of the distance execution has to be repositioned slightly off. – DasNerdwork Apr 9 '20 at 12:40
2

You're probably looking for "local coordinates". /execute positioned ^ ^ ^-.5 moves the execution position half a block back.

9
  • I'll try that now and see if it works! Thank you – DasNerdwork Apr 9 '20 at 12:40
  • I tried execute positioned ^ ^ ^-.5 as @e[type=minecraft:armor_stand] unless entity @e[type=minecraft:armor_stand,distance=0.5..1] unless block ~ ~ ~-.4 minecraft:air if block ~-.4 ~ ~.4 minecraft:carved_pumpkin[facing=north] if block ~.4 ~ ~.4 minecraft:carved_pumpkin[facing=north] run tp ~ ~ ~-.1 but it didn't change anything. Shouldn't this work? Seems to me like I formatted something wrong, like a missing at @s – DasNerdwork Apr 9 '20 at 12:53
  • That is executed from a command block? Then you're trying to first go back 0.5 blocks from the view direction of the command block and I have no idea what that would even mean. You'll probably want something like "/execute as <something> at @s positioned ^ ^ ^-.5 <...>". You should also first see what this does by using a shorter command than that complex thing in your last comment. – Fabian Röling Apr 9 '20 at 16:22
  • Yeah right, what I meant was executing as the armor stand and detecting another armor stand in front of it. Tested it with the say command and it should work, but it doesn't. I don't really know why. If I remove a block, the armorstand stops teleporting because of the unless block ~ ~ ~-.4 minecraft:air, but if I place it again it should start teleporting again. A single armorstand works, but as soon as I use two, they stay. That's why I thought the problem is in the unless entity @e[type=minecraft:armor_stand,distance=0.5..1 so I tried to reposition the distance detection. – DasNerdwork Apr 9 '20 at 21:24
  • The full command looks like execute as @e[type=minecraft:armor_stand] at @s positioned ^ ^ ^-.5 unless entity @e[type=minecraft:armor_stand,distance=0.5..1] unless air block ahead, if pumpkin facing north below run tp ~ ~ ~-.1 but neither this, nor the tilde or anything else worked so far. As soon as they stop once, they keep standing still :( – DasNerdwork Apr 9 '20 at 21:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.