Hi I am trying to make my own Custom Crafting Dropper, I Need to testforblock
near the player to find a dropper with the ingredients.
I tried this:
execute @p[r=10] ~ ~ ~ /testforblock ~ ~ ~ dropper 1 {Items:[0:{Slot:0b,id:"minecraft:stone",Count:1b,Damage:0s,},1:{Slot:1b,id:"minecraft:stone",Count:1b,Damage:0s,},2:{Slot:2b,id:"minecraft:stone",Count:1b,Damage:0s,},3:{Slot:3b,id:"minecraft:stone",Count:1b,Damage:0s,},4:{Slot:4b,id:"minecraft:redstone_block",Count:1b,Damage:0s,},5:{Slot:5b,id:"minecraft:stone",Count:1b,Damage:0s,},6:{Slot:6b,id:"minecraft:stone",Count:1b,Damage:0s,},7:{Slot:7b,id:"minecraft:stone",Count:1b,Damage:0s,},8:{Slot:8b,id:"minecraft:stone",Count:1b,Damage:0s,},],id:"Dropper",Lock:"",}
But the command can't find the dropper.
My plan is that I will spawn a dropper from A villager named "Test" using
execute @e[name=Test] ~ ~ ~ /setblock ~ ~ ~ dropper
and then the villager will die
kill @e[name=Test]
The testforblock
will test if the ingredients are inside the dropper and I will clone the dropper with the results from the custom crafting and replace the dropper with The ingredients.
Best Answer
The problem is that your command is looking for a player within a radius of 10 of the command block, standing inside a dropper with specific items in it. That won't do.
In fact, it is quite difficult to detect the presence of a single, arbitrary block in the vicinity of the player. Luckily for you, your dropper is not arbitrary, but is created at the position of an entity (your villager)!
What you want to do is keep this villager alive. Let me back up a little. You want to use an armor stand instead, they are the gold standard for use as entity markers for commands, due to the
Marker
,NoGravity
andInvisible
tags.Now that you are using an armorstand, don't kill it, and use the following command to detect the dropper:
The armorstand serves to save arbitrary coordinates and execute from there, similar to how you create the dropper at an arbitrary place.
It doesn't really matter if the player is within 10 blocks, but if you really want to, you can daisy-chain execute commands
This will run the second execute (and everything beyond) only if the armorstand is within 10 blocks of any player.