From c35ba92499bde19f19fbbfec859d4a220488e808 Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Mon, 22 Dec 2025 13:26:15 +0100 Subject: [PATCH 01/68] Create a page for Item --- wiki/ref/Item/en.yml | 0 wiki/ref/Item/meta.yml | 0 wiki/ref/Item/page.kubedoc | 10 ++++++++++ 3 files changed, 10 insertions(+) create mode 100644 wiki/ref/Item/en.yml create mode 100644 wiki/ref/Item/meta.yml create mode 100644 wiki/ref/Item/page.kubedoc diff --git a/wiki/ref/Item/en.yml b/wiki/ref/Item/en.yml new file mode 100644 index 00000000..e69de29b diff --git a/wiki/ref/Item/meta.yml b/wiki/ref/Item/meta.yml new file mode 100644 index 00000000..e69de29b diff --git a/wiki/ref/Item/page.kubedoc b/wiki/ref/Item/page.kubedoc new file mode 100644 index 00000000..f03156bf --- /dev/null +++ b/wiki/ref/Item/page.kubedoc @@ -0,0 +1,10 @@ +`Item`s are objects representing Minecraft items. +They are usually used in places where the item's components are needed. + +# Type wrappers +Various data types can wrap into `Item`s when an `Item` is expected. + +## String literals +- #[[orange|`<`]]#[[yellow|`item`]]#[[orange|`>`]] + - #[[orange|`<`]]#[[yellow|`item`]]#[[orange|`>`]] - A string corresponding to item ID. + - Example: `minecraft:diamond_sword` \ No newline at end of file From 116612b8f41a6b66f294fcb2a1c3375503508f71 Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Mon, 22 Dec 2025 13:32:50 +0100 Subject: [PATCH 02/68] Test en.yml --- wiki/ref/Item/en.yml | 3 +++ wiki/ref/Item/page.kubedoc | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/wiki/ref/Item/en.yml b/wiki/ref/Item/en.yml index e69de29b..fe59e2da 100644 --- a/wiki/ref/Item/en.yml +++ b/wiki/ref/Item/en.yml @@ -0,0 +1,3 @@ +- item: "#[[orange|`<`]]#[[yellow|`item`]]#[[orange|`>`]]" +- components: "#[[orange|`<`]]#[[yellow|`components`]]#[[orange|`>`]]" +- custom-data: "#[[orange|`<`]]#[[yellow|`custom-data`]]#[[orange|`>`]]" \ No newline at end of file diff --git a/wiki/ref/Item/page.kubedoc b/wiki/ref/Item/page.kubedoc index f03156bf..e19b0449 100644 --- a/wiki/ref/Item/page.kubedoc +++ b/wiki/ref/Item/page.kubedoc @@ -5,6 +5,6 @@ They are usually used in places where the item's components are needed. Various data types can wrap into `Item`s when an `Item` is expected. ## String literals -- #[[orange|`<`]]#[[yellow|`item`]]#[[orange|`>`]] - - #[[orange|`<`]]#[[yellow|`item`]]#[[orange|`>`]] - A string corresponding to item ID. +- {item} + - {item} - A string corresponding to item ID. - Example: `minecraft:diamond_sword` \ No newline at end of file From 0e6d772f89b3e8eb71a6c219096604a5d75d7ab4 Mon Sep 17 00:00:00 2001 From: Donaldino7712 <100215778+Donaldino7712@users.noreply.github.com> Date: Mon, 22 Dec 2025 13:38:27 +0100 Subject: [PATCH 03/68] why were the dashes here --- wiki/ref/Item/en.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wiki/ref/Item/en.yml b/wiki/ref/Item/en.yml index fe59e2da..3995b3a8 100644 --- a/wiki/ref/Item/en.yml +++ b/wiki/ref/Item/en.yml @@ -1,3 +1,3 @@ -- item: "#[[orange|`<`]]#[[yellow|`item`]]#[[orange|`>`]]" -- components: "#[[orange|`<`]]#[[yellow|`components`]]#[[orange|`>`]]" -- custom-data: "#[[orange|`<`]]#[[yellow|`custom-data`]]#[[orange|`>`]]" \ No newline at end of file +item: "#[[orange|`<`]]#[[yellow|`item`]]#[[orange|`>`]]" +components: "#[[orange|`<`]]#[[yellow|`components`]]#[[orange|`>`]]" +custom-data: "#[[orange|`<`]]#[[yellow|`custom-data`]]#[[orange|`>`]]" From 6927883ead7ee5b524e328f269bd9d7be53ff5fe Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Mon, 22 Dec 2025 13:39:41 +0100 Subject: [PATCH 04/68] Add components --- wiki/ref/Item/page.kubedoc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/wiki/ref/Item/page.kubedoc b/wiki/ref/Item/page.kubedoc index e19b0449..4b1db34c 100644 --- a/wiki/ref/Item/page.kubedoc +++ b/wiki/ref/Item/page.kubedoc @@ -7,4 +7,9 @@ Various data types can wrap into `Item`s when an `Item` is expected. ## String literals - {item} - {item} - A string corresponding to item ID. - - Example: `minecraft:diamond_sword` \ No newline at end of file + - Example: `minecraft:diamond_sword` + +- {item}`[`{components}`]` + - {item} - A string corresponding to item ID. + - {components} - A list of components formatted as follows: `key1=value1,key2=value2`. + - Example: `minecraft:diamond_sword[damage=2]` \ No newline at end of file From ce02483a8ab34f7640f30bf2372d310a2831ed79 Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Mon, 22 Dec 2025 13:42:07 +0100 Subject: [PATCH 05/68] Double backticks? --- wiki/ref/Item/page.kubedoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiki/ref/Item/page.kubedoc b/wiki/ref/Item/page.kubedoc index 4b1db34c..5a596b13 100644 --- a/wiki/ref/Item/page.kubedoc +++ b/wiki/ref/Item/page.kubedoc @@ -9,7 +9,7 @@ Various data types can wrap into `Item`s when an `Item` is expected. - {item} - A string corresponding to item ID. - Example: `minecraft:diamond_sword` -- {item}`[`{components}`]` +- {item}``[``{components}``]`` - {item} - A string corresponding to item ID. - {components} - A list of components formatted as follows: `key1=value1,key2=value2`. - Example: `minecraft:diamond_sword[damage=2]` \ No newline at end of file From 4c53de63120838678304d604e3023636ca9af710 Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Mon, 22 Dec 2025 13:42:39 +0100 Subject: [PATCH 06/68] That was bad, go back --- wiki/ref/Item/page.kubedoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiki/ref/Item/page.kubedoc b/wiki/ref/Item/page.kubedoc index 5a596b13..04489c98 100644 --- a/wiki/ref/Item/page.kubedoc +++ b/wiki/ref/Item/page.kubedoc @@ -9,7 +9,7 @@ Various data types can wrap into `Item`s when an `Item` is expected. - {item} - A string corresponding to item ID. - Example: `minecraft:diamond_sword` -- {item}``[``{components}``]`` +- {item} `[` {components} `]` - {item} - A string corresponding to item ID. - {components} - A list of components formatted as follows: `key1=value1,key2=value2`. - Example: `minecraft:diamond_sword[damage=2]` \ No newline at end of file From eeaef9870d070b64d65fc815c1b67e288f169ae8 Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Mon, 22 Dec 2025 13:44:12 +0100 Subject: [PATCH 07/68] Add brackets to placeholders instead --- wiki/ref/Item/en.yml | 4 ++-- wiki/ref/Item/page.kubedoc | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/wiki/ref/Item/en.yml b/wiki/ref/Item/en.yml index 3995b3a8..f4002da3 100644 --- a/wiki/ref/Item/en.yml +++ b/wiki/ref/Item/en.yml @@ -1,3 +1,3 @@ item: "#[[orange|`<`]]#[[yellow|`item`]]#[[orange|`>`]]" -components: "#[[orange|`<`]]#[[yellow|`components`]]#[[orange|`>`]]" -custom-data: "#[[orange|`<`]]#[[yellow|`custom-data`]]#[[orange|`>`]]" +components: "`[`#[[orange|`<`]]#[[yellow|`components`]]#[[orange|`>`]]`]`" +custom-data: "`{`#[[orange|`<`]]#[[yellow|`custom-data`]]#[[orange|`>`]]`}`" diff --git a/wiki/ref/Item/page.kubedoc b/wiki/ref/Item/page.kubedoc index 04489c98..9a312abc 100644 --- a/wiki/ref/Item/page.kubedoc +++ b/wiki/ref/Item/page.kubedoc @@ -9,7 +9,7 @@ Various data types can wrap into `Item`s when an `Item` is expected. - {item} - A string corresponding to item ID. - Example: `minecraft:diamond_sword` -- {item} `[` {components} `]` +- {item}{components} - {item} - A string corresponding to item ID. - - {components} - A list of components formatted as follows: `key1=value1,key2=value2`. + - {components} - A list of components formatted as follows: `[key1=value1,key2=value2]`. - Example: `minecraft:diamond_sword[damage=2]` \ No newline at end of file From 550a2ad1a71779df603f21eb9a4037cad29361fe Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Mon, 22 Dec 2025 13:45:24 +0100 Subject: [PATCH 08/68] Escape maybe? --- wiki/ref/Item/en.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wiki/ref/Item/en.yml b/wiki/ref/Item/en.yml index f4002da3..27ef7ef0 100644 --- a/wiki/ref/Item/en.yml +++ b/wiki/ref/Item/en.yml @@ -1,3 +1,3 @@ item: "#[[orange|`<`]]#[[yellow|`item`]]#[[orange|`>`]]" -components: "`[`#[[orange|`<`]]#[[yellow|`components`]]#[[orange|`>`]]`]`" -custom-data: "`{`#[[orange|`<`]]#[[yellow|`custom-data`]]#[[orange|`>`]]`}`" +components: "`\[`#[[orange|`<`]]#[[yellow|`components`]]#[[orange|`>`]]`\]`" +custom-data: "`\{`#[[orange|`<`]]#[[yellow|`custom-data`]]#[[orange|`>`]]`\}`" From e998bef4ccc3ef3517e7e843d3dc3b9f24ab2dbb Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Mon, 22 Dec 2025 13:53:06 +0100 Subject: [PATCH 09/68] Another attempt --- wiki/ref/Item/en.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wiki/ref/Item/en.yml b/wiki/ref/Item/en.yml index 27ef7ef0..b3e5a24b 100644 --- a/wiki/ref/Item/en.yml +++ b/wiki/ref/Item/en.yml @@ -1,3 +1,3 @@ item: "#[[orange|`<`]]#[[yellow|`item`]]#[[orange|`>`]]" -components: "`\[`#[[orange|`<`]]#[[yellow|`components`]]#[[orange|`>`]]`\]`" -custom-data: "`\{`#[[orange|`<`]]#[[yellow|`custom-data`]]#[[orange|`>`]]`\}`" +components: "#[[blue|`[`]]#[[orange|`<`]]#[[yellow|`components`]]#[[orange|`>`]]#[[blue|`[`]]" +custom-data: "#[[orange|`<`]]#[[yellow|`custom-data`]]#[[orange|`>`]]" From 496b5793f217a65509b72fff4e3156ac220ec5f8 Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Mon, 22 Dec 2025 13:54:00 +0100 Subject: [PATCH 10/68] Is the bracket a problem? --- wiki/ref/Item/page.kubedoc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wiki/ref/Item/page.kubedoc b/wiki/ref/Item/page.kubedoc index 9a312abc..f4af91a7 100644 --- a/wiki/ref/Item/page.kubedoc +++ b/wiki/ref/Item/page.kubedoc @@ -9,6 +9,8 @@ Various data types can wrap into `Item`s when an `Item` is expected. - {item} - A string corresponding to item ID. - Example: `minecraft:diamond_sword` +- #[[blue|`[`]] + - {item}{components} - {item} - A string corresponding to item ID. - {components} - A list of components formatted as follows: `[key1=value1,key2=value2]`. From e5dac15187c7a2ab9915af6ba205a6122aaf5084 Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Mon, 22 Dec 2025 13:54:38 +0100 Subject: [PATCH 11/68] x --- wiki/ref/Item/page.kubedoc | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/wiki/ref/Item/page.kubedoc b/wiki/ref/Item/page.kubedoc index f4af91a7..1f440e71 100644 --- a/wiki/ref/Item/page.kubedoc +++ b/wiki/ref/Item/page.kubedoc @@ -9,9 +9,4 @@ Various data types can wrap into `Item`s when an `Item` is expected. - {item} - A string corresponding to item ID. - Example: `minecraft:diamond_sword` -- #[[blue|`[`]] - -- {item}{components} - - {item} - A string corresponding to item ID. - - {components} - A list of components formatted as follows: `[key1=value1,key2=value2]`. - - Example: `minecraft:diamond_sword[damage=2]` \ No newline at end of file +- #[[blue|`[`]] \ No newline at end of file From ece391bc38cb672cb92329fb2e391fc15370cd60 Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Mon, 22 Dec 2025 13:56:22 +0100 Subject: [PATCH 12/68] Put a backslash --- wiki/ref/Item/page.kubedoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiki/ref/Item/page.kubedoc b/wiki/ref/Item/page.kubedoc index 1f440e71..e068bd1f 100644 --- a/wiki/ref/Item/page.kubedoc +++ b/wiki/ref/Item/page.kubedoc @@ -9,4 +9,4 @@ Various data types can wrap into `Item`s when an `Item` is expected. - {item} - A string corresponding to item ID. - Example: `minecraft:diamond_sword` -- #[[blue|`[`]] \ No newline at end of file +- #[[blue|`\[`]] \ No newline at end of file From ec16bbec7b0cad1d6723ad6efbb50398c4161e57 Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Mon, 22 Dec 2025 13:58:13 +0100 Subject: [PATCH 13/68] Hmm? --- wiki/ref/Item/page.kubedoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiki/ref/Item/page.kubedoc b/wiki/ref/Item/page.kubedoc index e068bd1f..9aa1d75a 100644 --- a/wiki/ref/Item/page.kubedoc +++ b/wiki/ref/Item/page.kubedoc @@ -9,4 +9,4 @@ Various data types can wrap into `Item`s when an `Item` is expected. - {item} - A string corresponding to item ID. - Example: `minecraft:diamond_sword` -- #[[blue|`\[`]] \ No newline at end of file +- #[[blue|`\[`]]#[[orange|`<`]]#[[yellow|`components`]]#[[orange|`>`]]#[[blue|`\]`]] \ No newline at end of file From 088c1d16440915e9c5d1a40549f58f29a401df9f Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Mon, 22 Dec 2025 14:06:21 +0100 Subject: [PATCH 14/68] Can I nest colors? --- wiki/ref/Item/page.kubedoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiki/ref/Item/page.kubedoc b/wiki/ref/Item/page.kubedoc index 9aa1d75a..af6ce972 100644 --- a/wiki/ref/Item/page.kubedoc +++ b/wiki/ref/Item/page.kubedoc @@ -9,4 +9,4 @@ Various data types can wrap into `Item`s when an `Item` is expected. - {item} - A string corresponding to item ID. - Example: `minecraft:diamond_sword` -- #[[blue|`\[`]]#[[orange|`<`]]#[[yellow|`components`]]#[[orange|`>`]]#[[blue|`\]`]] \ No newline at end of file +- #[[blue|`\[`#[[orange|`<`#[[yellow|`components`]]`>`]]`\]`]] From 6bdf26a457317320f0ba6e044dcf26f143a40862 Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Mon, 22 Dec 2025 14:08:04 +0100 Subject: [PATCH 15/68] Maybe the discolor is caused by HTML parsing bug? --- wiki/ref/Item/page.kubedoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiki/ref/Item/page.kubedoc b/wiki/ref/Item/page.kubedoc index af6ce972..74324352 100644 --- a/wiki/ref/Item/page.kubedoc +++ b/wiki/ref/Item/page.kubedoc @@ -9,4 +9,4 @@ Various data types can wrap into `Item`s when an `Item` is expected. - {item} - A string corresponding to item ID. - Example: `minecraft:diamond_sword` -- #[[blue|`\[`#[[orange|`<`#[[yellow|`components`]]`>`]]`\]`]] +- #[[blue|`\[`#[[orange|`<`#[[yellow|`components`]]`>`]]`\]`]] From 8c21e98c8187c92a95513d1f76494f6eaea6a67e Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Mon, 22 Dec 2025 14:09:10 +0100 Subject: [PATCH 16/68] No, it isn't --- wiki/ref/Item/page.kubedoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiki/ref/Item/page.kubedoc b/wiki/ref/Item/page.kubedoc index 74324352..af6ce972 100644 --- a/wiki/ref/Item/page.kubedoc +++ b/wiki/ref/Item/page.kubedoc @@ -9,4 +9,4 @@ Various data types can wrap into `Item`s when an `Item` is expected. - {item} - A string corresponding to item ID. - Example: `minecraft:diamond_sword` -- #[[blue|`\[`#[[orange|`<`#[[yellow|`components`]]`>`]]`\]`]] +- #[[blue|`\[`#[[orange|`<`#[[yellow|`components`]]`>`]]`\]`]] From 683907b76e82fd7ba3cdb7a7227534d9a95d87ef Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Mon, 22 Dec 2025 14:10:09 +0100 Subject: [PATCH 17/68] Remove blue --- wiki/ref/Item/page.kubedoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiki/ref/Item/page.kubedoc b/wiki/ref/Item/page.kubedoc index af6ce972..dcf32456 100644 --- a/wiki/ref/Item/page.kubedoc +++ b/wiki/ref/Item/page.kubedoc @@ -9,4 +9,4 @@ Various data types can wrap into `Item`s when an `Item` is expected. - {item} - A string corresponding to item ID. - Example: `minecraft:diamond_sword` -- #[[blue|`\[`#[[orange|`<`#[[yellow|`components`]]`>`]]`\]`]] +- `\[`#[[orange|`<`#[[yellow|`components`]]`>`]]`\]` From fbba652f0d007f737ce71e896eec46fb0c3a3098 Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Mon, 22 Dec 2025 14:15:51 +0100 Subject: [PATCH 18/68] This is it, I think --- wiki/ref/Item/en.yml | 6 +++--- wiki/ref/Item/page.kubedoc | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/wiki/ref/Item/en.yml b/wiki/ref/Item/en.yml index b3e5a24b..c1e8b69e 100644 --- a/wiki/ref/Item/en.yml +++ b/wiki/ref/Item/en.yml @@ -1,3 +1,3 @@ -item: "#[[orange|`<`]]#[[yellow|`item`]]#[[orange|`>`]]" -components: "#[[blue|`[`]]#[[orange|`<`]]#[[yellow|`components`]]#[[orange|`>`]]#[[blue|`[`]]" -custom-data: "#[[orange|`<`]]#[[yellow|`custom-data`]]#[[orange|`>`]]" +item: "[[yellow|``]]" +components: "#[[blue|`\[ `#[[yellow|``]]` \]`]]" +custom-data: "#[[blue|`\[ `#[[yellow|``]]` \]`]]" diff --git a/wiki/ref/Item/page.kubedoc b/wiki/ref/Item/page.kubedoc index dcf32456..69063e66 100644 --- a/wiki/ref/Item/page.kubedoc +++ b/wiki/ref/Item/page.kubedoc @@ -9,4 +9,7 @@ Various data types can wrap into `Item`s when an `Item` is expected. - {item} - A string corresponding to item ID. - Example: `minecraft:diamond_sword` -- `\[`#[[orange|`<`#[[yellow|`components`]]`>`]]`\]` +- {item}{components} + - {item} - A string corresponding to item ID. + - {components} - A list of components formatted as follows: `[key1=value1,key2=value2]`. + - Example: `minecraft:diamond_sword[damage=2]` From c761bc85055cfe21a9eb4ae24c6aff855261b76b Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Mon, 22 Dec 2025 14:16:36 +0100 Subject: [PATCH 19/68] No --- wiki/ref/Item/en.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wiki/ref/Item/en.yml b/wiki/ref/Item/en.yml index c1e8b69e..b571bd1f 100644 --- a/wiki/ref/Item/en.yml +++ b/wiki/ref/Item/en.yml @@ -1,3 +1,3 @@ -item: "[[yellow|``]]" -components: "#[[blue|`\[ `#[[yellow|``]]` \]`]]" -custom-data: "#[[blue|`\[ `#[[yellow|``]]` \]`]]" +item: "[[yellow|`<``item``>`]]" +components: "#[[blue|`\[ `#[[yellow|`<``components``>`]]` \]`]]" +custom-data: "#[[blue|`\[ `#[[yellow|`<``custom-data``>`]]` \]`]]" From 2c9679afcc1b2a0868b94591746c37ef61e6d0dc Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Mon, 22 Dec 2025 14:21:34 +0100 Subject: [PATCH 20/68] Test --- wiki/ref/Item/en.yml | 6 +++--- wiki/ref/Item/page.kubedoc | 5 +---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/wiki/ref/Item/en.yml b/wiki/ref/Item/en.yml index b571bd1f..82806bbe 100644 --- a/wiki/ref/Item/en.yml +++ b/wiki/ref/Item/en.yml @@ -1,3 +1,3 @@ -item: "[[yellow|`<``item``>`]]" -components: "#[[blue|`\[ `#[[yellow|`<``components``>`]]` \]`]]" -custom-data: "#[[blue|`\[ `#[[yellow|`<``custom-data``>`]]` \]`]]" +item: "#[[orange|`<`#[[yellow|`item`]]`>`]]" +components: "#[[blue|`\\[ `#[[orange|`<`#[[yellow|`components`]]`>`]]` \\]`]]" +custom-data: "#[[blue|`\\{ `#[[orange|`<`#[[yellow|`custom-data`]]`>`]]` \\}`]]" diff --git a/wiki/ref/Item/page.kubedoc b/wiki/ref/Item/page.kubedoc index 69063e66..880aa40b 100644 --- a/wiki/ref/Item/page.kubedoc +++ b/wiki/ref/Item/page.kubedoc @@ -9,7 +9,4 @@ Various data types can wrap into `Item`s when an `Item` is expected. - {item} - A string corresponding to item ID. - Example: `minecraft:diamond_sword` -- {item}{components} - - {item} - A string corresponding to item ID. - - {components} - A list of components formatted as follows: `[key1=value1,key2=value2]`. - - Example: `minecraft:diamond_sword[damage=2]` +- #[[blue|`\[ `#[[orange|`<`#[[yellow|`components`]]`>`]]` \]`]] \ No newline at end of file From 0dcb93f27023323965f00d8d914127619426d178 Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Mon, 22 Dec 2025 14:22:42 +0100 Subject: [PATCH 21/68] Maybe zero-width spaces will avoid ligatures? --- wiki/ref/Item/page.kubedoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiki/ref/Item/page.kubedoc b/wiki/ref/Item/page.kubedoc index 880aa40b..b64115b5 100644 --- a/wiki/ref/Item/page.kubedoc +++ b/wiki/ref/Item/page.kubedoc @@ -9,4 +9,4 @@ Various data types can wrap into `Item`s when an `Item` is expected. - {item} - A string corresponding to item ID. - Example: `minecraft:diamond_sword` -- #[[blue|`\[ `#[[orange|`<`#[[yellow|`components`]]`>`]]` \]`]] \ No newline at end of file +- #[[blue|`\[​`#[[orange|`<`#[[yellow|`components`]]`>`]]`​\]`]] \ No newline at end of file From 56758ac94ab18e146c5bbd3748ea0c6feb0d00ae Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Mon, 22 Dec 2025 14:27:18 +0100 Subject: [PATCH 22/68] Finally? --- wiki/ref/Item/page.kubedoc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/wiki/ref/Item/page.kubedoc b/wiki/ref/Item/page.kubedoc index b64115b5..e8a2f490 100644 --- a/wiki/ref/Item/page.kubedoc +++ b/wiki/ref/Item/page.kubedoc @@ -9,4 +9,9 @@ Various data types can wrap into `Item`s when an `Item` is expected. - {item} - A string corresponding to item ID. - Example: `minecraft:diamond_sword` +- {item}{components} + - {item} - A string corresponding to item ID. + - {components} - A list of components formatted as follows: `[key1=value1,key2=value2]`. + - Example: `minecraft:diamond_sword[damage=2]` + - #[[blue|`\[​`#[[orange|`<`#[[yellow|`components`]]`>`]]`​\]`]] \ No newline at end of file From ab7363ef33f9341e7654aeb9a71445cc87e9096b Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Mon, 22 Dec 2025 14:28:14 +0100 Subject: [PATCH 23/68] Add zero-wide spaces in placeholders --- wiki/ref/Item/en.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wiki/ref/Item/en.yml b/wiki/ref/Item/en.yml index 82806bbe..a931fe6d 100644 --- a/wiki/ref/Item/en.yml +++ b/wiki/ref/Item/en.yml @@ -1,3 +1,3 @@ item: "#[[orange|`<`#[[yellow|`item`]]`>`]]" -components: "#[[blue|`\\[ `#[[orange|`<`#[[yellow|`components`]]`>`]]` \\]`]]" -custom-data: "#[[blue|`\\{ `#[[orange|`<`#[[yellow|`custom-data`]]`>`]]` \\}`]]" +components: "#[[blue|`\\[​`#[[orange|`<`#[[yellow|`components`]]`>`]]`​\\]`]]" +custom-data: "#[[blue|`\\{​`#[[orange|`<`#[[yellow|`custom-data`]]`>`]]`​\\}`]]" From a248fa31e6af56b482a96d4f69eb9056b0275db0 Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Mon, 22 Dec 2025 14:34:45 +0100 Subject: [PATCH 24/68] Escape the square brackets --- wiki/ref/Item/page.kubedoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiki/ref/Item/page.kubedoc b/wiki/ref/Item/page.kubedoc index e8a2f490..d872d2ae 100644 --- a/wiki/ref/Item/page.kubedoc +++ b/wiki/ref/Item/page.kubedoc @@ -11,7 +11,7 @@ Various data types can wrap into `Item`s when an `Item` is expected. - {item}{components} - {item} - A string corresponding to item ID. - - {components} - A list of components formatted as follows: `[key1=value1,key2=value2]`. + - {components} - A list of components formatted as follows: `\[key1=value1,key2=value2\]`. - Example: `minecraft:diamond_sword[damage=2]` - #[[blue|`\[​`#[[orange|`<`#[[yellow|`components`]]`>`]]`​\]`]] \ No newline at end of file From 5cdf82184203a63b212e704c87dec10772fa8b57 Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Mon, 22 Dec 2025 16:46:39 +0100 Subject: [PATCH 25/68] Add ItemStack stub and documentation for ItemWrapper --- wiki/ref/Item/page.kubedoc | 22 ++- wiki/ref/ItemStack/en.yml | 3 + wiki/ref/ItemStack/meta.yml | 0 wiki/ref/ItemStack/page.kubedoc | 31 +++++ wiki/ref/ItemWrapper/en.yml | 3 + wiki/ref/ItemWrapper/meta.yml | 0 wiki/ref/ItemWrapper/page.kubedoc | 217 ++++++++++++++++++++++++++++++ 7 files changed, 273 insertions(+), 3 deletions(-) create mode 100644 wiki/ref/ItemStack/en.yml create mode 100644 wiki/ref/ItemStack/meta.yml create mode 100644 wiki/ref/ItemStack/page.kubedoc create mode 100644 wiki/ref/ItemWrapper/en.yml create mode 100644 wiki/ref/ItemWrapper/meta.yml create mode 100644 wiki/ref/ItemWrapper/page.kubedoc diff --git a/wiki/ref/Item/page.kubedoc b/wiki/ref/Item/page.kubedoc index d872d2ae..b55ae13b 100644 --- a/wiki/ref/Item/page.kubedoc +++ b/wiki/ref/Item/page.kubedoc @@ -5,13 +5,29 @@ They are usually used in places where the item's components are needed. Various data types can wrap into `Item`s when an `Item` is expected. ## String literals -- {item} + +### {item} - {item} - A string corresponding to item ID. + Special case: `''` (empty string), `'-'`, `air` and `minecraft:air` all result in the air item. - Example: `minecraft:diamond_sword` + - Results in a Diamond Sword. -- {item}{components} +### {item}{components} - {item} - A string corresponding to item ID. - {components} - A list of components formatted as follows: `\[key1=value1,key2=value2\]`. - Example: `minecraft:diamond_sword[damage=2]` + - Results in a Diamond Sword with 2 durability damage. + +### {item}{custom-data} + - {item} - A string corresponding to item ID. + - {custom-data} - A NBT compound tag to be stored into the `minecraft:custom_data` component, formatted as a stringified NBT: `\{key1:value1, key2:value2\}`. + - Example: `minecraft:diamond_sword{souls:2l}` + - Results in a Diamond Sword with `minecraft:custom_data` component set to `{souls:2l}`. + +# Methods + +This page contains only a small subset of possible methods. The following methods can be useful in scripts. +In code snippets below, `item` will refer to the instance of `Item`. -- #[[blue|`\[​`#[[orange|`<`#[[yellow|`components`]]`>`]]`​\]`]] \ No newline at end of file +- `[js]item.getId()` | Getter bean: `[js]item.id` + - Returns: The item's namespaced ID as a string. \ No newline at end of file diff --git a/wiki/ref/ItemStack/en.yml b/wiki/ref/ItemStack/en.yml new file mode 100644 index 00000000..a931fe6d --- /dev/null +++ b/wiki/ref/ItemStack/en.yml @@ -0,0 +1,3 @@ +item: "#[[orange|`<`#[[yellow|`item`]]`>`]]" +components: "#[[blue|`\\[​`#[[orange|`<`#[[yellow|`components`]]`>`]]`​\\]`]]" +custom-data: "#[[blue|`\\{​`#[[orange|`<`#[[yellow|`custom-data`]]`>`]]`​\\}`]]" diff --git a/wiki/ref/ItemStack/meta.yml b/wiki/ref/ItemStack/meta.yml new file mode 100644 index 00000000..e69de29b diff --git a/wiki/ref/ItemStack/page.kubedoc b/wiki/ref/ItemStack/page.kubedoc new file mode 100644 index 00000000..015f8883 --- /dev/null +++ b/wiki/ref/ItemStack/page.kubedoc @@ -0,0 +1,31 @@ +`ItemStack`s are objects representing stacks of Minecraft items. +They are usually used in recipe outputs. + +# Type wrappers +Various data types can wrap into `ItemStack`s when an `ItemStack` is expected. + +## String literals + +### {item} + - {item} - A string corresponding to item ID. + Special case: `''` (empty string), `'-'`, `air` and `minecraft:air` all result in the air item. + - Example: `minecraft:diamond_sword` + - Results in a Diamond Sword. + +### {item}{components} + - {item} - A string corresponding to item ID. + - {components} - A list of components formatted as follows: `\[key1=value1,key2=value2\]`. + - Example: `minecraft:diamond_sword[damage=2]` + - Results in a Diamond Sword with 2 durability damage. + +### {item}{custom-data} + - {item} - A string corresponding to item ID. + - {custom-data} - A NBT compound tag to be stored into the `minecraft:custom_data` component, formatted as a stringified NBT: `\{key1:value1, key2:value2\}`. + - Example: `minecraft:diamond_sword{souls:2l}` + - Results in a Diamond Sword with `minecraft:custom_data` component set to `{souls:2l}`. + +# Methods + +This page contains only a small subset of possible methods. The following methods can be useful in scripts. +In code snippets below, `stack` will refer to the instance of `ItemStack`. + diff --git a/wiki/ref/ItemWrapper/en.yml b/wiki/ref/ItemWrapper/en.yml new file mode 100644 index 00000000..a931fe6d --- /dev/null +++ b/wiki/ref/ItemWrapper/en.yml @@ -0,0 +1,3 @@ +item: "#[[orange|`<`#[[yellow|`item`]]`>`]]" +components: "#[[blue|`\\[​`#[[orange|`<`#[[yellow|`components`]]`>`]]`​\\]`]]" +custom-data: "#[[blue|`\\{​`#[[orange|`<`#[[yellow|`custom-data`]]`>`]]`​\\}`]]" diff --git a/wiki/ref/ItemWrapper/meta.yml b/wiki/ref/ItemWrapper/meta.yml new file mode 100644 index 00000000..e69de29b diff --git a/wiki/ref/ItemWrapper/page.kubedoc b/wiki/ref/ItemWrapper/page.kubedoc new file mode 100644 index 00000000..d325df60 --- /dev/null +++ b/wiki/ref/ItemWrapper/page.kubedoc @@ -0,0 +1,217 @@ +`ItemWrapper` is an interface containing many useful static methods for getting items from string. +It's exposed to [[/global-scope|global scope]] as `Item`. + +# Static methods + +## `of` +```js +Item.of(itemStack) +Item.of(itemStack, components) +Item.of(itemStack, count) +Item.of(itemStack, count, components) +``` +**Parameters** +- `[js]itemStack` - an [[/ref/ItemStack|ItemStack]]. Like with any other place that expects an `ItemStack`, the argument will be converted to `ItemStack` if possible. +**Optional parameters**: +- `[js]components` - A map of components. Can be a string representing key-value pairs: `damage=2, item_name={text:"Hello world"}`. +- `[js]count` - An integer, representing the size of the item stack. +**Returns** +- A new [[/ref/ItemStack|ItemStack]]. + +## `getList` + +```js +Item.getList() +Item.list // Bean +``` + +**Returns** +- A list of most items (as [[/ref/ItemStack|ItemStack]]s) in the game. Items, that are not in a creative tab are ignored. + +## `getTypeList` + +```js +Item.getTypeList() +Item.typeList // Bean +``` + +**Returns** +- A list of all the namespaced item IDs in the game as strings. + +## `getTypeToStackMap` + +```js +Item.getTypeToStackMap() +Item.typeToStackMap // Bean +``` + +**Returns** +- A map between ResourceLocations and collections of variants of [[/ref/ItemStack|ItemStack]]. + +## `getVariants` + +```js +Item.getVariants(itemStack) +``` +**Parameters** +- `[js]itemStack` - an [[/ref/ItemStack|ItemStack]]. +**Returns** +- A collections of variant of the given [[/ref/ItemStack|ItemStack]]. + +## `getEmpty` + +```js +Item.getEmpty() +Item.empty // Bean +``` + +**Returns** +- An [[/ref/ItemStack|ItemStack]] that represents an empty slot or air. + +## `fireworks` + +```js +Item.fireworks(fireworksProps) +``` + +**Parameters** +- `[js]fireworksProps` - a record containing fireworks properties. + +This parameter accepts an object in this place. + +```ts +type Fireworks = { + explosions?: FireworkExplosion[]; + flightDuration?: int +} + +type FireworkExplosion = { + /** Whether the explosion has a twinkle or not. */ + hasTwinkle?: boolean + /** Whether the explosion has a trail or not. */ + hasTrail?: boolean + /** The shape of the firework explosion. */ + shape?: 'small_ball' | 'large_ball' | 'star' | 'creeper' | 'burst' + /** + * What colors do the explosions have. + * Most comfortably described as an array of hex numbers, like: + * [0x2244ee, 0x33aaff] + */ + colors?: int[] + /** + * What colors do the explosions fade into. + * Most comfortably described as an array of hex numbers, like: + * [0x2244ee, 0x33aaff] + */ + fadeColors?: int[] +} +``` + +**Returns** +- A `Fireworks` object. + +**Example** +```js +Item.fireworks({ + explosions: [ + { + hasTwinkle: true, + hasTrail: false, + shape: 'creeper', + colors: [0xaa11ff], + fadeColors: [0xee33ff], + }, + ], + flightDuration: 5 +}) +``` + +## `getItem` + +```js +Item.getItem(id) +``` + +**Parameters** +- `[js]id` - a ResourceLocation instance or a string representing a resource location, like `'minecraft:diamond_sword'`. +**Returns** +An [[/ref/Item|Item]] instance. + +## `getID` + +```js +Item.getID(item) +``` + +**Parameters** +- `[js]item` - an [[/ref/Item|Item]]. +**Returns** +An ResourceLocation of the item. + +## `exists` + +```js +Item.exists(id) +``` + +**Parameters** +- `[js]id` - a ResourceLocation instance or a string representing a resource location, like `'minecraft:diamond_sword'`. +**Returns** +`true` if the item corresponding to the ID exists, `false` otherwise. + +## `isItem` + +```js +Item.isItem(object) +``` + +**Parameters** +- `[js]object` - Any object. +**Returns** +`true` if the object is an instance of [[/ref/ItemStack|ItemStack]], `false` otherwise. + +## `playerHead` + +```js +Item.playerHead(nickname) +``` + +**Parameters** +- `[js]nickname` - A nickname of a player to get their head. +**Returns** +A player head with the `minecraft:profile` data component applied. + +## `playerHeadfromBase64` + +```js +Item.playerHeadfromBase64(uuid, textureBase64) +``` + +**Parameters** +- `[js]uuid` - A non-null UUID. +- `[js]textureBase64` - Texture data JSON to apply to the head, encoded in Base64. + +**Returns** +A player head with the `minecraft:profile` data component applied. + +## `playerHeadFromUrl` + +```js +Item.playerHeadFromUrl(url) +``` + +**Parameters** +- `[js]url` - A URL leading to the texture data JSON to apply to the head. +**Returns** +A player head with the `minecraft:profile` data component applied. + +## `playerHeadfromStringHash` + +```js +Item.playerHeadfromStringHash(stringHash) +``` + +**Parameters** +- `[js]stringHash` - A string hash of the player to get the texture data JSON from. +**Returns** +A player head with the `minecraft:profile` data component applied. From 839167e5aea59415827078d8ff13df3e3054d5a6 Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Tue, 23 Dec 2025 12:16:10 +0100 Subject: [PATCH 26/68] Update ItemStack page - Mention other strings that wrap into empty ingredients - Mention string list syntax for Ingredients - Mention non-bean methods to make it more apparent that the beans are readonly, and can't be written to --- wiki/concepts/ingredient/page.kubedoc | 78 +++++++++++++++++++-------- 1 file changed, 57 insertions(+), 21 deletions(-) diff --git a/wiki/concepts/ingredient/page.kubedoc b/wiki/concepts/ingredient/page.kubedoc index b6e694b5..5485a1fa 100644 --- a/wiki/concepts/ingredient/page.kubedoc +++ b/wiki/concepts/ingredient/page.kubedoc @@ -4,10 +4,10 @@ This page was created with KubeJS 7.2 (for 1.21.1) in mind. Most of the informat We are working on creating alternate versions of this page for other versions of Minecraft. <<< -An `Ingredient` is a filter over items that is used to determine which item stacks are valid inputs for a given recipe. In their most basic form, they can either match a single item, a item tag, or any combination of the previous two (as a list). Additionally, more complex ingredients exist that allow filtering by creative tab or mod name, or let you subtract one ingredient from another, as elaborated on below. +An `Ingredient` is a filter over items that is used to determine which item stacks are valid inputs for a given recipe. In their most basic form, they can either match a single item, an item tag, or any combination of the previous two (as a list). Additionally, more complex ingredients exist that allow filtering by creative tab or mod name, or let you subtract one ingredient from another, as elaborated on below. >>> info -Ingredients are **unstacked** by default, though NeoForge provides a `SizedIngredient` to fill that gap. SizedIngredients use the same syntax as ingredients, though additionally support a stack size (see [[/concepts/item-stack|`ItemStack`]] as well) during parsing. +Ingredients are **unstacked** by default, though NeoForge provides a `SizedIngredient` to fill that gap. SizedIngredients use the same syntax as ingredients, though additionally support a stack size (see [[/concepts/item-stack|`ItemStack`]] as well) during parsing. <<< # Creating Ingredients @@ -15,7 +15,7 @@ KubeJS will automatically try to *wrap* any input to an ingredient in places whe ## Simple Ingredients Most simple ingredient types may simply be written as a string, for example: -- `'-'` will return an ingredient that matches nothing, while `'*'` returns one that matches anything +- `''` (empty string), `'-'`, `air` and `minecraft:air` will return an ingredient that matches nothing, while `'*'` returns one that matches anything - any item ID (such as `'minecraft:apple'`) will create an Ingredient that matches that specific item (ignoring data) - any ID beginning with a `#` will match the tag with the given name, for example `'#c:ingots/iron'` will match all iron ingots - an item ID followed by a **component filter** (using the same syntax as [`/give`](https://minecraft.wiki/w/Argument_types#item_stack)) creates an ingredient that matches that item with the given data @@ -31,36 +31,72 @@ Use [[/tutorials/hand|`/kubejs hand`]] to get some useful string representations As mentioned above, Ingredients may also be *nested* by using lists, which means that for example, ```js [ - "minecraft:apple", // either an apple - "#c:ingots/copper", // OR any copper ingot - "@create", // OR any item added by Create - "-" // OR nothing, which does... nothing + 'minecraft:apple', // either an apple + '#c:ingots/copper', // OR any copper ingot + '@create', // OR any item added by Create + '-' // OR nothing, which does... nothing ] ``` -is valid syntax and will match any item that fulfills ANY of these conditions. +and: +```js +Ingredient.of('[minecraft:apple, #c:ingots/copper, @create, -]') +``` +are valid syntaxes and will match any item that fulfills ANY of these conditions. -Additionally, if you want to create an `[js]Ingredient` that needs to match **multiple** conditions, you can use the method `[js]ingredient.and(other)` on an existing ingredient to create a so-called `IntersectionIngredient`: `[js]Ingredient.of('#c:ingots').and('@create')` for example will match any ingots that have been added by Create. +Additionally, if you want to create an `[js]Ingredient` that needs to match **multiple** conditions, you can use the method `[js]ingredient.and(other)` on an existing ingredient to create a so-called `IntersectionIngredient`: `[js]Ingredient.of('#c:ingots').and('@create')` for example will match any ingots that have been added by Create. -Similarly, `[js]ingredient.except(other)` can be used on an ingredient to create a `SubtractionIngredient`, i.e. an ingredient that matches all items from the first ingredient that are NOT contained in the second ingredient. In the above example, replacing `and` with `except` would thus match any ingot NOT added by Create. +Similarly, `[js]ingredient.except(other)` can be used on an ingredient to create a `SubtractionIngredient`, i.e. an ingredient that matches all items from the first ingredient that are NOT contained in the second ingredient. In the above example, replacing `and` with `except` would thus match any ingot NOT added by Create. Finally, you can create a SizedIngredient directly by using `[js]Ingredient.of(ingredient, amount)`. # Using Ingredients >>> danger -Ingredients are **lazily resolved** and will cache their results once tested. For this reason, we do __not__ allow using Ingredient in contexts where ItemStack is expected! +Ingredients are **lazily resolved** and will cache their results once tested. +For this reason, we do __not__ allow using Ingredient in contexts where ItemStack is expected! +<<< + +## Useful Methods + +- `[js]ingredient.and(other)`: + - `other` - Another ingredient. + - **Returns**: An ingredient accepting items that match both this ingredient and `other`. +- `[js]ingredient.or(other)`: + - `other` - Another ingredient. + - **Returns**: An ingredient accepting items that match this ingredient or `other`. +- `[js]ingredient.except(other)`: + - `other` - Another ingredient. + - **Returns**: An ingredient accepting items that match this ingredient, but not `other`. +- `[js]ingredient.withCount(count)` + - `count` - An integer specifying count of the ingredient. + - **Returns**: a `SizedIngredient` of this ingredient with the given count +- `[js]ingredient.asStack()` + - **Returns**: a `SizedIngredient` of size 1, equivalent to `[js]ingredient.withCount(1)` +- `[js]ingredient.test(item)`: + - `item`: The `ItemStack` to test whether it is a part of the ingredient. + - **Returns**: `true` if the provided item stack matches this ingredient, `false` otherwise. **This resolves the ingredient!** +- `[js]ingredient.getItems()` +- `[js]ingredient.getStackArray()` + - **Returns**: An array of all ItemStacks that match the ingredient. **This resolves the ingredient!** + +>>> info +Also available as **read-only** beans: `[js]ingredient.items`, `[js]ingredient.stackArray`. <<< -## Useful Methods and Properties -- `[js]ingredient.and(other)`: create an ingredient accepting items that match both this ingredient and `other` -- `[js]ingredient.or(other)`: create an ingredient accepting items that match this ingredient or `other` -- `[js]ingredient.except(other)`: create an ingredient accepting items that match this ingredient, but not `other` -- `[js]ingredient.withCount(count)`: Returns a `SizedIngredient` of this ingredient with the given count - - `[js]ingredient.asStack()` = `[js]ingredient.withCount(1)` -- `[js]ingredient.test(item)`: tests if the provided item stack matches this ingredient. **This resolves the ingredient!** -- `[js]ingredient.items`: **resolves** the ingredient and returns a list of all matching item stacks - - (`[js]ingredient.stacks`, `[js]ingredient.stackArray`, `[js]ingredient.displayStacks` are variants of this) -- `[js]ingredient.first`: **resolves** the ingredient and returns the first stack that matches it +- `[js]ingredient.getStacks()` +- `[js]ingredient.getDisplayStacks()` + - **Returns**: An ItemStackSet of all ItemStacks that match the ingredient. **This resolves the ingredient!** + +>>> info +Also available as **read-only** beans: `[js]ingredient.stacks`, `[js]ingredient.displayStacks`. +<<< + +- `[js]ingredient.getFirst()`: +- **Returns**: The first stack that matches the ingredient. **This resolves the ingredient!** + +>>> info +Also available as a **read-only** bean: `[js]ingredient.first`. +<<< # Further Reading - [Ingredients | NeoForged docs](https://docs.neoforged.net/docs/1.21.1/resources/server/recipes/ingredients/) \ No newline at end of file From 9fa2782eceb014f24f06ad3c9e25250053761da3 Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Tue, 23 Dec 2025 12:30:51 +0100 Subject: [PATCH 27/68] Add syntaxes for sized ingredients --- wiki/concepts/ingredient/page.kubedoc | 35 ++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/wiki/concepts/ingredient/page.kubedoc b/wiki/concepts/ingredient/page.kubedoc index 5485a1fa..24318a02 100644 --- a/wiki/concepts/ingredient/page.kubedoc +++ b/wiki/concepts/ingredient/page.kubedoc @@ -14,19 +14,42 @@ Ingredients are **unstacked** by default, though NeoForge provides a `SizedIngre KubeJS will automatically try to *wrap* any input to an ingredient in places where it is expected, but you can also use the `Ingredient` wrapper ([source](https://github.com/KubeJS-Mods/KubeJS/blob/main/src/main/java/dev/latvian/mods/kubejs/plugin/builtin/wrapper/IngredientWrapper.java)) to explicitly create them yourself, specifically using the method `[js]Ingredient.of(input)`: ## Simple Ingredients -Most simple ingredient types may simply be written as a string, for example: -- `''` (empty string), `'-'`, `air` and `minecraft:air` will return an ingredient that matches nothing, while `'*'` returns one that matches anything -- any item ID (such as `'minecraft:apple'`) will create an Ingredient that matches that specific item (ignoring data) -- any ID beginning with a `#` will match the tag with the given name, for example `'#c:ingots/iron'` will match all iron ingots -- an item ID followed by a **component filter** (using the same syntax as [`/give`](https://minecraft.wiki/w/Argument_types#item_stack)) creates an ingredient that matches that item with the given data +Most simple ingredient types may simply be written as string literals. +- `''` (empty string), `'-'`, `air` and `minecraft:air` will return an ingredient that matches nothing, while `'*'` returns one that matches anything. +- Any item ID will create an Ingredient that matches that specific item (ignoring data). + - Example: `[js]Ingredient.of('minecraft:apple')` +- Any ID beginning with a `#` will match the tag with the given name, for example `'#c:ingots/iron'` will match all iron ingots. + - Example: `[js]Ingredient.of('#c:ingots/copper')` + +>>> warn +Tag ingredients are not available in startup scripts! +<<< + +- An item ID followed by a **component filter** (using the same syntax as [`/give`](https://minecraft.wiki/w/Argument_types#item_stack)) creates an ingredient that matches that item with the given components + - Example: `[js]Ingredient.of('minecraft:diamond_sword[damage=2]')` - `'@modid'` will match all items added by the mod with the given mod ID + - Example: `[js]Ingredient.of('@create')` - `%` followed by an ID will match any items contained in the creative tab with that ID -- A regular expression (either using the JavaScript regex syntax or as a string) will match all items where the ID matches that regex, e.g. `[js]/minecraft:(gold|iron)_ingot/` will match bold Gold and Iron Ingots. + - Example: `[js]Ingredient.of('%minecraft:building_blocks')` +- A regular expression (either using the JavaScript regex syntax or as a string) will match all items where the ID matches that regex. + - Examples: + - `[js]Ingredient.of(/minecraft:(gold|iron)_ingot/)` + - `[js]Ingredient.of('/minecraft:(gold|iron)_ingot/')` + - Both of these will match both Gold and Iron Ingots. >>> quote Use [[/tutorials/hand|`/kubejs hand`]] to get some useful string representations of the item in your hand! <<< +## Sized ingredients +You can create sized ingredients from regular ones by either: +- in string syntax - prepending the ingredient with an integer number and a letter `x`. + - Example: `[js]Ingredient.of('2x minecraft:apple')` +- using `[js]Ingredient.of(ingredient, count)` + - Example: `[js]Ingredient.of('minecraft:apple', 2)` +- or by using the `withSize` method on ingredients. + - Example: `[js]Ingredient.of('minecraft:apple').withSize(2)` + ## Compound Ingredients As mentioned above, Ingredients may also be *nested* by using lists, which means that for example, ```js From 1e07e4af76f767e929de0dfa422e8e0746748a9f Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Tue, 23 Dec 2025 13:07:15 +0100 Subject: [PATCH 28/68] Remove the duplicate mention of SizedIngredient syntax as it was added before --- wiki/concepts/ingredient/page.kubedoc | 2 -- 1 file changed, 2 deletions(-) diff --git a/wiki/concepts/ingredient/page.kubedoc b/wiki/concepts/ingredient/page.kubedoc index 24318a02..183fc702 100644 --- a/wiki/concepts/ingredient/page.kubedoc +++ b/wiki/concepts/ingredient/page.kubedoc @@ -70,8 +70,6 @@ Additionally, if you want to create an `[js]Ingredient` that needs to match **mu Similarly, `[js]ingredient.except(other)` can be used on an ingredient to create a `SubtractionIngredient`, i.e. an ingredient that matches all items from the first ingredient that are NOT contained in the second ingredient. In the above example, replacing `and` with `except` would thus match any ingot NOT added by Create. -Finally, you can create a SizedIngredient directly by using `[js]Ingredient.of(ingredient, amount)`. - # Using Ingredients >>> danger From 314892ac915933e9996a29203e50dd2e85307fbe Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Wed, 24 Dec 2025 16:48:26 +0100 Subject: [PATCH 29/68] Reword and add more info to ItemStack article --- wiki/concepts/item-stack/page.kubedoc | 145 +++++++++++++++++++------- wiki/ref/ItemWrapper/page.kubedoc | 4 + 2 files changed, 112 insertions(+), 37 deletions(-) diff --git a/wiki/concepts/item-stack/page.kubedoc b/wiki/concepts/item-stack/page.kubedoc index 89332a2d..4216e3ed 100644 --- a/wiki/concepts/item-stack/page.kubedoc +++ b/wiki/concepts/item-stack/page.kubedoc @@ -4,64 +4,135 @@ This page was created with KubeJS 7.2 (for 1.21.1) in mind. Most of the informat We are working on creating alternate versions of this page for other versions of Minecraft. <<< -An `ItemStack` is an item associated with an amount and optionally some data attached to it. Or to put it slightly differently, it is... well, _a single stack_ of items that all share the same data. It is also the representation of an "item" that is most familiar to players, since item stacks are what you hold in your inventory, pick up from the ground, etc. +An `ItemStack` is an item associated with an amount and optionally some data attached to it. +Or to put it slightly differently, it is... well, *a single stack* of items that all share the same data. It is also the representation of an "item" that is most familiar to players, since item stacks are what you hold in your inventory, pick up from the ground, etc. -You may consider the `Item` contained in an `ItemStack` to basically just be the raw "definition" of what that item is; for example, all diamond axes share the same item ID `minecraft:diamond_axe`, they all use the same item, but two diamond axes with different amounts of damage in your inventory, like `diamond_axe[damage=123]` and `diamond_axe[damage=456]` would be part of different **item stacks** since their data doesn't overlap. Similarly, two sticks with custom lore `stick[lore=[{text:"This Stick is very sticky."}]]` would work as part of the same item stack. +You may consider the `Item` contained in an `ItemStack` to basically just be the raw "definition" of what that item is. +For example, all Diamond Axes share the same item ID `minecraft:diamond_axe`, they all use the same item, but two Diamond Axes with different amounts of damage in your inventory, like `minecraft:diamond_axe[damage=123]` and `minecraft:diamond_axe[damage=456]` would be part of different **item stacks** since their data doesn't overlap. +Similarly, two sticks with custom lore `minecraft:stick[lore=[{text:"This Stick is very sticky."}]]` would work as part of the same item stack. >>> quote -Since 1.20.4, data on items has changed *significantly* with the transition from NBT to data components. A neat side effect of this is that you can now change and override things that used to be hardcoded into the item definition itself, like the item's max stack size, enchantibility, repair ingredients, etc. +Since 1.20.4, data on items has changed *significantly* with the transition from NBT to data components. A neat side effect of this is that you can now change and override things that used to be hardcoded into the item definition itself, like the item's max stack size, enchantability, repair ingredients, etc. <<< # Creating ItemStacks -KubeJS will automatically try to *wrap* any input to an item stack in places where it is expected, but you can also use the `Item` wrapper ([source](https://github.com/KubeJS-Mods/KubeJS/blob/main/src/main/java/dev/latvian/mods/kubejs/plugin/builtin/wrapper/ItemWrapper.java)) to explicitly create them yourself, specifically using `[js]Item.of(input)` and `[js]Item.of(input, count)`: +KubeJS will automatically try to *wrap* any input to an item stack in places where it is expected, but you can also use the `Item` wrapper ([[/ref/ItemWrapper|reference]]) to explicitly create them yourself, specifically using `[js]Item.of(input)` and `[js]Item.of(input, count)`: -In this case, the most simple way to write an item (and the one we recommend here) is by specifying its string ID, which you can most easily find by either enabling *advanced tooltips* in your game (press F3+H) and hovering over the item in your inventory, or by using the ever-useful [[/tutorials/hand|`/kubejs hand`]]! +Most ItemStacks can be simply written as string literals. -Here are some example string inputs that will parse to item stacks: +- `''` (empty string), `'-'`, `'air'` and `'minecraft:air'` will return an empty ItemStack. It doesn't seem particularly useful, but hey, it's there! +- Any item ID will create an ItemStack of that specific item. +You can find item IDs easily by either enabling *advanced tooltips* in your game (press F3+H) and hovering over the item in your inventory, or by using the ever-useful [[/tutorials/hand|`/kubejs hand`]]! + - Example: `[js]Item.of('minecraft:apple')` +- Prepending the item ID with an integer number and a letter `x` will create an item stack, with the stack size equal to the specified integer number. + - Example: `[js]Item.of('2x minecraft:apple')` +- An item ID followed by a component (using the same syntax as [`/give`](https://minecraft.wiki/w/Argument_types#item_stack)) creates an item stack of the given item with the given components + - Example: `[js]Item.of('minecraft:diamond_sword[damage=2]')` -- `[js]'minecraft:air'` is the empty item, which... doesn't seem particularly useful, but hey, maybe good to know still! -- `[js]'minecraft:apple'` is a single apple. (Note: If you're using vanilla items, the `minecraft:` may be omitted as well!) -- `[js]'2x minecraft:apple'` represents a stack of two apples together. -- `[js]'3x stick[lore=[{text:"This Stick is very sticky."}]]'` represents a stack of three very sticky sticks (with custom data components!) +You can of course, combine these syntaxes: +- `[js]Item.of('3x minecraft:stick[lore=[{text:"This Stick is very sticky."}]])'` will result a stack of three very sticky sticks (with custom data components!) -Also note that while possible in some older versions of KubeJS, [[/concepts/ingredient|`Ingredient`]]s are **unsupported** and WILL now error if you try to convert them to an ItemStack implicitly, just use `ingredient.first`! +Also note that while possible in some older versions of KubeJS, [[/concepts/ingredient|`Ingredient`]]s are **unsupported** and WILL now error if you try to convert them to an ItemStack implicitly. If you want to explicitly convert an `Ingredient` into an `ItemStack`, use `ingredient.first`! # Using ItemStacks ## Useful Methods and Properties -- `[js]item.block`: If this item is a `BlockItem`, returns the associated block, else `null` -- `[js]item.count` (**writable**): The count of this item stack - - related: `[js]item.grow(amount)` and `[js]item.shrink(amount)` in- or decrease the current stack's count by `amount` - - related: `[js]item.withCount(count)`: Copies this stack with the specified `count` -- `[js]item.areItemsEqual(other)`: Returns `true` if `item` and `other` have the same item type -- `[js]item.areComponentsEqual(other)`: Returns `true` if `item` and `other` have the same item and data +- `[js]item.getBlock()`: + - **Returns**: The associated `Block` is the item corresponds to a block (that is - is an instance of `BlockItem`), otherwise `null`. +>>>info +Also available as a **read-only** bean: `item.block`. +<<< +- `[js]item.count` - Accessor for the stack size of the item. +>>>info +Also available as a getter `[js]item.setCount(count)` and setter `[js]item.getCount()`. +<<< +- `[js]item.grow(amount)` + - `amount` - Specifies, by how much should the stack size be increased. + - Returns nothing (`undefined`). + +- `[js]item.shrink(amount)` + - `amount` - Specifies, by how much should the stack size be decreased. + - Returns nothing (`undefined`). + +- `[js]item.withCount(count)` + - `count` - The stack size of the new item stack. + - **Returns** - A copy of the `item` with stack size of `count`. + +- `[js]item.areItemsEqual(other)`: + - `other`: An `ItemStack` to compare to. + - **Returns** `true` if `item` and `other` relate to the same item type, `false` otherwise. + +- `[js]item.areComponentsEqual(other)`: + - `other`: An `ItemStack` to compare to. + - **Returns** `true` if `item` and `other` relate to the same item and have **identical components**, `false` otherwise. ## Registry Object Functions -(these functions are all present on `Item` as well) -- `[js]item.id`: Returns the item's ID in the item registry (as a string) - - related: `[js]item.idLocation` (as `ResourceLocation`), `[js]item.key` (as `ResourceKey`) - - related: `[js]item.mod` returns *namespace* the item was registered for -- `[js]item.holder`: Wraps this item as a Holder (internal registry object) -- `[js]item.registry`: Returns the item registry - - related: `[js]item.registryId`: Returns the *key* of the item registry -- `[js]item.tags`: Returns a list of all tags for this item - - related: `[js]item.tagKeys`: Returns a list of `TagKey` instead of `ResourceLocation` - - related: `[js]item.hasTag(tag)`: Checks if this item has a certain tag +These functions are all inherited from `Item`. +Described here will be **read-only** beans, but be aware that for the `x` bean, `getX()` getter exists. + +- `[js]item.id`: Gets the item's ID in the item registry (as a string) +- `[js]item.idLocation`: Gets the item's ID in the item registry (as a `ResourceLocation`) +- `[js]item.key`: Gets the item's ID in the item registry (as a `ResourceKey`) +- `[js]item.mod`: Gets the **namespace** of an item. + - For example, for `item` being `minecraft:stone`, `item.mod` will be `minecraft`. + +- `[js]item.holder`: Gets the item wrapped into a Holder (internal registry object). +- `[js]item.registry`: Gets the item registry. +- `[js]item.registryId`: Gets the *key* of the item registry +- `[js]item.tags`: Gets a list of all tags for this item, as `ResourceLocation` objects. +- `[js]item.tagKeys`: Gets a list of all tags for this item, as `TagKey` objects. + +- `[js]item.hasTag(tag)`: Checks if this item has a certain tag. + - `tag` - A `ResourceLocation` or a string corresponding to a tag (for example `minecraft:logs`). + - **Returns**: `true` if the item has `tag` as a tag, `false` otherwise. ## Component Functions WIP! (TODO: make a page on Components and KubeJS' ComponentFunctions interface) -- `[js]componentString`: Returns the item's data components as a string representation -- `[js]withCustomName(name)`: Copies this item stack with the specified name -- `[js]enchantments`: Retrieves the item's enchantments -- `[js]hasEnchantment(enchantment, level)`: Checks if the item has a specific enchantment at or above a given level -- `[js]enchant(enchantment, level)`: Adds an enchantment to the ItemStack (TODO: enchantments page?) -- `[js]enchant(enchantments)`: Adds enchantments to the ItemStack (TODO: enchantments page?) -- `[js]getHarvestSpeed(block?)`: Gets the item's harvest speed for a given block (or default) -- `[js]typeData`: ??? (is this just a custom map for scripters to use to attach data to item definitions?) -- `[js]toItemString()`: Converts the ItemStack to its KubeJS string representation -- `[js]asIngredient()`: Converts the ItemStack to an `Ingredient` +- `[js]item.components`: Gets a `DataComponentMap` (a map of item's components) of the item. +- `[js]item.componentString`: Gets a stringified representation of the item's components. + +- `[js]item.enchantments`: Retrieves the item's enchantments, as an `ItemEnchantments` object. +- `[js]item.hasEnchantment(enchantment, level)`: + - `enchantment`: The enchantment to check for. It may be a string representing an enchantment (like `minecraft:efficiency`). + - `level`: The level to compare to. + - **Returns**: `true` if the item has the given enchantment at a given level or higher, `false` otherwise. +- `[js]item.enchant(enchantment, level)`: + - `enchantment`: The enchantment to check for. It may be a string representing an enchantment (like `minecraft:efficiency`). + - `level`: The level of the enchantment + - **Returns**: A copy of `item` with the enchantment applied. Only enchantments that were not present on the `item` already or that were below the level applied will be changed. +- `[js]item.enchant(enchantments)`: + - `enchantments`: The enchantments to apply. It may be an object with keys being strings representing enchantments and values being the levels of enchantments. + - **Returns**: A copy of `item` with the enchantments applied. Only enchantments that were not present on the `item` already or that were below the level applied will be changed. + - Example: + ```js + const enchItem = item.enchant({ + "minecraft:efficiency": 5, + "minecraft:unbreaking": 3, + "minecraft:mending": 1 + }) + // Will result in a copy of an item with the following enchantments applied: + // Efficiency V, Unbreaking III, Mending + ``` + +- `[js]item.getHarvestSpeed()`: +- `[js]item.getHarvestSpeed(block)`: + - `block` #[[#z\51565D|\[Optional\]]]: The `Block` to check the harvest speed against. + - **Returns**: The harvest speed of the item against a given block, or its default harvest speed if `block` isn't provided. +- `[js]item.toItemString()`: + - **Returns**: A KubeJS string representation of an ItemStack. + Essentially does the reverse of an item wrapper, for example: + For an `item` being a stack of 64 Sand, `[js]item.toItemString()` returns `[js]'64x minecraft:sand'`. +- `[js]item.asIngredient()` + - **Returns**: An `Ingredient` which matches the `item`. + +- `[js]item.withCustomName(name)`: + - `name` - A text `Component` to apply as custom name. It may be a plain string, for example: `[js]'My custom item!'` + - **Returns**: A copy of `item` with `minecraft:custom_name` data component applied. - `[js]withLore(lore)`: Copies this item stack with the specified lore text + - `lore` - An **array** of text `Component`s to apply as lore. Components in the array may be plain strings, for example: `[js]\['Some cool lore!', 'KubeJS rocks!'\]` + - **Returns**: A copy of `item` with `minecraft:lore` data component applied. +- `[js]typeData`: ??? (is this just a custom map for scripters to use to attach data to item definitions?) # Further Reading - [Data Components](/concepts/data-components) diff --git a/wiki/ref/ItemWrapper/page.kubedoc b/wiki/ref/ItemWrapper/page.kubedoc index d325df60..cb0e08f5 100644 --- a/wiki/ref/ItemWrapper/page.kubedoc +++ b/wiki/ref/ItemWrapper/page.kubedoc @@ -215,3 +215,7 @@ Item.playerHeadfromStringHash(stringHash) - `[js]stringHash` - A string hash of the player to get the texture data JSON from. **Returns** A player head with the `minecraft:profile` data component applied. + +# Source + +([ItemWrapper.java](https://github.com/KubeJS-Mods/KubeJS/blob/main/src/main/java/dev/latvian/mods/kubejs/plugin/builtin/wrapper/ItemWrapper.java)) \ No newline at end of file From 6e8d8fc86ca7227b748f2ad50968f2f7a155dac8 Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Wed, 24 Dec 2025 16:49:53 +0100 Subject: [PATCH 30/68] Add line break --- wiki/concepts/item-stack/page.kubedoc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wiki/concepts/item-stack/page.kubedoc b/wiki/concepts/item-stack/page.kubedoc index 4216e3ed..b6e68cc9 100644 --- a/wiki/concepts/item-stack/page.kubedoc +++ b/wiki/concepts/item-stack/page.kubedoc @@ -130,7 +130,8 @@ WIP! (TODO: make a page on Components and KubeJS' ComponentFunctions interface) - `name` - A text `Component` to apply as custom name. It may be a plain string, for example: `[js]'My custom item!'` - **Returns**: A copy of `item` with `minecraft:custom_name` data component applied. - `[js]withLore(lore)`: Copies this item stack with the specified lore text - - `lore` - An **array** of text `Component`s to apply as lore. Components in the array may be plain strings, for example: `[js]\['Some cool lore!', 'KubeJS rocks!'\]` + - `lore` - An **array** of text `Component`s to apply as lore. Components in the array may be plain strings. + For example: `[js]\['Some cool lore!', 'KubeJS rocks!'\]` - **Returns**: A copy of `item` with `minecraft:lore` data component applied. - `[js]typeData`: ??? (is this just a custom map for scripters to use to attach data to item definitions?) From e397b6132255a6f6e2baa004decc43ca854eccb2 Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Wed, 24 Dec 2025 16:55:39 +0100 Subject: [PATCH 31/68] Testing something --- wiki/concepts/item-stack/page.kubedoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiki/concepts/item-stack/page.kubedoc b/wiki/concepts/item-stack/page.kubedoc index b6e68cc9..4e89c859 100644 --- a/wiki/concepts/item-stack/page.kubedoc +++ b/wiki/concepts/item-stack/page.kubedoc @@ -117,7 +117,7 @@ WIP! (TODO: make a page on Components and KubeJS' ComponentFunctions interface) - `[js]item.getHarvestSpeed()`: - `[js]item.getHarvestSpeed(block)`: - - `block` #[[#z\51565D|\[Optional\]]]: The `Block` to check the harvest speed against. + - `block` #[[#51565D;border:1px solid black|\[Optional\]]]: The `Block` to check the harvest speed against. - **Returns**: The harvest speed of the item against a given block, or its default harvest speed if `block` isn't provided. - `[js]item.toItemString()`: - **Returns**: A KubeJS string representation of an ItemStack. From d401934f9779c04f041e4bcf0c6cfe88d94947e9 Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Wed, 24 Dec 2025 17:06:51 +0100 Subject: [PATCH 32/68] Yep, that's definitely a CSS injection --- wiki/concepts/item-stack/page.kubedoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiki/concepts/item-stack/page.kubedoc b/wiki/concepts/item-stack/page.kubedoc index 4e89c859..7d07e70e 100644 --- a/wiki/concepts/item-stack/page.kubedoc +++ b/wiki/concepts/item-stack/page.kubedoc @@ -117,7 +117,7 @@ WIP! (TODO: make a page on Components and KubeJS' ComponentFunctions interface) - `[js]item.getHarvestSpeed()`: - `[js]item.getHarvestSpeed(block)`: - - `block` #[[#51565D;border:1px solid black|\[Optional\]]]: The `Block` to check the harvest speed against. + - `block` #[[#c3c7cb;border:1px solid #51565d;font-size:0.8rem;padding:0.25em 0.5em; border-radius: 1em|\[Optional\]]]: The `Block` to check the harvest speed against. - **Returns**: The harvest speed of the item against a given block, or its default harvest speed if `block` isn't provided. - `[js]item.toItemString()`: - **Returns**: A KubeJS string representation of an ItemStack. From 6abc4e6f1730c25c3340c3f54652ba5828d0236d Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Wed, 24 Dec 2025 17:12:08 +0100 Subject: [PATCH 33/68] It makes for a cool Optional badge --- wiki/concepts/item-stack/en.yml | 4 +++- wiki/concepts/item-stack/page.kubedoc | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/wiki/concepts/item-stack/en.yml b/wiki/concepts/item-stack/en.yml index 1ba6d222..60a31a46 100644 --- a/wiki/concepts/item-stack/en.yml +++ b/wiki/concepts/item-stack/en.yml @@ -1,2 +1,4 @@ title: "ItemStack" -description: "Item stacks, stacked items, items in a stack (sometimes with data, too)" \ No newline at end of file +description: "Item stacks, stacked items, items in a stack (sometimes with data, too)" + +optional: "#[[#c3c7cb;border:1px solid #51565d;font-size:0.8rem;padding:0.2em 0.3em; border-radius: 1em|Optional]]" \ No newline at end of file diff --git a/wiki/concepts/item-stack/page.kubedoc b/wiki/concepts/item-stack/page.kubedoc index 7d07e70e..2ea17d32 100644 --- a/wiki/concepts/item-stack/page.kubedoc +++ b/wiki/concepts/item-stack/page.kubedoc @@ -117,7 +117,7 @@ WIP! (TODO: make a page on Components and KubeJS' ComponentFunctions interface) - `[js]item.getHarvestSpeed()`: - `[js]item.getHarvestSpeed(block)`: - - `block` #[[#c3c7cb;border:1px solid #51565d;font-size:0.8rem;padding:0.25em 0.5em; border-radius: 1em|\[Optional\]]]: The `Block` to check the harvest speed against. + - `block` {optional}: The `Block` to check the harvest speed against. - **Returns**: The harvest speed of the item against a given block, or its default harvest speed if `block` isn't provided. - `[js]item.toItemString()`: - **Returns**: A KubeJS string representation of an ItemStack. From ef6d2d0f6d58ea72c5bb234a6f01c363da70bbfd Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Wed, 24 Dec 2025 17:55:26 +0100 Subject: [PATCH 34/68] Does it inject HTML??? --- wiki/concepts/item-stack/en.yml | 1 + wiki/concepts/item-stack/page.kubedoc | 2 ++ 2 files changed, 3 insertions(+) diff --git a/wiki/concepts/item-stack/en.yml b/wiki/concepts/item-stack/en.yml index 60a31a46..d9bb3588 100644 --- a/wiki/concepts/item-stack/en.yml +++ b/wiki/concepts/item-stack/en.yml @@ -1,4 +1,5 @@ title: "ItemStack" description: "Item stacks, stacked items, items in a stack (sometimes with data, too)" +# CSS injection used optional: "#[[#c3c7cb;border:1px solid #51565d;font-size:0.8rem;padding:0.2em 0.3em; border-radius: 1em|Optional]]" \ No newline at end of file diff --git a/wiki/concepts/item-stack/page.kubedoc b/wiki/concepts/item-stack/page.kubedoc index 2ea17d32..edb92a5d 100644 --- a/wiki/concepts/item-stack/page.kubedoc +++ b/wiki/concepts/item-stack/page.kubedoc @@ -137,3 +137,5 @@ WIP! (TODO: make a page on Components and KubeJS' ComponentFunctions interface) - `[js]typeData`: ??? (is this just a custom map for scripters to use to attach data to item definitions?) # Further Reading - [Data Components](/concepts/data-components) + +#[[#ffffff;">
Hacked<\/div>
Hacked<\/div> Date: Wed, 24 Dec 2025 20:55:54 +0100 Subject: [PATCH 37/68] Document Data Components --- wiki/concepts/data-components/page.kubedoc | 31 ++++++++++++++++++++++ wiki/concepts/item-stack/page.kubedoc | 6 ++--- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/wiki/concepts/data-components/page.kubedoc b/wiki/concepts/data-components/page.kubedoc index a6548659..7633e909 100644 --- a/wiki/concepts/data-components/page.kubedoc +++ b/wiki/concepts/data-components/page.kubedoc @@ -1,4 +1,35 @@ WIP! +**Data components** are structured data consisting of key-value pairs, that define various properties of items and block entities, such as their name, lore, enchantments, inventory, etc. Data components can be attached to Items (and thus [/concepts/item-stack|ItemStacks]), and block entities. + +This article will discuss how you can create data component types and manipulate them. + +# Creating DataComponentMaps + +In places where DataComponentMap is expected (such as the second argument of `[js]Item.of(item, components)`), you can write string literals with the same string format as you would use in [`/give`](https://minecraft.wiki/w/Argument_types#item_stack). + +Example: `[js]Item.of('minecraft:diamond_sword', '\[damage=2,lore=[{text:"This item is cool."}]\]')` + +# Using DataComponentMaps + +In the following examples, `components` will refer to the DataComponentMap. + +- `[js]components.get(type)` + - `type` - A component type. It can be a string representing a type, for example `[js]'minecraft:lore'`. + - **Returns**: Value associated with the component type. +- `[js]components.has(type)` + - `type` - A component type. It can be a string representing a type, for example `[js]'minecraft:lore'`. + - **Returns**: `true` is the component has data associated with a type, `false` otherwise. +- `[js]components.isEmpty()` + - **Returns**: `true` is the component contains no data, `false` otherwise. +>>>info +Also available as a **read-only** bean: `components.empty`. +<<< +- `[js]components.keySet()` + - **Returns**: A set of all types (as implementations of `DataComponentType` interface) in the component map. +- `[js]components.size()` + - **Returns**: The amount of keys in the component map. + +As with usual read-only maps, `components` also contain `filter` and `forEach` methods. # Further Reading - [Minecraft Wiki: Data Component format](https://minecraft.wiki/w/Data_component_format) diff --git a/wiki/concepts/item-stack/page.kubedoc b/wiki/concepts/item-stack/page.kubedoc index ba11e65d..9a907c48 100644 --- a/wiki/concepts/item-stack/page.kubedoc +++ b/wiki/concepts/item-stack/page.kubedoc @@ -22,14 +22,14 @@ KubeJS will automatically try to *wrap* any input to an item stack in places whe Most ItemStacks can be simply written as string literals. - `''` (empty string), `'-'`, `'air'` and `'minecraft:air'` will return an empty ItemStack. It doesn't seem particularly useful, but hey, it's there! -- Any item ID will create an ItemStack of that specific item. -You can find item IDs easily by either enabling *advanced tooltips* in your game (press F3+H) and hovering over the item in your inventory, or by using the ever-useful [[/tutorials/hand|`/kubejs hand`]]! +- Any item ID will create an ItemStack of that specific item. You can find item IDs easily by either enabling *advanced tooltips* in your game (press F3+H) and hovering over the item in your inventory, or by using the ever-useful [[/tutorials/hand|`/kubejs hand`]]! - Example: `[js]Item.of('minecraft:apple')` - Prepending the item ID with an integer number and a letter `x` will create an item stack, with the stack size equal to the specified integer number. - Example: `[js]Item.of('2x minecraft:apple')` -- An item ID followed by a component (using the same syntax as [`/give`](https://minecraft.wiki/w/Argument_types#item_stack)) creates an item stack of the given item with the given components +- An item ID followed by a component (using the same syntax as [`/give`](https://minecraft.wiki/w/Argument_types#item_stack)) creates an item stack of the given item with the given components. - Example: `[js]Item.of('minecraft:diamond_sword[damage=2]')` + You can of course, combine these syntaxes: - `[js]Item.of('3x minecraft:stick[lore=[{text:"This Stick is very sticky."}]])'` will result a stack of three very sticky sticks (with custom data components!) From 4d5a1af8be21c039290dfdf182b9020b996ced5f Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Wed, 24 Dec 2025 20:57:10 +0100 Subject: [PATCH 38/68] Whoops, broken link --- wiki/concepts/data-components/page.kubedoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiki/concepts/data-components/page.kubedoc b/wiki/concepts/data-components/page.kubedoc index 7633e909..b661b82c 100644 --- a/wiki/concepts/data-components/page.kubedoc +++ b/wiki/concepts/data-components/page.kubedoc @@ -1,5 +1,5 @@ WIP! -**Data components** are structured data consisting of key-value pairs, that define various properties of items and block entities, such as their name, lore, enchantments, inventory, etc. Data components can be attached to Items (and thus [/concepts/item-stack|ItemStacks]), and block entities. +**Data components** are structured data consisting of key-value pairs, that define various properties of items and block entities, such as their name, lore, enchantments, inventory, etc. Data components can be attached to Items (and thus [[/concepts/item-stack|ItemStacks]]), and block entities. This article will discuss how you can create data component types and manipulate them. From 3264cb3b7829854c962f838b37fe5b434a99115a Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Wed, 24 Dec 2025 20:59:03 +0100 Subject: [PATCH 39/68] Change grammar a bit --- wiki/concepts/data-components/page.kubedoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiki/concepts/data-components/page.kubedoc b/wiki/concepts/data-components/page.kubedoc index b661b82c..ff5aad2f 100644 --- a/wiki/concepts/data-components/page.kubedoc +++ b/wiki/concepts/data-components/page.kubedoc @@ -29,7 +29,7 @@ Also available as a **read-only** bean: `components.empty`. - `[js]components.size()` - **Returns**: The amount of keys in the component map. -As with usual read-only maps, `components` also contain `filter` and `forEach` methods. +Just like other read-only maps, `components` also contain `filter` and `forEach` methods. # Further Reading - [Minecraft Wiki: Data Component format](https://minecraft.wiki/w/Data_component_format) From 794470183c4f52bf6c688fadb6d382985b358953 Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Wed, 24 Dec 2025 21:07:28 +0100 Subject: [PATCH 40/68] Add `item` before methods where I forgot to add `item` --- wiki/concepts/item-stack/page.kubedoc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/wiki/concepts/item-stack/page.kubedoc b/wiki/concepts/item-stack/page.kubedoc index 9a907c48..d89a0fd7 100644 --- a/wiki/concepts/item-stack/page.kubedoc +++ b/wiki/concepts/item-stack/page.kubedoc @@ -130,11 +130,11 @@ const enchItem = item.enchant({ - `[js]item.withCustomName(name)`: - `name` - A text `Component` to apply as custom name. It may be a plain string, for example: `[js]'My custom item!'` - **Returns**: A copy of `item` with `minecraft:custom_name` data component applied. -- `[js]withLore(lore)`: Copies this item stack with the specified lore text - - `lore` - An **array** of text `Component`s to apply as lore. Components in the array may be plain strings. - For example: `[js]\['Some cool lore!', 'KubeJS rocks!'\]` +- `[js]item.withLore(lore)`: Copies this item stack with the specified lore text + - `lore` - An **array** of text `Component`s to apply as lore. Components in the array may be plain strings. + - For example: `[js]\['Some cool lore!', 'KubeJS rocks!'\]` - **Returns**: A copy of `item` with `minecraft:lore` data component applied. -- `[js]typeData`: ??? (is this just a custom map for scripters to use to attach data to item definitions?) +- `[js]item.typeData`: ??? (is this just a custom map for scripters to use to attach data to item definitions?) # Further Reading - [Data Components](/concepts/data-components) From 2395d081d3397f2b1392b7efe7ae0c0ce8435fb5 Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Thu, 25 Dec 2025 14:19:38 +0100 Subject: [PATCH 41/68] Document BlockWrapper - Remove my own ItemStack article in favor of the existing one in `concepts` folder --- wiki/global-scope/page.kubedoc | 51 ++++++- wiki/ref/BlockWrapper/en.yml | 1 + wiki/ref/{ItemStack => BlockWrapper}/meta.yml | 0 wiki/ref/BlockWrapper/page.kubedoc | 132 ++++++++++++++++++ wiki/ref/ItemStack/en.yml | 3 - wiki/ref/ItemStack/page.kubedoc | 31 ---- wiki/ref/ItemWrapper/page.kubedoc | 20 +-- 7 files changed, 192 insertions(+), 46 deletions(-) create mode 100644 wiki/ref/BlockWrapper/en.yml rename wiki/ref/{ItemStack => BlockWrapper}/meta.yml (100%) create mode 100644 wiki/ref/BlockWrapper/page.kubedoc delete mode 100644 wiki/ref/ItemStack/en.yml delete mode 100644 wiki/ref/ItemStack/page.kubedoc diff --git a/wiki/global-scope/page.kubedoc b/wiki/global-scope/page.kubedoc index 4170c0ef..6e1612c5 100644 --- a/wiki/global-scope/page.kubedoc +++ b/wiki/global-scope/page.kubedoc @@ -13,8 +13,55 @@ | `HOUR` | number | 3600000 (`60 * MINUTE`) | # Classes - -|> 1.20.1 +|> 1.21.1 +- [[/ref/BlockWrapper/|`Block`]] +- `BlockPos` +- `BlockProperties` +- `BlockStatePredicate` +- `Blocks` +- `Client` +- `Color` +- `Component` +- `DamageSource` +- `DataMap` +- `Direction` +- `Duration` +- `EntitySelector` +- `Facing` +- `Fluid` +- `FluidAmounts` +- `Ingredient` +- [[/ref/ItemWrapper/|`Item`]] +- `Items` +- `Java` +- `JavaMath` +- `JsonIO` +- `JsonUtils` +- `Matrix3f` +- `Matrix4f` +- `MobEffectUtil` +- `NBT` +- `NBTIO` +- `Notification` +- `ParticleOptions` +- `Platform` +- `Quaternionf` +- `Registry` +- `RotationAxis` +- `SizedIngredient` +- `SoundType` +- `Stats` +- `StringUtils` +- `Text` +- `TextIcons` +- `Types` +- `UUID` +- `Utils` +- `Vec3d` +- `Vec3f` +- `Vec3i` +- `Vec4f` +<||> 1.20.1 - WIP <||>+ 1.19.2 - `Platform` diff --git a/wiki/ref/BlockWrapper/en.yml b/wiki/ref/BlockWrapper/en.yml new file mode 100644 index 00000000..40c0cf37 --- /dev/null +++ b/wiki/ref/BlockWrapper/en.yml @@ -0,0 +1 @@ +block: "[[/concepts/block|Block]]" \ No newline at end of file diff --git a/wiki/ref/ItemStack/meta.yml b/wiki/ref/BlockWrapper/meta.yml similarity index 100% rename from wiki/ref/ItemStack/meta.yml rename to wiki/ref/BlockWrapper/meta.yml diff --git a/wiki/ref/BlockWrapper/page.kubedoc b/wiki/ref/BlockWrapper/page.kubedoc new file mode 100644 index 00000000..b5ddbe85 --- /dev/null +++ b/wiki/ref/BlockWrapper/page.kubedoc @@ -0,0 +1,132 @@ +`BlockWrapper` is an interface containing many useful static methods for getting blocks from string. +It's exposed to [[/global-scope|global scope]] as `Block`. + +# Static methods + +## ID related + +### `getBlock` + +```js +Block.of(id) +``` +**Parameters** +- `[js]id`: - a ResourceLocation instance corresponding to a block ID. It can be a string representing a resource location, for example: `[js]'minecraft:stone'`. +**Returns** +A new {block} corresponding to the provided `id`. + +### `getId` + +```js +Block.getId(block) +``` +**Parameters** +- `[js]block`: A {block} instance. It can be a string representing a resource location of a block, for example: `[js]'minecraft:stone'`, but in this case that conversion isn't useful. +**Returns** +A ResourceLocation corresponding to the provided `block`. + +## Predicates + +### `id` + +```js +Block.id(id) +``` + +**Parameters** +- `[js]id`: - a ResourceLocation instance corresponding to a block ID. It can be a string representing a resource location, for example: `[js]'minecraft:stone'`. +**Returns** +A new `BlockIDPredicate` matching the block with the given `id`. + +### `entity` + +```js +Block.entity(id) +``` + +**Parameters** +- `[js]id`: - a ResourceLocation instance corresponding to a block entity ID. It can be a string representing a resource location, for example: `[js]'minecraft:chest'`. +**Returns** +A new `BlockEntityPredicate` matching the block entity with the given `id`. + +### `custom` + +```js +Block.custom(blockPredicate) +``` + +**Parameters** +- `[js]blockPredicate`: - a BlockPredicate instance. It can be a function, which takes a `LevelBlock` (KubeJS' interface for script-friendly block access) and returns a boolean. +**Returns** +If `blockPredicate` was already a BlockPredicate, it returns the same `blockPredicate`. +If `blockPredicate` was a function, it returns the function wrapped into a `BlockPredicate`. +**Example** +```js +// Returns a BlockPredicate that matches all blocks whose block light is greater than 7 +Block.custom(block => block.blockLight > 7) +``` + +## Collections + +### `getTypeList` + +```js +Block.getTypeList() +Block.typeList // read-only bean +``` + +**Returns** +A list of class names of all blocks registered in the game. + +### `getTaggedIds` + +```js +Block.getTaggedIds(tag) +``` + +**Parameters** +- `[js]tag`: - a `ResourceLocation` instance corresponding to a block tag. It can be a string representing a resource location, for example: `[js]'minecraft:logs'`. + +**Returns** +A list of `ResourceLocation`s of all blocks in a block tag. + +### `getAllBlockStates` + +```js +Block.getAllBlockStates() +Block.allBlockStates // read-only bean +``` + +**Returns** +A set of all `BlockState`s registered in the game. + +### `getFacing` + +```js +Block.getFacing() +Block.facing // read-only bean +``` + +**Returns** +A map of all directions (as strings) to `Direction` enumerations. +It can be used as a usual JavaScript object: +```js +Block.facing.south // Direction.SOUTH +``` + +## Other + +### `withProperties` + +```js +Block.withProperties(blockState, properties) +``` +**Parameters** +- `[js]blockState`: A `BlockState` instance. It can be a string representing a block state, for example: `[js]'minecraft:oak_log\[axis=x\]'`, but in this case that conversion isn't useful, since this method is more useful for modification of existing `BlockState`. +- `[js]properties`: A map of block state property keys to their values. It can be an object, for example `[js]{axis: 'x'}`. If the property isn't present on the block, the newly created block state won't have that property set. +**Returns** +A new `BlockState` with all the properties on the `properties` map/object set. + +# Source + +([BlockWrapper.java](https://github.com/KubeJS-Mods/KubeJS/blob/main/src/main/java/dev/latvian/mods/kubejs/plugin/builtin/wrapper/BlockWrapper.java)) \ No newline at end of file diff --git a/wiki/ref/ItemStack/en.yml b/wiki/ref/ItemStack/en.yml deleted file mode 100644 index a931fe6d..00000000 --- a/wiki/ref/ItemStack/en.yml +++ /dev/null @@ -1,3 +0,0 @@ -item: "#[[orange|`<`#[[yellow|`item`]]`>`]]" -components: "#[[blue|`\\[​`#[[orange|`<`#[[yellow|`components`]]`>`]]`​\\]`]]" -custom-data: "#[[blue|`\\{​`#[[orange|`<`#[[yellow|`custom-data`]]`>`]]`​\\}`]]" diff --git a/wiki/ref/ItemStack/page.kubedoc b/wiki/ref/ItemStack/page.kubedoc deleted file mode 100644 index 015f8883..00000000 --- a/wiki/ref/ItemStack/page.kubedoc +++ /dev/null @@ -1,31 +0,0 @@ -`ItemStack`s are objects representing stacks of Minecraft items. -They are usually used in recipe outputs. - -# Type wrappers -Various data types can wrap into `ItemStack`s when an `ItemStack` is expected. - -## String literals - -### {item} - - {item} - A string corresponding to item ID. - Special case: `''` (empty string), `'-'`, `air` and `minecraft:air` all result in the air item. - - Example: `minecraft:diamond_sword` - - Results in a Diamond Sword. - -### {item}{components} - - {item} - A string corresponding to item ID. - - {components} - A list of components formatted as follows: `\[key1=value1,key2=value2\]`. - - Example: `minecraft:diamond_sword[damage=2]` - - Results in a Diamond Sword with 2 durability damage. - -### {item}{custom-data} - - {item} - A string corresponding to item ID. - - {custom-data} - A NBT compound tag to be stored into the `minecraft:custom_data` component, formatted as a stringified NBT: `\{key1:value1, key2:value2\}`. - - Example: `minecraft:diamond_sword{souls:2l}` - - Results in a Diamond Sword with `minecraft:custom_data` component set to `{souls:2l}`. - -# Methods - -This page contains only a small subset of possible methods. The following methods can be useful in scripts. -In code snippets below, `stack` will refer to the instance of `ItemStack`. - diff --git a/wiki/ref/ItemWrapper/page.kubedoc b/wiki/ref/ItemWrapper/page.kubedoc index cb0e08f5..4f1e35bd 100644 --- a/wiki/ref/ItemWrapper/page.kubedoc +++ b/wiki/ref/ItemWrapper/page.kubedoc @@ -11,12 +11,12 @@ Item.of(itemStack, count) Item.of(itemStack, count, components) ``` **Parameters** -- `[js]itemStack` - an [[/ref/ItemStack|ItemStack]]. Like with any other place that expects an `ItemStack`, the argument will be converted to `ItemStack` if possible. +- `[js]itemStack` - an [[/concepts/item-stack|ItemStack]]. Like with any other place that expects an `ItemStack`, the argument will be converted to `ItemStack` if possible. **Optional parameters**: - `[js]components` - A map of components. Can be a string representing key-value pairs: `damage=2, item_name={text:"Hello world"}`. - `[js]count` - An integer, representing the size of the item stack. **Returns** -- A new [[/ref/ItemStack|ItemStack]]. +- A new [[/concepts/item-stack|ItemStack]]. ## `getList` @@ -26,7 +26,7 @@ Item.list // Bean ``` **Returns** -- A list of most items (as [[/ref/ItemStack|ItemStack]]s) in the game. Items, that are not in a creative tab are ignored. +- A list of most items (as [[/concepts/item-stack|ItemStack]]s) in the game. Items, that are not in a creative tab are ignored. ## `getTypeList` @@ -46,7 +46,7 @@ Item.typeToStackMap // Bean ``` **Returns** -- A map between ResourceLocations and collections of variants of [[/ref/ItemStack|ItemStack]]. +- A map between ResourceLocations and collections of variants of [[/concepts/item-stack|ItemStack]]. ## `getVariants` @@ -54,9 +54,9 @@ Item.typeToStackMap // Bean Item.getVariants(itemStack) ``` **Parameters** -- `[js]itemStack` - an [[/ref/ItemStack|ItemStack]]. +- `[js]itemStack` - an [[/concepts/item-stack|ItemStack]]. **Returns** -- A collections of variant of the given [[/ref/ItemStack|ItemStack]]. +- A collections of variant of the given [[/concepts/item-stack|ItemStack]]. ## `getEmpty` @@ -66,7 +66,7 @@ Item.empty // Bean ``` **Returns** -- An [[/ref/ItemStack|ItemStack]] that represents an empty slot or air. +- An [[/concepts/item-stack|ItemStack]] that represents an empty slot or air. ## `fireworks` @@ -135,7 +135,7 @@ Item.getItem(id) **Parameters** - `[js]id` - a ResourceLocation instance or a string representing a resource location, like `'minecraft:diamond_sword'`. **Returns** -An [[/ref/Item|Item]] instance. +An [[/concepts/item|Item]] instance. ## `getID` @@ -144,7 +144,7 @@ Item.getID(item) ``` **Parameters** -- `[js]item` - an [[/ref/Item|Item]]. +- `[js]item` - an [[/concepts/item|Item]]. **Returns** An ResourceLocation of the item. @@ -168,7 +168,7 @@ Item.isItem(object) **Parameters** - `[js]object` - Any object. **Returns** -`true` if the object is an instance of [[/ref/ItemStack|ItemStack]], `false` otherwise. +`true` if the object is an instance of [[/concepts/item-stack|ItemStack]], `false` otherwise. ## `playerHead` From 13957564cb781098cb1a12652bdfd426ad189510 Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Thu, 25 Dec 2025 14:23:31 +0100 Subject: [PATCH 42/68] Fix broken links, add horizontal lines --- wiki/global-scope/page.kubedoc | 4 ++-- wiki/ref/BlockWrapper/page.kubedoc | 31 +++++++++++++++++++++++++----- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/wiki/global-scope/page.kubedoc b/wiki/global-scope/page.kubedoc index 6e1612c5..2e8cb12b 100644 --- a/wiki/global-scope/page.kubedoc +++ b/wiki/global-scope/page.kubedoc @@ -14,7 +14,7 @@ # Classes |> 1.21.1 -- [[/ref/BlockWrapper/|`Block`]] +- [[/ref/BlockWrapper|`Block`]] - `BlockPos` - `BlockProperties` - `BlockStatePredicate` @@ -31,7 +31,7 @@ - `Fluid` - `FluidAmounts` - `Ingredient` -- [[/ref/ItemWrapper/|`Item`]] +- [[/ref/ItemWrapper|`Item`]] - `Items` - `Java` - `JavaMath` diff --git a/wiki/ref/BlockWrapper/page.kubedoc b/wiki/ref/BlockWrapper/page.kubedoc index b5ddbe85..109d5942 100644 --- a/wiki/ref/BlockWrapper/page.kubedoc +++ b/wiki/ref/BlockWrapper/page.kubedoc @@ -11,10 +11,12 @@ It's exposed to [[/global-scope|global scope]] as `Block`. Block.of(id) ``` **Parameters** -- `[js]id`: - a ResourceLocation instance corresponding to a block ID. It can be a string representing a resource location, for example: `[js]'minecraft:stone'`. +- `[js]id`: A ResourceLocation instance corresponding to a block ID. It can be a string representing a resource location, for example: `[js]'minecraft:stone'`. **Returns** A new {block} corresponding to the provided `id`. +--- + ### `getId` ```js @@ -25,6 +27,8 @@ Block.getId(block) **Returns** A ResourceLocation corresponding to the provided `block`. +--- + ## Predicates ### `id` @@ -34,10 +38,12 @@ Block.id(id) ``` **Parameters** -- `[js]id`: - a ResourceLocation instance corresponding to a block ID. It can be a string representing a resource location, for example: `[js]'minecraft:stone'`. +- `[js]id`: A ResourceLocation instance corresponding to a block ID. It can be a string representing a resource location, for example: `[js]'minecraft:stone'`. **Returns** A new `BlockIDPredicate` matching the block with the given `id`. +--- + ### `entity` ```js @@ -45,10 +51,12 @@ Block.entity(id) ``` **Parameters** -- `[js]id`: - a ResourceLocation instance corresponding to a block entity ID. It can be a string representing a resource location, for example: `[js]'minecraft:chest'`. +- `[js]id`: A ResourceLocation instance corresponding to a block entity ID. It can be a string representing a resource location, for example: `[js]'minecraft:chest'`. **Returns** A new `BlockEntityPredicate` matching the block entity with the given `id`. +--- + ### `custom` ```js @@ -56,7 +64,7 @@ Block.custom(blockPredicate) ``` **Parameters** -- `[js]blockPredicate`: - a BlockPredicate instance. It can be a function, which takes a `LevelBlock` (KubeJS' interface for script-friendly block access) and returns a boolean. +- `[js]blockPredicate`: A BlockPredicate instance. It can be a function, which takes a `LevelBlock` (KubeJS' interface for script-friendly block access) and returns a boolean. **Returns** If `blockPredicate` was already a BlockPredicate, it returns the same `blockPredicate`. If `blockPredicate` was a function, it returns the function wrapped into a `BlockPredicate`. @@ -66,6 +74,8 @@ If `blockPredicate` was a function, it returns the function wrapped into a `Bloc Block.custom(block => block.blockLight > 7) ``` +--- + ## Collections ### `getTypeList` @@ -78,6 +88,8 @@ Block.typeList // read-only bean **Returns** A list of class names of all blocks registered in the game. +--- + ### `getTaggedIds` ```js @@ -85,11 +97,13 @@ Block.getTaggedIds(tag) ``` **Parameters** -- `[js]tag`: - a `ResourceLocation` instance corresponding to a block tag. It can be a string representing a resource location, for example: `[js]'minecraft:logs'`. +- `[js]tag`: A `ResourceLocation` instance corresponding to a block tag. It can be a string representing a resource location, for example: `[js]'minecraft:logs'`. **Returns** A list of `ResourceLocation`s of all blocks in a block tag. +--- + ### `getAllBlockStates` ```js @@ -100,6 +114,9 @@ Block.allBlockStates // read-only bean **Returns** A set of all `BlockState`s registered in the game. + +--- + ### `getFacing` ```js @@ -114,6 +131,8 @@ It can be used as a usual JavaScript object: Block.facing.south // Direction.SOUTH ``` +--- + ## Other ### `withProperties` @@ -127,6 +146,8 @@ Block.withProperties(blockState, properties) **Returns** A new `BlockState` with all the properties on the `properties` map/object set. +--- + # Source ([BlockWrapper.java](https://github.com/KubeJS-Mods/KubeJS/blob/main/src/main/java/dev/latvian/mods/kubejs/plugin/builtin/wrapper/BlockWrapper.java)) \ No newline at end of file From 53704cb45a364027fcf333cc6b73364859dc368d Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Thu, 25 Dec 2025 14:28:12 +0100 Subject: [PATCH 43/68] Add horizontal lines to ItemWrapper article as well --- wiki/ref/ItemWrapper/page.kubedoc | 43 ++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/wiki/ref/ItemWrapper/page.kubedoc b/wiki/ref/ItemWrapper/page.kubedoc index 4f1e35bd..06441e9a 100644 --- a/wiki/ref/ItemWrapper/page.kubedoc +++ b/wiki/ref/ItemWrapper/page.kubedoc @@ -16,7 +16,9 @@ Item.of(itemStack, count, components) - `[js]components` - A map of components. Can be a string representing key-value pairs: `damage=2, item_name={text:"Hello world"}`. - `[js]count` - An integer, representing the size of the item stack. **Returns** -- A new [[/concepts/item-stack|ItemStack]]. +A new [[/concepts/item-stack|ItemStack]]. + +--- ## `getList` @@ -26,7 +28,9 @@ Item.list // Bean ``` **Returns** -- A list of most items (as [[/concepts/item-stack|ItemStack]]s) in the game. Items, that are not in a creative tab are ignored. +A list of most items (as [[/concepts/item-stack|ItemStack]]s) in the game. Items, that are not in a creative tab are ignored. + +--- ## `getTypeList` @@ -36,7 +40,9 @@ Item.typeList // Bean ``` **Returns** -- A list of all the namespaced item IDs in the game as strings. +A list of all the namespaced item IDs in the game as strings. + +--- ## `getTypeToStackMap` @@ -46,7 +52,9 @@ Item.typeToStackMap // Bean ``` **Returns** -- A map between ResourceLocations and collections of variants of [[/concepts/item-stack|ItemStack]]. +A map between ResourceLocations and collections of variants of [[/concepts/item-stack|ItemStack]]. + +--- ## `getVariants` @@ -56,18 +64,22 @@ Item.getVariants(itemStack) **Parameters** - `[js]itemStack` - an [[/concepts/item-stack|ItemStack]]. **Returns** -- A collections of variant of the given [[/concepts/item-stack|ItemStack]]. +A collection of variants of the given [[/concepts/item-stack|ItemStack]]. + +--- ## `getEmpty` ```js Item.getEmpty() -Item.empty // Bean +Item.empty // Read-only bean ``` **Returns** - An [[/concepts/item-stack|ItemStack]] that represents an empty slot or air. +--- + ## `fireworks` ```js @@ -126,6 +138,8 @@ Item.fireworks({ }) ``` +--- + ## `getItem` ```js @@ -137,6 +151,8 @@ Item.getItem(id) **Returns** An [[/concepts/item|Item]] instance. +--- + ## `getID` ```js @@ -148,6 +164,8 @@ Item.getID(item) **Returns** An ResourceLocation of the item. +--- + ## `exists` ```js @@ -156,9 +174,12 @@ Item.exists(id) **Parameters** - `[js]id` - a ResourceLocation instance or a string representing a resource location, like `'minecraft:diamond_sword'`. + **Returns** `true` if the item corresponding to the ID exists, `false` otherwise. +--- + ## `isItem` ```js @@ -167,9 +188,12 @@ Item.isItem(object) **Parameters** - `[js]object` - Any object. + **Returns** `true` if the object is an instance of [[/concepts/item-stack|ItemStack]], `false` otherwise. +--- + ## `playerHead` ```js @@ -178,9 +202,12 @@ Item.playerHead(nickname) **Parameters** - `[js]nickname` - A nickname of a player to get their head. + **Returns** A player head with the `minecraft:profile` data component applied. +--- + ## `playerHeadfromBase64` ```js @@ -194,6 +221,8 @@ Item.playerHeadfromBase64(uuid, textureBase64) **Returns** A player head with the `minecraft:profile` data component applied. +--- + ## `playerHeadFromUrl` ```js @@ -205,6 +234,8 @@ Item.playerHeadFromUrl(url) **Returns** A player head with the `minecraft:profile` data component applied. +--- + ## `playerHeadfromStringHash` ```js From f1d5c7058ba00336e6295380e17d27ceaa875fef Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Thu, 25 Dec 2025 15:07:53 +0100 Subject: [PATCH 44/68] Test moving article into subfolder, axe redundant ref articles --- wiki/{ref/Item => concepts/item}/en.yml | 3 +++ wiki/{ref/Item => concepts/item}/meta.yml | 0 wiki/{ref/Item => concepts/item}/page.kubedoc | 2 ++ wiki/ref/Boolean/page.kubedoc | 10 ---------- wiki/ref/ID/en.yml | 0 wiki/ref/ID/page.kubedoc | 17 ----------------- wiki/ref/Number/page.kubedoc | 10 ---------- wiki/ref/Void/page.kubedoc | 10 ---------- wiki/ref/{ => builders}/BlockBuilder/en.yml | 0 wiki/ref/{ => builders}/BlockBuilder/meta.yml | 0 .../{ => builders}/BlockBuilder/page.kubedoc | 0 wiki/ref/builders/en.yml | 2 ++ 12 files changed, 7 insertions(+), 47 deletions(-) rename wiki/{ref/Item => concepts/item}/en.yml (69%) rename wiki/{ref/Item => concepts/item}/meta.yml (100%) rename wiki/{ref/Item => concepts/item}/page.kubedoc (98%) delete mode 100644 wiki/ref/Boolean/page.kubedoc delete mode 100644 wiki/ref/ID/en.yml delete mode 100644 wiki/ref/ID/page.kubedoc delete mode 100644 wiki/ref/Number/page.kubedoc delete mode 100644 wiki/ref/Void/page.kubedoc rename wiki/ref/{ => builders}/BlockBuilder/en.yml (100%) rename wiki/ref/{ => builders}/BlockBuilder/meta.yml (100%) rename wiki/ref/{ => builders}/BlockBuilder/page.kubedoc (100%) create mode 100644 wiki/ref/builders/en.yml diff --git a/wiki/ref/Item/en.yml b/wiki/concepts/item/en.yml similarity index 69% rename from wiki/ref/Item/en.yml rename to wiki/concepts/item/en.yml index a931fe6d..6997ce0b 100644 --- a/wiki/ref/Item/en.yml +++ b/wiki/concepts/item/en.yml @@ -1,3 +1,6 @@ +title: "Item" +description: "Things you can pick up to your inventory, store in chests, etc." + item: "#[[orange|`<`#[[yellow|`item`]]`>`]]" components: "#[[blue|`\\[​`#[[orange|`<`#[[yellow|`components`]]`>`]]`​\\]`]]" custom-data: "#[[blue|`\\{​`#[[orange|`<`#[[yellow|`custom-data`]]`>`]]`​\\}`]]" diff --git a/wiki/ref/Item/meta.yml b/wiki/concepts/item/meta.yml similarity index 100% rename from wiki/ref/Item/meta.yml rename to wiki/concepts/item/meta.yml diff --git a/wiki/ref/Item/page.kubedoc b/wiki/concepts/item/page.kubedoc similarity index 98% rename from wiki/ref/Item/page.kubedoc rename to wiki/concepts/item/page.kubedoc index b55ae13b..63af9aad 100644 --- a/wiki/ref/Item/page.kubedoc +++ b/wiki/concepts/item/page.kubedoc @@ -1,6 +1,8 @@ `Item`s are objects representing Minecraft items. They are usually used in places where the item's components are needed. +TODO: Reword this article! + # Type wrappers Various data types can wrap into `Item`s when an `Item` is expected. diff --git a/wiki/ref/Boolean/page.kubedoc b/wiki/ref/Boolean/page.kubedoc deleted file mode 100644 index 2d9c6756..00000000 --- a/wiki/ref/Boolean/page.kubedoc +++ /dev/null @@ -1,10 +0,0 @@ -Type representing any true of false values - ---- -# Properties ---- -None ---- -# Methods ---- -None \ No newline at end of file diff --git a/wiki/ref/ID/en.yml b/wiki/ref/ID/en.yml deleted file mode 100644 index e69de29b..00000000 diff --git a/wiki/ref/ID/page.kubedoc b/wiki/ref/ID/page.kubedoc deleted file mode 100644 index d896533f..00000000 --- a/wiki/ref/ID/page.kubedoc +++ /dev/null @@ -1,17 +0,0 @@ -ID is basically a [[$String]] with namespace and path. - -Examples: -- `'minecraft:stone'` -- `'minecraft:textures/blocks/stone'` -- `'kubejs:custom_item'` - -This class is called `ResourceLocation` in mojang mappings and `Identifier` in Yarn. - ---- -# Properties ---- -## $$.namespace: String -Namespace - of `'example:thing'` namespace would be `'example'` ---- -## $$.path: String -Path - of `'example:thing'` path would be `'thing'` \ No newline at end of file diff --git a/wiki/ref/Number/page.kubedoc b/wiki/ref/Number/page.kubedoc deleted file mode 100644 index 06cbdeac..00000000 --- a/wiki/ref/Number/page.kubedoc +++ /dev/null @@ -1,10 +0,0 @@ -Type representing any number (both whole and floating point) - ---- -# Properties ---- -None ---- -# Methods ---- -None \ No newline at end of file diff --git a/wiki/ref/Void/page.kubedoc b/wiki/ref/Void/page.kubedoc deleted file mode 100644 index 7c4eca37..00000000 --- a/wiki/ref/Void/page.kubedoc +++ /dev/null @@ -1,10 +0,0 @@ -Nothing. Void... is nothing. - ---- -# Properties ---- -None ---- -# Methods ---- -None \ No newline at end of file diff --git a/wiki/ref/BlockBuilder/en.yml b/wiki/ref/builders/BlockBuilder/en.yml similarity index 100% rename from wiki/ref/BlockBuilder/en.yml rename to wiki/ref/builders/BlockBuilder/en.yml diff --git a/wiki/ref/BlockBuilder/meta.yml b/wiki/ref/builders/BlockBuilder/meta.yml similarity index 100% rename from wiki/ref/BlockBuilder/meta.yml rename to wiki/ref/builders/BlockBuilder/meta.yml diff --git a/wiki/ref/BlockBuilder/page.kubedoc b/wiki/ref/builders/BlockBuilder/page.kubedoc similarity index 100% rename from wiki/ref/BlockBuilder/page.kubedoc rename to wiki/ref/builders/BlockBuilder/page.kubedoc diff --git a/wiki/ref/builders/en.yml b/wiki/ref/builders/en.yml new file mode 100644 index 00000000..d1a64c14 --- /dev/null +++ b/wiki/ref/builders/en.yml @@ -0,0 +1,2 @@ +title: "Builders" +description: "Classes that use builder pattern to create things" \ No newline at end of file From 4b9e6e0f1f48d9cfb913e500f69c3b8aed74655d Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Thu, 25 Dec 2025 15:32:09 +0100 Subject: [PATCH 45/68] Perestroika in `ref` - Grouped articles by theme - Changed links to those articles in order to not break them (barely anything linked there anyway) - So far, put Unit (which shouldn't be here anyway) and empty TextWrapper article into `utils` directory --- wiki/concepts/item-stack/page.kubedoc | 2 +- wiki/global-scope/page.kubedoc | 4 ++-- wiki/ref/{BlockProperty => builders/FoodBuilder}/en.yml | 0 wiki/ref/{ => builders}/FoodBuilder/page.kubedoc | 0 wiki/ref/{Consumer => enums/BlockProperty}/en.yml | 0 wiki/ref/{ => enums}/BlockProperty/page.kubedoc | 0 wiki/ref/{ => enums}/Direction/en.yml | 0 wiki/ref/{ => enums}/Direction/page.kubedoc | 0 wiki/ref/{ => enums}/FluidAmounts/en.yml | 0 wiki/ref/{ => enums}/FluidAmounts/page.kubedoc | 0 wiki/ref/{FoodBuilder => enums/MapColor}/en.yml | 0 wiki/ref/{ => enums}/MapColor/meta.yml | 0 wiki/ref/{ => enums}/MapColor/page.kubedoc | 0 wiki/ref/{MapColor => enums/RenderType}/en.yml | 0 wiki/ref/{ => enums}/RenderType/page.kubedoc | 0 wiki/ref/{MutableBlock => enums/SoundType}/en.yml | 0 wiki/ref/{ => enums}/SoundType/meta.yml | 0 wiki/ref/{ => enums}/SoundType/page.kubedoc | 0 wiki/ref/enums/en.yml | 2 ++ wiki/ref/{MutableItem => java/Consumer}/en.yml | 0 wiki/ref/{ => java}/Consumer/page.kubedoc | 0 wiki/ref/java/en.yml | 2 ++ wiki/ref/{ => js}/String/page.kubedoc | 0 wiki/ref/js/en.yml | 2 ++ wiki/ref/{MutableToolTier => mutables/MutableBlock}/en.yml | 0 wiki/ref/{ => mutables}/MutableBlock/page.kubedoc | 0 wiki/ref/{RenderType => mutables/MutableItem}/en.yml | 0 wiki/ref/{ => mutables}/MutableItem/page.kubedoc | 0 wiki/ref/{SoundType => mutables/MutableToolTier}/en.yml | 0 wiki/ref/{ => mutables}/MutableToolTier/page.kubedoc | 0 wiki/ref/mutables/en.yml | 2 ++ wiki/ref/{ => utils}/TextComponent/en.yml | 0 wiki/ref/{ => utils}/Unit/en.yml | 0 wiki/ref/{ => utils}/Unit/meta.yml | 0 wiki/ref/{ => utils}/Unit/page.kubedoc | 0 wiki/ref/utils/en.yml | 2 ++ wiki/ref/{ => wrappers}/BlockWrapper/en.yml | 0 wiki/ref/{ => wrappers}/BlockWrapper/meta.yml | 0 wiki/ref/{ => wrappers}/BlockWrapper/page.kubedoc | 0 wiki/ref/{ => wrappers}/ItemWrapper/en.yml | 0 wiki/ref/{ => wrappers}/ItemWrapper/meta.yml | 0 wiki/ref/{ => wrappers}/ItemWrapper/page.kubedoc | 0 wiki/ref/wrappers/en.yml | 2 ++ wiki/test/page.kubedoc | 2 +- 44 files changed, 16 insertions(+), 4 deletions(-) rename wiki/ref/{BlockProperty => builders/FoodBuilder}/en.yml (100%) rename wiki/ref/{ => builders}/FoodBuilder/page.kubedoc (100%) rename wiki/ref/{Consumer => enums/BlockProperty}/en.yml (100%) rename wiki/ref/{ => enums}/BlockProperty/page.kubedoc (100%) rename wiki/ref/{ => enums}/Direction/en.yml (100%) rename wiki/ref/{ => enums}/Direction/page.kubedoc (100%) rename wiki/ref/{ => enums}/FluidAmounts/en.yml (100%) rename wiki/ref/{ => enums}/FluidAmounts/page.kubedoc (100%) rename wiki/ref/{FoodBuilder => enums/MapColor}/en.yml (100%) rename wiki/ref/{ => enums}/MapColor/meta.yml (100%) rename wiki/ref/{ => enums}/MapColor/page.kubedoc (100%) rename wiki/ref/{MapColor => enums/RenderType}/en.yml (100%) rename wiki/ref/{ => enums}/RenderType/page.kubedoc (100%) rename wiki/ref/{MutableBlock => enums/SoundType}/en.yml (100%) rename wiki/ref/{ => enums}/SoundType/meta.yml (100%) rename wiki/ref/{ => enums}/SoundType/page.kubedoc (100%) create mode 100644 wiki/ref/enums/en.yml rename wiki/ref/{MutableItem => java/Consumer}/en.yml (100%) rename wiki/ref/{ => java}/Consumer/page.kubedoc (100%) create mode 100644 wiki/ref/java/en.yml rename wiki/ref/{ => js}/String/page.kubedoc (100%) create mode 100644 wiki/ref/js/en.yml rename wiki/ref/{MutableToolTier => mutables/MutableBlock}/en.yml (100%) rename wiki/ref/{ => mutables}/MutableBlock/page.kubedoc (100%) rename wiki/ref/{RenderType => mutables/MutableItem}/en.yml (100%) rename wiki/ref/{ => mutables}/MutableItem/page.kubedoc (100%) rename wiki/ref/{SoundType => mutables/MutableToolTier}/en.yml (100%) rename wiki/ref/{ => mutables}/MutableToolTier/page.kubedoc (100%) create mode 100644 wiki/ref/mutables/en.yml rename wiki/ref/{ => utils}/TextComponent/en.yml (100%) rename wiki/ref/{ => utils}/Unit/en.yml (100%) rename wiki/ref/{ => utils}/Unit/meta.yml (100%) rename wiki/ref/{ => utils}/Unit/page.kubedoc (100%) create mode 100644 wiki/ref/utils/en.yml rename wiki/ref/{ => wrappers}/BlockWrapper/en.yml (100%) rename wiki/ref/{ => wrappers}/BlockWrapper/meta.yml (100%) rename wiki/ref/{ => wrappers}/BlockWrapper/page.kubedoc (100%) rename wiki/ref/{ => wrappers}/ItemWrapper/en.yml (100%) rename wiki/ref/{ => wrappers}/ItemWrapper/meta.yml (100%) rename wiki/ref/{ => wrappers}/ItemWrapper/page.kubedoc (100%) create mode 100644 wiki/ref/wrappers/en.yml diff --git a/wiki/concepts/item-stack/page.kubedoc b/wiki/concepts/item-stack/page.kubedoc index d89a0fd7..1151f062 100644 --- a/wiki/concepts/item-stack/page.kubedoc +++ b/wiki/concepts/item-stack/page.kubedoc @@ -17,7 +17,7 @@ Since 1.20.4, data on items has changed *significantly* with the transition from # Creating ItemStacks -KubeJS will automatically try to *wrap* any input to an item stack in places where it is expected, but you can also use the `Item` wrapper ([[/ref/ItemWrapper|reference]]) to explicitly create them yourself, specifically using `[js]Item.of(input)` and `[js]Item.of(input, count)`: +KubeJS will automatically try to *wrap* any input to an item stack in places where it is expected, but you can also use the `Item` wrapper ([[/ref/wrappers/ItemWrapper|reference]]) to explicitly create them yourself, specifically using `[js]Item.of(input)` and `[js]Item.of(input, count)`: Most ItemStacks can be simply written as string literals. diff --git a/wiki/global-scope/page.kubedoc b/wiki/global-scope/page.kubedoc index 2e8cb12b..a96d722a 100644 --- a/wiki/global-scope/page.kubedoc +++ b/wiki/global-scope/page.kubedoc @@ -14,7 +14,7 @@ # Classes |> 1.21.1 -- [[/ref/BlockWrapper|`Block`]] +- [[/ref/wrappers/BlockWrapper|`Block`]] - `BlockPos` - `BlockProperties` - `BlockStatePredicate` @@ -31,7 +31,7 @@ - `Fluid` - `FluidAmounts` - `Ingredient` -- [[/ref/ItemWrapper|`Item`]] +- [[/ref/wrappers/ItemWrapper|`Item`]] - `Items` - `Java` - `JavaMath` diff --git a/wiki/ref/BlockProperty/en.yml b/wiki/ref/builders/FoodBuilder/en.yml similarity index 100% rename from wiki/ref/BlockProperty/en.yml rename to wiki/ref/builders/FoodBuilder/en.yml diff --git a/wiki/ref/FoodBuilder/page.kubedoc b/wiki/ref/builders/FoodBuilder/page.kubedoc similarity index 100% rename from wiki/ref/FoodBuilder/page.kubedoc rename to wiki/ref/builders/FoodBuilder/page.kubedoc diff --git a/wiki/ref/Consumer/en.yml b/wiki/ref/enums/BlockProperty/en.yml similarity index 100% rename from wiki/ref/Consumer/en.yml rename to wiki/ref/enums/BlockProperty/en.yml diff --git a/wiki/ref/BlockProperty/page.kubedoc b/wiki/ref/enums/BlockProperty/page.kubedoc similarity index 100% rename from wiki/ref/BlockProperty/page.kubedoc rename to wiki/ref/enums/BlockProperty/page.kubedoc diff --git a/wiki/ref/Direction/en.yml b/wiki/ref/enums/Direction/en.yml similarity index 100% rename from wiki/ref/Direction/en.yml rename to wiki/ref/enums/Direction/en.yml diff --git a/wiki/ref/Direction/page.kubedoc b/wiki/ref/enums/Direction/page.kubedoc similarity index 100% rename from wiki/ref/Direction/page.kubedoc rename to wiki/ref/enums/Direction/page.kubedoc diff --git a/wiki/ref/FluidAmounts/en.yml b/wiki/ref/enums/FluidAmounts/en.yml similarity index 100% rename from wiki/ref/FluidAmounts/en.yml rename to wiki/ref/enums/FluidAmounts/en.yml diff --git a/wiki/ref/FluidAmounts/page.kubedoc b/wiki/ref/enums/FluidAmounts/page.kubedoc similarity index 100% rename from wiki/ref/FluidAmounts/page.kubedoc rename to wiki/ref/enums/FluidAmounts/page.kubedoc diff --git a/wiki/ref/FoodBuilder/en.yml b/wiki/ref/enums/MapColor/en.yml similarity index 100% rename from wiki/ref/FoodBuilder/en.yml rename to wiki/ref/enums/MapColor/en.yml diff --git a/wiki/ref/MapColor/meta.yml b/wiki/ref/enums/MapColor/meta.yml similarity index 100% rename from wiki/ref/MapColor/meta.yml rename to wiki/ref/enums/MapColor/meta.yml diff --git a/wiki/ref/MapColor/page.kubedoc b/wiki/ref/enums/MapColor/page.kubedoc similarity index 100% rename from wiki/ref/MapColor/page.kubedoc rename to wiki/ref/enums/MapColor/page.kubedoc diff --git a/wiki/ref/MapColor/en.yml b/wiki/ref/enums/RenderType/en.yml similarity index 100% rename from wiki/ref/MapColor/en.yml rename to wiki/ref/enums/RenderType/en.yml diff --git a/wiki/ref/RenderType/page.kubedoc b/wiki/ref/enums/RenderType/page.kubedoc similarity index 100% rename from wiki/ref/RenderType/page.kubedoc rename to wiki/ref/enums/RenderType/page.kubedoc diff --git a/wiki/ref/MutableBlock/en.yml b/wiki/ref/enums/SoundType/en.yml similarity index 100% rename from wiki/ref/MutableBlock/en.yml rename to wiki/ref/enums/SoundType/en.yml diff --git a/wiki/ref/SoundType/meta.yml b/wiki/ref/enums/SoundType/meta.yml similarity index 100% rename from wiki/ref/SoundType/meta.yml rename to wiki/ref/enums/SoundType/meta.yml diff --git a/wiki/ref/SoundType/page.kubedoc b/wiki/ref/enums/SoundType/page.kubedoc similarity index 100% rename from wiki/ref/SoundType/page.kubedoc rename to wiki/ref/enums/SoundType/page.kubedoc diff --git a/wiki/ref/enums/en.yml b/wiki/ref/enums/en.yml new file mode 100644 index 00000000..fc8d033c --- /dev/null +++ b/wiki/ref/enums/en.yml @@ -0,0 +1,2 @@ +title: "Enums and alikes" +description: "Enumeration classes and other value-heavy classes/interfaces used throughout Minecraft and KubeJS" \ No newline at end of file diff --git a/wiki/ref/MutableItem/en.yml b/wiki/ref/java/Consumer/en.yml similarity index 100% rename from wiki/ref/MutableItem/en.yml rename to wiki/ref/java/Consumer/en.yml diff --git a/wiki/ref/Consumer/page.kubedoc b/wiki/ref/java/Consumer/page.kubedoc similarity index 100% rename from wiki/ref/Consumer/page.kubedoc rename to wiki/ref/java/Consumer/page.kubedoc diff --git a/wiki/ref/java/en.yml b/wiki/ref/java/en.yml new file mode 100644 index 00000000..511bf2d4 --- /dev/null +++ b/wiki/ref/java/en.yml @@ -0,0 +1,2 @@ +title: "Java" +description: "Lets you script Java" \ No newline at end of file diff --git a/wiki/ref/String/page.kubedoc b/wiki/ref/js/String/page.kubedoc similarity index 100% rename from wiki/ref/String/page.kubedoc rename to wiki/ref/js/String/page.kubedoc diff --git a/wiki/ref/js/en.yml b/wiki/ref/js/en.yml new file mode 100644 index 00000000..693f9899 --- /dev/null +++ b/wiki/ref/js/en.yml @@ -0,0 +1,2 @@ +title: "JavaScript enhancements" +description: "Existing JavaScript objects enhanced by KubeJS" \ No newline at end of file diff --git a/wiki/ref/MutableToolTier/en.yml b/wiki/ref/mutables/MutableBlock/en.yml similarity index 100% rename from wiki/ref/MutableToolTier/en.yml rename to wiki/ref/mutables/MutableBlock/en.yml diff --git a/wiki/ref/MutableBlock/page.kubedoc b/wiki/ref/mutables/MutableBlock/page.kubedoc similarity index 100% rename from wiki/ref/MutableBlock/page.kubedoc rename to wiki/ref/mutables/MutableBlock/page.kubedoc diff --git a/wiki/ref/RenderType/en.yml b/wiki/ref/mutables/MutableItem/en.yml similarity index 100% rename from wiki/ref/RenderType/en.yml rename to wiki/ref/mutables/MutableItem/en.yml diff --git a/wiki/ref/MutableItem/page.kubedoc b/wiki/ref/mutables/MutableItem/page.kubedoc similarity index 100% rename from wiki/ref/MutableItem/page.kubedoc rename to wiki/ref/mutables/MutableItem/page.kubedoc diff --git a/wiki/ref/SoundType/en.yml b/wiki/ref/mutables/MutableToolTier/en.yml similarity index 100% rename from wiki/ref/SoundType/en.yml rename to wiki/ref/mutables/MutableToolTier/en.yml diff --git a/wiki/ref/MutableToolTier/page.kubedoc b/wiki/ref/mutables/MutableToolTier/page.kubedoc similarity index 100% rename from wiki/ref/MutableToolTier/page.kubedoc rename to wiki/ref/mutables/MutableToolTier/page.kubedoc diff --git a/wiki/ref/mutables/en.yml b/wiki/ref/mutables/en.yml new file mode 100644 index 00000000..791f2dad --- /dev/null +++ b/wiki/ref/mutables/en.yml @@ -0,0 +1,2 @@ +title: "Mutables" +description: "Mutable versions of immutable classes" \ No newline at end of file diff --git a/wiki/ref/TextComponent/en.yml b/wiki/ref/utils/TextComponent/en.yml similarity index 100% rename from wiki/ref/TextComponent/en.yml rename to wiki/ref/utils/TextComponent/en.yml diff --git a/wiki/ref/Unit/en.yml b/wiki/ref/utils/Unit/en.yml similarity index 100% rename from wiki/ref/Unit/en.yml rename to wiki/ref/utils/Unit/en.yml diff --git a/wiki/ref/Unit/meta.yml b/wiki/ref/utils/Unit/meta.yml similarity index 100% rename from wiki/ref/Unit/meta.yml rename to wiki/ref/utils/Unit/meta.yml diff --git a/wiki/ref/Unit/page.kubedoc b/wiki/ref/utils/Unit/page.kubedoc similarity index 100% rename from wiki/ref/Unit/page.kubedoc rename to wiki/ref/utils/Unit/page.kubedoc diff --git a/wiki/ref/utils/en.yml b/wiki/ref/utils/en.yml new file mode 100644 index 00000000..a599c482 --- /dev/null +++ b/wiki/ref/utils/en.yml @@ -0,0 +1,2 @@ +title: "Utilities" +description: "Various classes/interfaces that provide useful values/methods" \ No newline at end of file diff --git a/wiki/ref/BlockWrapper/en.yml b/wiki/ref/wrappers/BlockWrapper/en.yml similarity index 100% rename from wiki/ref/BlockWrapper/en.yml rename to wiki/ref/wrappers/BlockWrapper/en.yml diff --git a/wiki/ref/BlockWrapper/meta.yml b/wiki/ref/wrappers/BlockWrapper/meta.yml similarity index 100% rename from wiki/ref/BlockWrapper/meta.yml rename to wiki/ref/wrappers/BlockWrapper/meta.yml diff --git a/wiki/ref/BlockWrapper/page.kubedoc b/wiki/ref/wrappers/BlockWrapper/page.kubedoc similarity index 100% rename from wiki/ref/BlockWrapper/page.kubedoc rename to wiki/ref/wrappers/BlockWrapper/page.kubedoc diff --git a/wiki/ref/ItemWrapper/en.yml b/wiki/ref/wrappers/ItemWrapper/en.yml similarity index 100% rename from wiki/ref/ItemWrapper/en.yml rename to wiki/ref/wrappers/ItemWrapper/en.yml diff --git a/wiki/ref/ItemWrapper/meta.yml b/wiki/ref/wrappers/ItemWrapper/meta.yml similarity index 100% rename from wiki/ref/ItemWrapper/meta.yml rename to wiki/ref/wrappers/ItemWrapper/meta.yml diff --git a/wiki/ref/ItemWrapper/page.kubedoc b/wiki/ref/wrappers/ItemWrapper/page.kubedoc similarity index 100% rename from wiki/ref/ItemWrapper/page.kubedoc rename to wiki/ref/wrappers/ItemWrapper/page.kubedoc diff --git a/wiki/ref/wrappers/en.yml b/wiki/ref/wrappers/en.yml new file mode 100644 index 00000000..663f8450 --- /dev/null +++ b/wiki/ref/wrappers/en.yml @@ -0,0 +1,2 @@ +title: "Wrappers" +description: "Classes that turn strings and other JS objects into Java objects" \ No newline at end of file diff --git a/wiki/test/page.kubedoc b/wiki/test/page.kubedoc index 59282fd1..54f5a82d 100644 --- a/wiki/test/page.kubedoc +++ b/wiki/test/page.kubedoc @@ -59,7 +59,7 @@ Inline `code` and `code II` and `code *III*` Inline image ![[emoji:test.png|Test]] test [[@000001]] [[[/tutorials/block-registry]]] -[[[/ref/BlockBuilder]]] +[[[/ref/builders/BlockBuilder]]] [[[/fake-page]]] --- From 5b898fcfaa73a4f8dd8a5a80c09e5f267807d908 Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Thu, 25 Dec 2025 18:03:23 +0100 Subject: [PATCH 46/68] Document Java functional interfaces --- wiki/ref/java/Consumer/en.yml | 0 wiki/ref/java/Consumer/page.kubedoc | 13 ------- wiki/ref/java/en.yml | 2 +- .../java/functional-interface/Consumer/en.yml | 2 ++ .../Consumer/page.kubedoc | 24 +++++++++++++ .../java/functional-interface/Function/en.yml | 2 ++ .../Function/page.kubedoc | 13 +++++++ .../functional-interface/Predicate/en.yml | 2 ++ .../Predicate/page.kubedoc | 26 ++++++++++++++ .../java/functional-interface/Supplier/en.yml | 2 ++ .../Supplier/page.kubedoc | 34 +++++++++++++++++++ wiki/ref/java/functional-interface/en.yml | 2 ++ .../java/functional-interface/page.kubedoc | 19 +++++++++++ 13 files changed, 127 insertions(+), 14 deletions(-) delete mode 100644 wiki/ref/java/Consumer/en.yml delete mode 100644 wiki/ref/java/Consumer/page.kubedoc create mode 100644 wiki/ref/java/functional-interface/Consumer/en.yml create mode 100644 wiki/ref/java/functional-interface/Consumer/page.kubedoc create mode 100644 wiki/ref/java/functional-interface/Function/en.yml create mode 100644 wiki/ref/java/functional-interface/Function/page.kubedoc create mode 100644 wiki/ref/java/functional-interface/Predicate/en.yml create mode 100644 wiki/ref/java/functional-interface/Predicate/page.kubedoc create mode 100644 wiki/ref/java/functional-interface/Supplier/en.yml create mode 100644 wiki/ref/java/functional-interface/Supplier/page.kubedoc create mode 100644 wiki/ref/java/functional-interface/en.yml create mode 100644 wiki/ref/java/functional-interface/page.kubedoc diff --git a/wiki/ref/java/Consumer/en.yml b/wiki/ref/java/Consumer/en.yml deleted file mode 100644 index e69de29b..00000000 diff --git a/wiki/ref/java/Consumer/page.kubedoc b/wiki/ref/java/Consumer/page.kubedoc deleted file mode 100644 index f8313427..00000000 --- a/wiki/ref/java/Consumer/page.kubedoc +++ /dev/null @@ -1,13 +0,0 @@ -Consumer is a generic class that usually means that method has a callback function. - -If your method looks something like: - -`object`$$.example(callback: Consumer) - -Then the script for this will be: -```js -object.example(obj => { - console.log(obj) // obj is a string -}) -``` -Of course, the argument name in callback doesn't matter. \ No newline at end of file diff --git a/wiki/ref/java/en.yml b/wiki/ref/java/en.yml index 511bf2d4..f947827e 100644 --- a/wiki/ref/java/en.yml +++ b/wiki/ref/java/en.yml @@ -1,2 +1,2 @@ title: "Java" -description: "Lets you script Java" \ No newline at end of file +description: "Reference for Java built-in types that can be described by JavaScript" \ No newline at end of file diff --git a/wiki/ref/java/functional-interface/Consumer/en.yml b/wiki/ref/java/functional-interface/Consumer/en.yml new file mode 100644 index 00000000..fdc90f34 --- /dev/null +++ b/wiki/ref/java/functional-interface/Consumer/en.yml @@ -0,0 +1,2 @@ +title: "Consumer" +description: "A function that takes one parameter and returns nothing" \ No newline at end of file diff --git a/wiki/ref/java/functional-interface/Consumer/page.kubedoc b/wiki/ref/java/functional-interface/Consumer/page.kubedoc new file mode 100644 index 00000000..718dc8e4 --- /dev/null +++ b/wiki/ref/java/functional-interface/Consumer/page.kubedoc @@ -0,0 +1,24 @@ +**Consumer** functional interfaces represent functions, that take a value of a type (specified in type argument) and return nothing. + +They are commonly used in KubeJS events - the event is passed as a parameter to event handler function. + +Examples: +```js +// A function that takes `event` and returns nothing +const handler = event => { + // When passed into `ServerEvents.recipes` event handler, + // `event` will be of type RecipesKubeEvent + event.shaped('minecraft:brick_slab', ['BBB'], { B: 'minecraft:brick' }) +} + +// handler's expected type is Consumer +ServerEvents.recipes(handler) +``` + +```js +// Or more commonly, put the function directly inside of the parameter +ServerEvents.recipes(event => { + // `event` will be of type RecipesKubeEvent + event.shaped('minecraft:brick_slab', ['BBB'], { B: 'minecraft:brick' }) +}) +``` \ No newline at end of file diff --git a/wiki/ref/java/functional-interface/Function/en.yml b/wiki/ref/java/functional-interface/Function/en.yml new file mode 100644 index 00000000..5ba9b2b4 --- /dev/null +++ b/wiki/ref/java/functional-interface/Function/en.yml @@ -0,0 +1,2 @@ +title: "Function" +description: "A function that takes a parameter and returns a value" \ No newline at end of file diff --git a/wiki/ref/java/functional-interface/Function/page.kubedoc b/wiki/ref/java/functional-interface/Function/page.kubedoc new file mode 100644 index 00000000..0b0bfe56 --- /dev/null +++ b/wiki/ref/java/functional-interface/Function/page.kubedoc @@ -0,0 +1,13 @@ +**Supplier** functional interfaces represent functions, that take a parameter (specified in type argument) and return a value of a type (specified in another type argument). + +They are usually used in customized callbacks. + +Examples: +```js +const $ItemProperties = Java.loadClass('net.minecraft.world.item.Item$Properties') +const $ShieldItem = Java.loadClass('net.minecraft.world.item.ShieldItem') + +// An inpractical example of a function that takes a number and outputs a ShieldItem +// If could be assigned to places where Function is expected. +const intToShieldFunction = (durability) => new $ShieldItem(new $ItemProperties().durability(durability).stacksTo(1)) +``` diff --git a/wiki/ref/java/functional-interface/Predicate/en.yml b/wiki/ref/java/functional-interface/Predicate/en.yml new file mode 100644 index 00000000..1d46d44f --- /dev/null +++ b/wiki/ref/java/functional-interface/Predicate/en.yml @@ -0,0 +1,2 @@ +title: "Predicate" +description: "A function that takes one parameter and returns a boolean" \ No newline at end of file diff --git a/wiki/ref/java/functional-interface/Predicate/page.kubedoc b/wiki/ref/java/functional-interface/Predicate/page.kubedoc new file mode 100644 index 00000000..3208b51e --- /dev/null +++ b/wiki/ref/java/functional-interface/Predicate/page.kubedoc @@ -0,0 +1,26 @@ +**Predicate** functional interfaces represent functions, that take a value of a type (specified in type argument) and return a boolean value. + +They are commonly used in callbacks used to filter lists and other collections. + +Examples: +```js +// When passed into the `rayTraceEntity` predicate parameter, `entity` will be of type Entity +const cowPredicate = entity => entity.type == 'minecraft:cow' + +PlayerEvents.tick(event => { + if (event.server.tickCount % 10 != 0) return + // The expected type of `rayTraceEntity`'s first parameter is Predicate + const rayTracedCow = event.player.rayTraceEntity(cowPredicate) +}) +``` + +```js +// Or more commonly, put the function directly inside of the parameter +PlayerEvents.tick(event => { + if (event.server.tickCount % 10 != 0) return; + const rayTracedCow = event.player.rayTraceEntity(entity => { + // `entity` will be of type Entity + return entity.type == 'minecraft:cow' + }) +}) +``` \ No newline at end of file diff --git a/wiki/ref/java/functional-interface/Supplier/en.yml b/wiki/ref/java/functional-interface/Supplier/en.yml new file mode 100644 index 00000000..87c1dfd6 --- /dev/null +++ b/wiki/ref/java/functional-interface/Supplier/en.yml @@ -0,0 +1,2 @@ +title: "Supplier" +description: "A function that takes nothing and returns a value" \ No newline at end of file diff --git a/wiki/ref/java/functional-interface/Supplier/page.kubedoc b/wiki/ref/java/functional-interface/Supplier/page.kubedoc new file mode 100644 index 00000000..d56a7643 --- /dev/null +++ b/wiki/ref/java/functional-interface/Supplier/page.kubedoc @@ -0,0 +1,34 @@ +**Supplier** functional interfaces represent functions, that take nothing and return a value of a type (specified in type argument). + +They are usually used in places, where: +- The value needs to be fetched lazily, that means that the method that uses such callback can choose when to execute the function to fetch the value, +- The value can be dependent on external sources, and may change over time. + +Examples: +```js +const $ItemProperties = Java.loadClass('net.minecraft.world.item.Item$Properties') +const $ShieldItem = Java.loadClass('net.minecraft.world.item.ShieldItem') + +// A function that takes nothing and outputs a ShieldItem +const shieldSupplier = () => new $ShieldItem(new $ItemProperties().durability(128).stacksTo(1)) + +StartupEvents.registry('item', event => { + event.createCustom( + 'kubejs:copper_shield', + shieldSupplier + ) +}) +``` + +```js +// Or more commonly, put the function directly inside of the parameter +const $ItemProperties = Java.loadClass('net.minecraft.world.item.Item$Properties') +const $ShieldItem = Java.loadClass('net.minecraft.world.item.ShieldItem') + +StartupEvents.registry('item', event => { + event.createCustom( + 'kubejs:copper_shield', + () => new $ShieldItem(new $ItemProperties().durability(128).stacksTo(1)) + ) +}) +``` \ No newline at end of file diff --git a/wiki/ref/java/functional-interface/en.yml b/wiki/ref/java/functional-interface/en.yml new file mode 100644 index 00000000..4af76ee9 --- /dev/null +++ b/wiki/ref/java/functional-interface/en.yml @@ -0,0 +1,2 @@ +title: "Functional interfaces" +description: "No first-class functions? No problem!" \ No newline at end of file diff --git a/wiki/ref/java/functional-interface/page.kubedoc b/wiki/ref/java/functional-interface/page.kubedoc new file mode 100644 index 00000000..187f7858 --- /dev/null +++ b/wiki/ref/java/functional-interface/page.kubedoc @@ -0,0 +1,19 @@ +Java does not feature [first-class functions](https://developer.mozilla.org/en-US/docs/Glossary/First-class_Function) like JavaScript does. +That doesn't mean that Java can't represent callbacks (functions passed into functions as an argument)! + +To represent them, Java uses **functional interfaces**. + +Functional interfaces are interfaces, that feature only one abstract method. That method will be the target for lambda expressions in Java. + +In JavaScript scripts, they can be represented by passing in a function that roughly matches the signature (parameters and return type) of the single abstract method. + +# Common functional interfaces + +[[[/ref/java/functional-interface/Consumer]]] +[[[/ref/java/functional-interface/Supplier]]] +[[[/ref/java/functional-interface/Predicate]]] +[[[/ref/java/functional-interface/Function]]] + +# Reference + +[JavaDocs for `java.util.function` package](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/function/package-summary.html) \ No newline at end of file From 0376e9f7f1287e855502e1dbb20b8e0550d18d6b Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Tue, 30 Dec 2025 18:17:37 +0100 Subject: [PATCH 47/68] Start documenting blocks (`LevelBlock`) --- wiki/concepts/block/en.yml | 2 + wiki/concepts/block/page.kubedoc | 96 ++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 wiki/concepts/block/en.yml create mode 100644 wiki/concepts/block/page.kubedoc diff --git a/wiki/concepts/block/en.yml b/wiki/concepts/block/en.yml new file mode 100644 index 00000000..c4a021bf --- /dev/null +++ b/wiki/concepts/block/en.yml @@ -0,0 +1,2 @@ +title: "Block" +description: "It wouldn't be Minecraft if not for blocks!" \ No newline at end of file diff --git a/wiki/concepts/block/page.kubedoc b/wiki/concepts/block/page.kubedoc new file mode 100644 index 00000000..24d74ad6 --- /dev/null +++ b/wiki/concepts/block/page.kubedoc @@ -0,0 +1,96 @@ +**Blocks** are the very foundation of a Minecraft block. + +In the game, their role is split into: +- `Block`s - which are the singleton objects defining block behavior. These aren't generally used in in-world interactions. + +- `BlockState`s - which define additional properties attacked to a block (like axis, being waterlogged, orientation, etc.). These are actual objects stored in world, and can be manipulated. KubeJS also adds an additional `LevelBlock` interface which abstracts away common cases of manipulating blocks in world. + +# Creating BlockStates + +In places where `BlockState`s are expected, KubeJS will try to implicitly convert other objects into them. +Most `BlockState`s can be written as string literals, with block property syntax being the same as one used in [`/setblock` or `/fill`](https://minecraft.wiki/w/Argument_types#minecraft:block_state). + +# How to get LevelBlocks + +`LevelBlock`s are usually obtained via block-getting methods on `Level` (object representing the Minecraft world), such as `[js]level.getBlock(x, y, z)`. + +# Useful LevelBlock methods + +## Position + +| Getter | Read-only bean | Description | +| `[js]block.getNorth()` | `[js]block.north` | Gets the block to the north of self. | +| `[js]block.getSouth()` | `[js]block.south` | Gets the block to the south of self. | +| `[js]block.getEast()` | `[js]block.east` | Gets the block to the east of self. | +| `[js]block.getWest()` | `[js]block.west` | Gets the block to the west of self. | +| `[js]block.getUp()` | `[js]block.up` | Gets the block above self. | +| `[js]block.getDown()` | `[js]block.down` | Gets the block below self. | + +--- + +## Relative + +These getters allow you to get blocks around the currently referenced block, as `LevelBlock`s. + +| Getter | Read-only bean | Description | +| `[js]block.getNorth()` | `[js]block.north` | Gets the block to the north of the `block`. | +| `[js]block.getSouth()` | `[js]block.south` | Gets the block to the south of the `block`. | +| `[js]block.getEast()` | `[js]block.east` | Gets the block to the east of the `block`. | +| `[js]block.getWest()` | `[js]block.west` | Gets the block to the west of the `block`. | +| `[js]block.getUp()` | `[js]block.up` | Gets the block above the `block`. | +| `[js]block.getDown()` | `[js]block.down` | Gets the block below the `block`. | +--- + +## Other + +### Accessors + +| Getter | Setter | Bean | Description | +| `[js]block.getEntityData()` | `[js]block.setEntityData(entityData)` | `[js]block.entityData` | Gets or sets the block entity data of the block. | +| `[js]block.getBlockState()` | `[js]block.setBlockState(state)` | `[js]block.blockState` | Gets or sets the BlockState of the block. | + + +### Getters + +>>> #players-in-radius-note +Gets a list of all player entities in an 8-block radius. +**Note**: `getPlayersInRadius` also has an overload with customizable radius, see "Other methods". +<<< + +| Getter | Read-only bean | Description | +| `[js]block.getBiomeId()` | `[js]block.biomeId` | Gets the biome ID as ResourceLocation. | +| `[js]block.getBlock()` | `[js]block.block` | Gets the Block of the block. | +| `[js]block.getBlockLight()` | `[js]block.blockLight` | Gets the block's block light level. | +| `[js]block.getCanSeeSky()` | `[js]block.canSeeSky` | Gets `true` if block can see sky, `false` if it can't. | +| `[js]block.getDimension()` | `[js]block.dimension` | Gets the dimension of the block. | +| `[js]block.getDimensionKey()` | `[js]block.dimensionKey` | Gets the dimension key of the block. | +| `[js]block.getEntity()` | `[js]block.entity` | Gets the block entity of the block. | +| `[js]block.getEntityId()` | `[js]block.entityId` | Gets the block entity ID (as ResourceLocation) of the block. | +| `[js]block.getId()` | `[js]block.id` | Gets the block's ID as string. | +| `[js]block.getIdLocation()` | `[js]block.idLocation` | Gets the block's ID as ResourceLocation. | +| `[js]block.getInventory()` | `[js]block.inventory` | Gets the block's inventory. The block must have an inventory. | +| `[js]block.getItem()` | `[js]block.item` | Gets the ItemStack corresponding to this block. | +| `[js]block.getKey()` | `[js]block.key` | Gets the block's ResourceKey. | +| `[js]block.getLevel()` | `[js]block.level` | Gets the world the block is in. | +| `[js]block.getLight()` | `[js]block.light` | Gets the block's light level. | +| `[js]block.getMod()` | `[js]block.mod` | Gets the block's mod ID as string. | +| `[js]block.getPlayersInRadius()` | `[js]block.playersInRadius` | <#players-in-radius-note> | +| `[js]block.getProperties()` | `[js]block.properties` | Gets the block's properties. | +| `[js]block.getRegistry()` | `[js]block.registry` | Gets the block registry. | +| `[js]block.getRegistryId()` | `[js]block.registryId` | Gets the block's ResourceKey from the block registry. | +| `[js]block.getSkyLight()` | `[js]block.skyLight` | Gets the block's sky light level. | +| `[js]block.getTagKeys()` | `[js]block.tagKeys` | Gets the list of block's TagKeys. | +| `[js]block.getTags()` | `[js]block.tags` | Gets the list of block's tags as ResourceLocations. | +| `[js]block.getTypeData()` | `[js]block.typeData` | ??? | + +### Other methods + +--- + + + + +# Useful BlockState methods + + + From 13f0161298c1159e510d9598267d10d0a85d7007 Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Tue, 30 Dec 2025 18:28:06 +0100 Subject: [PATCH 48/68] Do I really need a variable block every time I want a code block together with text in a table cell? --- wiki/concepts/block/page.kubedoc | 38 +++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/wiki/concepts/block/page.kubedoc b/wiki/concepts/block/page.kubedoc index 24d74ad6..68326c72 100644 --- a/wiki/concepts/block/page.kubedoc +++ b/wiki/concepts/block/page.kubedoc @@ -30,15 +30,34 @@ Most `BlockState`s can be written as string literals, with block property syntax ## Relative +>>> #get-north +Gets the block to the north of the `block`. +<<< +>>> #get-south +Gets the block to the south of the `block`. +<<< +>>> #get-east +Gets the block to the east of the `block`. +<<< +>>> #get-west +Gets the block to the west of the `block`. +<<< +>>> #get-up +Gets the block above the `block`. +<<< +>>> #get-down +Gets the block below the `block`. +<<< + These getters allow you to get blocks around the currently referenced block, as `LevelBlock`s. -| Getter | Read-only bean | Description | -| `[js]block.getNorth()` | `[js]block.north` | Gets the block to the north of the `block`. | -| `[js]block.getSouth()` | `[js]block.south` | Gets the block to the south of the `block`. | -| `[js]block.getEast()` | `[js]block.east` | Gets the block to the east of the `block`. | -| `[js]block.getWest()` | `[js]block.west` | Gets the block to the west of the `block`. | -| `[js]block.getUp()` | `[js]block.up` | Gets the block above the `block`. | -| `[js]block.getDown()` | `[js]block.down` | Gets the block below the `block`. | +| Getter | Read-only bean | Description | +| `[js]block.getNorth()` | `[js]block.north` | <#get-north> | +| `[js]block.getSouth()` | `[js]block.south` | <#get-south> | +| `[js]block.getEast()` | `[js]block.east` | <#get-east> | +| `[js]block.getWest()` | `[js]block.west` | <#get-west> | +| `[js]block.getUp()` | `[js]block.up` | <#get-up> | +| `[js]block.getDown()` | `[js]block.down` | <#get-down> | --- ## Other @@ -56,12 +75,15 @@ These getters allow you to get blocks around the currently referenced block, as Gets a list of all player entities in an 8-block radius. **Note**: `getPlayersInRadius` also has an overload with customizable radius, see "Other methods". <<< +>>> #can-see-sky +Gets `true` if block can see sky, `false` if it can't. +<<< | Getter | Read-only bean | Description | | `[js]block.getBiomeId()` | `[js]block.biomeId` | Gets the biome ID as ResourceLocation. | | `[js]block.getBlock()` | `[js]block.block` | Gets the Block of the block. | | `[js]block.getBlockLight()` | `[js]block.blockLight` | Gets the block's block light level. | -| `[js]block.getCanSeeSky()` | `[js]block.canSeeSky` | Gets `true` if block can see sky, `false` if it can't. | +| `[js]block.getCanSeeSky()` | `[js]block.canSeeSky` | <#can-see-sky> | | `[js]block.getDimension()` | `[js]block.dimension` | Gets the dimension of the block. | | `[js]block.getDimensionKey()` | `[js]block.dimensionKey` | Gets the dimension key of the block. | | `[js]block.getEntity()` | `[js]block.entity` | Gets the block entity of the block. | From 87d36c6755e6a0632d5bfc3b9d813070b2fe13a6 Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Tue, 30 Dec 2025 21:19:26 +0100 Subject: [PATCH 49/68] Document up to `block.explode`, add ExplosionProperties page Oops, all placeholders! --- wiki/concepts/block/en.yml | 4 +- wiki/concepts/block/page.kubedoc | 62 ++++++++++--- wiki/ref/records/ExplosionProperties/en.yml | 2 + .../records/ExplosionProperties/page.kubedoc | 87 +++++++++++++++++++ wiki/ref/records/en.yml | 2 + 5 files changed, 146 insertions(+), 11 deletions(-) create mode 100644 wiki/ref/records/ExplosionProperties/en.yml create mode 100644 wiki/ref/records/ExplosionProperties/page.kubedoc create mode 100644 wiki/ref/records/en.yml diff --git a/wiki/concepts/block/en.yml b/wiki/concepts/block/en.yml index c4a021bf..e099215b 100644 --- a/wiki/concepts/block/en.yml +++ b/wiki/concepts/block/en.yml @@ -1,2 +1,4 @@ title: "Block" -description: "It wouldn't be Minecraft if not for blocks!" \ No newline at end of file +description: "It wouldn't be Minecraft if not for blocks!" + +optional: "#[[#c3c7cb;border:1px solid #51565d;font-size:0.8rem;padding:0.2em 0.3em; border-radius: 1em|Optional]]" \ No newline at end of file diff --git a/wiki/concepts/block/page.kubedoc b/wiki/concepts/block/page.kubedoc index 68326c72..a41f3258 100644 --- a/wiki/concepts/block/page.kubedoc +++ b/wiki/concepts/block/page.kubedoc @@ -18,13 +18,22 @@ Most `BlockState`s can be written as string literals, with block property syntax ## Position -| Getter | Read-only bean | Description | -| `[js]block.getNorth()` | `[js]block.north` | Gets the block to the north of self. | -| `[js]block.getSouth()` | `[js]block.south` | Gets the block to the south of self. | -| `[js]block.getEast()` | `[js]block.east` | Gets the block to the east of self. | -| `[js]block.getWest()` | `[js]block.west` | Gets the block to the west of self. | -| `[js]block.getUp()` | `[js]block.up` | Gets the block above self. | -| `[js]block.getDown()` | `[js]block.down` | Gets the block below self. | +| Getter | Read-only bean | Description | +| `[js]block.getPos()` | `[js]block.pos` | Gets the position of the block, as BlockPos. | +| `[js]block.getX()` | `[js]block.x` | Gets the x coordinate of the block. | +| `[js]block.getY()` | `[js]block.y` | Gets the y coordinate of the block. | +| `[js]block.getZ()` | `[js]block.z` | Gets the z coordinate of the block. | +| `[js]block.getCenterX()` | `[js]block.centerX` | Gets the x coordinate of the center of the block. | +| `[js]block.getCenterY()` | `[js]block.centerY` | Gets the y coordinate of the center of the block. | +| `[js]block.getCenterZ()` | `[js]block.centerZ` | Gets the z coordinate of the center of the block. | + +**Example** +Position related beans on `LevelBlock` make for a useful application of a [destructuring pattern](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring) to quickly get all the block's coordinates to variables. + +```js +const \{ x, y, z \} = block +// Now x, y and z constants are respectively the block's x, y and z coordinate. +``` --- @@ -64,10 +73,28 @@ These getters allow you to get blocks around the currently referenced block, as ### Accessors -| Getter | Setter | Bean | Description | -| `[js]block.getEntityData()` | `[js]block.setEntityData(entityData)` | `[js]block.entityData` | Gets or sets the block entity data of the block. | -| `[js]block.getBlockState()` | `[js]block.setBlockState(state)` | `[js]block.blockState` | Gets or sets the BlockState of the block. | +>>> #entity-data +Gets or sets the block entity data (as `CompoundTag`) of the block. The data get or set may be `null`. +<<< +>>> #block-state-note +Gets or sets the BlockState of the block. +**Note**: `setBlockState` also has an overload that allows for setting block update flags, see "Setters". +<<< + +| Getter | Setter | Bean | Description | +| `[js]block.getEntityData()` | `[js]block.setEntityData(entityData)` | `[js]block.entityData` | <#entity-data> | +| `[js]block.getBlockState()` | `[js]block.setBlockState(state)` | `[js]block.blockState` | <#block-state-note> | + +### Setters +- `[js]block.set(block, properties, updateFlags)` + - `[js]block`: The Block to set the `block` to. It may be a string representing a block, for example `[js]'minecraft:oak_log'` + - `[js]properties` {optional}: Block properties to set on that block. It can be an object representing the block properties, for example `[js]\{ axis: 'x' \}` + - `[js]updateFlags` {optional}: Block update flags. They are a bit map of update properties. + +- `[js]block.setBlockState(blockState, updateFlags)` + - `[js]blockState`: The BlockState to set the `block` to. It may be a string representing a block state, for example `[js]'minecraft:oak_log\[axis=x\]'` + - `[js]updateFlags` {optional}: Block update flags. They are a bit map of update properties. ### Getters @@ -107,6 +134,21 @@ Gets `true` if block can see sky, `false` if it can't. ### Other methods +- `[js]block.offset(direction)` +- `[js]block.offset(direction, amount)` + - `[js]direction`: A `Direction`. In can be a string representing a direction, for example `[js]'north'` + - `[js]amount` {optional}: Amount of blocks to move away from the `block`. Defaults to `1` if not provided. +- `[js]block.offset(x, y, z)` + - `[js]x`, `[js]y`, `[js]z`: Amount of blocks to move from the `block` in x, y and z directions respectively. + - **Returns**: A `LevelBlock` representing a block at a specified offset. + +- `[js]block.mergeEntityData(entityData)` + - `[js]entityData`: The block entity data (as `CompoundTag`) to merge with existing entity data. + +- `[js]block.explode(explosionProperties)` + - `[js]explosionProperties`: The [[/ref/records/ExplosionProperties|explosion properties]] to use. + - **Returns**: An `Explosion` object. Also creates an explosion at the location of the block. + --- diff --git a/wiki/ref/records/ExplosionProperties/en.yml b/wiki/ref/records/ExplosionProperties/en.yml new file mode 100644 index 00000000..87c1dfd6 --- /dev/null +++ b/wiki/ref/records/ExplosionProperties/en.yml @@ -0,0 +1,2 @@ +title: "Supplier" +description: "A function that takes nothing and returns a value" \ No newline at end of file diff --git a/wiki/ref/records/ExplosionProperties/page.kubedoc b/wiki/ref/records/ExplosionProperties/page.kubedoc new file mode 100644 index 00000000..e1a24c21 --- /dev/null +++ b/wiki/ref/records/ExplosionProperties/page.kubedoc @@ -0,0 +1,87 @@ +**ExplosionProperties** define explosion properties. Nothing to write home about here. + +>>> #source-type +[[/concepts/entity|`Entity`]] +<<< +>>> #source-description +Specifies the source of the explosion's damage (for example, the player who lit the TNT). +<<< +>>> #damage-source-type +`DamageSource` +<<< +>>> #damage-source-description +Specifies the damage source for the explosion. +<<< +>>> #explosion-damage-calculator-type +`ExplosionDamageCalculator` +<<< +>>> #explosion-damage-calculator-description +Explosion damage calculator. +<<< +>>> #strength-type +`number` (float) +<<< +>>> #strength-description +Specifies the strength of the explosion. +Defaults to `3` if not provided. +<<< +>>> #causes-fire-type +`boolean` +<<< +>>> #causes-fire-description +Specifies, whether explosion causes fire, like Ghast fireball explosions or bed explosions in the Nether. +Defaults to `false` if not provided. +<<< +>>> #mode-type +`Level.ExplosionInteraction` +<<< +>>> #mode-description +The explosion mode. +May be also a string representing a mode: +`'none'`, `'block'`, `'mob'`, `'tnt'`, `'trigger'` +Defaults to `'none'` if not provided. +<<< +>>> #particles-type +`boolean` +<<< +>>> #particles-description +Whether the explosion emits particles or not. Defaults to `true` if not provided. +<<< +>>> #small-particles-type +`ParticleOptions` +<<< +>>> #small-particles-description +Specifies the small particles used in the explosion. +May be also a string representing the particle to use, for example `'minecraft:angry_villager'`. +Defaults to `'minecraft:explosion'` if not provided. +<<< +>>> #large-particles-type +`ParticleOptions` +<<< +>>> #large-particles-description +Specifies the large particles used in the explosion. +May be also a string representing the particle to use, for example `'minecraft:angry_villager'`. +Defaults to `'minecraft:explosion_emitter'` if not provided. +<<< +>>> #explosion-sound-type +`Holder` +<<< +>>> #explosion-sound-description +Specifies the sound of the explosion. +May be also a string representing a sound, for example `'minecraft:block.amethyst_block.chime'`. +Defaults to `'minecraft:entity.generic.explode'` if not provided. +<<< + +# Properties + +| Property | Type | Description | +| `source` | <#source-type> | <#source-description> | +| `damageSource` | <#damage-source-type> | <#damage-source-description> | +| `damageCalculator` | <#explosion-damage-calculator-type> | <#explosion-damage-calculator-description> | +| `strength` | <#strength-type> | <#strength-description> | +| `causesFire` | <#causes-fire-type> | <#causes-fire-description> | +| `mode` | <#mode-type> | <#mode-description> | +| `particles` | <#particles-type> | <#particles-description> | +| `smallParticles` | <#small-particles-type> | <#small-particles-description> | +| `largeParticles` | <#large-particles-type> | <#large-particles-description> | +| `explosionSound` | <#explosion-sound-type> | <#explosion-sound-description> | \ No newline at end of file diff --git a/wiki/ref/records/en.yml b/wiki/ref/records/en.yml new file mode 100644 index 00000000..1abc4365 --- /dev/null +++ b/wiki/ref/records/en.yml @@ -0,0 +1,2 @@ +title: "Records" +description: "Classes usually representing properties of something" \ No newline at end of file From 63040917cb0cc4cbf963d8fa4e23799a48bc43aa Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Tue, 30 Dec 2025 21:23:38 +0100 Subject: [PATCH 50/68] Can't espace in codeblocks Also, changed ExplosionProperties page title and description and added [js] --- wiki/concepts/block/page.kubedoc | 2 +- wiki/ref/records/ExplosionProperties/en.yml | 4 ++-- .../records/ExplosionProperties/page.kubedoc | 23 ++++++++++--------- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/wiki/concepts/block/page.kubedoc b/wiki/concepts/block/page.kubedoc index a41f3258..4db55ecd 100644 --- a/wiki/concepts/block/page.kubedoc +++ b/wiki/concepts/block/page.kubedoc @@ -31,7 +31,7 @@ Most `BlockState`s can be written as string literals, with block property syntax Position related beans on `LevelBlock` make for a useful application of a [destructuring pattern](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring) to quickly get all the block's coordinates to variables. ```js -const \{ x, y, z \} = block +const { x, y, z } = block // Now x, y and z constants are respectively the block's x, y and z coordinate. ``` diff --git a/wiki/ref/records/ExplosionProperties/en.yml b/wiki/ref/records/ExplosionProperties/en.yml index 87c1dfd6..2b548a4b 100644 --- a/wiki/ref/records/ExplosionProperties/en.yml +++ b/wiki/ref/records/ExplosionProperties/en.yml @@ -1,2 +1,2 @@ -title: "Supplier" -description: "A function that takes nothing and returns a value" \ No newline at end of file +title: "ExplosionProperties" +description: "KABOOM!!!" \ No newline at end of file diff --git a/wiki/ref/records/ExplosionProperties/page.kubedoc b/wiki/ref/records/ExplosionProperties/page.kubedoc index e1a24c21..6558938f 100644 --- a/wiki/ref/records/ExplosionProperties/page.kubedoc +++ b/wiki/ref/records/ExplosionProperties/page.kubedoc @@ -23,14 +23,14 @@ Explosion damage calculator. <<< >>> #strength-description Specifies the strength of the explosion. -Defaults to `3` if not provided. +Defaults to `[js]3` if not provided. <<< >>> #causes-fire-type `boolean` <<< >>> #causes-fire-description Specifies, whether explosion causes fire, like Ghast fireball explosions or bed explosions in the Nether. -Defaults to `false` if not provided. +Defaults to `[js]false` if not provided. <<< >>> #mode-type `Level.ExplosionInteraction` @@ -38,38 +38,39 @@ Defaults to `false` if not provided. >>> #mode-description The explosion mode. May be also a string representing a mode: -`'none'`, `'block'`, `'mob'`, `'tnt'`, `'trigger'` -Defaults to `'none'` if not provided. +`[js]'none'`, `[js]'block'`, `[js]'mob'`, `[js]'tnt'`, `[js]'trigger'` +Defaults to `[js]'none'` if not provided. <<< >>> #particles-type `boolean` <<< >>> #particles-description -Whether the explosion emits particles or not. Defaults to `true` if not provided. +Whether the explosion emits particles or not. +Defaults to `[js]true` if not provided. <<< >>> #small-particles-type `ParticleOptions` <<< >>> #small-particles-description Specifies the small particles used in the explosion. -May be also a string representing the particle to use, for example `'minecraft:angry_villager'`. -Defaults to `'minecraft:explosion'` if not provided. +May be also a string representing the particle to use, for example `[js]'minecraft:angry_villager'`. +Defaults to `[js]'minecraft:explosion'` if not provided. <<< >>> #large-particles-type `ParticleOptions` <<< >>> #large-particles-description Specifies the large particles used in the explosion. -May be also a string representing the particle to use, for example `'minecraft:angry_villager'`. -Defaults to `'minecraft:explosion_emitter'` if not provided. +May be also a string representing the particle to use, for example `[js]'minecraft:angry_villager'`. +Defaults to `[js]'minecraft:explosion_emitter'` if not provided. <<< >>> #explosion-sound-type `Holder` <<< >>> #explosion-sound-description Specifies the sound of the explosion. -May be also a string representing a sound, for example `'minecraft:block.amethyst_block.chime'`. -Defaults to `'minecraft:entity.generic.explode'` if not provided. +May be also a string representing a sound, for example `[js]'minecraft:block.amethyst_block.chime'`. +Defaults to `[js]'minecraft:entity.generic.explode'` if not provided. <<< # Properties From 59cfafd4bc86cef7d24b76044f6afebe998c77b0 Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Wed, 31 Dec 2025 14:52:04 +0100 Subject: [PATCH 51/68] Some block-related changes - Move LevelBlock into its own article - Create subarticles for Block in general - Create documentation for Fireworks and FireworkExplosion - Now, that the following articles are there, change `Item.fireworks` documentation to link there --- wiki/concepts/block/Block/en.yml | 4 + wiki/concepts/block/BlockState/en.yml | 4 + wiki/concepts/block/BlockState/page.kubedoc | 6 + wiki/concepts/block/LevelBlock/en.yml | 4 + wiki/concepts/block/LevelBlock/page.kubedoc | 158 ++++++++++++++++++ wiki/concepts/block/page.kubedoc | 157 +---------------- wiki/ref/records/FireworkExplosion/en.yml | 2 + .../records/FireworkExplosion/page.kubedoc | 52 ++++++ wiki/ref/records/Fireworks/en.yml | 2 + wiki/ref/records/Fireworks/page.kubedoc | 22 +++ wiki/ref/wrappers/ItemWrapper/page.kubedoc | 39 +---- 11 files changed, 264 insertions(+), 186 deletions(-) create mode 100644 wiki/concepts/block/Block/en.yml create mode 100644 wiki/concepts/block/BlockState/en.yml create mode 100644 wiki/concepts/block/BlockState/page.kubedoc create mode 100644 wiki/concepts/block/LevelBlock/en.yml create mode 100644 wiki/concepts/block/LevelBlock/page.kubedoc create mode 100644 wiki/ref/records/FireworkExplosion/en.yml create mode 100644 wiki/ref/records/FireworkExplosion/page.kubedoc create mode 100644 wiki/ref/records/Fireworks/en.yml create mode 100644 wiki/ref/records/Fireworks/page.kubedoc diff --git a/wiki/concepts/block/Block/en.yml b/wiki/concepts/block/Block/en.yml new file mode 100644 index 00000000..613014b0 --- /dev/null +++ b/wiki/concepts/block/Block/en.yml @@ -0,0 +1,4 @@ +title: "Block" +description: "The base representation of a Minecraft block" + +optional: "#[[#c3c7cb;border:1px solid #51565d;font-size:0.8rem;padding:0.2em 0.3em; border-radius: 1em|Optional]]" \ No newline at end of file diff --git a/wiki/concepts/block/BlockState/en.yml b/wiki/concepts/block/BlockState/en.yml new file mode 100644 index 00000000..7c0ffbec --- /dev/null +++ b/wiki/concepts/block/BlockState/en.yml @@ -0,0 +1,4 @@ +title: "BlockState" +description: "Block with states!" + +optional: "#[[#c3c7cb;border:1px solid #51565d;font-size:0.8rem;padding:0.2em 0.3em; border-radius: 1em|Optional]]" \ No newline at end of file diff --git a/wiki/concepts/block/BlockState/page.kubedoc b/wiki/concepts/block/BlockState/page.kubedoc new file mode 100644 index 00000000..7d4f7579 --- /dev/null +++ b/wiki/concepts/block/BlockState/page.kubedoc @@ -0,0 +1,6 @@ +# Creating BlockStates + +In places where `BlockState`s are expected, KubeJS will try to implicitly convert other objects into them. +Most `BlockState`s can be written as string literals, with block property syntax being the same as one used in [`/setblock` or `/fill`](https://minecraft.wiki/w/Argument_types#minecraft:block_state). + +# Useful BlockState methods \ No newline at end of file diff --git a/wiki/concepts/block/LevelBlock/en.yml b/wiki/concepts/block/LevelBlock/en.yml new file mode 100644 index 00000000..01760a48 --- /dev/null +++ b/wiki/concepts/block/LevelBlock/en.yml @@ -0,0 +1,4 @@ +title: "LevelBlock" +description: "A representation of a block in world" + +optional: "#[[#c3c7cb;border:1px solid #51565d;font-size:0.8rem;padding:0.2em 0.3em; border-radius: 1em|Optional]]" \ No newline at end of file diff --git a/wiki/concepts/block/LevelBlock/page.kubedoc b/wiki/concepts/block/LevelBlock/page.kubedoc new file mode 100644 index 00000000..ab220759 --- /dev/null +++ b/wiki/concepts/block/LevelBlock/page.kubedoc @@ -0,0 +1,158 @@ +**LevelBlock** is a KubeJS interface defining the script-friendly abstraction of a block in world. LevelBlocks can be easily manipulated to your heart's content. + +# How to get LevelBlocks + +`LevelBlock`s are usually obtained via block-getting methods on `Level` (object representing the Minecraft world), such as `[js]level.getBlock(x, y, z)`. + +# Useful LevelBlock methods + +## Position + +| Getter | Read-only bean | Description | +| `[js]block.getPos()` | `[js]block.pos` | Gets the position of the block, as BlockPos. | +| `[js]block.getX()` | `[js]block.x` | Gets the x coordinate of the block. | +| `[js]block.getY()` | `[js]block.y` | Gets the y coordinate of the block. | +| `[js]block.getZ()` | `[js]block.z` | Gets the z coordinate of the block. | +| `[js]block.getCenterX()` | `[js]block.centerX` | Gets the x coordinate of the center of the block. | +| `[js]block.getCenterY()` | `[js]block.centerY` | Gets the y coordinate of the center of the block. | +| `[js]block.getCenterZ()` | `[js]block.centerZ` | Gets the z coordinate of the center of the block. | + +**Example** +Position related beans on `LevelBlock` make for a useful application of a [destructuring pattern](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring) to quickly get all the block's coordinates to variables. + +```js +const { x, y, z } = block +// Now x, y and z constants are respectively the block's x, y and z coordinate. +``` + +--- + +## Relative + +>>> #get-north +Gets the block to the north of the `block`. +<<< +>>> #get-south +Gets the block to the south of the `block`. +<<< +>>> #get-east +Gets the block to the east of the `block`. +<<< +>>> #get-west +Gets the block to the west of the `block`. +<<< +>>> #get-up +Gets the block above the `block`. +<<< +>>> #get-down +Gets the block below the `block`. +<<< + +These getters allow you to get blocks around the currently referenced block, as `LevelBlock`s. + +| Getter | Read-only bean | Description | +| `[js]block.getNorth()` | `[js]block.north` | <#get-north> | +| `[js]block.getSouth()` | `[js]block.south` | <#get-south> | +| `[js]block.getEast()` | `[js]block.east` | <#get-east> | +| `[js]block.getWest()` | `[js]block.west` | <#get-west> | +| `[js]block.getUp()` | `[js]block.up` | <#get-up> | +| `[js]block.getDown()` | `[js]block.down` | <#get-down> | +--- + +## Other + +### Accessors + +>>> #entity-data +Gets or sets the block entity data (as `CompoundTag`) of the block. The data get or set may be `null`. +<<< +>>> #block-state-note +Gets or sets the BlockState of the block. +**Note**: `setBlockState` also has an overload that allows for setting block update flags, see "Setters". +<<< + +| Getter | Setter | Bean | Description | +| `[js]block.getEntityData()` | `[js]block.setEntityData(entityData)` | `[js]block.entityData` | <#entity-data> | +| `[js]block.getBlockState()` | `[js]block.setBlockState(state)` | `[js]block.blockState` | <#block-state-note> | + +### Setters + +- `[js]block.set(block, properties, updateFlags)` + - `[js]block`: The Block to set the `block` to. It may be a string representing a block, for example `[js]'minecraft:oak_log'` + - `[js]properties` {optional}: Block properties to set on that block. It can be an object representing the block properties, for example `[js]\{ axis: 'x' \}` + - `[js]updateFlags` {optional}: Block update flags. They are a bit map of update properties. + +- `[js]block.setBlockState(blockState, updateFlags)` + - `[js]blockState`: The BlockState to set the `block` to. It may be a string representing a block state, for example `[js]'minecraft:oak_log\[axis=x\]'` + - `[js]updateFlags` {optional}: Block update flags. They are a bit map of update properties. + +### Getters + +>>> #players-in-radius-note +Gets a list of all player entities in an 8-block radius. +**Note**: `getPlayersInRadius` also has an overload with customizable radius, see "Other methods". +<<< +>>> #can-see-sky +Gets `true` if block can see sky, `false` if it can't. +<<< + +| Getter | Read-only bean | Description | +| `[js]block.getBiomeId()` | `[js]block.biomeId` | Gets the biome ID as ResourceLocation. | +| `[js]block.getBlock()` | `[js]block.block` | Gets the Block of the block. | +| `[js]block.getBlockLight()` | `[js]block.blockLight` | Gets the block's block light level. | +| `[js]block.getCanSeeSky()` | `[js]block.canSeeSky` | <#can-see-sky> | +| `[js]block.getDimension()` | `[js]block.dimension` | Gets the dimension of the block. | +| `[js]block.getDimensionKey()` | `[js]block.dimensionKey` | Gets the dimension key of the block. | +| `[js]block.getEntity()` | `[js]block.entity` | Gets the block entity of the block. | +| `[js]block.getEntityId()` | `[js]block.entityId` | Gets the block entity ID (as ResourceLocation) of the block. | +| `[js]block.getId()` | `[js]block.id` | Gets the block's ID as string. | +| `[js]block.getIdLocation()` | `[js]block.idLocation` | Gets the block's ID as ResourceLocation. | +| `[js]block.getInventory()` | `[js]block.inventory` | Gets the block's inventory. The block must have an inventory. | +| `[js]block.getItem()` | `[js]block.item` | Gets the ItemStack corresponding to this block. | +| `[js]block.getKey()` | `[js]block.key` | Gets the block's ResourceKey. | +| `[js]block.getLevel()` | `[js]block.level` | Gets the world the block is in. | +| `[js]block.getLight()` | `[js]block.light` | Gets the block's light level. | +| `[js]block.getMod()` | `[js]block.mod` | Gets the block's mod ID as string. | +| `[js]block.getPlayersInRadius()` | `[js]block.playersInRadius` | <#players-in-radius-note> | +| `[js]block.getProperties()` | `[js]block.properties` | Gets the block's properties. | +| `[js]block.getRegistry()` | `[js]block.registry` | Gets the block registry. | +| `[js]block.getRegistryId()` | `[js]block.registryId` | Gets the block's ResourceKey from the block registry. | +| `[js]block.getSkyLight()` | `[js]block.skyLight` | Gets the block's sky light level. | +| `[js]block.getTagKeys()` | `[js]block.tagKeys` | Gets the list of block's TagKeys. | +| `[js]block.getTags()` | `[js]block.tags` | Gets the list of block's tags as ResourceLocations. | +| `[js]block.getTypeData()` | `[js]block.typeData` | ??? | + +### Other methods + +- `[js]block.offset(direction)` +- `[js]block.offset(direction, amount)` + - `[js]direction`: A `Direction`. In can be a string representing a direction, for example `[js]'north'` + - `[js]amount` {optional}: Amount of blocks to move away from the `block`. Defaults to `1` if not provided. +- `[js]block.offset(x, y, z)` + - `[js]x`, `[js]y`, `[js]z`: Amount of blocks to move from the `block` in x, y and z directions respectively. + - **Returns**: A `LevelBlock` representing a block at a specified offset. + +- `[js]block.mergeEntityData(entityData)` + - `[js]entityData`: The block entity data (as `CompoundTag`) to merge with existing entity data. + +- `[js]block.explode(explosionProperties)` + - `[js]explosionProperties`: The [[/ref/records/ExplosionProperties|explosion properties]] to use. + - **Returns**: An `Explosion` object. Also creates an explosion at the location of the block. + +- `[js]block.createEntity(entityType)` + - `[js]entityType`: The type of entity to create. It may be a string representing an entity, for example `[js]'minecraft:creeper'` + - **Returns**: An new [[/concepts/entity|`Entity`]] object with its position set to the position of the `block` (not its center!). Of course, you still need to spawn the entity, so don't discard the return type! + +- `[js]block.spawnLightning()` +- `[js]block.spawnLightning(isEffectOnly)` +- `[js]block.spawnLightning(isEffectOnly, player)` + - `[js]isEffectOnly` {optional}: Whether the lightning is purely visual (that is, harmless). Defaults to `[js]false` if not provided. + - `[js]player` {optional}: A player who caused the lightning. + - Results in a Lightning Bolt spawned at the center of the `block`, optionally with above properties set. + +- `[js]block.spawnFireworks(fireworksProperties, flightTime)` + - `[js]fireworksProperties`: The [[/ref/records/Fireworks|firework properties]] to use. + - `[js]flightTime`: Flight time of the firework, in ticks. + - Results in a firework launched from the center of the `block`, with above properties set. + +--- diff --git a/wiki/concepts/block/page.kubedoc b/wiki/concepts/block/page.kubedoc index 4db55ecd..b391b0fb 100644 --- a/wiki/concepts/block/page.kubedoc +++ b/wiki/concepts/block/page.kubedoc @@ -1,160 +1,13 @@ **Blocks** are the very foundation of a Minecraft block. -In the game, their role is split into: -- `Block`s - which are the singleton objects defining block behavior. These aren't generally used in in-world interactions. +In the game, their role is split into the following Java objects: +- [[/concepts/block/Block|`Block`]] - which are the singleton objects defining block behavior. These aren't generally used in in-world interactions. -- `BlockState`s - which define additional properties attacked to a block (like axis, being waterlogged, orientation, etc.). These are actual objects stored in world, and can be manipulated. KubeJS also adds an additional `LevelBlock` interface which abstracts away common cases of manipulating blocks in world. +- [[/concepts/block/BlockState|`BlockState`]] - which define additional properties attacked to a block (like axis, being waterlogged, orientation, etc.). These are actual objects stored in world, and can be manipulated. -# Creating BlockStates +- [[/concepts/block/LevelBlock|`LevelBlock`]] - a special interface added by KubeJS which abstracts away common cases of manipulating blocks in world. -In places where `BlockState`s are expected, KubeJS will try to implicitly convert other objects into them. -Most `BlockState`s can be written as string literals, with block property syntax being the same as one used in [`/setblock` or `/fill`](https://minecraft.wiki/w/Argument_types#minecraft:block_state). - -# How to get LevelBlocks - -`LevelBlock`s are usually obtained via block-getting methods on `Level` (object representing the Minecraft world), such as `[js]level.getBlock(x, y, z)`. - -# Useful LevelBlock methods - -## Position - -| Getter | Read-only bean | Description | -| `[js]block.getPos()` | `[js]block.pos` | Gets the position of the block, as BlockPos. | -| `[js]block.getX()` | `[js]block.x` | Gets the x coordinate of the block. | -| `[js]block.getY()` | `[js]block.y` | Gets the y coordinate of the block. | -| `[js]block.getZ()` | `[js]block.z` | Gets the z coordinate of the block. | -| `[js]block.getCenterX()` | `[js]block.centerX` | Gets the x coordinate of the center of the block. | -| `[js]block.getCenterY()` | `[js]block.centerY` | Gets the y coordinate of the center of the block. | -| `[js]block.getCenterZ()` | `[js]block.centerZ` | Gets the z coordinate of the center of the block. | - -**Example** -Position related beans on `LevelBlock` make for a useful application of a [destructuring pattern](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring) to quickly get all the block's coordinates to variables. - -```js -const { x, y, z } = block -// Now x, y and z constants are respectively the block's x, y and z coordinate. -``` - ---- - -## Relative - ->>> #get-north -Gets the block to the north of the `block`. -<<< ->>> #get-south -Gets the block to the south of the `block`. -<<< ->>> #get-east -Gets the block to the east of the `block`. -<<< ->>> #get-west -Gets the block to the west of the `block`. -<<< ->>> #get-up -Gets the block above the `block`. -<<< ->>> #get-down -Gets the block below the `block`. -<<< - -These getters allow you to get blocks around the currently referenced block, as `LevelBlock`s. - -| Getter | Read-only bean | Description | -| `[js]block.getNorth()` | `[js]block.north` | <#get-north> | -| `[js]block.getSouth()` | `[js]block.south` | <#get-south> | -| `[js]block.getEast()` | `[js]block.east` | <#get-east> | -| `[js]block.getWest()` | `[js]block.west` | <#get-west> | -| `[js]block.getUp()` | `[js]block.up` | <#get-up> | -| `[js]block.getDown()` | `[js]block.down` | <#get-down> | ---- - -## Other - -### Accessors - ->>> #entity-data -Gets or sets the block entity data (as `CompoundTag`) of the block. The data get or set may be `null`. -<<< ->>> #block-state-note -Gets or sets the BlockState of the block. -**Note**: `setBlockState` also has an overload that allows for setting block update flags, see "Setters". -<<< - -| Getter | Setter | Bean | Description | -| `[js]block.getEntityData()` | `[js]block.setEntityData(entityData)` | `[js]block.entityData` | <#entity-data> | -| `[js]block.getBlockState()` | `[js]block.setBlockState(state)` | `[js]block.blockState` | <#block-state-note> | - -### Setters - -- `[js]block.set(block, properties, updateFlags)` - - `[js]block`: The Block to set the `block` to. It may be a string representing a block, for example `[js]'minecraft:oak_log'` - - `[js]properties` {optional}: Block properties to set on that block. It can be an object representing the block properties, for example `[js]\{ axis: 'x' \}` - - `[js]updateFlags` {optional}: Block update flags. They are a bit map of update properties. - -- `[js]block.setBlockState(blockState, updateFlags)` - - `[js]blockState`: The BlockState to set the `block` to. It may be a string representing a block state, for example `[js]'minecraft:oak_log\[axis=x\]'` - - `[js]updateFlags` {optional}: Block update flags. They are a bit map of update properties. - -### Getters - ->>> #players-in-radius-note -Gets a list of all player entities in an 8-block radius. -**Note**: `getPlayersInRadius` also has an overload with customizable radius, see "Other methods". -<<< ->>> #can-see-sky -Gets `true` if block can see sky, `false` if it can't. -<<< - -| Getter | Read-only bean | Description | -| `[js]block.getBiomeId()` | `[js]block.biomeId` | Gets the biome ID as ResourceLocation. | -| `[js]block.getBlock()` | `[js]block.block` | Gets the Block of the block. | -| `[js]block.getBlockLight()` | `[js]block.blockLight` | Gets the block's block light level. | -| `[js]block.getCanSeeSky()` | `[js]block.canSeeSky` | <#can-see-sky> | -| `[js]block.getDimension()` | `[js]block.dimension` | Gets the dimension of the block. | -| `[js]block.getDimensionKey()` | `[js]block.dimensionKey` | Gets the dimension key of the block. | -| `[js]block.getEntity()` | `[js]block.entity` | Gets the block entity of the block. | -| `[js]block.getEntityId()` | `[js]block.entityId` | Gets the block entity ID (as ResourceLocation) of the block. | -| `[js]block.getId()` | `[js]block.id` | Gets the block's ID as string. | -| `[js]block.getIdLocation()` | `[js]block.idLocation` | Gets the block's ID as ResourceLocation. | -| `[js]block.getInventory()` | `[js]block.inventory` | Gets the block's inventory. The block must have an inventory. | -| `[js]block.getItem()` | `[js]block.item` | Gets the ItemStack corresponding to this block. | -| `[js]block.getKey()` | `[js]block.key` | Gets the block's ResourceKey. | -| `[js]block.getLevel()` | `[js]block.level` | Gets the world the block is in. | -| `[js]block.getLight()` | `[js]block.light` | Gets the block's light level. | -| `[js]block.getMod()` | `[js]block.mod` | Gets the block's mod ID as string. | -| `[js]block.getPlayersInRadius()` | `[js]block.playersInRadius` | <#players-in-radius-note> | -| `[js]block.getProperties()` | `[js]block.properties` | Gets the block's properties. | -| `[js]block.getRegistry()` | `[js]block.registry` | Gets the block registry. | -| `[js]block.getRegistryId()` | `[js]block.registryId` | Gets the block's ResourceKey from the block registry. | -| `[js]block.getSkyLight()` | `[js]block.skyLight` | Gets the block's sky light level. | -| `[js]block.getTagKeys()` | `[js]block.tagKeys` | Gets the list of block's TagKeys. | -| `[js]block.getTags()` | `[js]block.tags` | Gets the list of block's tags as ResourceLocations. | -| `[js]block.getTypeData()` | `[js]block.typeData` | ??? | - -### Other methods - -- `[js]block.offset(direction)` -- `[js]block.offset(direction, amount)` - - `[js]direction`: A `Direction`. In can be a string representing a direction, for example `[js]'north'` - - `[js]amount` {optional}: Amount of blocks to move away from the `block`. Defaults to `1` if not provided. -- `[js]block.offset(x, y, z)` - - `[js]x`, `[js]y`, `[js]z`: Amount of blocks to move from the `block` in x, y and z directions respectively. - - **Returns**: A `LevelBlock` representing a block at a specified offset. - -- `[js]block.mergeEntityData(entityData)` - - `[js]entityData`: The block entity data (as `CompoundTag`) to merge with existing entity data. - -- `[js]block.explode(explosionProperties)` - - `[js]explosionProperties`: The [[/ref/records/ExplosionProperties|explosion properties]] to use. - - **Returns**: An `Explosion` object. Also creates an explosion at the location of the block. - ---- - - - - -# Useful BlockState methods +# See also diff --git a/wiki/ref/records/FireworkExplosion/en.yml b/wiki/ref/records/FireworkExplosion/en.yml new file mode 100644 index 00000000..003fe5ba --- /dev/null +++ b/wiki/ref/records/FireworkExplosion/en.yml @@ -0,0 +1,2 @@ +title: "Fireworks" +description: "Let's celebrate!" \ No newline at end of file diff --git a/wiki/ref/records/FireworkExplosion/page.kubedoc b/wiki/ref/records/FireworkExplosion/page.kubedoc new file mode 100644 index 00000000..74b8b1b7 --- /dev/null +++ b/wiki/ref/records/FireworkExplosion/page.kubedoc @@ -0,0 +1,52 @@ +**FireworkExplosion** record defines how fireworks explode. This record is used as a part of the `minecraft:firework_explosion` data component. + +>>> #shape-type +`Shape` +<<< +>>> #shape-description +Defines the shape of the explosion. +May be also a string representing a shape: +`[js]'small_ball'`, `[js]'large_ball'`, `[js]'star'`, `[js]'creeper'`, `[js]'burst'`. +<<< +>>> #colors-type +`IntList` +<<< +>>> #colors-description +The RGB colors of the initial particles of the explosion. +Can be described in JS as an array of numbers: +```js +[0x00ff00, 0xff0000, 0x0000ff] +``` +<<< +>>> #fade-colors-type +`IntList` +<<< +>>> #fade-colors-description +The RGB colors of the fading particles of the explosion. +Can be described in JS as an array of numbers: +```js +[0x00ff00, 0xff0000, 0x0000ff] +``` +<<< +>>> #has-trail-type +`boolean` +<<< +>>> #has-trail-description +Whether the firework has a trail effect. +<<< +>>> #has-twinkle-type +`boolean` +<<< +>>> #has-twinkle-description +Whether the firework has a twinkle effect. +<<< + +# Properties + +| Property | Type | Description | +| ------------ | ------------------- | -------------------------- | +| `shape` | <#shape-type> | <#shape-description> | +| `colors` | <#colors-type> | <#colors-description> | +| `fadeColors` | <#fade-colors-type> | <#fade-colors-description> | +| `hasTrail` | <#has-trail-type> | <#has-trail-description> | +| `hasTwinkle` | <#has-twinkle-type> | <#has-twinkle-description> | \ No newline at end of file diff --git a/wiki/ref/records/Fireworks/en.yml b/wiki/ref/records/Fireworks/en.yml new file mode 100644 index 00000000..5f348e52 --- /dev/null +++ b/wiki/ref/records/Fireworks/en.yml @@ -0,0 +1,2 @@ +title: "FireworkExplosion" +description: "The actual cool lights" \ No newline at end of file diff --git a/wiki/ref/records/Fireworks/page.kubedoc b/wiki/ref/records/Fireworks/page.kubedoc new file mode 100644 index 00000000..e1a2a2d4 --- /dev/null +++ b/wiki/ref/records/Fireworks/page.kubedoc @@ -0,0 +1,22 @@ +**Fireworks** record defines firework properties. This record is used as a part of the `minecraft:firework` data component. + +>>> #flight-duration-type +`number` +(integer) +<<< +>>> #flight-duration-description +Specifies the flight duration of the rocket, that is - with how much gunpowder the rocket was crafted. Used to specify, for how long should the firework boost Elytra flight and how far should firework fly, with certain random variation. +<<< +>>> #explosions-type +`List<[[/ref/records/FireworkExplosion|FireworkExplosion]]>` +<<< +>>> #explosions-description +A list of up to 256 [[/ref/records/FireworkExplosion|firework explosions]]. +<<< + +# Properties + +| Property | Type | Description | +| ---------------- | ----------------------- | ------------------------------ | +| `flightDuration` | <#flight-duration-type> | <#flight-duration-description> | +| `explosions` | <#explosions-type> | <#explosions-description> | diff --git a/wiki/ref/wrappers/ItemWrapper/page.kubedoc b/wiki/ref/wrappers/ItemWrapper/page.kubedoc index 06441e9a..eaefab1e 100644 --- a/wiki/ref/wrappers/ItemWrapper/page.kubedoc +++ b/wiki/ref/wrappers/ItemWrapper/page.kubedoc @@ -83,44 +83,15 @@ Item.empty // Read-only bean ## `fireworks` ```js -Item.fireworks(fireworksProps) +Item.fireworks(fireworkProperties) ``` **Parameters** -- `[js]fireworksProps` - a record containing fireworks properties. - -This parameter accepts an object in this place. - -```ts -type Fireworks = { - explosions?: FireworkExplosion[]; - flightDuration?: int -} - -type FireworkExplosion = { - /** Whether the explosion has a twinkle or not. */ - hasTwinkle?: boolean - /** Whether the explosion has a trail or not. */ - hasTrail?: boolean - /** The shape of the firework explosion. */ - shape?: 'small_ball' | 'large_ball' | 'star' | 'creeper' | 'burst' - /** - * What colors do the explosions have. - * Most comfortably described as an array of hex numbers, like: - * [0x2244ee, 0x33aaff] - */ - colors?: int[] - /** - * What colors do the explosions fade into. - * Most comfortably described as an array of hex numbers, like: - * [0x2244ee, 0x33aaff] - */ - fadeColors?: int[] -} -``` +- `[js]fireworkProperties` - The [[/ref/records/Fireworks|firework properties]] to use. **Returns** -- A `Fireworks` object. +If `fireworkProperties` was already an instance of [[/ref/records/Fireworks|`Fireworks`]], it returns the same [[/ref/records/Fireworks|`Fireworks`]]. +If `fireworkProperties` was an object or an array, it returns the [[/ref/records/Fireworks|`Fireworks`]] instance created from the object/array. **Example** ```js @@ -134,7 +105,7 @@ Item.fireworks({ fadeColors: [0xee33ff], }, ], - flightDuration: 5 + flightDuration: 2 }) ``` From f33537a1b27f6593c5bb063927610cb540bdd617 Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Wed, 31 Dec 2025 14:56:27 +0100 Subject: [PATCH 52/68] Of course this Markdown does not Markdown --- wiki/ref/records/FireworkExplosion/page.kubedoc | 1 - wiki/ref/records/Fireworks/page.kubedoc | 6 ++++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/wiki/ref/records/FireworkExplosion/page.kubedoc b/wiki/ref/records/FireworkExplosion/page.kubedoc index 74b8b1b7..ed88e2c5 100644 --- a/wiki/ref/records/FireworkExplosion/page.kubedoc +++ b/wiki/ref/records/FireworkExplosion/page.kubedoc @@ -44,7 +44,6 @@ Whether the firework has a twinkle effect. # Properties | Property | Type | Description | -| ------------ | ------------------- | -------------------------- | | `shape` | <#shape-type> | <#shape-description> | | `colors` | <#colors-type> | <#colors-description> | | `fadeColors` | <#fade-colors-type> | <#fade-colors-description> | diff --git a/wiki/ref/records/Fireworks/page.kubedoc b/wiki/ref/records/Fireworks/page.kubedoc index e1a2a2d4..7e7ea0f8 100644 --- a/wiki/ref/records/Fireworks/page.kubedoc +++ b/wiki/ref/records/Fireworks/page.kubedoc @@ -7,8 +7,11 @@ >>> #flight-duration-description Specifies the flight duration of the rocket, that is - with how much gunpowder the rocket was crafted. Used to specify, for how long should the firework boost Elytra flight and how far should firework fly, with certain random variation. <<< +>>> #link-in-codeblock +List<[[/ref/records/FireworkExplosion|FireworkExplosion]]> +<<< >>> #explosions-type -`List<[[/ref/records/FireworkExplosion|FireworkExplosion]]>` +`<#link-in-codeblock>` <<< >>> #explosions-description A list of up to 256 [[/ref/records/FireworkExplosion|firework explosions]]. @@ -17,6 +20,5 @@ A list of up to 256 [[/ref/records/FireworkExplosion|firework explosions]]. # Properties | Property | Type | Description | -| ---------------- | ----------------------- | ------------------------------ | | `flightDuration` | <#flight-duration-type> | <#flight-duration-description> | | `explosions` | <#explosions-type> | <#explosions-description> | From d78f15dc3bb02adee75373d60fbd27284d11fa79 Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Wed, 31 Dec 2025 14:57:44 +0100 Subject: [PATCH 53/68] Can't have link inside codeblock, only codeblock inside link --- wiki/ref/records/Fireworks/page.kubedoc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/wiki/ref/records/Fireworks/page.kubedoc b/wiki/ref/records/Fireworks/page.kubedoc index 7e7ea0f8..83ad45a1 100644 --- a/wiki/ref/records/Fireworks/page.kubedoc +++ b/wiki/ref/records/Fireworks/page.kubedoc @@ -7,11 +7,8 @@ >>> #flight-duration-description Specifies the flight duration of the rocket, that is - with how much gunpowder the rocket was crafted. Used to specify, for how long should the firework boost Elytra flight and how far should firework fly, with certain random variation. <<< ->>> #link-in-codeblock -List<[[/ref/records/FireworkExplosion|FireworkExplosion]]> -<<< >>> #explosions-type -`<#link-in-codeblock>` +`List<`[[/ref/records/FireworkExplosion|`FireworkExplosion`]]`>` <<< >>> #explosions-description A list of up to 256 [[/ref/records/FireworkExplosion|firework explosions]]. From db444a59f01dea91fb1af5c19aa753a989a1dc68 Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Wed, 31 Dec 2025 15:40:14 +0100 Subject: [PATCH 54/68] Finally, complete documentation of LevelBlock --- wiki/concepts/block/LevelBlock/page.kubedoc | 51 +++++++++++++++++++-- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/wiki/concepts/block/LevelBlock/page.kubedoc b/wiki/concepts/block/LevelBlock/page.kubedoc index ab220759..8192cfea 100644 --- a/wiki/concepts/block/LevelBlock/page.kubedoc +++ b/wiki/concepts/block/LevelBlock/page.kubedoc @@ -89,12 +89,24 @@ Gets or sets the BlockState of the block. ### Getters >>> #players-in-radius-note -Gets a list of all player entities in an 8-block radius. -**Note**: `getPlayersInRadius` also has an overload with customizable radius, see "Other methods". +Gets a list of all player entities in an 8-block radius, excluding fake players. +**Note**: `getPlayersInRadius` also has an overload with customizable radius, see below this table. +<<< +>>> #inventory-note +Gets the block's inventory (as `InventoryKJS`) accessible from the top of the block. +Will get `[js]null` if the block does not have an inventory. +**Note**: `getInventory` also has an overload with customizable access side, see below this table. <<< >>> #can-see-sky Gets `true` if block can see sky, `false` if it can't. <<< +>>> #drops-note +Gets the block's drops that are independent of entity and item held (as a list of [[/concepts/item-stack|ItemStacks]]). +Will get an empty list if the block is not on a server-side world. +**Note**: `getDrops` also has an overload with customizable entity and item, see below this table. +<<< + +**Parameterless (with beans)** | Getter | Read-only bean | Description | | `[js]block.getBiomeId()` | `[js]block.biomeId` | Gets the biome ID as ResourceLocation. | @@ -103,11 +115,12 @@ Gets `true` if block can see sky, `false` if it can't. | `[js]block.getCanSeeSky()` | `[js]block.canSeeSky` | <#can-see-sky> | | `[js]block.getDimension()` | `[js]block.dimension` | Gets the dimension of the block. | | `[js]block.getDimensionKey()` | `[js]block.dimensionKey` | Gets the dimension key of the block. | +| `[js]block.getDrops()` | `[js]block.drops` | <#drops-note> | | `[js]block.getEntity()` | `[js]block.entity` | Gets the block entity of the block. | | `[js]block.getEntityId()` | `[js]block.entityId` | Gets the block entity ID (as ResourceLocation) of the block. | | `[js]block.getId()` | `[js]block.id` | Gets the block's ID as string. | | `[js]block.getIdLocation()` | `[js]block.idLocation` | Gets the block's ID as ResourceLocation. | -| `[js]block.getInventory()` | `[js]block.inventory` | Gets the block's inventory. The block must have an inventory. | +| `[js]block.getInventory()` | `[js]block.inventory` | <#inventory-note> | | `[js]block.getItem()` | `[js]block.item` | Gets the ItemStack corresponding to this block. | | `[js]block.getKey()` | `[js]block.key` | Gets the block's ResourceKey. | | `[js]block.getLevel()` | `[js]block.level` | Gets the world the block is in. | @@ -122,6 +135,26 @@ Gets `true` if block can see sky, `false` if it can't. | `[js]block.getTags()` | `[js]block.tags` | Gets the list of block's tags as ResourceLocations. | | `[js]block.getTypeData()` | `[js]block.typeData` | ??? | +**With parameters** + +- `[js]block.getInventory()` +- `[js]block.getInventory(direction)` + - `[js]direction` {optional}: A `Direction`. In can be a string representing a direction, for example `[js]'north'`. Defaults to `[js]'up'` if not provided. + - **Returns**: The block's inventory (as `InventoryKJS`) accessible from the specified side. Will get `[js]null` if the block does not have an inventory. + +- `[js]block.getDrops()` +- `[js]block.getDrops(entity, heldItem)` + - `[js]entity`: The [[/concepts/entity|`Entity`]] that would break the block. Defaults to `[js]null` if not provided. There's no overload without `heldItem`, so it must be provided too, regardless whether you want to use an item or not. + - `[js]heldItem`: The held item (as [[/concepts/item-stack|ItemStack]]) that would break the block. Defaults to air if not provided. + - **Returns**: The block's drops as a list of [[/concepts/item-stack|ItemStacks]], if the block is on a server-side world, an empty list otherwise. + - This method doesn't break the block, it just simulates the drops for that block. + +- `[js]block.getPlayersInRadius()` +- `[js]block.getPlayersInRadius(radius)` + - `[js]radius` {optional}: The radius around the `block` to search players for. Defaults to `8` if not provided. + - **Returns**: All players found (as a list of [[/concepts/entity|Entities]]), excluding fake players. + - ==Guarantee==: Entities in this list are guaranteed to be [[/concepts/player|Players]], so documentation for [[/concepts/player|Player]] applies to those entities as well. + ### Other methods - `[js]block.offset(direction)` @@ -155,4 +188,14 @@ Gets `true` if block can see sky, `false` if it can't. - `[js]flightTime`: Flight time of the firework, in ticks. - Results in a firework launched from the center of the `block`, with above properties set. ---- +- `[js]block.popItem(item)` + - `[js]item`: The item to pop from the block (as [[/concepts/item-stack|ItemStack]]). + - Results in the specified `[js]item` being popped as an item entity from the location of the block. + +- `[js]block.popItemFromFace(item, direction)` + - `[js]item`: The item to pop from the block (as [[/concepts/item-stack|ItemStack]]). + - `[js]direction`: A `Direction`. In can be a string representing a direction, for example `[js]'north'` + - Results in the specified `[js]item` being popped as an item entity from the specified side from the location of the block. + +- `[js]block.toBlockStateString()` + - **Returns**: The block's state as a string, with syntax being the same as one used in [`/setblock` or `/fill`](https://minecraft.wiki/w/Argument_types#minecraft:block_state). From b010f42eabc33631bf390c5f91245882af032831 Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Wed, 31 Dec 2025 15:46:16 +0100 Subject: [PATCH 55/68] Typo --- wiki/concepts/block/LevelBlock/page.kubedoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiki/concepts/block/LevelBlock/page.kubedoc b/wiki/concepts/block/LevelBlock/page.kubedoc index 8192cfea..57a3292b 100644 --- a/wiki/concepts/block/LevelBlock/page.kubedoc +++ b/wiki/concepts/block/LevelBlock/page.kubedoc @@ -194,7 +194,7 @@ Will get an empty list if the block is not on a server-side world. - `[js]block.popItemFromFace(item, direction)` - `[js]item`: The item to pop from the block (as [[/concepts/item-stack|ItemStack]]). - - `[js]direction`: A `Direction`. In can be a string representing a direction, for example `[js]'north'` + - `[js]direction`: A `Direction`. It can be a string representing a direction, for example `[js]'north'` - Results in the specified `[js]item` being popped as an item entity from the specified side from the location of the block. - `[js]block.toBlockStateString()` From 93ede9871de6aed4eb949d0b9bad3473b83b190b Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Thu, 1 Jan 2026 13:00:24 +0100 Subject: [PATCH 56/68] Document record usage --- .../records/ExplosionProperties/page.kubedoc | 2 + wiki/ref/records/FireworkExplosion/en.yml | 4 +- .../records/FireworkExplosion/page.kubedoc | 2 + wiki/ref/records/Fireworks/en.yml | 9 ++- wiki/ref/records/Fireworks/page.kubedoc | 2 + wiki/ref/records/en.yml | 7 ++- wiki/ref/records/page.kubedoc | 63 +++++++++++++++++++ 7 files changed, 84 insertions(+), 5 deletions(-) create mode 100644 wiki/ref/records/page.kubedoc diff --git a/wiki/ref/records/ExplosionProperties/page.kubedoc b/wiki/ref/records/ExplosionProperties/page.kubedoc index 6558938f..4c7ab2f9 100644 --- a/wiki/ref/records/ExplosionProperties/page.kubedoc +++ b/wiki/ref/records/ExplosionProperties/page.kubedoc @@ -1,3 +1,5 @@ +{record} + **ExplosionProperties** define explosion properties. Nothing to write home about here. >>> #source-type diff --git a/wiki/ref/records/FireworkExplosion/en.yml b/wiki/ref/records/FireworkExplosion/en.yml index 003fe5ba..5f348e52 100644 --- a/wiki/ref/records/FireworkExplosion/en.yml +++ b/wiki/ref/records/FireworkExplosion/en.yml @@ -1,2 +1,2 @@ -title: "Fireworks" -description: "Let's celebrate!" \ No newline at end of file +title: "FireworkExplosion" +description: "The actual cool lights" \ No newline at end of file diff --git a/wiki/ref/records/FireworkExplosion/page.kubedoc b/wiki/ref/records/FireworkExplosion/page.kubedoc index ed88e2c5..4f7d21f2 100644 --- a/wiki/ref/records/FireworkExplosion/page.kubedoc +++ b/wiki/ref/records/FireworkExplosion/page.kubedoc @@ -1,3 +1,5 @@ +{record} + **FireworkExplosion** record defines how fireworks explode. This record is used as a part of the `minecraft:firework_explosion` data component. >>> #shape-type diff --git a/wiki/ref/records/Fireworks/en.yml b/wiki/ref/records/Fireworks/en.yml index 5f348e52..e6d0c7d5 100644 --- a/wiki/ref/records/Fireworks/en.yml +++ b/wiki/ref/records/Fireworks/en.yml @@ -1,2 +1,7 @@ -title: "FireworkExplosion" -description: "The actual cool lights" \ No newline at end of file +title: "Fireworks" +description: "Let's celebrate!" + +record: | + >>> info + This class is a [[/ref/records|record]]. If you want to learn, how to use them in KubeJS scripts, [[/ref/records|go here]]. + <<< diff --git a/wiki/ref/records/Fireworks/page.kubedoc b/wiki/ref/records/Fireworks/page.kubedoc index 83ad45a1..bfc337bc 100644 --- a/wiki/ref/records/Fireworks/page.kubedoc +++ b/wiki/ref/records/Fireworks/page.kubedoc @@ -1,3 +1,5 @@ +{record} + **Fireworks** record defines firework properties. This record is used as a part of the `minecraft:firework` data component. >>> #flight-duration-type diff --git a/wiki/ref/records/en.yml b/wiki/ref/records/en.yml index 1abc4365..7129a16f 100644 --- a/wiki/ref/records/en.yml +++ b/wiki/ref/records/en.yml @@ -1,2 +1,7 @@ title: "Records" -description: "Classes usually representing properties of something" \ No newline at end of file +description: "Classes usually representing properties of something" + +record: | + >>> info + This class is a [[/ref/records|record]]. If you want to learn, how to use them in KubeJS scripts, [[/ref/records|go here]]. + <<< diff --git a/wiki/ref/records/page.kubedoc b/wiki/ref/records/page.kubedoc new file mode 100644 index 00000000..03dc476c --- /dev/null +++ b/wiki/ref/records/page.kubedoc @@ -0,0 +1,63 @@ +**Records** in Java are usually immutable, non-extensible classes which role is to hold data. +Their role can be described as similar to a JavaScript object. + +Records in Minecraft are mainly used to provide data for [[/concepts/data-components|data components]]. +KubeJS also uses them to provide script-friendly interfaces for defining properties of things. + +# Usage + +In KubeJS scripts, records can be described in two ways: JavaScript objects and JavaScript arrays. + +>>> info +The following examples will use [[/ref/wrappers/ItemWrapper#fireworks|`Item.fireworks`]] method which takes in a parameter of [[/ref/records/Fireworks|`Fireworks`]]. +<<< + +# JavaScript objects + +In this style, the object must have keys named exactly like the record's accessors. +All properties of the object are considered optional, and are considered `[js]null` if they aren't provided in the object. + +**Example** + +```js +Item.fireworks({ + explosions: [ + { + hasTwinkle: true, + hasTrail: false, + shape: 'creeper', + colors: [0xaa11ff], + fadeColors: [0xee33ff], + }, + ], + flightDuration: 2 +}) +``` + +## JavaScript arrays + +In this style, the array must be provided **exactly** in order of the argument appearances in the record's constuctor. +All array fields are considered optional, and are considered `[js]null` if they aren't provided in the array. + +>>> info +For convenience, record properties in record documentations here are described exactly in order as they appear in the constructor. +<<< + +```js +// Comments are added to show what value corresponds to what property. + +Item.fireworks([ + 2, // flightDuration + [ // explosions + [ + 'creeper', // shape + [0xaa11ff], // colors + [0xee33ff], // fadeColors + false, // hasTrail + true // hasTwinkle + ] + ] +]) +``` + +# Common records \ No newline at end of file From f62e0839294f35f0636462708d050c25ee7111b9 Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Thu, 1 Jan 2026 13:04:45 +0100 Subject: [PATCH 57/68] Multiline placeholder attempt 2 --- wiki/ref/records/Fireworks/en.yml | 7 +++---- wiki/ref/records/en.yml | 7 +++---- wiki/ref/records/page.kubedoc | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/wiki/ref/records/Fireworks/en.yml b/wiki/ref/records/Fireworks/en.yml index e6d0c7d5..c6bd3dab 100644 --- a/wiki/ref/records/Fireworks/en.yml +++ b/wiki/ref/records/Fireworks/en.yml @@ -1,7 +1,6 @@ title: "Fireworks" description: "Let's celebrate!" -record: | - >>> info - This class is a [[/ref/records|record]]. If you want to learn, how to use them in KubeJS scripts, [[/ref/records|go here]]. - <<< +record: ">>> info\ + This class is a [[/ref/records|record]]. If you want to learn, how to use them in KubeJS scripts, [[/ref/records|go here]].\ + <<<" diff --git a/wiki/ref/records/en.yml b/wiki/ref/records/en.yml index 7129a16f..f6c3e6da 100644 --- a/wiki/ref/records/en.yml +++ b/wiki/ref/records/en.yml @@ -1,7 +1,6 @@ title: "Records" description: "Classes usually representing properties of something" -record: | - >>> info - This class is a [[/ref/records|record]]. If you want to learn, how to use them in KubeJS scripts, [[/ref/records|go here]]. - <<< +record: ">>> info\ + This class is a [[/ref/records|record]]. If you want to learn, how to use them in KubeJS scripts, [[/ref/records|go here]].\ + <<<" diff --git a/wiki/ref/records/page.kubedoc b/wiki/ref/records/page.kubedoc index 03dc476c..3a721f67 100644 --- a/wiki/ref/records/page.kubedoc +++ b/wiki/ref/records/page.kubedoc @@ -9,7 +9,7 @@ KubeJS also uses them to provide script-friendly interfaces for defining propert In KubeJS scripts, records can be described in two ways: JavaScript objects and JavaScript arrays. >>> info -The following examples will use [[/ref/wrappers/ItemWrapper#fireworks|`Item.fireworks`]] method which takes in a parameter of [[/ref/records/Fireworks|`Fireworks`]]. +The following examples will use [[/ref/wrappers/ItemWrapper|`Item.fireworks`]] method which takes in a parameter of [[/ref/records/Fireworks|`Fireworks`]]. <<< # JavaScript objects From fd96b7e8a3c8751eb9ecd4a4648e942f7ace2051 Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Thu, 1 Jan 2026 13:06:55 +0100 Subject: [PATCH 58/68] Single line then. Sigh --- wiki/ref/records/Fireworks/en.yml | 4 +--- wiki/ref/records/en.yml | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/wiki/ref/records/Fireworks/en.yml b/wiki/ref/records/Fireworks/en.yml index c6bd3dab..9e263982 100644 --- a/wiki/ref/records/Fireworks/en.yml +++ b/wiki/ref/records/Fireworks/en.yml @@ -1,6 +1,4 @@ title: "Fireworks" description: "Let's celebrate!" -record: ">>> info\ - This class is a [[/ref/records|record]]. If you want to learn, how to use them in KubeJS scripts, [[/ref/records|go here]].\ - <<<" +record: ">>> info\nThis class is a [[/ref/records|record]]. If you want to learn, how to use them in KubeJS scripts, [[/ref/records|go here]].\n<<<" diff --git a/wiki/ref/records/en.yml b/wiki/ref/records/en.yml index f6c3e6da..d101c959 100644 --- a/wiki/ref/records/en.yml +++ b/wiki/ref/records/en.yml @@ -1,6 +1,4 @@ title: "Records" description: "Classes usually representing properties of something" -record: ">>> info\ - This class is a [[/ref/records|record]]. If you want to learn, how to use them in KubeJS scripts, [[/ref/records|go here]].\ - <<<" +record: ">>> info\nThis class is a [[/ref/records|record]]. If you want to learn, how to use them in KubeJS scripts, [[/ref/records|go here]].\n<<<" From 885c496614660bc8b989d2b061ed03740b06383e Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Thu, 1 Jan 2026 13:08:34 +0100 Subject: [PATCH 59/68] This YAML does not YAML --- wiki/ref/records/ExplosionProperties/en.yml | 4 +++- wiki/ref/records/FireworkExplosion/en.yml | 4 +++- wiki/ref/records/Fireworks/en.yml | 2 +- wiki/ref/records/en.yml | 4 +--- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/wiki/ref/records/ExplosionProperties/en.yml b/wiki/ref/records/ExplosionProperties/en.yml index 2b548a4b..f27655b2 100644 --- a/wiki/ref/records/ExplosionProperties/en.yml +++ b/wiki/ref/records/ExplosionProperties/en.yml @@ -1,2 +1,4 @@ title: "ExplosionProperties" -description: "KABOOM!!!" \ No newline at end of file +description: "KABOOM!!!" + +record: ">>> info This class is a [[/ref/records|record]]. If you want to learn, how to use them in KubeJS scripts, [[/ref/records|go here]]. <<<" diff --git a/wiki/ref/records/FireworkExplosion/en.yml b/wiki/ref/records/FireworkExplosion/en.yml index 5f348e52..01388445 100644 --- a/wiki/ref/records/FireworkExplosion/en.yml +++ b/wiki/ref/records/FireworkExplosion/en.yml @@ -1,2 +1,4 @@ title: "FireworkExplosion" -description: "The actual cool lights" \ No newline at end of file +description: "The actual cool lights" + +record: ">>> info This class is a [[/ref/records|record]]. If you want to learn, how to use them in KubeJS scripts, [[/ref/records|go here]]. <<<" diff --git a/wiki/ref/records/Fireworks/en.yml b/wiki/ref/records/Fireworks/en.yml index 9e263982..72d1f2ae 100644 --- a/wiki/ref/records/Fireworks/en.yml +++ b/wiki/ref/records/Fireworks/en.yml @@ -1,4 +1,4 @@ title: "Fireworks" description: "Let's celebrate!" -record: ">>> info\nThis class is a [[/ref/records|record]]. If you want to learn, how to use them in KubeJS scripts, [[/ref/records|go here]].\n<<<" +record: ">>> info This class is a [[/ref/records|record]]. If you want to learn, how to use them in KubeJS scripts, [[/ref/records|go here]]. <<<" diff --git a/wiki/ref/records/en.yml b/wiki/ref/records/en.yml index d101c959..1abc4365 100644 --- a/wiki/ref/records/en.yml +++ b/wiki/ref/records/en.yml @@ -1,4 +1,2 @@ title: "Records" -description: "Classes usually representing properties of something" - -record: ">>> info\nThis class is a [[/ref/records|record]]. If you want to learn, how to use them in KubeJS scripts, [[/ref/records|go here]].\n<<<" +description: "Classes usually representing properties of something" \ No newline at end of file From e6e8aabb429287371942574e72200f03b2a9b573 Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Thu, 1 Jan 2026 13:09:48 +0100 Subject: [PATCH 60/68] I give up, let there be duplicate links --- wiki/ref/records/ExplosionProperties/en.yml | 2 +- wiki/ref/records/ExplosionProperties/page.kubedoc | 4 +++- wiki/ref/records/FireworkExplosion/en.yml | 2 -- wiki/ref/records/FireworkExplosion/page.kubedoc | 4 +++- wiki/ref/records/Fireworks/en.yml | 2 -- wiki/ref/records/Fireworks/page.kubedoc | 4 +++- 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/wiki/ref/records/ExplosionProperties/en.yml b/wiki/ref/records/ExplosionProperties/en.yml index f27655b2..21ea9b02 100644 --- a/wiki/ref/records/ExplosionProperties/en.yml +++ b/wiki/ref/records/ExplosionProperties/en.yml @@ -1,4 +1,4 @@ title: "ExplosionProperties" description: "KABOOM!!!" -record: ">>> info This class is a [[/ref/records|record]]. If you want to learn, how to use them in KubeJS scripts, [[/ref/records|go here]]. <<<" +record: "" diff --git a/wiki/ref/records/ExplosionProperties/page.kubedoc b/wiki/ref/records/ExplosionProperties/page.kubedoc index 4c7ab2f9..0b59e4dd 100644 --- a/wiki/ref/records/ExplosionProperties/page.kubedoc +++ b/wiki/ref/records/ExplosionProperties/page.kubedoc @@ -1,4 +1,6 @@ -{record} +>>> info +This class is a [[/ref/records|record]]. If you want to learn, how to use them in KubeJS scripts, [[/ref/records|go here]]. +<<< **ExplosionProperties** define explosion properties. Nothing to write home about here. diff --git a/wiki/ref/records/FireworkExplosion/en.yml b/wiki/ref/records/FireworkExplosion/en.yml index 01388445..7c9d79b5 100644 --- a/wiki/ref/records/FireworkExplosion/en.yml +++ b/wiki/ref/records/FireworkExplosion/en.yml @@ -1,4 +1,2 @@ title: "FireworkExplosion" description: "The actual cool lights" - -record: ">>> info This class is a [[/ref/records|record]]. If you want to learn, how to use them in KubeJS scripts, [[/ref/records|go here]]. <<<" diff --git a/wiki/ref/records/FireworkExplosion/page.kubedoc b/wiki/ref/records/FireworkExplosion/page.kubedoc index 4f7d21f2..e97e20e3 100644 --- a/wiki/ref/records/FireworkExplosion/page.kubedoc +++ b/wiki/ref/records/FireworkExplosion/page.kubedoc @@ -1,4 +1,6 @@ -{record} +>>> info +This class is a [[/ref/records|record]]. If you want to learn, how to use them in KubeJS scripts, [[/ref/records|go here]]. +<<< **FireworkExplosion** record defines how fireworks explode. This record is used as a part of the `minecraft:firework_explosion` data component. diff --git a/wiki/ref/records/Fireworks/en.yml b/wiki/ref/records/Fireworks/en.yml index 72d1f2ae..2e364fa2 100644 --- a/wiki/ref/records/Fireworks/en.yml +++ b/wiki/ref/records/Fireworks/en.yml @@ -1,4 +1,2 @@ title: "Fireworks" description: "Let's celebrate!" - -record: ">>> info This class is a [[/ref/records|record]]. If you want to learn, how to use them in KubeJS scripts, [[/ref/records|go here]]. <<<" diff --git a/wiki/ref/records/Fireworks/page.kubedoc b/wiki/ref/records/Fireworks/page.kubedoc index bfc337bc..dc0c63ef 100644 --- a/wiki/ref/records/Fireworks/page.kubedoc +++ b/wiki/ref/records/Fireworks/page.kubedoc @@ -1,4 +1,6 @@ -{record} +>>> info +This class is a [[/ref/records|record]]. If you want to learn, how to use them in KubeJS scripts, [[/ref/records|go here]]. +<<< **Fireworks** record defines firework properties. This record is used as a part of the `minecraft:firework` data component. From ba226965421b76ff15277ba4c8bcd1d60088bef2 Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Mon, 5 Jan 2026 15:52:15 +0100 Subject: [PATCH 61/68] Document JavaWrapper --- wiki/concepts/block/Block/page.kubedoc | 10 ++ wiki/concepts/block/LevelBlock/page.kubedoc | 2 + wiki/ref/java/class/en.yml | 2 + wiki/ref/java/class/page.kubedoc | 0 wiki/ref/records/page.kubedoc | 2 +- wiki/ref/wrappers/BlockWrapper/en.yml | 3 +- wiki/ref/wrappers/ItemWrapper/en.yml | 5 +- wiki/ref/wrappers/JavaWrapper/en.yml | 2 + wiki/ref/wrappers/JavaWrapper/meta.yml | 0 wiki/ref/wrappers/JavaWrapper/page.kubedoc | 127 ++++++++++++++++++++ 10 files changed, 148 insertions(+), 5 deletions(-) create mode 100644 wiki/concepts/block/Block/page.kubedoc create mode 100644 wiki/ref/java/class/en.yml create mode 100644 wiki/ref/java/class/page.kubedoc create mode 100644 wiki/ref/wrappers/JavaWrapper/en.yml create mode 100644 wiki/ref/wrappers/JavaWrapper/meta.yml create mode 100644 wiki/ref/wrappers/JavaWrapper/page.kubedoc diff --git a/wiki/concepts/block/Block/page.kubedoc b/wiki/concepts/block/Block/page.kubedoc new file mode 100644 index 00000000..0c916aca --- /dev/null +++ b/wiki/concepts/block/Block/page.kubedoc @@ -0,0 +1,10 @@ +# Creating Blocks + +In places where `Block`s are expected, KubeJS will convert strings representing the blocks' ID into `Block` instances. + +For example: `[js]'minecraft:stone'`. + +# Useful Block methods + +In the following examples, `[js]block` will refer to the instance of `Block`. + diff --git a/wiki/concepts/block/LevelBlock/page.kubedoc b/wiki/concepts/block/LevelBlock/page.kubedoc index 57a3292b..2653ab8e 100644 --- a/wiki/concepts/block/LevelBlock/page.kubedoc +++ b/wiki/concepts/block/LevelBlock/page.kubedoc @@ -6,6 +6,8 @@ # Useful LevelBlock methods +In the following examples, `[js]block` will refer to the instance of `LevelBlock`. + ## Position | Getter | Read-only bean | Description | diff --git a/wiki/ref/java/class/en.yml b/wiki/ref/java/class/en.yml new file mode 100644 index 00000000..c266bb97 --- /dev/null +++ b/wiki/ref/java/class/en.yml @@ -0,0 +1,2 @@ +title: "Classes" +description: "From where all Java objects come from" \ No newline at end of file diff --git a/wiki/ref/java/class/page.kubedoc b/wiki/ref/java/class/page.kubedoc new file mode 100644 index 00000000..e69de29b diff --git a/wiki/ref/records/page.kubedoc b/wiki/ref/records/page.kubedoc index 3a721f67..b3a69f7f 100644 --- a/wiki/ref/records/page.kubedoc +++ b/wiki/ref/records/page.kubedoc @@ -12,7 +12,7 @@ In KubeJS scripts, records can be described in two ways: JavaScript objects and The following examples will use [[/ref/wrappers/ItemWrapper|`Item.fireworks`]] method which takes in a parameter of [[/ref/records/Fireworks|`Fireworks`]]. <<< -# JavaScript objects +## JavaScript objects In this style, the object must have keys named exactly like the record's accessors. All properties of the object are considered optional, and are considered `[js]null` if they aren't provided in the object. diff --git a/wiki/ref/wrappers/BlockWrapper/en.yml b/wiki/ref/wrappers/BlockWrapper/en.yml index 40c0cf37..9f6a282a 100644 --- a/wiki/ref/wrappers/BlockWrapper/en.yml +++ b/wiki/ref/wrappers/BlockWrapper/en.yml @@ -1 +1,2 @@ -block: "[[/concepts/block|Block]]" \ No newline at end of file +title: "BlockWrapper" +description: "Getting blocks from string" \ No newline at end of file diff --git a/wiki/ref/wrappers/ItemWrapper/en.yml b/wiki/ref/wrappers/ItemWrapper/en.yml index a931fe6d..b1b57e08 100644 --- a/wiki/ref/wrappers/ItemWrapper/en.yml +++ b/wiki/ref/wrappers/ItemWrapper/en.yml @@ -1,3 +1,2 @@ -item: "#[[orange|`<`#[[yellow|`item`]]`>`]]" -components: "#[[blue|`\\[​`#[[orange|`<`#[[yellow|`components`]]`>`]]`​\\]`]]" -custom-data: "#[[blue|`\\{​`#[[orange|`<`#[[yellow|`custom-data`]]`>`]]`​\\}`]]" +title: "ItemWrapper" +description: "Getting items from string" \ No newline at end of file diff --git a/wiki/ref/wrappers/JavaWrapper/en.yml b/wiki/ref/wrappers/JavaWrapper/en.yml new file mode 100644 index 00000000..a193c68a --- /dev/null +++ b/wiki/ref/wrappers/JavaWrapper/en.yml @@ -0,0 +1,2 @@ +title: "JavaWrapper" +description: "Lets you script Java" \ No newline at end of file diff --git a/wiki/ref/wrappers/JavaWrapper/meta.yml b/wiki/ref/wrappers/JavaWrapper/meta.yml new file mode 100644 index 00000000..e69de29b diff --git a/wiki/ref/wrappers/JavaWrapper/page.kubedoc b/wiki/ref/wrappers/JavaWrapper/page.kubedoc new file mode 100644 index 00000000..92cda258 --- /dev/null +++ b/wiki/ref/wrappers/JavaWrapper/page.kubedoc @@ -0,0 +1,127 @@ +`JavaWrapper` is an interface containing many useful static methods for accessing Java classes from KubeJS scripts. +It's exposed to [[/global-scope|global scope]] as `Java`. + +# Static methods + +## `loadClass` + +```js +Java.loadClass(className) +``` + +**Parameters** +- `[js]className`: A string representing a fully qualified class name - that is, a name of a class prefixed with a name of a package the class is in. + +**Returns** +A reference to a Java class. +To learn, how to use such reference, see [[/ref/java/class|here]]. + +===Throws=== +If the provided class name is not allowed by the class filter or not found, this method throws an error. + +--- + +## `tryLoadClass` + +```js +Java.tryloadClass(className) +``` + +**Parameters** +- `[js]className`: A string representing a fully qualified class name - that is, a name of a class prefixed with a name of a package the class is in. + +**Returns** +A reference to a Java class, or `[js]null` if the provided class name is not allowed by the class filter. +To learn, how to use such reference, see [[/ref/java/class|here]]. + +--- + +## `cast` + +```js +Java.cast(theClass, object) +``` + +Casts `[js]object` to the target type of `[js]theClass`. Use this in situations, where Rhino can't determine the correct type, for example if the object is provided indirectly. + +**Parameters** +- `[js]theClass`: A reference to a Java class to cast the object to. +- `[js]object`: Any Java object. + +**Returns** +- The `[js]object` cast to `theClass`. + +--- + +## `createConsole` + +```js +Java.createConsole(name) +``` + +Creates a custom `ConsoleJS` instance that allows for logging under a custom name. + +**Parameters** +- `[js]name`: A name of the console. + +**Returns** +- The new `ConsoleJS` instance. +This instance can be used just like `console` in global scope, but logs created by that console will bear the custom name. + +**Example** + +```js +const myConsole = Java.createConsole("My cool console") +console.log("Standard KubeJS log.") +myConsole.log("That's an awesome log!") + +/* Should log something similar to: +[15:38:22] [Server thread/INFO] [KubeJS Server/]: server_scripts:test.js#2: Standard KubeJS log. +[15:38:22] [Server thread/INFO] [My cool console/]: That's an awesome log! +*/ + +``` + +--- + +## `makeFunctionProxy` + +>>> warn +There is a way easier way to acquire implementations of interfaces. See [[/ref/java/class|here]]. +<<< + +```js +Java.makeFunctionProxy(targetClassTypeInfo, theFunction) +``` + +**Parameters** +- `[js]targetClassTypeInfo`: A `TypeInfo` implementation that implements `asClass()` abstract method which returns the target interface class. +- `[js]theFunction`: The JS function. + +**Returns** +The function wrapped into an implementation of a functional interface. + +--- + +## `mergeRecord` + +>>> warn +This method is presumably unfinished, as it currently does not do anything to the record. +<<< + +```js +Java.mergeRecord(originalRecord, mergeMap) +``` + +**Parameters** +- `[js]originalRecord`: A `Record` that serves as a base. +- `[js]mergeMap`: A Java `Map` with string keys and any values to merge with `originalRecord`. It may be a JS object. + +**Returns** +The `[js]originalRecord`. + +--- + +# Source + +([JavaWrapper.java](https://github.com/KubeJS-Mods/KubeJS/blob/main/src/main/java/dev/latvian/mods/kubejs/plugin/builtin/wrapper/JavaWrapper.java)) \ No newline at end of file From 8f4e9b84fe67adb5d034a3f5576a774ee496d7b4 Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Tue, 6 Jan 2026 11:53:04 +0100 Subject: [PATCH 62/68] "or not found" --- wiki/ref/wrappers/JavaWrapper/page.kubedoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiki/ref/wrappers/JavaWrapper/page.kubedoc b/wiki/ref/wrappers/JavaWrapper/page.kubedoc index 92cda258..759b3ba6 100644 --- a/wiki/ref/wrappers/JavaWrapper/page.kubedoc +++ b/wiki/ref/wrappers/JavaWrapper/page.kubedoc @@ -31,7 +31,7 @@ Java.tryloadClass(className) - `[js]className`: A string representing a fully qualified class name - that is, a name of a class prefixed with a name of a package the class is in. **Returns** -A reference to a Java class, or `[js]null` if the provided class name is not allowed by the class filter. +A reference to a Java class, or `[js]null` if the provided class name is not allowed by the class filter or not found. To learn, how to use such reference, see [[/ref/java/class|here]]. --- From 7394974d89e59adf865f4b333e817502b08f8408 Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Tue, 6 Jan 2026 17:01:44 +0100 Subject: [PATCH 63/68] Document UtilsWrapper --- wiki/ref/wrappers/UtilsWrapper/en.yml | 6 + wiki/ref/wrappers/UtilsWrapper/meta.yml | 0 wiki/ref/wrappers/UtilsWrapper/page.kubedoc | 311 ++++++++++++++++++++ 3 files changed, 317 insertions(+) create mode 100644 wiki/ref/wrappers/UtilsWrapper/en.yml create mode 100644 wiki/ref/wrappers/UtilsWrapper/meta.yml create mode 100644 wiki/ref/wrappers/UtilsWrapper/page.kubedoc diff --git a/wiki/ref/wrappers/UtilsWrapper/en.yml b/wiki/ref/wrappers/UtilsWrapper/en.yml new file mode 100644 index 00000000..cf366d4b --- /dev/null +++ b/wiki/ref/wrappers/UtilsWrapper/en.yml @@ -0,0 +1,6 @@ +title: "UtilsWrapper" +description: "Various Java utilities" + +random-link: "https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Random.html" +pattern-link: "https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/regex/Pattern.html" +future-link: "https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/concurrent/CompletableFuture.html" \ No newline at end of file diff --git a/wiki/ref/wrappers/UtilsWrapper/meta.yml b/wiki/ref/wrappers/UtilsWrapper/meta.yml new file mode 100644 index 00000000..e69de29b diff --git a/wiki/ref/wrappers/UtilsWrapper/page.kubedoc b/wiki/ref/wrappers/UtilsWrapper/page.kubedoc new file mode 100644 index 00000000..0c897904 --- /dev/null +++ b/wiki/ref/wrappers/UtilsWrapper/page.kubedoc @@ -0,0 +1,311 @@ +`UtilsWrapper` is an interface containing many useful methods for interacting with Java classes. +It's exposed to [[/global-scope|global scope]] as `Utils`. + +# Static methods + +## RNG + +### `getRandom` + +```js +Utils.getRandom() +Utils.random // read-only bean +``` + +**Returns** +The shared instance of `RandomSource` to generate random numbers from. +This method will always return the same `RandomSource` instance. + +--- + +### `newRandom` + +```js +Utils.newRandom() +``` + +**Returns** +A **new** instance of `RandomSource` to generate random numbers from. + +--- + +### `randomOf` + +```js +Utils.randomOf(random, collection) +``` + +>>> #random +`[js]random`: An instance of [`Random`]({random-link}). +Note that unlike `RandomSource` obtained via `[js]Utils.getRandom` or `[js]Utils.randomOf`, this [`Random`]({random-link}) comes from a built-in Java package ([`java.util.Random`]({random-link})) and not from Minecraft (`net.minecraft.util.RandomSource`), and are not assignable to each other, since they have not in a common ancestor tree. +<<< + +**Parameters** +- <#random> +- `[js]collection` - Any Java collection. This includes all sorts of lists, but not maps. It may be also a JS array, like `[js]\['one', 'two', 'three'\]`. + +**Returns** +A random element from the list. + +--- + +## Collections + +### `emptyList` + +```js +Utils.emptyList() +``` +**Returns** +A new empty, immutable (read-only) `ArrayList`. + +### `emptyList` + +--- + +```js +Utils.emptyMap() +``` +**Returns** +A new empty, immutable (read-only) `Map`. + +--- + +### `newList` + +```js +Utils.newList() +``` +**Returns** +A new empty, mutable `ArrayList`. + +--- + +### `newMap` + +```js +Utils.newMap() +``` +**Returns** +A new empty, mutable `LinkedHashMap`. + +--- + +### `newCountingMap` + +```js +Utils.newCountingMap() +``` +**Returns** +A new empty, mutable `CountingMap`. + +--- + +## Java Regex + +### `regex` + +```js +Utils.regex(regexLike) +``` + +**Parameters** +- `[js]regexLike`: Any value, but preferably one of the following: + - A JavaScript [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp), + - A JavaScript string (which will be used to create a regular expression object) + - A Java character sequence (that includes Java strings) + - A Java [`Pattern`]({pattern-link}). + +**Returns** +If the `[js]regexLike` was: + - a [`Pattern`]({pattern-link}) - returns the same Pattern + - a [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp) - returns a `Pattern` corresponding to the RegExp, + - a string or a character sequence - If the string is formed similarly to a JavaScript regex literal, returns a `Pattern` corresponding to the string. +If `[js]regexLike` was of a different type, this returns `[js]null`. + +===Throws=== +If the given string doesn't start with a `/`, this throws an exception. +Other malformations are silently ignored, until the string is passed into the [`Pattern.compile`](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/regex/Pattern.html#compile(java.lang.String)) method, which may throw an exception on an improper pattern. + +```js +Utils.regex(regexString, flags) +``` +- `[js]regexString`: A string that represents the regular expression pattern. +- `[js]flags`: A bit mask of regular expression flags to use. See the field summary of the [`Pattern`]({pattern-link}) class to learn more. + +**Returns** + +A new [`Pattern`]({pattern-link}) with the given pattern and flags. + +===Throws=== +If the given string doesn't start with a `/`, this throws an exception. +Other malformations are silently ignored, until the string is passed into the [`Pattern.compile`](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/regex/Pattern.html#compile(java.lang.String)) method, which may throw an exception on an improper pattern. + +--- + +### Registry lookup + +### `getStat` + +```js +Utils.getStat(id) +``` + +**Parameters** +- `[js]resourceLocation`: The stat's `ResourceLocation`. + +>>> danger +Do NOT pass strings in place of the `ResourceLocation` here! +Stats are referred to by **reference**, not by resource location's string value. + +Unless you are making your own stat and have a reference to `ResourceLocation` on hand, do not use this method. +<<< + +**Returns** +A `Stat` coming from the `CUSTOM` field corresponding to the provided `id`. + +--- + +### `getSound` + +```js +Utils.getSound(id) +``` + +**Parameters** +- `[js]id`: The sound's resource location. It may be a string. + +**Returns** +A `SoundEvent` corresponding to the given `id`, or `[js]null` if the sound even doesn't exist. + +--- + +### `getSound` + +```js +Utils.getSound(id) +``` + +**Parameters** +- `[js]id`: The sound's resource location. It may be a string. + +**Returns** +A `SoundEvent` corresponding to the given `id`, or `[js]null` if the sound even doesn't exist. + +--- + +### `findCreativeTab` + +```js +Utils.findCreativeTab(id) +``` + +**Parameters** +- `[js]id`: The creative tab's resource location. It may be a string representing the creative mode tab, for example `[js]'minecraft:building_blocks'`. + +**Returns** +A `SoundEvent` corresponding to the given `id`, or `[js]null` if the sound even doesn't exist. + +--- + +## `Lazy and asynchronous Java` + +### `lazy` + +```js +Utils.lazy(supplier) +``` + +Creates a lazy supplier. After the first `get` call to the resulting supplier, its return value is [memoized](https://en.wikipedia.org/wiki/Memoization) and never forgotten, unless done explicitly with its `forget` method. + +**Parameters** +- `[js]supplier`: A [[/ref/java/functional-interface/Supplier|`Supplier`]]. It may be a JS function that takes no parameters and returns a value, for example `[js]() => { return 42 }`. + +**Returns** +A [[/ref/java/utils/Lazy|`Lazy`]] supplier corresponding to the given `[js]supplier`. + +--- + +### `expiringLazy` + +```js +Utils.expiringLazy(supplier, duration) +``` + +Creates an expiring lazy supplier. Its [memoized](https://en.wikipedia.org/wiki/Memoization) value expires after the specified duration. + +**Parameters** +- `[js]supplier`: A [[/ref/java/functional-interface/Supplier|`Supplier`]]. It may be a JS function that takes no arguments and returns a value, for example `[js]() => { return 42 }`. +- `[js]duration`: A [`Duration`](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/time/Duration.html). It may be also: + - a number representing milliseconds, for example `[js]2000`, + - or a string representing a duration, with format being the one used in [`Duration#parse`](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/time/Duration.html#parse(java.lang.CharSequence)) static method. For example, `[js]'PT2S'` represents a duration of 2 seconds. + +**Returns** +A [[/ref/java/utils/Lazy|`Lazy`]] supplier corresponding to the given `[js]supplier`, which forgets about its [memoized](https://en.wikipedia.org/wiki/Memoization) value after the specified `[js]duration`. + +--- + +### `runAsync` + +```js +Utils.runAsync(runnable) +``` + +Runs the provided runnable function in KubeJS' background thread. + +**Parameters** +- `[js]runnable`: Any Java class that implements the [`Runnable`](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Runnable.html) interface. It may be also a JS function that takes no arguments and doesn't return anything, for example `[js]() => { console.log('Ran asynchronously!') }` + +**Returns** +A [`CompletableFuture`]({future-link}) representing the eventual completion or failure of the asynchronous call. +The return type of this asynchronous call is `void` (does not return anything). +(`CompletableFuture` in Java fulfills similar role to [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) found in JavaScript) + +--- + +### `supplyAsync` + +```js +Utils.supplyAsync(supplier) +``` + +Runs the provided supplier function in KubeJS' background thread. + +**Parameters** +- `[js]supplier`: A [[/ref/java/functional-interface/Supplier|`Supplier`]]. It may be also a JS function that takes no arguments and returns a value, for example `[js]() => { return 'Asynchronously supplied!' }` + +**Returns** +A [`CompletableFuture`]({future-link}) representing the eventual completion or failure of the asynchronous call. +The return type of this asynchronous call is `Object` (represents anything that the provided `supplier` can supply). +(`CompletableFuture` in Java fulfills similar role to [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) found in JavaScript) + +--- +# Other + +### `getSystemTime` + +```js +Utils.getSystemTime() +Utils.systemTime // read-only bean +``` + +**Returns** +The difference between current time and midnight, January 1, 1970, UTC, in milliseconds. +Also known as [Unix time](https://en.wikipedia.org/wiki/Unix_time). + +--- + +### `isWrapped` + +```js +Utils.isWrapped(object) +``` + +**Returns** +`[js]true` if object's class implements the [`WrappedJS`](https://github.com/KubeJS-Mods/KubeJS/blob/main/src/main/java/dev/latvian/mods/kubejs/util/WrappedJS.java) marker interface, `[js]false` if it does not. + +--- + +# Source + +([UtilsWrapper.java](https://github.com/KubeJS-Mods/KubeJS/blob/main/src/main/java/dev/latvian/mods/kubejs/plugin/builtin/wrapper/UtilsWrapper.java)) \ No newline at end of file From 3be0bf422f15d7999001dfe045a5454405654078 Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Tue, 6 Jan 2026 17:03:39 +0100 Subject: [PATCH 64/68] Fix formatting? --- wiki/ref/wrappers/UtilsWrapper/page.kubedoc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/wiki/ref/wrappers/UtilsWrapper/page.kubedoc b/wiki/ref/wrappers/UtilsWrapper/page.kubedoc index 0c897904..4385cdcf 100644 --- a/wiki/ref/wrappers/UtilsWrapper/page.kubedoc +++ b/wiki/ref/wrappers/UtilsWrapper/page.kubedoc @@ -118,14 +118,16 @@ Utils.regex(regexLike) **Returns** If the `[js]regexLike` was: + - a [`Pattern`]({pattern-link}) - returns the same Pattern - a [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp) - returns a `Pattern` corresponding to the RegExp, - a string or a character sequence - If the string is formed similarly to a JavaScript regex literal, returns a `Pattern` corresponding to the string. + If `[js]regexLike` was of a different type, this returns `[js]null`. ===Throws=== If the given string doesn't start with a `/`, this throws an exception. -Other malformations are silently ignored, until the string is passed into the [`Pattern.compile`](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/regex/Pattern.html#compile(java.lang.String)) method, which may throw an exception on an improper pattern. +Other malformations are silently ignored, until the string is passed into the [`Pattern.compile`](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/regex/Pattern.html#compile(java.lang.String) method, which may throw an exception on an improper pattern. ```js Utils.regex(regexString, flags) @@ -139,7 +141,7 @@ A new [`Pattern`]({pattern-link}) with the given pattern and flags. ===Throws=== If the given string doesn't start with a `/`, this throws an exception. -Other malformations are silently ignored, until the string is passed into the [`Pattern.compile`](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/regex/Pattern.html#compile(java.lang.String)) method, which may throw an exception on an improper pattern. +Other malformations are silently ignored, until the string is passed into the [`Pattern.compile`](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/regex/Pattern.html#compile(java.lang.String) method, which may throw an exception on an improper pattern. --- From d70ec46cb4045b7b80a631650d5bfbf2cbd6dc03 Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Tue, 6 Jan 2026 17:04:09 +0100 Subject: [PATCH 65/68] Ah, the indent was a problem --- wiki/ref/wrappers/UtilsWrapper/page.kubedoc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/wiki/ref/wrappers/UtilsWrapper/page.kubedoc b/wiki/ref/wrappers/UtilsWrapper/page.kubedoc index 4385cdcf..6f9685a6 100644 --- a/wiki/ref/wrappers/UtilsWrapper/page.kubedoc +++ b/wiki/ref/wrappers/UtilsWrapper/page.kubedoc @@ -118,10 +118,9 @@ Utils.regex(regexLike) **Returns** If the `[js]regexLike` was: - - - a [`Pattern`]({pattern-link}) - returns the same Pattern - - a [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp) - returns a `Pattern` corresponding to the RegExp, - - a string or a character sequence - If the string is formed similarly to a JavaScript regex literal, returns a `Pattern` corresponding to the string. +- a [`Pattern`]({pattern-link}) - returns the same Pattern +- a [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp) - returns a `Pattern` corresponding to the RegExp, +- a string or a character sequence - If the string is formed similarly to a JavaScript regex literal, returns a `Pattern` corresponding to the string. If `[js]regexLike` was of a different type, this returns `[js]null`. From 77ca74b1c1dce13375e453d6d75e21787cf05a3c Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Tue, 6 Jan 2026 17:07:53 +0100 Subject: [PATCH 66/68] Fix mistakes --- wiki/ref/wrappers/UtilsWrapper/page.kubedoc | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/wiki/ref/wrappers/UtilsWrapper/page.kubedoc b/wiki/ref/wrappers/UtilsWrapper/page.kubedoc index 6f9685a6..957c0b24 100644 --- a/wiki/ref/wrappers/UtilsWrapper/page.kubedoc +++ b/wiki/ref/wrappers/UtilsWrapper/page.kubedoc @@ -177,21 +177,7 @@ Utils.getSound(id) - `[js]id`: The sound's resource location. It may be a string. **Returns** -A `SoundEvent` corresponding to the given `id`, or `[js]null` if the sound even doesn't exist. - ---- - -### `getSound` - -```js -Utils.getSound(id) -``` - -**Parameters** -- `[js]id`: The sound's resource location. It may be a string. - -**Returns** -A `SoundEvent` corresponding to the given `id`, or `[js]null` if the sound even doesn't exist. +A `SoundEvent` corresponding to the given `id`, or `[js]null` if the sound event doesn't exist under the provided ID. --- @@ -205,11 +191,11 @@ Utils.findCreativeTab(id) - `[js]id`: The creative tab's resource location. It may be a string representing the creative mode tab, for example `[js]'minecraft:building_blocks'`. **Returns** -A `SoundEvent` corresponding to the given `id`, or `[js]null` if the sound even doesn't exist. +A `CreativeModeTab` corresponding to the given `id`, or `[js]null` if the creative mode tab doesn't exist under the provided ID. --- -## `Lazy and asynchronous Java` +## Lazy and asynchronous Java ### `lazy` From 7ff5db9cd31e68adf195f572619434f488fb3421 Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Tue, 6 Jan 2026 17:09:28 +0100 Subject: [PATCH 67/68] More fixes --- wiki/ref/wrappers/UtilsWrapper/page.kubedoc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wiki/ref/wrappers/UtilsWrapper/page.kubedoc b/wiki/ref/wrappers/UtilsWrapper/page.kubedoc index 957c0b24..45090336 100644 --- a/wiki/ref/wrappers/UtilsWrapper/page.kubedoc +++ b/wiki/ref/wrappers/UtilsWrapper/page.kubedoc @@ -37,7 +37,7 @@ Utils.randomOf(random, collection) >>> #random `[js]random`: An instance of [`Random`]({random-link}). -Note that unlike `RandomSource` obtained via `[js]Utils.getRandom` or `[js]Utils.randomOf`, this [`Random`]({random-link}) comes from a built-in Java package ([`java.util.Random`]({random-link})) and not from Minecraft (`net.minecraft.util.RandomSource`), and are not assignable to each other, since they have not in a common ancestor tree. +Note that unlike `RandomSource` obtained via `[js]Utils.getRandom()` or `[js]Utils.randomOf(random, collection)`, this [`Random`]({random-link}) comes from a built-in Java package ([`java.util.Random`]({random-link})) and not from Minecraft (`net.minecraft.util.RandomSource`), and are not assignable to each other, since they have not in a common ancestor tree. <<< **Parameters** @@ -59,10 +59,10 @@ Utils.emptyList() **Returns** A new empty, immutable (read-only) `ArrayList`. -### `emptyList` - --- +### `emptyMap` + ```js Utils.emptyMap() ``` From 047ba9a750787f57fff07d47ff3a9cfd108dd069 Mon Sep 17 00:00:00 2001 From: KonSola5 <125081901+KonSola5@users.noreply.github.com> Date: Tue, 6 Jan 2026 17:18:08 +0100 Subject: [PATCH 68/68] Even more fixes --- wiki/ref/wrappers/UtilsWrapper/page.kubedoc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wiki/ref/wrappers/UtilsWrapper/page.kubedoc b/wiki/ref/wrappers/UtilsWrapper/page.kubedoc index 45090336..659413bb 100644 --- a/wiki/ref/wrappers/UtilsWrapper/page.kubedoc +++ b/wiki/ref/wrappers/UtilsWrapper/page.kubedoc @@ -45,7 +45,7 @@ Note that unlike `RandomSource` obtained via `[js]Utils.getRandom()` or `[js]Uti - `[js]collection` - Any Java collection. This includes all sorts of lists, but not maps. It may be also a JS array, like `[js]\['one', 'two', 'three'\]`. **Returns** -A random element from the list. +A random element from the collection. --- @@ -144,7 +144,7 @@ Other malformations are silently ignored, until the string is passed into the [` --- -### Registry lookup +## Registry lookup ### `getStat` @@ -153,7 +153,7 @@ Utils.getStat(id) ``` **Parameters** -- `[js]resourceLocation`: The stat's `ResourceLocation`. +- `[js]id`: The stat's `ResourceLocation`. >>> danger Do NOT pass strings in place of the `ResourceLocation` here!