Arqade Asked by Reflexive on January 15, 2021
I’m creating a map where the player gets four pieces of wool ( Red Black Blue Green ) and I need it so if they place the block anywhere it will trigger a command block.
I have tried:
/testfor @a {SelectedItem:{id:minecraft:wool,Damage:14s}}
< I wanted to manipulate this but I had no idea how.
scoreboard objectives: the first thing I tried because I hoped there was a stat.blockplaced.wool:14
or something along those lines but i Had no luck.
/testforblocks
: So I am unsure of the way to use this. I would have hoped it was something like this: /testforblocks 1 1 1 -1 -1 -1 minecraft:wool 14
but no it didnt work that way. Instead it has this: /testforblocks x1 y1 z1 x2 y2 z2 x y z [mode]
which I believe I have to make a clone of the map and then it will testfor a block placed? I am unsure
/testforblock
: now this would probably work but it involves a lot of command blocks and when I tried to do it things started getting muddled up
Instead of wool I thought there might be a way to implement the sign clickevent tag into different kinds of swords but to no avail.
/execute @a ~ ~ ~ /testforblock
: I though of this and then realised it would still need a region
my other idea was to do this /testforblock <playername>[xd=,zd=,yd=]
but i dismissed that thought.
So I’ve tried to this by myself and nothing has really worked. The most promising is just making a bunch of testforblock
commands.
Edit
Just had a more promising idea of using armor stands with marker disabled to testforblock.
2nd Edit
Alright so I filled the area I need with no marker invisible armor stands. Then I used this command:
/execute @e[type=armor_stand] ~ ~ ~ /testforblock ~ ~ ~ minecraft:wool 14
I ran it in a repeating command block and got this error:
[12:55:37] Failed to execute ‘/testforblock ~ ~ ~ minecraft:wool 14’ as testfor
So new question: How do I fix this error?
There are a few ways to detect a certain block in an area:
If you just want to detect whether or not a certain block is inside an area and if you don't mind having the block destroyed, you can use this command:
/execute @a ~ ~ ~ fill ~-10 ~-10 ~-10 ~10 ~10 ~10 air 0 replace wool 14
You can detect the block placed using a comparator or a conditional chain command block.
If you, however, want to know where the block is placed and or keep the block, you can use this more complex approach.
/execute @a ~ ~ ~ fill ~-8 ~-8 ~-8 ~8 ~8 ~8 structure_void 0 keep
#Repeat this section for how many types of blocks you want to test for
/execute @a ~ ~ ~ fill ~-8 ~-8 ~-8 ~8 ~8 ~8 air 0 replace wool 11
/execute @a ~ ~ ~ fill ~-8 ~-8 ~-8 ~8 ~8 ~8 command_block 0 keep {auto:1,Command:"summon armor_stand ~ ~ ~ {Invisible:1,NoGravity:1,Marker:1,Tags:["wool11"]}"}
/execute @a ~ ~ ~ fill ~-8 ~-8 ~-8 ~8 ~8 ~8 air 0 replace wool 14
/execute @a ~ ~ ~ fill ~-8 ~-8 ~-8 ~8 ~8 ~8 command_block 0 keep {auto:1,Command:"summon armor_stand ~ ~ ~ {Invisible:1,NoGravity:1,Marker:1,Tags:["wool14"]}"}
...
/execute @a ~ ~ ~ fill ~-8 ~-8 ~-8 ~8 ~8 ~8 air 0 replace structure_void
/blockdata ~2 ~ ~ {auto:1}
/blockdata ~1 ~ ~ {auto:0}
[Impulse] /execute @a ~ ~ ~ fill ~-10 ~-10 ~-10 ~10 ~10 ~10 air replace command_block
/execute @e[type=armor_stand,tag=wool11] ~ ~ ~ say You placed blue wool!
/execute @e[type=armor_stand,tag=wool14] ~ ~ ~ say You placed red wool!
Correct answer by misoloo on January 15, 2021
We will be referring to three areas in this answer: A, B, and C, and using wool for this testing function:
When you want to activate the test function, /fill
area B with structure voids:
fill 10 10 10 19 19 19 minecraft:structure_void
Next, /clone
the volume tested with filtering set to the block type you want to test for:
clone 0 0 0 9 9 9 10 10 10 filtered minecraft:red_wool
Then perform /execute if blocks
with areas C and B, attempting to clone area C to area B.
execute if blocks 20 20 20 29 29 29 10 10 10 all
That command will pass if the blocks match, which means that no wool was there. It will fail if the blocks did not match, indicating that wool was not there.
Answered by SF. on January 15, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP