Minecraft Wiki
Advertisement

I comandi sono delle funzioni avanzate di Minecraft, che possono essere attivate grazie a determinate stringhe di testo.

Uso

Nella modalità giocatore singolo di Minecraft, i comandi si usano con la chat di testo, apribile con il tasto Template:Key (default) o con il tasto Template:Key. Usando il tasto Template:Key, comparirà automaticamente nella chat il simbolo Template:Key, che è l'inizio di ogni comando. I tasti Template:Key e Template:Key possono essere usati per vedere tutti i messaggi precedentemente inviati nella chat, inclusi i comandi già eseguiti. Il tasto Template:Key permette di completare la scrittura del comando e, una volta scritto quest'ultimo, permette di elencare tutti gli argomenti del comando stesso.

I comandi possono anche essere inseriti nella console di un server multigiocatore, ma in questo caso non devono essere preceduti dal tasto Template:Key.

I comandi scritti nel blocco comandi possono essere preceduti dal tasto Template:Key, ma non è necessario.

La maggioranza dei comandi possono essere eseguiti solo in queste situazioni:

  • In un server multigiocatore, inseriti da un amministratore in chat, nella console del server, oppure in un blocco comandi.
  • In un proprio server multigiocatore in LAN, inseriti dal giocatore che ha avviato il mondo in LAN con i trucchi abilitati.
  • In un mondo in giocatore singolo, se i trucchi sono stati attivati alla creazione del mondo (grazie al pulsante: "Altre opzioni del mondo").


Nota:In un mondo giocatore singolo ove i trucchi non sono stati abilitati alla creazione, è possibile abilitarli abilitando la connesione LAN (premendo Template:Key -> "Apri in LAN" -> "Comandi: SI " e "Avvia mondo LAN"). In realtà, non c'è bisogno di avere una rete LAN, o che altri giocatori entrino nel server. Con questa procedura, i comandi non rimarranno per sempre, ma solo fino alla chiusura del mondo, e tutte le modifiche fatte fino ad allora saranno comunque salvate. Per avere i trucchi sempre abilitati, bisogna fare lo stesso procedimento ogni volta che si apre il proprio mondo. Bisogna ricordare, però, che mentre un mondo è aperto alla LAN, premendo il pulsante Template:Key, il gioco non andrà in pausa, e per disabilitare la LAN sarà necessario riavviare il mondo.

Note sul tilde

In molti comandi, possono essere indicate le coordinate del posto in cui ci si trova utilizzando i tasti Template:Key o Template:Key. Aggiungendo o sottraendo un numero da esso, ci si sposterà solamente nell'asse in cui è stato aggiunto quel numero di tanto quanto è stato specificato. Scrivere un unico tilde, infatti, è la stessa cosa di scrivere ~0.

Per esempio: /tp 0 64 0 teletrasporterà il giocatore alle coordinate (0;64;0), mentre /tp ~2 ~ ~ farà spostare il giocatore di due blocchi sull'asse "x".

Questi due metodi di scrivere le coordinate, possono anche essere mescolati fra loro. Se uno vuole spostarsi in un posto preciso solamente di un'asse, può scrivere /tp 64 ~ ~.

Bisogna fare attenzione a come viene usato il tilde nel blocco comandi, per alcuni comandi, come /tp , il tilde si riferisce alla posizione del giocatore, mentre per altri, come /setblock, si riferisce alla posizione del blocco comandi.

Selezione dei Target

Nei comandi in cui il nome di un giocatore è considerato come un argomento, è possibile selezionare più giocatori con una stessa caratteristica.

Per esempio, per cambiare la modalità di gioco a tutti i giocatori della squadra Rossa, basterà scrivere:

/gamemode creative @a[team=Red]

Variabili di selezione

Sommario delle variabili
Variable Function
@p giocatore più vicino
@r giocatore casuale
@a tutti i giocatori
@e tutte le entità
@s l'entità che esegue il comando

Una variabile di selezione identifica un determinato gruppo di giocatori. Esistono quattro variabili:

