1

Okay so im making an adventure map and i have a command block that will say when someone has found mining supplies and then you will have to click where it says here to receive some of it. The thing is it just says like error on line 323 unterminated character or something. Also i cant type the command cuz i broke to block so here is a picture of the text enter image description here

  • 3
    In the future it would be helpful to copy/paste the text directly instead of taking a screenshot. – Skylinerw Aug 3 '16 at 1:33
  • I don't believe you can run two commands at once in a run_command. Instead, you can place a redstone block somewhere or change a scoreboard objective that will activate both commands separately (the answer below has a good solution as well, but if you want a single clickable word that does everything, try this). – Daniel G Aug 3 '16 at 1:58
7

All of the problems I noted with your code:

  • You didn't escape ", causing the problem you're getting
    Fix this by escaping quotes within quotes, like so: /"
  • You have multiple commands in one run statement.
    Fix this by having multiple clicks.
  • You didn't separate your text elements
    Fix this by having each text element in its own dictionary.
  • Your command in the runCommand value is too long.

Here is an expanded (and corrected) JSON view of your code:

[
    "",
    {
        "selector": "@p",
        "color": "dark_purple",
        "bold": true,
        "italic": true
    },
    {
        "text": " has found mining supplies! Click ",
        "color": "aqua",
        "bold": true,
        "italic": false
    },
    {
        "text": "here for Torches",
        "color": "dark_red",
        "italic": true,
        "underlined": true,
        "clickEvent": {
            "action": "run_command",
            "value": "/give @p torch 10"
        },
        "bold": false
    },
    {
        "text": " and ",
        "color": "aqua",
        "italic": true,
        "underlined": false
    },
    {
        "text": "Here for a Pickaxe",
        "color": "dark_red",
        "italic": true,
        "underlined": true,
        "clickEvent": {
            "action": "run_command",
            "value": "/give @p iron_pickaxe 1 249 {display:{Name:\"Dull Pickaxe\",Lore:[\"This pickaxe is very worn out\",\"can only be used for fighting\",\"and mining weak stone\"]}}"
        }
    }
]

A minified Command Block friendly version of this code is this:

/tellraw @a ["",{"selector":"@p","color":"dark_purple","bold":true,"italic":true},{"text":" has found mining supplies! Click ","color":"aqua","bold":true,"italic":false},{"text":"here for Torches","color":"dark_red","italic":true,"underlined":true,"clickEvent":{"action":"run_command","value":"/give @p torch 10"},"bold":false},{"text":" and ","color":"aqua","italic":true,"underlined":false},{"text":"Here for a Pickaxe","color":"dark_red","italic":true,"underlined":true,"clickEvent":{"action":"run_command","value":"/give @p iron_pickaxe 1 249 {display:{Name:\"Dull Pickaxe\",Lore:[\"This pickaxe is very worn out\",\"can only be used for fighting\",\"and mining weak stone\"]}}"}}]

In the future, you should use generators to do this for you.

Note: The Pickaxe command may be too long to actually run. You might want to make it act as a "trigger" command that causes other command blocks to run. You can do this using the aptly-named /trigger command. From there, have a bunch of command blocks give the items to everyone with that scoreboard value set to 1.

To do this, create a Scoreboard objective with some unique name, like NeedsItemPack83028. Then, make it a valid Trigger by running /scoreboard players enable @a NeedsItemPack83028. Your command block would have the command set to /trigger NeedsItemPack83028. From there, you have a bunch of command blocks on a tick clock checking for NeedsItemPack83028. Apply the items to everyone who has it, and clear the flag.

Now, this opens the trigger command up to abuse. You can have a second Scoreboard item (ItemPack83028Redeemed) that can not be set by triggers. Ensure that that is false before giving items (!=).

  • You don't need the trigger, unless you want the player to be able to change the objective. Otherwise, you can use /scoreboard objectives set <entity> <objective> <value> [datatag (not required)], which command blocks have permission to use – Daniel G Aug 3 '16 at 2:00
  • @DanielG Thanks for the correction. It's been a while since I worked with scoreboards ^^ – Kaz Wolfe Aug 3 '16 at 2:03
  • @DanielG That is not correct in this case. When players run a /tellraw command's click event, they are running the command as though they typed it in the chat themselves. This means the command is subject to standard chat limitations, being the requirement of a high enough OP level to run /scoreboard. The /trigger command is supposed to be used in cases like these, unless only OP'd players are meant to run the command. – Skylinerw Aug 3 '16 at 2:17
  • @Skylinerw Thanks, I never realized that. All the examples I've seen have cheats enabled. Thanks! – Daniel G Aug 3 '16 at 13:35

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.