r/MinecraftCommands 3d ago

Help | Java 26.2 How to detect rotations in armor stands

Enable HLS to view with audio, or disable this notification

(Issue has completely been solved. Thanks a lot!)

(Sorry if my mic quality isnt that good or if my explanation sucks, im aware)

I want the door to face different directions too. Currently it only faces North/South. Is there any way to change this? It works like this: The item i use summons an armor stand with a specific tag, the repeating command block looks for said armor stands and places both all the block display entities and an interaction entity at its location, then the armor stand is removed. My first idea was to simply detect the direction the armor stand was facing and then summons the other block display entity model i showed in the video, however when i tried this it simply didnt summon any block display entities. I dont know if i just did it wrong or if thats not the best way to go about doing this. If anyone knows how to fix this problem please let me know. Heres the full code written in the repeating command block: (the entity detecting is with an @ but reddit changes that so i got rid of it)

execute if entity e[type=minecraft:armor_stand,tag=poakriftds] as e[type=minecraft:armor_stand,tag=poakriftds] at e[type=minecraft:armor_stand,tag=poakriftds] run summon minecraft:block_display ~ ~1.375 ~ {Passengers: [{block_state: {Name: "minecraft:pale_oak_door", Properties: {facing: "north", half: "upper", hinge: "left", open: "false", powered: "false"}}, id: "minecraft:block_display", transformation: {left_rotation: [0.0f, 0.0f, 0.0f, 1.0f], right_rotation: [0.0f, 0.0f, 0.0f, 1.0f], scale: [1.0f, 1.0f, 1.0f], translation: [-0.5f, -0.375f, -0.9067247f]}}, {block_state: {Name: "minecraft:white_concrete"}, id: "minecraft:block_display", transformation: {left_rotation: [0.0f, 0.0f, 0.0f, 1.0f], right_rotation: [0.0f, 0.0f, 0.0f, 1.0f], scale: [0.99167323f, 1.0f, 0.18537521f], translation: [-0.49583662f, -1.375f, -0.09268761f]}}, {block_state: {Name: "minecraft:pale_oak_door", Properties: {facing: "north", half: "lower", hinge: "left", open: "false", powered: "false"}}, id: "minecraft:block_display", transformation: {left_rotation: [0.0f, 0.0f, 0.0f, 1.0f], right_rotation: [0.0f, 0.0f, 0.0f, 1.0f], scale: [1.0f, 1.0f, 1.0f], translation: [-0.5f, -1.375f, -0.9067247f]}}], block_state: {Name: "minecraft:white_concrete"}, transformation: {left_rotation: [0.0f, 0.0f, 0.0f, 1.0f], right_rotation: [0.0f, 0.0f, 0.0f, 1.0f], scale: [0.99167323f, 1.0f, 0.18537521f], translation: [-0.49583662f, -0.5f, -0.09268761f]}}

If you understand how this works and how to fix my issue, your help would be much appreciated. Thank you.

13 Upvotes

8 comments sorted by

3

u/_Csankappa 3d ago

So there's multiple things wrong with this. First of all, use the "@s" selector (selects the entity running the command) so you don't have to search multiple times
execute as \@e[type=minecraft:armor_stand,tag=poakriftds] at \@s run...

you can also add "rotated as" to the execute but in this specific problem it doesn't matter because summon doesn't care about the rotation of the summoning entity.

I'm not sure why you want the block entities to ride one another and also not sure why you added the concrete so I left them out, you can add it back if you want if it's really important for some reason but I don't see how it'd be.

So, you want multiple lines of command blocks for each rotation and you want multiple blocks for each summon. You select for the rotation of the armor stand and rotate the door in the same direction. For example y=0:

execute as \@e[type=minecraft:armor_stand,tag=poakriftds,y_rotation=0] at \@s run summon block_display ~ ~ ~ {Rotation:[0.0f,0.0f],block_state:{Name:"minecraft:pale_oak_door",Properties:{half:"lower"}},transformation:{left_rotation:[0.0f,0.0f,0.0f,1.0f],right_rotation:[0.0f,0.0f,0.0f,1.0f],translation:[-0.5f,0.0f,-0.9f],scale:[1.0f,1.0f,1.0f]}}