@p
Seleziona il giocatore più vicino. Se ci sono più giocatori alla stessa distanza, viene selezionato il primo giocatore che è entrato nel server.
La Selezione dei Target può essere usata per selezionare solo alcuni player, anche se sono tutti alla stessa distanza. Per esempio, @p[team=Red] seleziona solamente i giocatori della squadra Rossa, escludendo eventuali altri giocatori, anche se essi sono più vicini.
Utilizzando l'argomento c, si potrà cambiare il numero massimo di giocatori che vengono selezionati. (per esempio, @p[c=3] seleziona i tre giocatori più vicini). Se negativo, invertirà il comando (per esempio, @p[c=-1] seleziona il giocatore più lontano).
@r
Seleziona un giocatore a caso.
La Selezione dei Target può essere usata per ridurre il numero di giocatori che possono essere selezionati. Per esempio, @r[team=Red] potrà selezionare solamente giocatori della squadra Rossa.
Utilizzando l'argomento c, si può aumentare l numero di giocatori scelti casualmente. Per esempio, @r[c=3] seleziona tre giocatori a caso.
@a
Seleziona tutti i giocatori..
La Selezione dei Target può essere usata per selezionare solamente un gruppo specifico di giocatori. Per esempio, @a[team=Red] seleziona solamente i giocatori della squadra Rossa.
@e
Seleziona tutte le entità (inclusi i giocatori).
La Selezione dei Target può essere usata per selezionare solamente un gruppo specifico di entità. Per esempio, @e[type=Cow] seleziona solamente le mucche.


Argomenti di Selezione dei Target

Summary of target selector arguments
Argument(s) Selection criteria
x, y, z coordinate
r, rm radius (max, min)
m game mode
c count
l, lm experience (max, min)
score_name max score
score_name_min min score
team team name
name player name
dx, dy, dz volume dimensions
rx, rxm vertical rotation (max, min)
ry, rym horizontal rotation (max, min)
type entity type

Dopo aver usato un selettore di Target, puoi usare gli argomenti per precisare i gruppi di entità selezionati. Quando usati con @a o @e, gli argomenti restringono il numero di target dall'elenco completo a un gruppo specifico. Quando usati con @p o @r, gli argomenti restringono il numero di bersagli dall'elenco completo a un gruppo più piccolo da cui è selezionato il giocatore più vicino o casuale.

Dopo la selezione di variabile aggiungi, fra parentesi quadre, un elenco separato di coppie argomento-valore separate da virgole:

@<variable>[<argument>=<value>,<argument>=<value>,…].

Non sono consentiti spazi prima delle parentesi, segni di uguale o virgole e possono essere utilizzate solo virgole per separare le coppie argomento-valore.

Gli argomenti sono sensibili a maiuscolo e minuscolo e gli argomenti non supportati vengono ignorati dal sistema. Per esempio, kill @e[type=Creeper,r=20] ucciderà tutti i Creeper nel raggio di 20 blocchi, ma kill @e[Type=Creeper,r=20] ucciderà tutte le entità (anche i player) in quel raggio poichè non è presente l'argomento che restringe i target solo ai creeper.

Se i primi argomenti (fino a quattro) vengono specificati semplicemente come valori senza scrivere gli argomenti, verranno valutati, in ordine, x, y, z, e r. Pertanto i seguenti due comandi avranno lo stesso effetto:

/gamemode creative @a[x=10,y=20,z=30,r=4]
/gamemode creative @a[10,20,30,4]
Selecting targets by coordinate
[x=X,y=Y,z=Z] — Selects only targets at that exact position (ignoring fractions).
Use tilde notation to specify a coordinate relative to the command's execution position.
Selecting targets by radius
[r=R] — Selects only targets less than R blocks from the command's execution.
[rm=RM] — Selects only targets more than RM blocks from the command's execution.
If a coordinate (above) and either or both radius/i are both defined, the radius/i will center on the coordinate rather than the postion of the command's execution. By using a very distant coordinate and a very large radius, it is possible to simulate a near-linear edge to use to specify targets.
Selecting targets by game mode
[m=M] — Selects only targets with the specified game mode. Permitted value for M are:
  • -1: all game modes
  • 0: survival mode
  • 1: creative mode
  • 2: adventure mode
  • 3: spectator mode
