You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/introduction/datapacking/custom-recipes.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -54,6 +54,7 @@ Here's an example of adding a Farmer's Delight cutting board recipe, which defin
54
54
});
55
55
```
56
56
57
+
<!-- Note that you are effectively recreating the JSON file, and how mods handle recipes can vary from mod to mod, so no one bit of advice will apply to all mods. -->
57
58
58
59
### Looping
59
60
Of course, this starts becoming powerful when you start to combine them with a [loop, function or otherwise](../saving-time/loops.md), allowing you to easily add tons of custom recipes without having to manage a single datapack file.
@@ -133,7 +134,7 @@ Here's a datapack example:
133
134
}
134
135
```
135
136
136
-
The field:
137
+
Let's break it down into it's parts:
137
138
138
139
- An ItemStack `input` field
139
140
@@ -214,4 +215,3 @@ Now for the fun part: Actually using it!
Copy file name to clipboardExpand all lines: docs/introduction/datapacking/loading-data.md
+19-2Lines changed: 19 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,24 @@
2
2
title: Loading Data with KubeJS
3
3
---
4
4
5
+
# Loading Data with KubeJS
6
+
You can also use KubeJS to load assets from resource packs and data from datapacks!
7
+
8
+
---
9
+
10
+
## Loading Assets
11
+
12
+
[Resource pack](https://minecraft.wiki/w/Resource_pack) assets (custom textures, language files, etc.) can be placed in `kubejs/assets` to be loaded. This folder is loaded the same way as the `assets` folder in a resource pack. Assets in this folder will not appear as a separate resource pack and will be automatically loaded for every world.
13
+
14
+
If you already have a resource pack, you can simply copy the folder(s) from inside the resource pack’s `assets` folder into KubeJS’s `assets` folder.
15
+
16
+
## Loading Data
17
+
18
+
!!! note
19
+
Consider looking into [JsonIO](jsonio.md) if you have to generate a generate a large amount of ([nonrecipe](custom-recipes.md)) datapack files, rather than manually writing them.
20
+
21
+
Datapack data can be placed in `kubejs/data` to be loaded. Data within this folder will not appear as a separate datapack. It is loaded the same way as the `data` folder in a datapack and will be automatically loaded for every world.
22
+
23
+
If you already have a datapack, you can simply copy the folder(s) from inside the datapack’s `data` folder into KubeJS’s `data` folder.
Copy file name to clipboardExpand all lines: docs/introduction/saving-time/loops.md
+26-8Lines changed: 26 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ After reading the previous chapters, you might have started thinking about custo
11
11
12
12
---
13
13
14
-
# Arrays
14
+
##Arrays
15
15
Some events allow you to use an array instead of just a single item, enabling you to perform actions on multiple items rather than needing separate methods for each.
16
16
17
17
```js
@@ -22,8 +22,7 @@ JEIEvents.hideItems(event => {
22
22
23
23
1. Hides both the `ae2:inscriber` and the `ae2:vibration_chamber`
24
24
25
-
26
-
# Loops
25
+
## Loops
27
26
Loops allow you to iterate over arrays and perform actions on each element. This is particularly useful when you have a list of items and want to apply the same logic to all of them.
28
27
29
28
Here's an example of using a `foreach` loop to define recipes for upgrading furnaces:
2.**Recipe Definition**: For each furnace, a shaped recipe for the output furnace (`furnace`) is defined using the provided material (`mat`) and base furnace (`base`).
54
53
55
54
56
-
# Functions
55
+
##Functions
57
56
Functions allow you to reuse code by defining a function and repeatedly calling it with multiple arguments, even across different files! Knowing a little bit of [javascript](https://www.w3schools.com/js/default.asp) can go a very long way when working with functions.
1. Defines helper function `potting` with the elements of of `output` and `pottedInput`
75
+
2. Creating shaped recipes using the helper
76
+
77
+
### Helper Functions
60
78
Using the knowledge that you can call constants across different files, you could create a helper file with various functions in it and simply call them from anywhere.
Of course, functions aren't as rigid as the above examples imply. With a little bit of JavaScript knowledge, you can create pretty some nice things.
91
109
92
-
The function below is excerpted from [CABIN](https://github.com/ThePansmith/CABIN), and is used to generate the recipes used to turn machines into usable parts. If the fourth parameter is omitted, it defaults to creating a stonecutting recipe instead.
110
+
The function below is excerpted from [CABIN](https://github.com/ThePansmith/CABIN), and is used to generate the recipes used to turn machines into usable parts. If the fourth parameter is omitted, it defaults to creating a stonecutting recipe instead.
Likewise, you can define functions that call other functions. For example:
143
161
144
162
```js
@@ -166,7 +184,7 @@ if (Platform.isLoaded("createdeco")) { // (1)
166
184
2. Ifs, switches, and otherwise are not limited to just functions or mechanics!
167
185
168
186
169
-
# Regex
187
+
##Regex
170
188
A **regex**, shorthand for "regular expression", is a pattern describing a certain amount of text. Essentially, it acts as a filter, allowing anything that matches to pass. Regex can be quite powerful, enabling you to search with surprisingly complex options. Getting into the nitty-gritty of regex is beyond this guide (consider looking [here](https://regexr.com/) for a starting place), but here are some practical examples:
0 commit comments