• Hey! Register here to create your account, engage with the community, and talk about what is new!

How to replace a type of block in an area

OliveIncarnate

New member
Joined
Aug 15, 2023
Messages
2
Reaction score
1
So basically what I’m wondering is if there’s a way to with code select an area of block but only replace block A (basically the //replace command but only with code).
 
Solution
You can achieve the thing by:
First, Repeating On Grid using the Repeat codeblock (prismarine block), inside its chest put a Variable (preferably a LOCAL one), that variable will be the current block location, and put the 2 corners inside the chest. Then between the Sticky Pistons, place an If Game: Block Equals (If Game should be a Red Nether Brick), inside its chest, put your Variable in the first slot (as the location parameter), and put your blocks that you want to replace in the rest of the chest (you can put an air Text if you want to replace air), now between the If Game's pistons, just place a Game Action: Set Region (I recommend Set Region rather than Set Block because it doesn't do any block updates, therefor consumes...

ARMcPro

Forum adept
Overlord
Joined
Oct 20, 2020
Messages
1,263
Reaction score
353
You can achieve the thing by:
First, Repeating On Grid using the Repeat codeblock (prismarine block), inside its chest put a Variable (preferably a LOCAL one), that variable will be the current block location, and put the 2 corners inside the chest. Then between the Sticky Pistons, place an If Game: Block Equals (If Game should be a Red Nether Brick), inside its chest, put your Variable in the first slot (as the location parameter), and put your blocks that you want to replace in the rest of the chest (you can put an air Text if you want to replace air), now between the If Game's pistons, just place a Game Action: Set Region (I recommend Set Region rather than Set Block because it doesn't do any block updates, therefor consumes less CPU), and inside its chest put the same Variable twice (in the 1st and 2nd slot) and put your block in the 3rd slot and you should be done!
 
Solution

OliveIncarnate

New member
Joined
Aug 15, 2023
Messages
2
Reaction score
1
You can achieve the thing by:
First, Repeating On Grid using the Repeat codeblock (prismarine block), inside its chest put a Variable (preferably a LOCAL one), that variable will be the current block location, and put the 2 corners inside the chest. Then between the Sticky Pistons, place an If Game: Block Equals (If Game should be a Red Nether Brick), inside its chest, put your Variable in the first slot (as the location parameter), and put your blocks that you want to replace in the rest of the chest (you can put an air Text if you want to replace air), now between the If Game's pistons, just place a Game Action: Set Region (I recommend Set Region rather than Set Block because it doesn't do any block updates, therefor consumes less CPU), and inside its chest put the same Variable twice (in the 1st and 2nd slot) and put your block in the 3rd slot and you should be done!
That worked Thx.
 
Top Bottom