Selecting targets by count
[c=C] — Selects only the specified number of targets. Usually in order of distance from the command executor.
When used with @p or @r, this argument defaults to 1, so using a higher number will increase the number of nearest or random targets returned. When used with @a or @e, this argument returns only the nearest targets.
If there are multiple nearest players, caused by them being precisely the same distance away, a player is selected by the time the player most recently joined the server. For example, if equally distant, @a[c=1] will select the player who has been on the server the longest and @e[type=Creeper,c=3] will select the three oldest creepers.
When used with a negative value, the order of targets is reversed. For example, @p[c=-3] will return the three farthest targets, and, if all potential targets are equally far away, @e[c=-3] will select the last three targets created.
Selecting targets by experience level
[l=L] — Selects only targets with no more than L experience levels.
[lm=LM] – Selects only targets with no less than LM experience levels.
Selecting targets by score
[score_name=SCORE] — Selects only targets with a score in objective name of no more than SCORE.
[score_name_min=SCOREMIN] — Selects only targets with a score in objective name of no less than SCOREMIN.
For example, @a[score_points_min=30,score_points=39] will select all players with a score in objective "points" between 30 and 39 (inclusive).
Selecting targets by team
[team=TEAM] — Selects only targets on team TEAM.
[team=!TEAM] — Selects only targets not on team TEAM.
[team=] — Selects only targets not on any team.
Selecting targets by name
[name=NAME] — Selects only targets named NAME.
[name=!NAME] — Selects only targets not named NAME.
Selecting targets by volume
[dx=DX,dy=DY,dz=DZ]
Selects only targets within the volume defined as starting from the location where the command was executed and extending DX blocks in the positive "x" direction (i.e., east), DY blocks in the positive "y" direction (i.e., upwards), and DZ blocks in the positive "z" direction (i.e., south). All values must be positive. If an initial coordinate is specified with the x, y, and z arguments, that will be used instead of the position of the command's execution for the lower northwestern corner (dx, dy, and dz still specify distances from that coordinate; they do not specify a separate coordinate).
It is possible to combine selection by radius and selection by volume, in which case the command will only select targets within the overlap of both regions (within certain radius/i of the volume's lower northwest corner and not outside the defined volume).
Selecting targets by vertical rotation
[rx=RX] — Selects only targets with a maximum vertical rotation of RX.
[rxm=RXM] — Selects only targets with a minimum vertical rotation of RXM.
Vertical rotation values vary from -90.0 facing straight up to 90.0 facing straight down (thus vertical rotation values increase with rotation downwards).
Selecting targets by horizontal rotation
[ry=RY] — Selects only targets with a maximum horizontal rotation of RY.
[rym=RYM] — Selects only targets with a minimum horizontal rotation of RYM.
Horizontal rotation values vary from -180.0 (facing due north), to -90.0 (facing due east), to 0.0 (facing due south), to 90.0 (facing due west), to 179.9 (just west of due north) before wrapping back to -180.0 (thus horizontal rotation values increase with rotation to the right, or clockwise viewed from above).
Selecting targets by type
[type=TYPE] — Selects only targets of the specific entity type.
[type=!TYPE] — Selects only targets not of the specific entity type.
Primarily only used with the @e variable (because all players are type=Player). "Entity types" are the entity IDs used to identify different types of entities internally (for example, Creeper for creepers, MinecartRideable for regular minecarts, PrimedTnt for primed TNT, etc.). Entity IDs are case-sensitive and invalid entity IDs will cause the command to fail.


Data tags

NBT tags can be specified for items and entities created with the /give, /summon and other commands. Data tags are data structures. The format is JSON, although it is not strict (lenient). The data is represented as a comma separated list of pairs. Each pair has the format <key>:<value>. The key is the name of the NBT tag and the value is the data that should be assigned to it. Tag names are case-sensitive, and whitespace outside keys or values is ignored.

The value can be different types:

  • String is a piece of text, can be wrapped with double-quotes. Double quotes have to be used if the String contains commas, curly brackets or square brackets. To use double-quotes inside Strings, the quote is escaped by a backslash (\"). When using most commands, escaping is disabled (except for double quotes) and keys must not be quoted (probably a bug [1]). This causes an issue where trailing backslashes do not work (as do any other things that need to be escaped), even when escaped properly. The reason is that it escapes the quotation mark after the string which causes a malformed JSON object. Example:"My name is \"Steve\""
  • Number are 1 or more digits that can have a leading sign (+/-). They're classified in Integers, that don't have a decimal mark, Doubles, that uses a dot (.) as a decimal mark, and Floats, that also have f appended after the number. Examples: integer:-128; double:-1.2345; & float:1.2f
  • List (or 'Array') is multiple, comma separated values wrapped with square brackets. The containing values do not need to be of the same type. Example:[1,2,3]
  • Boolean can either be true or false, but using Numbers works, too. When using numbers, 0 is false, everything else is true. Example:true
  • Compound or 'Object' is a container for data structures (as explained above). They are wrapped with curly braces.
Notice: The Data tag itself is a Compound. Example: {Health:18,CustomName:"Friend"}
  • null This is a placeholder an empty value. Do not put quotes. Example:null

When commands such as /testfor, /testforblock, and /clear are used to match NBT tags, they only check for the presence of the given tags in the target entity/block/item. This means that the entity/block/item may have additional tags and will still match. This is true even for lists/arrays: the order of a list is not acknowledged, and as long as every requested element is in the list, it will match even if there are additional elements.

For a complete listing of defined tags (though not all can be modified by commands), see:

  • Blocks
  • Entities
    • Mobs
    • Projectiles (arrows, fireballs, thrown potions, etc.)
    • Items (items on the ground)
    • Vehicles (boats, minecarts, etc.)
    • Dynamic Tiles (primed TNT, falling sand/gravel)
    • Other Entities (firework rockets, paintings, and item frames)
  • Tile Entities (chests, furnaces, command blocks, mob spawners, signs, etc.)
  • Player
    • Items (items in player's inventory or containers)

For a complete list of identifiers, see:

  • blocks
  • items
  • entities
  • enchantments
  • status/potion effects
  • attributes

Raw JSON text

The /tellraw and /title commands use a specific lenient JSON format to specify complicated text. Similar to the NBT format notation above, concepts such as Strings, Objects (Compounds), and Lists are used to represent the various properties of the raw text.

The format of raw JSON text is a JSON Object which supports the following (mostly optional) elements:

  • The base chat component Object
    •  text: A string representing raw text to display directly in chat. Note that selectors such as "@a" and "@p" are not translated into player names; use selector instead.
    •  extra: A list of additional objects, sharing the same format as the base object.
      • A list element with the same format as the base object (recursive). Note that all properties of this object are inherited by children except for text, extra, translate, with, and score. This means that children will retain the same formatting and events as this object unless they explicitly override them.
    •  color: The color to render this text in. Valid values are "black", "dark_blue", "dark_green", "dark_aqua", "dark_red", "dark_purple", "gold", "gray", "dark_gray", "blue", "green", "aqua", "red", "light_purple", "yellow", "white", and "reset" (cancels out the effects of colors used by parent objects). Technically, "bold", "underline", "italic", "strikethrough", and "obfuscated" are also accepted, but it may be better practice to use the tags below for such formats.
    •  bold: Boolean (true/false) - whether to render text in bold. Defaults to false.
    •  underlined: Boolean (true/false) - whether to render text underlined. Defaults to false.
    •  italic: Boolean (true/false) - whether to render text in italics. Defaults to false.
    •  strikethrough: Boolean (true/false) - whether to render text with a strikethrough. Defaults to false.
    •  obfuscated: Boolean (true/false) - whether to render text obfuscated. Defaults to false.
    •  insertion: When the text is shift-clicked by a player, this string will be inserted in their chat input. It will not overwrite any existing text the player was writing.
    •  clickEvent: Allows for events to occur when the player clicks on text.
      •  action: The action to perform when clicked. Valid values are "open_url" (opens value as a URL in the player's default web browser), "run_command" (has value entered in chat as though the player typed it themselves. This can be used to run commands, but the command will fail if the player does not have the required permissions to use it), and "suggest_command" (similar to "run_command", but the text only appears in the player's chat input, and is not automatically entered. Unlike insertion, this will replace the existing contents of the chat input).
      •  value: The URL, chat, or command used by the specified action. Note that commands must be prefixed with the usual "/" slash.
    •  hoverEvent: Allows for a tooltip to be displayed when the player hovers their mouse over text.
      •  action: The type of tooltip to show. Valid values are "show_text" (shows raw JSON text), "show_item" (shows the tooltip of an item which can have NBT tags), "show_achievement" (shows formatted text describing an achievement or statistic. Normal achievement names are green, final achievement names are dark_purple, and statistic names are gray. In addition, a description is given for achievements), and "show_entity" (shows an entity's name, possibly its type, and its UUID).
      •  value: The formatting of this tag varies depending on the action. Note that "show_text" is the only action to support an Object as the value; all other action values are Strings and should thus be wrapped in quotes.
        • "show_text": Can be either a raw String of text, or an Object with the same formatting as this base object. Note that clickEvent and hoverEvent do not function within the tooltip, but the formatting and extra tags still work.
        • "show_item": A string formatted like item NBT data. Contains the "id" tag, and optionally the "Damage" tag and "tag" tag (which is the same compound used as "dataTag" in the /give command).
        • "show_achievement": The achievement or statistic's name. This uses the same format as achievement and statistic Scoreboard objective criteria and the /achievement command.
        • "show_entity": A string formatted like a compound with the string values "type" (such as "Zombie"), "name", and "id" (should be an entity UUID, but can actually be any string).
    •  translate: The translation identifier of text to be displayed using the player's selected language. This identifier is the same as the identifiers found in lang files from assets or resource packs. The translated text will only be displayed if the text string is not used.
    •  with: A list of chat component arguments and/or string arguments to be used by translate.
      • The arguments are text corresponding to the arguments used by the translation string in the current language, in order (for example, the first list element corresponds to "%1$s" in a translation string).
    •  score: A compound for displaying a player's score in an objective. Displays nothing if the player is not tracked in the given objective. Ignored completely if text or translate is present.
      •  name: The name of the player whose score should be displayed. Selectors (such as @p) can be used, in addition to "fake" player names created by the scoreboard system. In addition, if the name is "*", it will show the player's own score (for example, /tellraw @a {score:{name:"*",objective:"obj"}} will show every online player their own score in the "obj" objective). Note that non-player entity scores (such as @e[type=Cow]) do not show, even if the entity has been given a score in the objective.
      •  objective: The internal name of the objective to display the player's score in.
      •  value: Optional. If present, this value is used regardless of what the score would have been.
    •  selector: A string containing a selector (@p,@a,@r, or @e) and, optionally, selector arguments. Unlike text, the selector will be translated into the correct player/entity names. If more than one player/entity is detected by the selector, it will be displayed in a form such as 'Name1 and Name2' or 'Name1, Name2, Name3, and Name4'. Ignored completely if text, translate, or score is present.

Due to the extra tag, the above format may be recursively nested to produce very complex and functional text strings. However, a raw json text doesn't have to be complicated at all: virtually all properties are optional and may be left out.

To be valid, each object must have at least either text, translate, or score (everything else is optional). As a matter of shorthand, however, the entire Object may be substituted with a String. In this case, that string will be considered the value of the text property. For example, "This is raw text" is equivalent to {text:"This is raw text"}. This shorthand substitution is valid anywhere a raw text object is required (including the base <raw json message> argument of /tellraw, the elements of the extra list, and the value of a "show_text" hover_event).

Finally, unlike other commands using JSON, /tellraw Strings support Unicode via the notation \u####, where #### is the Unicode hexadecimal number for the desired character.

External links
Skylinerw's JSON Formatting Examples
Tellraw Generator
Advertisement