#How can I replace all the same adjacent blocks from one ?

1 messages · Page 1 of 1 (latest)

ocean charm
#

How can I replace all the same adjacent blocks from one ? Like I have the coords of an iron ore block and I would to replace all the vein by red concrete. Like a recursive thing. In application Its not a too big replacing thing (around 640 blocks max)

scarlet hawkBOT
#

<@&1201956957406109788>

Someone will come and help soon!

💬 While you wait, take this time to provide more context and details.

🙇 If nobody has answered you by <t:1732663221:t>, feel free to use the Summon Helpers button to ping our helper team.

✅ Once your question has been resolved (or you no longer need it), please click Resolve Question or run /resolve

buoyant wind
#

Well as you said, it would be recursive.

Starting from wherever the starting block is, you would execute a function in each of the six directions with execute positioned ... if that block is the desired block. The function that gets run would be that same function, which will then run at each of the new positions, and so on

ocean charm
# buoyant wind Well as you said, it would be recursive. Starting from wherever the starting bl...

so something like this ? :

start :

function pictionary:raycast_bucket/recursive

1st function :

execute positioned ~ ~ ~ if block ~ ~ ~1 <same block has the first one> run function pictionary:raycast_bucket/place_block
execute positioned ~ ~ ~ if block ~ ~ ~-1 <same block has the first one> run function pictionary:raycast_bucket/place_block
execute positioned ~ ~ ~ if block ~ ~1 ~ <same block has the first one> run function pictionary:raycast_bucket/place_block
execute positioned ~ ~ ~ if block ~ ~-1 ~ <same block has the first one> run function pictionary:raycast_bucket/place_block

2nd function :

setblock ~ ~ ~ <block I want>
function pictionary:raycast_bucket/recursive
#

but it doesnt work...

#

why ?

buoyant wind
#

You're not changing the position

#

You're checking the block in each direction, but your positioned arguments aren't doing anything

#

Swap the tilde coordinates of your positioned and if block arguments

ocean charm
#

I made this :

#

start

function pictionary:raycast_bucket/recursive

to this

$execute if block ~ ~ ~ $(block) positioned ~ ~ ~ run function pictionary:raycast_bucket/place_block0 with storage minecraft:settings paint
$execute if block ~ ~ ~ $(block) positioned ~ ~ ~1 run function pictionary:raycast_bucket/place_block1 with storage minecraft:settings paint
$execute if block ~ ~ ~ $(block) positioned ~ ~ ~-1 run function pictionary:raycast_bucket/place_block2 with storage minecraft:settings paint
$execute if block ~ ~ ~ $(block) positioned ~ ~1 ~ run function pictionary:raycast_bucket/place_block3 with storage minecraft:settings paint
$execute if block ~ ~ ~ $(block) positioned ~ ~-1 ~ run function pictionary:raycast_bucket/place_block4 with storage minecraft:settings paint

to this (edited 5 times for each pos (up down left right and on place))

$setblock ~ ~ ~ $(color)[type=double]
execute positioned ~ ~ ~1 run function pictionary:raycast_bucket/recursive
buoyant wind
#

You switched too much

#

execute positioned ~ ~ ~1 if block ~ ~ ~ ...

ocean charm
#

just switch the coords ?

#

of the first try

buoyant wind
#

Do what I just demonstrated

#

You need to put the position change first, then check the block at that new position

#

What you're currently doing is just checking the block at the current position, then changing the position, which isn't what you want

ocean charm
ocean charm
# buoyant wind `execute positioned ~ ~ ~1 if block ~ ~ ~ ...`

Like this ? :

$execute positioned ~ ~ ~1 if block ~ ~ ~ $(block) run function pictionary:raycast_bucket/place_block1 with storage minecraft:settings paint
$execute positioned ~ ~ ~-1 if block ~ ~ ~ $(block) run function pictionary:raycast_bucket/place_block2 with storage minecraft:settings paint
$execute positioned ~ ~1 ~ if block ~ ~ ~ $(block) run function pictionary:raycast_bucket/place_block3 with storage minecraft:settings paint
$execute positioned ~ ~-1 ~ if block ~ ~ ~ $(block) run function pictionary:raycast_bucket/place_block4 with storage minecraft:settings paint


