1

Data Parsing Error...

momma_jibi's Avatar momma_jibi9/19/15 12:07 pm
10/8/2015 2:12 am
momma_jibi's Avatar momma_jibi
Hello! This is hopefully the first of many posts here. I am in the midst of creating a horror/adventure map (also my first), and am having trouble with the command block to testfor a player holding an item, which I then would like to have an effect once the item is held, but I figured I'd make sure it could be found first before writing an even longer code.

Here's my code: testfor @a {SelectedItem:[id:{"minecraft:torch 1 0"}]}

And here's the output I get: [09:02] Data tag parsing failed: Unable to locate name/value separator for string: "minecraft:torch 1 0"

I've tried taking away brackets, adding brackets, adding numbers, adding the item number, etc and it keeps giving me the same message or saying the code is wrong. So what am I doing/not doing here?
Posted by momma_jibi's Avatar
momma_jibi
Level 30 : Artisan Architect
22

Create an account or sign in to comment.

18

1
10/08/2015 2:12 am
Level 30 : Artisan Architect
momma_jibi
momma_jibi's Avatar
Thanks! I will give it a try soon and let you know!
1
10/03/2015 11:32 pm
Level 33 : Artisan Engineer
Jmal116
Jmal116's Avatar
JB1110Okay...One more thing and then I promise I'm done asking about the flashlight. I've gotten all of that to work and I've managed to add a beacon overhead when you walk to light up the path and make it look more realistic. Now, I need to get rid of the beacon (it doesn't go away when I am not holding the torch, nor when I move away from where I was before, it just creates an endless line of beacons above me). Below is the 9 command blocks I have so far, in order from the start, with space to add a couple more if needed.

I have the standard fill clock and then these, in order:
-snip-

Coincidentally, I happen to have made something that does almost exactly this a while back. It originally placed blocks below you, but it should work the same. IIRC it used 2 fills with some replace syntax to change how things are placed in the world, something like this:execute @a ~ ~3 ~ fill ~1 ~1 ~1 ~-1 ~-1 ~-1 air 0 replace beacon 0execute @a[score_HoldTorch_min=1] ~ ~3 ~ fill ~ ~ ~ ~ ~ ~ beacon 0 replace air 0
Basically it places a beacon above you, and then in the next tick clears all the beacons in a small square around your head before placing another one. You can make the square bigger if you need by changing the 1's in the first command to some other number.

Also note that I moved the beacon up from 2 to 3 blocks so that players could jump. I also made the box replacing the beacons a bit big to get rid of any beacons that may move out of range from you jumping. If you need to make it bigger for some reason, just change the 1's in the first command to something else.
1
10/02/2015 11:50 am
Level 30 : Artisan Architect
momma_jibi
momma_jibi's Avatar
Okay...One more thing and then I promise I'm done asking about the flashlight. I've gotten all of that to work and I've managed to add a beacon overhead when you walk to light up the path and make it look more realistic. Now, I need to get rid of the beacon (it doesn't go away when I am not holding the torch, nor when I move away from where I was before, it just creates an endless line of beacons above me). Below is the 9 command blocks I have so far, in order from the start, with space to add a couple more if needed.

I have the standard fill clock and then these, in order:
  • /scoreboard objectives add HoldTorch dummy
  • /scoreboard players set @a HoldTorch 0
  • scoreboard players set @a HoldTorch 1 {SelectedItem: {id:"minecraft:torch",Count:1b,Damage:0s}}
  • replaceitem entity @a[score_HoldTorch_min=1] slot.armor.head pumpkin 1 0
  • execute @a[score_HoldTorch_min=1] ~ ~ ~ fill ~ ~2 ~ ~ ~2 ~ beacon 0 keep
  • Space for next block
  • clear @a[score_HoldTorch=0] pumpkin
  • effect @a[score_HoldTorch_min=1] clear
1
10/01/2015 11:13 am
Level 30 : Artisan Architect
momma_jibi
momma_jibi's Avatar
It works! Thank you SO MUCH!
1
09/30/2015 11:51 am
Level 30 : Artisan Architect
momma_jibi
momma_jibi's Avatar
Yes, I am using a fill clock. It's kind of the only way to do it, for fastness' sake. I had tried the 3 top commands and gotten the pumpkin on my head, but I couldn't get it off. Your third/fourth command there should help, Thank you! I'll let you know how it goes.

While we're here, lol, I also want to learn how to do things like tp'ing the player and making knocking sounds with particles on doors. I'm sure I'll be able to look it up somewhere, but you guys have been so helpful, I might as well ask here, too!
1
09/28/2015 10:02 pm
Level 33 : Artisan Engineer
Jmal116
Jmal116's Avatar
If you're using a fill clock, then the easy way to remove it is to constantly set the player's score to 0 before all operations take place. For instance, running these 3 commands in sequence should accomplish what you want:
scoreboard players set @a HoldTorch 0
scoreboard players set @a HoldTorch 1 {SelectedItem:{id:"minecraft:torch",Count:1b,Damage:0s}}
replaceitem entity @a[score_HoldTorch_min=1] slot.armor.head pumpkin 1 0
clear @a[score_HoldTorch=0] pumpkin

Each tick the clock will recycle the score, checking to see if the player is still holding the torch. If they aren't, the pumpkin will be removed. If they are, then the player will notice nothing.
1
09/28/2015 12:57 pm
Level 30 : Artisan Architect
momma_jibi
momma_jibi's Avatar
Okay. I've got it to detect when I hold the torch and have it replaceitem when its held to add a pumpkin on my head. Now, my issue is getting the pumpkin to come off when I'm not holding the torch. Should that be on the same scoreboard clock, or a different one? Is there a removeitem command (for just the head) that I can use only when I'm NOT holding the torch in my hand? The crazy part is, I've seen this done freaking EVERYWHERE, but no one has a CURRENT, PROPER tutorial. It's a little upsetting, like a best-kept secret or something. And it shouldn't be...

