Skip to content

Commit 60acb43

Browse files
NBT and Text Component changes (#87)
* 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>
1 parent 00814e7 commit 60acb43

8 files changed

Lines changed: 67 additions & 72 deletions

File tree

src/lib/sidebar/tabs/WikiPages.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
<SidebarPage label="Target Selectors" icon={IconAt} page="/wiki/concepts/target-selectors" />
4949
<SidebarPage label="Coordinates" icon={IconTilde} page="/wiki/concepts/coordinates" />
5050
<SidebarPage label="Item Components" icon={IconComponents} page="/wiki/concepts/item-components" />
51-
<SidebarPage label="JSON Text" icon={IconBraces} page="/wiki/concepts/json-text" />
51+
<SidebarPage label="JSON Text" icon={IconBraces} page="/wiki/concepts/text" />
5252
<SidebarPage label="Resource Locations" icon={IconResourceLocation} page="/wiki/concepts/resource-locations" />
5353
<SidebarPage label="Ranges" icon={IconRange} page="/wiki/concepts/ranges" />
5454
</SidebarCategory>

src/routes/contribute/formatting/+page.svx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ this:
8080
```md
8181
title: "Site Development"
8282
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
8484
```
8585

8686
Front matter is denoted with triple hyphens (`---`) at the top of the page and the end of the front matter.

src/routes/search.json/meta.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.
Lines changed: 43 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
11
---
2-
title: JSON Text
3-
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
55
---
66

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.
99

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.
1111

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.
1313

1414
## 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).
1616

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.
1818

1919
### 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.
3232
- `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).
3434

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`:
3636
```json
37-
{"nbt":"ShopData.Name","storage":"minecraft:xyz"}
37+
{nbt:"ShopData.Name",storage:"minecraft:xyz"}
3838
```
3939

4040
### 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:
4242
- `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"`).
4343
- `bold`: Whether the text is bold. This can be `true` or `false`.
4444
- `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
4848

4949
**Example**: This text will be "Hello World", in red, bold, and strikethrough:
5050
```json
51-
{"text": "Hello World", "color": "red", "bold": true, "strikethrough": true}
51+
{text: "Hello World", color: "red", bold: true, strikethrough: true}
5252
```
5353

5454
### Interactivity properties
55-
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:
5656
- `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:
5858
- `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
6666
- `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.
7471

7572
**Example**: This text will be "Click me", in blue, and when clicked, it will run the command `/say Hello`:
7673
```json
77-
{"text": "Click me", "clickEvent": {"action": "run_command", "value": "/say Hello"}}
74+
{text: "Click me", "click_event": {"action": "run_command", "command": "/say Hello"}}
7875
```
7976

8077
### Other
81-
- `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.
8279
- `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.
8380

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:
8683
- [Minecraft Tools](https://minecraft.tools/tellraw.php)
8784
- [MinecraftJSON.com](https://minecraftjson.com/)
8885
- [Misode](https://misode.github.io/text-component)

src/routes/wiki/concepts/resource-locations/+page.svx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Resource Locations
33
description:
44
"A resource location is a kind of identified used in Minecraft to point to a certain piece of data, such as a function, item, or storage."
5-
version: 1.21.4
5+
version: 1.21.5
66
---
77

88
# Resource Locations

src/routes/wiki/files/predicates/+page.svx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Predicates
33
description: Predicates are a type of file which can be called to check if a certain condition is true.
4-
version: 1.21.4
4+
version: 1.21.5
55
---
66

77
# Predicates
@@ -124,6 +124,8 @@ These are all the possible conditions that can be used in a predicate.
124124
- `movement`: An object which matches the movement of the entity.
125125
- `periodic_tick`: Returns true once every `x` ticks of the entity's lifetime.
126126
- `movement_affected_by`: Following the same structure as `location`, this matches what affects the movement of the entity.
127+
- `components` - Matches entity components exactly (the component must be exactly equal to what is being checked).
128+
- `predicates` - Matches entity components ignoring any other data in the component (the component must contain what is being checked).
127129

128130
### `entity_scores`
129131
`entity_scores` checks if the entity's score on an object matches a specified value or range.

src/routes/wiki/info/json/+page.svx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: "A rough guide to the JSON format used in Minecraft Datapacks (amon
44
---
55

66
# 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.
88

99
## How JSON works
1010
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.

src/routes/wiki/nbt-scoreboards/nbt/+page.svx

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: NBT
33
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
55
---
66

77
<script lang="ts">
@@ -91,22 +91,25 @@ string, text, booleans, and more.
9191
Strings can store any text value, or more technically, any sequence of unicode characters.
9292

9393
**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>`
9595

9696
**Example**: `name:"Silabear"`, `name:'Cobblestone'`, `name:Aandeel`
9797

9898
### Whole Numbers
9999

100100
**Short**, **Int**, and **Long** data types all represent integers (whole numbers).
101101

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
106106
`9,223,372,036,854,775,807`
107107

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`)
110113

111114
**Example**: `count:1234s`, `bigNumber:1200000`, `reallyBigNumber:12123023687234L`, `byte:112b`
112115

@@ -125,23 +128,16 @@ appropriate suffix. For floats, the suffix is `f`. For doubles, the suffix is `d
125128

126129
### Bytes or Booleans
127130

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.
132132

133-
### Arrays
134133

135-
Arrays are used to store multiple values of the same type. There are currently 3 types of arrays:
136134

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
140137

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)
143139

144-
**Example**: `[B;1b,2B,true,false]`, `[I;1,2,3,4,5]`, `[L;1l,2l,3l,4l,5l]`
140+
**Example**: `["Silabear", 15, true, 242]`, `[B;1b,2B,true,false]`, `["Kanokarob", "LadyEternal", "lionlance", "thederdiscohund", "theblackswitch"]`, `[L;1l,2l,3l,4l,5l]`
145141

146142
## Validator
147143

0 commit comments

Comments
 (0)