buoyant wind
#

You just... You just write the command how I did

#

Yes, there you go

ocean charm
#

that doesnt work anymore

buoyant wind
#

In what way?

ocean charm
#

that make this pattern :

buoyant wind
#

Which one is the starting block?

ocean charm
#

the one I'm looking at

buoyant wind
#

Doesn't make any sense

#

The coordinates you have in the function you shared don't corroborate that, so either you haven't tested with this new updated function correctly, or something is wrong somewhere else

ocean charm
#

I edit some things

#

Here each coordinates

$setblock ~ ~ ~ $(color)[type=double]
execute positioned ~ ~ ~ run function pictionary:raycast_bucket/recursive
$setblock ~ ~ ~ $(color)[type=double]
execute positioned ~ ~ ~1 run function pictionary:raycast_bucket/recursive
$setblock ~ ~ ~ $(color)[type=double]
execute positioned ~ ~ ~-1 run function pictionary:raycast_bucket/recursive
$setblock ~ ~ ~ $(color)[type=double]
execute positioned ~ ~1 ~ run function pictionary:raycast_bucket/recursive
$setblock ~ ~ ~ $(color)[type=double]
execute positioned ~ ~-1 ~ run function pictionary:raycast_bucket/recursive
buoyant wind
#

I don't understand what these are or are for

#

They're all different functions?

ocean charm
#

for each directions

buoyant wind
#

Ok, I think you're doing this all wrong

buoyant wind
#

Each of those lines will all run the same function, which just sets the block, and then runs the first function again

#

No extra positioned argument

ocean charm
# buoyant wind Each of those lines will all run *the same* function, which just sets the block,...

Like that :

$execute positioned ~ ~ ~ if block ~ ~ ~ $(block) run function pictionary:raycast_bucket/place_block0 with storage minecraft:settings paint
$execute positioned ~ ~ ~1 if block ~ ~ ~ $(block) run function pictionary:raycast_bucket/place_block0 with storage minecraft:settings paint
$execute positioned ~ ~ ~-1 if block ~ ~ ~ $(block) run function pictionary:raycast_bucket/place_block0 with storage minecraft:settings paint
$execute positioned ~ ~1 ~ if block ~ ~ ~ $(block) run function pictionary:raycast_bucket/place_block0 with storage minecraft:settings paint
$execute positioned ~ ~-1 ~ if block ~ ~ ~ $(block) run function pictionary:raycast_bucket/place_block0 with storage minecraft:settings paint

and that :

$setblock ~ ~ ~ $(color)[type=double]
function pictionary:raycast_bucket/recursive

?

buoyant wind
#

Looks right at a glance

ocean charm
buoyant wind
#

That seems like what you want, yes?

ocean charm
#

nooo

buoyant wind
#

...

#

Ok, then explain what you want to happen

ocean charm
#

I want to make a paint bucket tool like on Photoshop

buoyant wind
#

So the issue here is it is not recurring beyond that + shape

ocean charm
#

yup

raven vector
#

you forgot to add the macro conditions to your recursive call

buoyant wind
#

In the place_block0 function

ocean charm
#

DAAAAMN

#

It works

#

perfectly

#

thanks all

scarlet hawkBOT
# ocean charm thanks all
🎗️ Is your question resolved?

If your question is resolved, that's great to hear! Make sure to run /resolve or click the Resolve Question button. Otherwise, feel free to continue asking for help! :D

scarlet hawkBOT
# ocean charm It works
🎗️ Is your question resolved?

If your question is resolved, that's great to hear! Make sure to run /resolve or click the Resolve Question button. Otherwise, feel free to continue asking for help! :D