Here's a copy of the code I'm trying. I've tried a couple variations, on the same command block and on one next to it.
/scoreboard players set @a HoldTorch 1 {SelectedItem:replaceitem slot.armor.head minecraft:pumpkin{id:minecraft:torch,Count:1b,Damage:0s}}
1
09/22/2015 4:33 pm
Level 33 : Artisan Engineer
Jmal116
Jmal116's Avatar
What's up with this AddItem thing? It's not something I've ever seen before, either as part of nbt data or as a command. Also I'm not aware of any effect you can put on the player to simulate the pumpkin, short of just putting a pumpkin on their head.

To put it on their head I would use the /replaceitem command. That may have been what you were going for:
replaceitem entity @p slot.armor.head pumpkin 1 0 [data]
1
09/22/2015 10:55 pm
Level 30 : Artisan Architect
momma_jibi
momma_jibi's Avatar
I had tried that, and it also hadn't worked. I think I got the AddItem bit from a very old tutorial or something. Either way, I've figured out the scoreboard system, at least a little, and think I'll be able to place a pumpkin when they hold the item, and take it off when they aren't holding it. No on/off function, but still cool, I hope.
1
09/20/2015 10:32 pm
Level 30 : Artisan Architect
momma_jibi
momma_jibi's Avatar
Okay, so I got that working and messed around with some more code. My desired outcome would be to ONLY have the pumpkinblur effect when holding the "flashlight", but as of yet I have found nothing that gives me the id/value for that effect. So, I have resorted to adding a pumpkin to the head while holding the flashlight. But now I am getting the error that my data structure is not correct after writing out everything and fixing the parsing/bracket errors. Here is what I've added, and it's all on one command block. When I have them separate, it makes you wear the pumpkin constantly and just plain gives it to you. I don't want that.

testfor @a {SelectedItem:{id:"minecraft:torch",Count:1b,Damage:0s}, AddItem:{entity:slot.armor.head:{id:"minecraft:pumpkin",Count:1b,Damage:0s}}}
1
09/20/2015 9:40 pm
Level 30 : Artisan Architect
momma_jibi
momma_jibi's Avatar
Wow, I hooked it up to a clock finally and got the desired result. Thank you for your help! Now to try and tie in the effect and change the look of it, lol.
1
09/20/2015 5:54 pm
Level 33 : Artisan Engineer
Jmal116
Jmal116's Avatar
Ah, small error in what I said above. Of the two command I gave, which one did you try? In the second one I left out a small part which causes it to not work. It should be this:testfor @a {SelectedItem:{id:"minecraft:torch",Count:1b,Damage:0s}}

When I tried that in my own world it seemed to work perfectly.
1
09/20/2015 9:33 pm
Level 30 : Artisan Architect
momma_jibi
momma_jibi's Avatar
I tried both, neither worked.
I'll give the revised one a try, thank you.
1
09/20/2015 4:55 pm
Level 33 : Artisan Engineer
Jmal116
Jmal116's Avatar
First off, the 'SelectedItem' tag is not a list, it is simply a single entry. Therefore it gets a curly bracket, rather than a square one (the square brackets comes into play when there is the possibility of there being more than one entry, like in an entire inventory). From there, 'id' is not a separate set of data and so doesn't have any extra brackets. Also, you don't need to define the count and data value of the item with the id tag, simply the item's name. Your command should come out something like this:testfor @a {SelectedItem:{id:"minecraft:torch"}}If you want to add in the count and damage value, you can do so with a couple additional tags:testfor @a {SelectedItem:{id:"minecraft:torch",Count:1,Damage:0}}

Also keep in mind it's often better to try to avoid testfor commands, and put the data you want directly into whatever commands you're running after. How you do that is going depend largely on what it is you want to do with the player.
1
09/20/2015 5:40 pm
Level 30 : Artisan Architect
momma_jibi
momma_jibi's Avatar
I tried all kinds of configurations, even as you suggest, and it didn't work. I'll keep trying, though. EDIT: When I put that code in, this is what I get: "[14:41] JB1110 did not match the required data structure" It's trying to testfor my player name and not the item in my hand.

Basically, I am changing a torch into a flashlight and I want to make it use the pumpkin blur when you hold it (hence the SelectedItem tag) so it looks like it's "on." I have looked in so many places for a CURRENT, useful application of this and have yet to see it, without a mod, which I don't want. If I could make it turn on/off with right click, have a spot like a flashlight AND make it light as you go, or dynamically, that'd be great, but I think unattainable atm.
1
09/20/2015 12:22 am
Level 30 : Artisan Architect
momma_jibi
momma_jibi's Avatar
t3xas- I'd be interested in that, but that is something that would come way after I do my project. I like to try and do one thing at a time, you know? Please check out my Projects and give it a diamond/subscribe to see when it's done and then maybe we can work something out.

1
09/19/2015 5:45 pm
Level 8 : Apprentice Artist
ArtifactHunter
ArtifactHunter's Avatar
idk, since idk how to do that...if you ever do figure out how, PM me so I can use it in my adventure maps! Also, I have six questions of my own...here's the PMC link in the spoiler...



Please do check it out, 1, 2, 3, 4, and 6 are some normal questions, but #5 is only for you if you can make REALLY AWESOME resource packs!
1
09/19/2015 5:38 pm
Level 19 : Journeyman Robot
SquidMannn
SquidMannn's Avatar
Test
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome