I had the idea to summon temporary armor stands at the 1st block in every row and then tp it through all all blocks in this row but i would have to use a command like
execute as @e[tag=temp] at @s if data entity @s Pos[1] < 10 run summon minecraft:armor_stand ~ ~1 ~ {Tags:["temp"]}
to summon it and this is not valid (i cannot test "if Pos[1] < 10", only "if Pos[1]").
[EDIT] I forgot to manage the tags: only the highest armor stand may have the tag "temp". [/EDIT]
Okay, here's the problem, in order to accomplish this, you're going to have to something I like to call "hard coding".
Essentially meaning, your going to have to calculate with precision each block in this 10 * 10 area without any shortcuts or simplified commands.
My best guess, is using the tp command to summon 10 armor stands with a custom tag relative to a homing armor stand using ^ ^ ^ instead of ~ ~ ~
Afterwards you target said custom tag and detect if sandstone is underneath, if so give an output that express that, if no kill the armor stand.
This is my best answer at the moment to help with your predicament. I will do some quick testing to see if I can give you some starter code to work with, or anything to help you visualize what I'm trying to explain.
Well if you're not sure about what hardcoding method you want, I definitely recommend using the following method, using a datapack.
If you want to get into hardcoding, datapacks are incredibly better than command blocks; first, because it can run a full process in one single tick, and second, because datapack commands are stored in text files.
If you are not familiar with datapacks, you might have to learn about that.
I learnt that as I looked at a silkspawner datapack's files :
You need a detecting function and an executing function.
Function "DETECTION" (run manualy)
/execute positioned #XYZ# if block stone ~ ~ ~ run function "EXECUTION"
***In this function, you have to put commands like this for EACH blocks coords in the area.
***this function is ran from an execute command, which means the commands in this function keep the /execute arguments, or in other words, it's like there was "/execute positioned #XYZ# if block ~ ~ ~ stone run" before each of them.
I added the "EXECUTION" function as you can add more commands with the armor stand summoning but if you only want this single command, you can put it instead of the /function commands in "DETECTION" function
More, it doesn't make any lag as most of the ran commands are unsuccessful detection
Rollback Post to RevisionRollBack
I got into chiptune music composition.
You can listen to them on my Youtube channel : https://www.youtube.com/channel/UCjWYbJGk7nvNDbnCvMlZGkw
Descriptions are in french, you'd just need some google translation copy-paste...
Also made some more or less complicated datapacks, shared here (planetminecraft).
... first, because it can run a full process in one single tick ...
As far as I know, chained command blocks work the same way. But of course a datapack is better for hardcoding.
My real summoning command is very long so I will keep the execution function although it will be a little bit slower.
But I still think my second idea(to summon 1 armor stand for each row, then tp it through the row, test all blocks and summon another armor stand for each positive tested block) in my first post is worth considering.
I can hardcode the positions for the first armor stands OR I store the y-value(Pos[1]) in a scoreboard objective (to be able to compare it to the max value). The same can be done for the tp-part.
I cannot test it at the moment but I will when I'm back home.
If you prefer to teleport the armor stand through all the area for testing the positions, of course it would probably need much less commands than the way I show you and could be done into a single tick as well using a function loop but I wonder about the FPS...
You could use aec instead of armor stand (well in fact, in this kind of system, it's always better to use aec); there're tons of videos proving armor stands are much laggier than aec.
I don't know about what you are exactly expecting for; I mean, if it's ran once in your project or happening in a player's waiting phase, then yes, using your method is perfectly fine.
As you saw, my detection function only works with "positioned" and not a single entity or score; when I tried it in the silkspawner datapack I took it from, The pack was running this kind of function in a 9x9x9 area around the player each tick as long as he was holding silk touch and it was not even laggy!
I don't know the size of your area, but it's definitely the best way if you want to minimize FPS loss
If you have a bit of programming skills, you could make a script for generating automaticaly the detection function; it could be possible (well personally, I copied the silkspawner pack's function and use some ctrl+h when I want to use that)
Well, for now, the question is "is FPS loss a problem or not?"
Rollback Post to RevisionRollBack
I got into chiptune music composition.
You can listen to them on my Youtube channel : https://www.youtube.com/channel/UCjWYbJGk7nvNDbnCvMlZGkw
Descriptions are in french, you'd just need some google translation copy-paste...
Also made some more or less complicated datapacks, shared here (planetminecraft).
I'm not sure yet how big the area is going to be, but it's definitely 2D. Maximum would be 190 blocks.
The problem is, it could have to be executed every tick and several other commands are executed at the same time.
All in all, I have come to the conclusion that your solution is the most lag-friendly and therefore the best. In addition, I can easily write a small program that does a lot of work for me.
Is there a way to dynamically summon armor stands for each e.g. sandstone block in an (2D-)area with air?
Something like this:
I had the idea to summon temporary armor stands at the 1st block in every row and then tp it through all all blocks in this row but i would have to use a command like
to summon it and this is not valid (i cannot test "if Pos[1] < 10", only "if Pos[1]").
[EDIT] I forgot to manage the tags: only the highest armor stand may have the tag "temp". [/EDIT]
Thank you in advance
Okay, here's the problem, in order to accomplish this, you're going to have to something I like to call "hard coding".
Essentially meaning, your going to have to calculate with precision each block in this 10 * 10 area without any shortcuts or simplified commands.
My best guess, is using the tp command to summon 10 armor stands with a custom tag relative to a homing armor stand using ^ ^ ^ instead of ~ ~ ~
Afterwards you target said custom tag and detect if sandstone is underneath, if so give an output that express that, if no kill the armor stand.
This is my best answer at the moment to help with your predicament. I will do some quick testing to see if I can give you some starter code to work with, or anything to help you visualize what I'm trying to explain.
If I hardcode it isn't dynamic xD
But if I have to, I can also hardcode the positions of the blocks instead of first summoning armor stands. I simply don't need them.
Second, it doesn't make sense to use ^ ^ ^. It is the same position as ~ ~ ~ and I only need the position.
The third thing is, if I really have to hardcode something I better choose the positions of the armor stands for my second idea.
I'm not sure if I got you right in everything, please tell me if not.
Well if you're not sure about what hardcoding method you want, I definitely recommend using the following method, using a datapack.
If you want to get into hardcoding, datapacks are incredibly better than command blocks; first, because it can run a full process in one single tick, and second, because datapack commands are stored in text files.
If you are not familiar with datapacks, you might have to learn about that.
I learnt that as I looked at a silkspawner datapack's files :
You need a detecting function and an executing function.
Function "DETECTION" (run manualy)
***In this function, you have to put commands like this for EACH blocks coords in the area.
Function "EXECUTION"
***this function is ran from an execute command, which means the commands in this function keep the /execute arguments, or in other words, it's like there was "/execute positioned #XYZ# if block ~ ~ ~ stone run" before each of them.
I added the "EXECUTION" function as you can add more commands with the armor stand summoning but if you only want this single command, you can put it instead of the /function commands in "DETECTION" function
More, it doesn't make any lag as most of the ran commands are unsuccessful detection
I got into chiptune music composition.
You can listen to them on my Youtube channel :
https://www.youtube.com/channel/UCjWYbJGk7nvNDbnCvMlZGkw
Descriptions are in french, you'd just need some google translation copy-paste...
Also made some more or less complicated datapacks, shared here (planetminecraft).
First, thank you very much for the idea to use a datapack!
As far as I know, chained command blocks work the same way. But of course a datapack is better for hardcoding.
My real summoning command is very long so I will keep the execution function although it will be a little bit slower.
But I still think my second idea(to summon 1 armor stand for each row, then tp it through the row, test all blocks and summon another armor stand for each positive tested block) in my first post is worth considering.
I can hardcode the positions for the first armor stands OR I store the y-value(Pos[1]) in a scoreboard objective (to be able to compare it to the max value). The same can be done for the tp-part.
I cannot test it at the moment but I will when I'm back home.
If you prefer to teleport the armor stand through all the area for testing the positions, of course it would probably need much less commands than the way I show you and could be done into a single tick as well using a function loop but I wonder about the FPS...
You could use aec instead of armor stand (well in fact, in this kind of system, it's always better to use aec); there're tons of videos proving armor stands are much laggier than aec.
I don't know about what you are exactly expecting for; I mean, if it's ran once in your project or happening in a player's waiting phase, then yes, using your method is perfectly fine.
As you saw, my detection function only works with "positioned" and not a single entity or score; when I tried it in the silkspawner datapack I took it from, The pack was running this kind of function in a 9x9x9 area around the player each tick as long as he was holding silk touch and it was not even laggy!
I don't know the size of your area, but it's definitely the best way if you want to minimize FPS loss
If you have a bit of programming skills, you could make a script for generating automaticaly the detection function; it could be possible (well personally, I copied the silkspawner pack's function and use some ctrl+h when I want to use that)
Well, for now, the question is "is FPS loss a problem or not?"
I got into chiptune music composition.
You can listen to them on my Youtube channel :
https://www.youtube.com/channel/UCjWYbJGk7nvNDbnCvMlZGkw
Descriptions are in french, you'd just need some google translation copy-paste...
Also made some more or less complicated datapacks, shared here (planetminecraft).
I'm not sure yet how big the area is going to be, but it's definitely 2D. Maximum would be 190 blocks.
The problem is, it could have to be executed every tick and several other commands are executed at the same time.
All in all, I have come to the conclusion that your solution is the most lag-friendly and therefore the best. In addition, I can easily write a small program that does a lot of work for me.
Thank you very much for your help!