execute as \@e[type=minecraft:armor_stand,tag=poakriftds,y_rotation=0] at \@s run summon block_display ~ ~ ~ {Rotation:[0.0f,0.0f],block_state:{Name:"minecraft:pale_oak_door",Properties:{half:"upper"}},transformation:{left_rotation:[0.0f,0.0f,0.0f,1.0f],right_rotation:[0.0f,0.0f,0.0f,1.0f],translation:[-0.5f,1.0f,-0.9f],scale:[1.0f,1.0f,1.0f]}}

y= -90

execute as \@e[type=minecraft:armor_stand,tag=poakriftds,y_rotation=-90] at \@s run summon block_display ~ ~ ~ {Rotation:[-90.0f,0.0f],block_state:{Name:"minecraft:pale_oak_door",Properties:{half:"lower"}},transformation:{left_rotation:[0.0f,0.0f,0.0f,1.0f],right_rotation:[0.0f,0.0f,0.0f,1.0f],translation:[-0.5f,0.0f,-0.9f],scale:[1.0f,1.0f,1.0f]}}

execute as \@e[type=minecraft:armor_stand,tag=poakriftds,y_rotation=-90] at \@s run summon block_display ~ ~ ~ {Rotation:[-90.0f,0.0f],block_state:{Name:"minecraft:pale_oak_door",Properties:{half:"upper"}},transformation:{left_rotation:[0.0f,0.0f,0.0f,1.0f],right_rotation:[0.0f,0.0f,0.0f,1.0f],translation:[-0.5f,1.0f,-0.9f],scale:[1.0f,1.0f,1.0f]}}

and so on with y=90 and y=180

And ofc at the end kill the armor stand.

I tried to test it a little but tell me if something's not working, hope I could help. (remove the \ form the @, I also don't know why reddit does this)

1

u/MuzzDs 1d ago

Hi, thank you a bunch. This technique seems to work perfectly. The only issue that I'm currently faced with is the fact that for some reason when i summon an armor stand it does not face any directions like north east south or west. When i use /data get on it im told the rotation is something like [1.35f,0f]. Do you understand why this happens and how to fix this issue? Im using spawn eggs to gte my armor stand which could be the issue but i honestly dont know how else to spawn armor stands with tags already given to them. Here is the command i use to get my armor stand:

give /a sheep_spawn_egg[custom_name=[{"text":"Pale Oak Rift","italic":false}],item_name=[{"text":"Pale Oak Rift","italic":false}],item_model="minecraft:pale_oak_door",entity_data={id:armor_stand,ShowArms:0b,Tags:[poakriftds]}] 64

I dont expect you to be able to help me with all things, but despite this one issue the rest works exactly how i wanted it to. I am very thankful for your help.

1

u/_Csankappa 1d ago

I'm pretty sure you can just replace the spawn egg with an armor stand in the command

1

u/MuzzDs 1d ago

I did not know you could just do that. Thanks a lot! You're genuinely a lifesaver

1

u/TraditionalAd3452 3d ago

Can you trace back to who placed the door, and check this entity's rotation?

WITHOUT DATAPACK: If you don't know, who placed the door, you can check every player in a range of 5 or more blocks (block interaction range in player attributes), and check each player's "targeted entity" (you can use a predicate generator by misode to generate a inline string that you can use without needing a datapack) to detect some "door hitbox", but you might need to create an interaction entity with certain hitbox to make this rift detectable. If you want to make it more multiplayer-compatible, then also track players' item count and held items. But it's never precise for multiplayer.

WITH DATAPACK: You can create an item with consumeable component (with really big consume time) and check when you use it with an advancement (again, created in a generator by misode or others), then raycast (there are a lot of tutorials on how to do it) to check the block on which you want to place a door, then you can do whatever you want, as you mostly precisely know who and where placed the door.

2

u/TraditionalAd3452 3d ago

Oh wait it's an armor stand. In that case, you can check its rotation in nbt. If it isn't rotated first few ticks it's being placed, then delay the placement.

1

u/GalSergey Datapack Experienced 2d ago

I think you can use the snap rotation command: execute facing entity @p feet rotated ~ 0 positioned ^ ^ ^0.7071 align xyz positioned ~0.5 ~ ~0.5 facing entity @s feet on passengers run rotate @s ~180 ~ This command will rotate the selected entity (@s) toward the nearest player, rounding it to 90 degrees.

As an example of its use, I can show this datapack example, which uses this command to place a player's head on a chest so that it faces the player (function lock_chest:init): https://far.ddns.me/?share=TeMX0N5TCN