0

Ok, I've tried many variants of /testforcommand and tried them in the lastest snapshot, 15w31c, to 1.8.6 and nothing works AT ALL.

The list of commands I've tried:

  • /testfor @p {Inventory:[{id:"minecraft:iron_­sword"}]}
  • /testfor @p {Inventory:[{Slot:0b,id:"minecraft:­iron_sword"}]}
  • /testfor @p {SelectedItemSlot:0,Inventory:[{Slot:0b,id:"minecraft:iron_sword"}]­}
  • /testfor @p {Inventory:[{tag:{display:{Name:"Iron_Sword"}}}]}
  • And more but I can't remember them due to the frustration

The idea I'm trying to get at is you have a special book when right-clicked it'll spawn two items. One of them you must have on the second hand, in 15w31c, at all time that will interact with whatever weapon of your choosing, Swords, Axes, and Bow & Arrows. The second item is just a book so no real need for it to be forced on right now. I know I have to use /testfor for the book, second hand item, and weapons, but like I said nothing is working.

11
  • Tried the first one, it worked....but remove the quotes from "minecraft:iron_sword" – ydobonebi Aug 4 '15 at 2:44
  • Second one works, remove quotes, when sword in slot 1 (0b) and since 2 of 2 work, I'll stop there unless you are still having issues. – ydobonebi Aug 4 '15 at 2:46
  • Nothing but the same thing but only this ---> My name did not match the required data structure – Jordan Ramirez Aug 4 '15 at 3:14
  • I had the sword in slot 1, it worked, when it wasn't I got that. That means it failed detection. Which slot are you testing? – ydobonebi Aug 4 '15 at 3:19
  • 0 for the time being – Jordan Ramirez Aug 4 '15 at 3:43
1

Tested the first 2 commands. Removing the quotes from minecraft:iron_sword and places a space after @p produces expected results.

enter image description here/testfor @p {Inventory:[{id:minecraft:ironsword}]}


enter image description here/testfor @p {Inventory:[{slot:0b,id:minecraft:iron_sword}]}


enter image description hereSame as above, but sword in wrong slot


In the first two examples, if you had those in a command block with a comparator attached, the comparator would output a 1 redstone strength. The last example would not output any redstone strength.

7
  • Yes, I blurred out my gamer tag...sorry I don't want people to know it on here :) – ydobonebi Aug 4 '15 at 4:56
  • Don't even need to remove the quotation marks; the commands OP gave should be working. – SirBenet Aug 4 '15 at 13:56
  • @colorfusion I agree you shouldn't have to, but I got different results each way. I can't explain why. – ydobonebi Aug 4 '15 at 15:45
  • Worked fine for me with and without the quotes. Makes it easier to read IMO (and will work with tools that use stricter JSON parsing), but it's mainly a matter of preference. – SirBenet Aug 4 '15 at 16:08
  • @colorfusion well, opinion is opinion, for me it takes up more characters (and there is a limit) and it's less readable to me. It breaks the continuity of the context to which it's being applied and makes it seem disjunctive. But hey, you know what they say about opinions? Just like assholes, everybody has one. – ydobonebi Aug 4 '15 at 16:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.