You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* update text components page
* update predicates page
* update versioning for all other pages which have been missed
* update nbt and other pages
---------
Co-authored-by: Cobblestone <aidenhperry@gmail.com>
Copy file name to clipboardExpand all lines: src/routes/contribute/formatting/+page.svx
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -80,7 +80,7 @@ this:
80
80
```md
81
81
title: "Site Development"
82
82
description: "This page is meant to be an introduction to formatting a page for the wiki. In it is multiple examples which you can examine raw in the [site source code](https://github.com/Datapack-Hub/wiki)."
83
-
version: 1.21.4
83
+
version: 1.21.5
84
84
```
85
85
86
86
Front matter is denoted with triple hyphens (`---`) at the top of the page and the end of the front matter.
description: Styled text in Minecraft commands is done through a JSON text format.
4
-
version: 1.21.4
2
+
title: Styled Text
3
+
description: Styled text in Minecraft commands is done through an NBT text format.
4
+
version: 1.21.5
5
5
---
6
6
7
-
# JSON Text
8
-
Styled text (bold, underline, colours, etc) is represented as JSON in Minecraft. A JSON text component is a way to format styled text in Minecraft commands, and is used in many places such as `/tellraw`, `/title`, and more.
7
+
# Styled Text
8
+
Styled text (bold, underline, colours, etc) is represented as NBT based structures, called "text components". A text component is a way to format styled text in Minecraft commands, and is used in many places such as `/tellraw`, `/title`, and more.
9
9
10
-
Instead of just using standard text (for example `"Hello World"`), we can use JSON text to format the text in a variety of ways, including colours, text effects, click events, hover events, language-based text, accessing NBT data, and more.
10
+
Instead of just using standard text (for example `"Hello World"`), we can use text components to format the text in a variety of ways, including colours, text effects, click events, hover events, language-based text, accessing NBT data, and more.
11
11
12
-
For more information about the JSON format in general, see the [JSON](/wiki/info/json) page.
12
+
For more information about the NBT format in general, see the [NBT](/wiki/nbt-scoreboards/nbt) page.
13
13
14
14
## Format
15
-
A JSON text component is formatted as either an object (`{"text":"Hello World","color":"red"}`), or an array of objects (`[{"text":"Hello"},{"text":"World"}]`). An object could just be a normal string (`["Hello", "World"]` is valid JSON text).
15
+
A text component is formatted as either an object (`{text:"Hello World",color:"red"}`), or an array of objects (`[{text:"Hello"},{text:"World"}]`). An object could just be a normal string (`["Hello", "World"]` and `"Hello World"` are both valid text components).
16
16
17
-
If the JSON text component is an array, then all the objects inherit the style from the first object. For instance, if the first object in an array is styled to be red, then all the other objects in the array will also be red unless specified otherwise.
17
+
If the text component is an array, then all the objects inherit the style from the first object. For instance, if the first object in an array is styled to be red, then all the other objects in the array will also be red unless specified otherwise.
18
18
19
19
### Content sources
20
-
The actual text of a JSON text object can be either static text or from a source such as NBT or scoreboard. Every object requires one of the following:
21
-
- `"text":"<text>"`: A simple string of text.
22
-
- `"score":{"name":"<player>","objective":"<objective>"}`: The score of a player in an objective. In some cases, `name` can be set to `"*"`, which will access the score of the player viewing the text.
23
-
- **NBT**: This will display the value of an NBT tag. If `"nbt"` is used in a JSON text object, then one of `"storage"`, `"entity"`, or `"block"` is also required. The following properties should be used:
24
-
- `"nbt":"<path>"`: The path to the NBT value. This is required - it should be a string value following the NBT path format.
25
-
- `"storage":"<namespace:storage>"`: The storage to get the NBT value from.
26
-
- `"entity":"<selector>"`: The entity to get the NBT value from.
27
-
- `"block":"<x> <y> <z>"`: The block to get the NBT value from.
28
-
- `"interpret":(true/false)`: If true, then the NBT value's text will be parsed and interpreted as a JSON text object. Defaults to false.
29
-
- `"selector":"<selector>"`: The name of a player or entity.
30
-
- `"translate":"<key>"`: A translation key from language files defined in a resource pack. This will display the value of the key in the player's selected language.
31
-
- `with`: This can also optionally be used to insert arguments into the translation key. This should be an array of JSON text objects.
20
+
The actual text of a text component can be either static text or from a source such as NBT or scoreboard. Every object requires one of the following:
21
+
- `text:"<text>"`: A simple string of text.
22
+
- `score:{name:"<player>",objective:"<objective>"}`: The score of a player in an objective. In some cases, `name` can be set to `"*"`, which will access the score of the player viewing the text.
23
+
- **NBT**: This will display the value of an NBT tag. If `nbt` is used in a text component, then one of `storage`, `entity`, or `block` is also required. The following properties should be used:
24
+
- `nbt:"<path>"`: The path to the NBT value. This is required - it should be a string value following the NBT path format.
25
+
- `storage:"<namespace:storage>"`: The storage to get the NBT value from.
26
+
- `entity:"<selector>"`: The entity to get the NBT value from.
27
+
- `block:"<x> <y> <z>"`: The block to get the NBT value from.
28
+
- `interpret:(true/false)`: If true, then the NBT value's text will be parsed and interpreted as a text component. Defaults to false.
29
+
- `selector:"<selector>"`: The name of a player or entity.
30
+
- `translate:"<key>"`: A translation key from language files defined in a resource pack. This will display the value of the key in the player's selected language.
31
+
- `with`: This can also optionally be used to insert arguments into the translation key. This should be an array of text components.
32
32
- `fallback`: This can also optionally be used to specify what to display if the translation is not found. If this is not specified, the key itself will be displayed if the translation is not found. This should be a string value.
33
-
- `"keybind":"<keybind id>"`: The key which a player has bound to a keybind. (For example, `key.jump` would show the text `Space`, assuming the player has not changed the keybind).
33
+
- `keybind:"<keybind id>"`: The key which a player has bound to a keybind. (For example, `key.jump` would show the text `Space`, assuming the player has not changed the keybind).
34
34
35
-
**Example**: This JSON text object will display the value of the path `ShopData.Name` in the NBT storage `minecraft:xyz`:
35
+
**Example**: This text component will display the value of the path `ShopData.Name` in the NBT storage `minecraft:xyz`:
36
36
```json
37
-
{"nbt":"ShopData.Name","storage":"minecraft:xyz"}
37
+
{nbt:"ShopData.Name",storage:"minecraft:xyz"}
38
38
```
39
39
40
40
### Style properties
41
-
The following properties can be used in a JSON text object to change the **style** of the text:
41
+
The following properties can be used in a text component to change the **style** of the text:
42
42
- `color`: The colour of the text. This can be one of the 16 standard colours (e.g `"red"`, `"light_purple"`, etc.), or a hex colour code (e.g `"#ff0000"`).
43
43
- `bold`: Whether the text is bold. This can be `true` or `false`.
44
44
- `italic`: Whether the text is italic. This can be `true` or `false`.
@@ -48,41 +48,38 @@ The following properties can be used in a JSON text object to change the **style
48
48
49
49
**Example**: This text will be "Hello World", in red, bold, and strikethrough:
The following properties can be used in a JSON text object to add **interactivity** to the text:
55
+
The following properties can be used in a text component to add **interactivity** to the text:
56
56
- `insertion`: Can be used to specify text to be inserted into the chat when the text is shift-clicked. This should be a string value.
57
-
- `clickEvent`: Can be used to specify an action to be performed when the text is clicked. This should be an object with the following properties:
57
+
- `click_event`: Can be used to specify an action to be performed when the text is clicked. This should be an object with the following properties:
58
58
- `action`: The action to be performed. This can be one of the following:
59
-
- `"open_url"`: Opens the url in `value` in the player's web browser.
60
-
- `"run_command"`: Runs the command in `value` (the player needs permission to run the commands, and this excludes commands like /say or /tell which make the player send something to chat).
61
-
- `"suggest_command"`: Opens and inserts the contents of `value` into the player's chat box.
62
-
- `"copy_to_clipboard"`: Copies `value` to the clipboard.
63
-
- `"change_page"`: (books only) Changes the page of the book to the page specified in `value`.
64
-
- `value`: The value of the action. This should be a string value.
65
-
- `hoverEvent`: Can be used to specify what happens when a player hovers over the text. This should be an object with the following properties
59
+
- `"open_url"`: Opens the url in the field `url` in the player's web browser.
60
+
- `"run_command"`: Runs the command in the field `command` (the player needs permission to run the commands, and this excludes commands like /say or /tell which make the player send something to chat).
61
+
- `"suggest_command"`: Opens and inserts the contents of `command` into the player's chat box.
62
+
- `"copy_to_clipboard"`: Copies the contents of the field `value` to the clipboard.
63
+
- `"change_page"`: (books only) Changes the page of the book to the page specified in the field `page`.
64
+
- `url` or `command` or `value` or `page`: These fields should be added to `click_event` alongside `action` depending on which action you use.
65
+
- `hover_event`: Can be used to specify what happens when a player hovers over the text. This should be an object with the following properties
66
66
- `action`: The action to be performed. This can be one of the following:
67
-
- `"show_text"`: Shows the text in `contents` in a tooltip by the player's mouse.
68
-
- `"show_entity"`: Shows the entity in `contents` in a tooltip by the player's mouse.
69
-
- `"show_item"`: Shows the item in `contents` in a tooltip by the player's mouse.
70
-
- `value`: The value of the action. This changes based on the `action`:
71
-
- If `"show_text"` is the action, this should be a JSON text object or array.
72
-
- If `"show_entity"` is the action, this should be an object which represents the entity to be displayed in the tooltip. This needs the properties `"id"`, `"type"`, and `"name"`. This is used for the `selector` component type
73
-
- If `"show_item"` is the action, this should be an object which represents the item to be displayed in the tooltip. This needs the properties `"id"`, `"count"`, `"components"`.
67
+
- `"show_text"`: Shows the text in the field `value` in a tooltip by the player's mouse.
68
+
- `"show_entity"`: Shows the entity based on the fields `uuid` and `id` in a tooltip by the player's mouse.
69
+
- `"show_item"`: Shows the item based on the fields `id` and `components` in a tooltip by the player's mouse.
70
+
- `value` or `uuid` + `id` or `id` + `components`: These fields should be added to `hover_event` alongside `action` depending on which action you use.
74
71
75
72
**Example**: This text will be "Click me", in blue, and when clicked, it will run the command `/say Hello`:
- `extra`: This property can be used to add another JSON text object after, which inherits all the styles and interactivity from the parent object.
78
+
- `extra`: This property can be used to add another component after, which inherits all the styles and interactivity from the parent object.
82
79
- `separator`: If the text source returns multiple values (e.g. multiple entities with the `selector` source, or multiple NBT values with the `nbt` source), this can be used to specify the separator between the values. This should be a string value.
83
80
84
-
## JSON text generators
85
-
Writing JSON text manually can be tedious - there are numerous generators which can be used to quickly create JSON text objects. Here are our recommendations:
81
+
## Text component generators
82
+
Writing text components manually can be tedious - there are numerous generators which can be used to quickly create text components. Here are our recommendations:
Copy file name to clipboardExpand all lines: src/routes/wiki/info/json/+page.svx
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ description: "A rough guide to the JSON format used in Minecraft Datapacks (amon
4
4
---
5
5
6
6
# JSON Format
7
-
JSON is a data storage type used by Minecraft Datapacks for files such as [predicates](/wiki/files/predicates) and [tags](/wiki/files/tags), as well as in [JSON Text](/wiki/concepts/json-text). JSON is a way of storing data, usually used in `.json` files but is also seen in `.mcmeta` files too.
7
+
JSON is a data storage type used by Minecraft Datapacks for files such as [predicates](/wiki/files/predicates) and [tags](/wiki/files/tags), as well as in [JSON Text](/wiki/concepts/text). JSON is a way of storing data, usually used in `.json` files but is also seen in `.mcmeta` files too.
8
8
9
9
## How JSON works
10
10
JSON stands for **JavaScript Object Notation**. It was originally created as a way of writing objects in Javascript. These days, JSON is used in almost every programming environment, datapacks included.
Copy file name to clipboardExpand all lines: src/routes/wiki/nbt-scoreboards/nbt/+page.svx
+16-20Lines changed: 16 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: NBT
3
3
description: NBT is Minecraft's way of storing internal data, such as item data, entity data, and block data. In datapacks, we can use it to store data in custom data storages.
4
-
version: 1.21.4
4
+
version: 1.21.5
5
5
---
6
6
7
7
<script lang="ts">
@@ -91,22 +91,25 @@ string, text, booleans, and more.
91
91
Strings can store any text value, or more technically, any sequence of unicode characters.
92
92
93
93
**Format**: Strings are stored within either double or single quotes. For strings containing standard characters
94
-
(`A-Z, a-z, 0-9, -,_,+,.`), the quotes are optional, but recommended. `"<text>"` or `'<text>'` or `<text>`
94
+
(`A-Z, a-z, 0-9, -,_,+,.`), the quotes are optional (as long as the text starfts with a letter), but recommended. `"<text>"` or `'<text>'` or `<text>`
**Short**, **Int**, and **Long** data types all represent integers (whole numbers).
101
101
102
-
- **Byte** is an unsigned 8 bit integers, it can be any value from `0` to `255`
103
-
- **Short** is a signed 16 bit integer, it can be any value from `-32,768` to `32,767`
104
-
- **Int** is a signed 32 bit integer, it can be any value from `-2,147,483,648` to `2,147,483,647`
105
-
- **Long** is a signed 64 bit integer, it can be any value from `-9,223,372,036,854,775,808` to
102
+
- **Byte** is an 8 bit integer, it can be any value from `0` to `255`
103
+
- **Short** is a 16 bit integer, it can be any value from `-32,768` to `32,767`
104
+
- **Int** is a 32 bit integer, it can be any value from `-2,147,483,648` to `2,147,483,647`
105
+
- **Long** is a 64 bit integer, it can be any value from `-9,223,372,036,854,775,808` to
106
106
`9,223,372,036,854,775,807`
107
107
108
-
**Format**: By default, numbers are stored as integers. To store a number in the other formats, you need to use the appropriate suffix.
109
-
For shorts, ints, and longs, the prefix is `s`, `i`, and `l` respectively.
108
+
**Format**: By default, numbers are stored as integers. To store a number in the other formats, you need to use the appropriate suffix. For shorts, ints, and longs, the prefix is `s`, `i`, and `l` respectively.
109
+
110
+
The suffix can be extended with `u` or `s` to say whether it is unsigned (only a positive number) or signed (can be positive or negative) - for example, `402ub`.
111
+
112
+
It is also possible to write using E notation (e.g `1.2E3` would be `1200`), hexadecimals (e.g `0xBC` would be `188`), and binary (e.g `0b110` would be `6`)
@@ -125,23 +128,16 @@ appropriate suffix. For floats, the suffix is `f`. For doubles, the suffix is `d
125
128
126
129
### Bytes or Booleans
127
130
128
-
In older versions of Minecraft, booleans were stored as bytes with `0b` representing
129
-
`false` and `1b` representing `true`. In newer versions, booleans were introduced.
130
-
Essentially, booleans represent the old `0b` and `1b` with a more descriptive name.
131
-
It's recommended to use booleans instead of bytes whenever possible, as they are more readable.
131
+
In older versions of Minecraft, booleans were stored as bytes with `0b` representing `false` and `1b` representing `true`. In newer versions, booleans were introduced. Essentially, booleans represent the old `0b` and `1b` with a more descriptive name. It's recommended to use booleans instead of bytes whenever possible, as they are more readable.
132
132
133
-
### Arrays
134
133
135
-
Arrays are used to store multiple values of the same type. There are currently 3 types of arrays:
136
134
137
-
- **Byte Array**: Used to store multiple bytes
138
-
- **Int Array**: Used to store multiple integers
139
-
- **Long Array**: Used to store multiple longs
135
+
### Lists/Arrays
136
+
Lists, or number arrays are used to store multiple values. Lists can store different types of values, whereas number arrays can only store the same type of number. In practicality, you often do not need to think about the difference
140
137
141
-
**Format**: Arrays are defined using square brackets (`[]`), followed by the type of the array, a semicolon, and then your data.
142
-
The data still has to have prefixes if it needs it.
138
+
**Format**: Theyu are defined using square brackets (`[]`), with the values separated by commas. Number arrays can be prefixed with the type of numbr the array is going to store and a semicolon (for instance, a list starting with `[B;` will only store bytes)
0 commit comments