#How can I replace all the same adjacent blocks from one ?
1 messages · Page 1 of 1 (latest)
<@&1201956957406109788>
💬 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
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
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 ?
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
It doesnt work
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
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
I didnt know how to do that aaaah
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
that doesnt work anymore
In what way?
that make this pattern :
Which one is the starting block?
the one I'm looking at
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
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
Ok, I think you're doing this all wrong
This function is the only place you need a positioned argument
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
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
?
Looks right at a glance
It make that :
That seems like what you want, yes?
nooo
I want to make a paint bucket tool like on Photoshop
So the issue here is it is not recurring beyond that + shape
yup
you forgot to add the macro conditions to your recursive call
In the place_block0 function
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
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