I’ve done my scouring of the forums and Google, but I can’t seem to find a solid solution for my problem.
To be clear, I am making a vanilla adventure map. The problem I’m trying to solve pretty much affects the entire map. I want to set up a dual-chain of command blocks to testfor the item in an item frame (this part is done), then I want the second chain to detect of the item placed in the item frame is NOT the required item.
I am fully aware that the second portion of my chain (where the problem exists) is simply polish, since I could achieve the desired function of removing the incorrect item separately, but it would really smooth out the entire process if I can make this work.
After doing some testing of my own, I have come up with a way to make it so that we don't need to use scoreboards!
I think that you should disable your current mechanic, to make way for this new one. I will be showing you both ways of doing this.
Note: Sorry this took so long, I had to compile all the images/gifs/etc...
Step 1:
The first thing that I did was create the item frame at -925 2 -574 in a brand new world. We need to know these coordinates to specify what item frame to place the tag onto later on in the process.
Step 2:
Next, we need to make sure that we can detect the item being placed into the item frame. For this example, I will be using a gold sword. We are going to put a testfor command into a repeating command block. The testfor command I will be using will look like this:
Now, when I place a golden sword in the item frame at -925 2 -574, the comparator turns on, seen below.
Step 3:
Okay, so now that we can test for when the item has been placed in the item frame, this is when the difficult part comes in.
After fiddling around for a while, I found a working redstone circuit that will give us our desired output. Here it is:
At first, this may look confusing. But let me explain.
Command Block 1 (Left):
This command is the same as the command we used in Step 2, which detects if a golden sword was placed into the item frame. If it returns true, then it will activate both the sticky piston and the redstone light. This redstone light means that we placed the correct item into the frame.
Command Block 2 (Right):
This command detects if any item has been placed into the frame, using a neat trick that I discovered while testing this solution. The command is as follows:
If the piston has not been extended, it will light up the right torch. this indicates that the item placed in the frame is not the correct one.
The only flaw that I can think of for this method is the 1 tick delay (1/20 of a second) when placing the correct item, and the 2 tick delay (1/10 of a second) when placing an incorrect item. I recommend placing the circuit far from the item frame, to avoid any noise. If the noise is really an issue that cannot be resolved, I will gladly show you an alternative.
Step 4:
That should be it! The only thing left to do is replace the redstone lights with whatever you want to do when the items are placed.
Final Notes:
If there is anything you need changed, or described better, I will gladly help you. If you want, I can provide a world download for the world shown in the screenshots. I hope this helped!
Also: You didn’t have to specify that you were testing for an item frame? All the syntax I’ve come across looks like this: /testfor @e[type=ItemFrame] {TileX:0,TileY:5,TileZ:1,Direction:2b,Item:{id:diamond_sword}}
Also: You didn’t have to specify that you were testing for an item frame? All the syntax I’ve come across looks like this: /testfor @e[type=ItemFrame] {TileX:0,TileY:5,TileZ:1,Direction:2b,Item:{id:diamond_sword}}
id:diamond_sword --> id:"minecraft:diamond_sword"
idk, this is an error? I immediately spotted this when I came acress this thread.
So, that diamond sword bit isn’t my code. It’s just an example of syntax I pulled off of some other thread. I get that there’s errors in it, but I’m more concerned with whether or not you have to specify that you are testing for an item frame.
Basically, the more compact the command can be, the better. I’m gonna be making close to 100 of these things and a good chunk of them will include named items.
Well, that would work if I wasn’t doing this in MCPE...But yea, I get what you mean. I’m not concerned about minor delays because I don’t foresee myself using this function in any tim-sensitive situations.
I’ve basically figured out the problem. What I was trying to do turned out to be NBT tags, which don’t work in Bedrock Edition. Thanks for all the replies though.
At the basic level, this works fine. The only problem is that I was trying to do this with an item frame and a named item, neither of which would work in Bedrock because they rely on NBT tags.
I'm guessing find out how to give yourself a named item in bedrock edition, then use that. I haven't used bedrock edition, but I'll give all the ideas I have.
I’ve done my scouring of the forums and Google, but I can’t seem to find a solid solution for my problem.
To be clear, I am making a vanilla adventure map. The problem I’m trying to solve pretty much affects the entire map. I want to set up a dual-chain of command blocks to testfor the item in an item frame (this part is done), then I want the second chain to detect of the item placed in the item frame is NOT the required item.
I am fully aware that the second portion of my chain (where the problem exists) is simply polish, since I could achieve the desired function of removing the incorrect item separately, but it would really smooth out the entire process if I can make this work.
Here's an idea:
Have a scoreboard tag added to the item frame that does match the requirements. Then, use:
Note: The ! means not.
This will detect if it does not match the requirements. If you need me to go into further detail, I will gladly do that!
~Spiralio
Spiralio,
I understand the “!” argument, but am woefully inexperienced with scoreboards. I would be very grateful for a quick rundown.
Thank you!
~Reaper67
After doing some testing of my own, I have come up with a way to make it so that we don't need to use scoreboards!
I think that you should disable your current mechanic, to make way for this new one. I will be showing you both ways of doing this.
Note: Sorry this took so long, I had to compile all the images/gifs/etc...
Step 1:
The first thing that I did was create the item frame at -925 2 -574 in a brand new world. We need to know these coordinates to specify what item frame to place the tag onto later on in the process.
Step 2:
Next, we need to make sure that we can detect the item being placed into the item frame. For this example, I will be using a gold sword. We are going to put a testfor command into a repeating command block. The testfor command I will be using will look like this:
Now, when I place a golden sword in the item frame at -925 2 -574, the comparator turns on, seen below.
Step 3:
Okay, so now that we can test for when the item has been placed in the item frame, this is when the difficult part comes in.
After fiddling around for a while, I found a working redstone circuit that will give us our desired output. Here it is:
At first, this may look confusing. But let me explain.
Command Block 1 (Left):
This command is the same as the command we used in Step 2, which detects if a golden sword was placed into the item frame. If it returns true, then it will activate both the sticky piston and the redstone light. This redstone light means that we placed the correct item into the frame.
Command Block 2 (Right):
This command detects if any item has been placed into the frame, using a neat trick that I discovered while testing this solution. The command is as follows:
If the piston has not been extended, it will light up the right torch. this indicates that the item placed in the frame is not the correct one.
The only flaw that I can think of for this method is the 1 tick delay (1/20 of a second) when placing the correct item, and the 2 tick delay (1/10 of a second) when placing an incorrect item. I recommend placing the circuit far from the item frame, to avoid any noise. If the noise is really an issue that cannot be resolved, I will gladly show you an alternative.
Step 4:
That should be it! The only thing left to do is replace the redstone lights with whatever you want to do when the items are placed.
Final Notes:
If there is anything you need changed, or described better, I will gladly help you. If you want, I can provide a world download for the world shown in the screenshots. I hope this helped!
~Spiralio
So, if I’m getting this right, replacing the lamps with additional command blocks should create an if/else system based on the item frame?
Also: You didn’t have to specify that you were testing for an item frame? All the syntax I’ve come across looks like this: /testfor @e[type=ItemFrame] {TileX:0,TileY:5,TileZ:1,Direction:2b,Item:{id:diamond_sword}}
id:diamond_sword --> id:"minecraft:diamond_sword"
idk, this is an error? I immediately spotted this when I came acress this thread.
So, that diamond sword bit isn’t my code. It’s just an example of syntax I pulled off of some other thread. I get that there’s errors in it, but I’m more concerned with whether or not you have to specify that you are testing for an item frame.
Basically, the more compact the command can be, the better. I’m gonna be making close to 100 of these things and a good chunk of them will include named items.
Well, that would work if I wasn’t doing this in MCPE...But yea, I get what you mean. I’m not concerned about minor delays because I don’t foresee myself using this function in any tim-sensitive situations.
That doesn't matter in these circumstances
It should after 1.12.
Whatever, what's the issue now again?
I’ve basically figured out the problem. What I was trying to do turned out to be NBT tags, which don’t work in Bedrock Edition. Thanks for all the replies though.
You can take a comparator output from a command block to check if it did its command. Just lead that into a torch and do something with it.
At the basic level, this works fine. The only problem is that I was trying to do this with an item frame and a named item, neither of which would work in Bedrock because they rely on NBT tags.
I'm guessing find out how to give yourself a named item in bedrock edition, then use that. I haven't used bedrock edition, but I'll give all the ideas I have.