diff --git a/docs/customize/drawer.md b/docs/customize/drawer.md index a731940..ec158fa 100644 --- a/docs/customize/drawer.md +++ b/docs/customize/drawer.md @@ -29,7 +29,7 @@ sprites/ ![DrawRecipe example](../assets/draw-recipes.gif){ loading=lazy width="280" } -=== "Hjson" +=== "HJSON" ```hjson drawer: { @@ -63,7 +63,7 @@ sprites/ } ``` -=== "Json" +=== "JSON" ```json "drawer": { diff --git a/docs/customize/menu.md b/docs/customize/menu.md index 6226cd6..2fb8c3a 100644 --- a/docs/customize/menu.md +++ b/docs/customize/menu.md @@ -3,7 +3,7 @@ You can select which menu style detailed-described blow you want with a case-insensitive name. The default menu style is `Transform`. -=== "Hjson" +=== "HJSON" Suppose you have such structure with a MultiCrafter, named `mine-crafter` ``` @@ -16,7 +16,7 @@ The default menu style is `Transform`. menu: Transform ``` -=== "Json" +=== "JSON" Suppose you have such structure with a MultiCrafter, named `mine-crafter` ``` diff --git a/docs/index.md b/docs/index.md index 90e473c..0ff9064 100644 --- a/docs/index.md +++ b/docs/index.md @@ -9,13 +9,13 @@ or search it on the Mod Browser with its name, `MultiCrafter Lib`. | Method | Json | JavaScript | Java | Note | |:----------:|:----:|:----------:|:-------:|:------------------------------:| -| Dependency | ✔️ | ✔️ | ✔️ | Players need download this mod | -| Injection | ✔️ | ✔️ | No Need | Keep your mod standalone | -| Jitpack | | | ✔️ | Full sources code support | +| Dependency | ✔️ | ✔️ | ✔️ | Players need download this mod | +| Injection | ✔️ | ✔️ | No Need | Keep your mod standalone | +| Jitpack | ❌ | ❌ | ✔️ | Full sources code support | === "Dependency" - **For a Json, JavaScript or Java mod.** + **For a JSON, JavaScript or Java mod.** If you want your mod to depend on MultiCrafter and only focus on your contents, it's for your use case. @@ -35,7 +35,7 @@ or search it on the Mod Browser with its name, `MultiCrafter Lib`. === "Injection" - **For a Json or JavaScript mod.** + **For a JSON or JavaScript mod.** *Injection makes your mod an actual Java mod, so it must fit the structure of Java mod.* diff --git a/docs/usage/java.md b/docs/usage/java.md index 52c29c3..7d93ee9 100644 --- a/docs/usage/java.md +++ b/docs/usage/java.md @@ -1,2 +1,183 @@ # Java +In your Java file containing all your blocks (create one if you don't already have one) imports the MultiCrater library. + +```java +import multicraft.* +``` + +Then create a new block with the type `MultiCrafter` + +```java +Block mine-crafter = new MultiCrafter("mine-crafter") {{ + +}}; +``` + +You can add recipes like this: + +```java +resolvedRecipes = Seq.with( + new Recipe() {{ + input = new IOEntry() {{ + items = ItemStack.with( + Items.copper, 1, + Items.lead, 1 + ); + }}; + output = new IOEntry() {{ + items = ItemStack.with( + Items.surgeAlloy, 1, + Items.thorium, 1 + ); + }}; + craftTime = 120f; + }}, + new Recipe() {{ + input = new IOEntry() {{ + items = ItemStack.with( + Items.copper, 1 + ); + }}; + output = new IOEntry() {{ + items = ItemStack.with( + Items.copper, 1, + Items.beryllium, 1 + ); + }}; + craftTime = 160f; + }} +); +``` + +### Recipe + +A recipe has several fields: + +| Field | Type | Note | +|-------------|------------------------------------|---------------------------------------------| +| input | IOEntry | | +| output | IOEntry | | +| crafterTime | Float | how long to do a synthesis, can be 0. | +| icon | Prov | such as `Icon.lock-open`. See [Icon](#icon) | +| iconColor | Color (RGB, RGBA, rgba8888 or Hex) | a color for icon | + + + +### Input and Output + +The `input` or `output` are `IOEntry`. +With this style, its power is unlimited. + +| Key | Type | Note | +|-------------|------------------------------------|-------------------------------------------------| +| items | ItemStack[] | how much item for input/output, default: empty | +| fluids | LiquidStack[] | how much fluid for input/output, default: empty | +| power | Float | unit: power/tick | how much power for input/output, default: 0f | +| heat | Float | how much heat for input/output, default: 0f | +| icon | Icon | such as `Icon.lock-open`. See [Icon](#icon) | +| iconColor | Color (RGB, RGBA, rgba8888 or Hex) | a color for icon | +| craftEffect | Effect | an independent craft effect for each recipe | + +### Icon + +You can customize which icon is used for your recipe selector menu. + +If you don't set a dedicated icon, it will find the first one from the recipe. + +For example: + +=== "alphaaaa" + + ![Alphaaaa](../assets/customizedIcon-alphaaaa.png){ loading=lazy } + +
+ + icon = Icon.alphaaaa +
+ iconColor: F30000 +
+ ``` + switchStyle = RecipeSwitchStyle.simple; + resolvedRecipes = Seq.with( + new Recipe() {{ + input = new IOEntry(){{ + fluids = Seq.with( + Liquids.ozone, 1.5f + ); + }}; + output = new IOEntry() {{ + items = Seq.with( + Items.coal, 1 + ) + power = 2f; + icon: alphaaaa + iconColor = Color.valueOf("#F30000"); + }}; + craftTime = 250f; + }}, + new Recipe() {{ + input = new IOEntry(){{ + items = Seq.with( + Items.copper, 1 + ); + }}; + output = new IOEntry() {{ + items = Seq.with( + Items.coal, 1 + ) + icon = () -> Icon.lock.uiIcon; + }}; + craftTime = 120f; + }} + ); + ``` +
+ +=== "mono" + + ![Mono](../assets/customizedIcon-mono.png){ loading=lazy width="250" } + +
+ + icon: mono + + ```java + switchStyle = RecipeSwitchStyle.simple; + resolvedRecipes = Seq.with( + new Recipe() {{ + input = new IOEntry(){{ + items = Seq.with( + Items.copper, 1 + ); + }}; + output = new IOEntry() {{ + items = Seq.with( + Items.coal, 1 + ) + }}; + craftTime = 60f; + icon = () -> UnitTypes.mono.uiIcon; + }}, + new Recipe() {{ + input = new IOEntry(){{ + items = Seq.with( + Items.copper, 1 + ); + }}; + output = new IOEntry() {{ + fluids = Seq.with( + Liquid.ozone, 1f + ) + }}; + craftTime = 60f; + }} + ); + ``` +
+ +- The `icon` variable as to be always defined by `icon = () -> ...;` +- For a built-in icon, it should start with `Icon.`, such as `Icon.lock-open` or `Icon.trash`. +- For an icon from item, fluid, unit or block, it should be the content `uiIcon`, such as `Units.mono.uiIcon`,`phase-heat.uiIcon`. +- For any texture, it should be its name, such as `your-mod-icon` or `alphaaaa`. + diff --git a/docs/usage/json.md b/docs/usage/json.md index d6f051d..4710531 100644 --- a/docs/usage/json.md +++ b/docs/usage/json.md @@ -1,6 +1,6 @@ -# Json & Javascript +# JSON & Javascript -=== "Hjson" +=== "HJSON" Create a file, for example, a `mine-crafter.hjson`, in the `content/blocks` folder. ``` @@ -47,7 +47,7 @@ ] ``` -=== "Json" +=== "JSON" Create a file, for example, a `mine-crafter.json`, in the `content/blocks` folder. ``` @@ -94,7 +94,7 @@ === "JavaScript" - In a javascript file, you should import the `MultiCrafter` class from `multi-cafter` + In a JavaScript file, you should import the `MultiCrafter` class from `multi-cafter` ```javascript const multi = require("multi-crafter/lib") const mineCrafter = multi.MultiCrafter("mine-crafter") @@ -119,8 +119,8 @@ craftTime: 210.0 }] ``` - - + + ### Recipe A recipe has several fields: @@ -129,8 +129,8 @@ A recipe has several fields: |-------------|--------------------------|---------------------------------------------| | input | Object, String or List | alias: [`in`,`i`] | | output | Object, String or List | alias: [`out`,`o`] | -| crafterTime | number | unit: tick | how long to do a synthesis, can be 0. | -| icon | String | such as `Icon.lock-open`. see [icon](#icon) | +| crafterTime | Number | unit: tick | how long to do a synthesis, can be 0. | +| icon | String | such as `Icon.lock-open`. See [Icon](#icon) | | iconColor | String | a hex color for icon | ### Input and Output @@ -141,14 +141,14 @@ The `input` or `output` can be a `String`. If so, it will be considered as an item or fluid. If there is no amount given, `1` will be the amount as default. -=== "Hjson" +=== "HJSON" ```hjson input: copper/2 output: water/1.2 ``` -=== "Json" +=== "JSON" ```json "input": "copper/2", @@ -167,14 +167,14 @@ If there is no amount given, `1` will be the amount as default. The `input` or `output` can be a `List`. If so, every element will be treated as an item or fluid. -=== "Hjson" +=== "HJSON" ```hjson input: [copper/2,lead/3] output: slag/2.5 ``` -=== "Json" +=== "JSON" ```json "input": ["copper/2","lead/3"], @@ -193,17 +193,17 @@ If so, every element will be treated as an item or fluid. The `input` or `output` can be an `Object`. With this style, its power is unlimited. -| Key | Type | Optional | Note | -|-------------|--------------------------------|:--------:|-------------------------------------------------| -| items | String or List | ✔️ | how much item for input/output, default: empty | -| fluids | String or List | ✔️ | how much fluid for input/output, default: empty | -| power | Number | unit: power/tick | ✔️ | how much power for input/output, default: 0 | -| heat | Number | ✔️ | how much heat for input/output, default: 0 | -| icon | String | ✔️ | such as `Icon.lock-open`. see [icon](#icon) | -| iconColor | String | ✔️ | a hex color for icon | -| craftEffect | String | ✔️ | an independent craft effect for each recipe | +| Key | Type | Note | +|-------------|--------------------------------|-------------------------------------------------| +| items | String or List | how much item for input/output, default: empty | +| fluids | String or List | how much fluid for input/output, default: empty | +| power | Number | unit: power/tick | how much power for input/output, default: 0 | +| heat | Number | how much heat for input/output, default: 0 | +| icon | String | such as `Icon.lock-open`. See [Icon](#icon) | +| iconColor | String | a hex color for icon | +| craftEffect | String | an independent craft effect for each recipe | -=== "Hjson" +=== "HJSON" ```hjson input: { @@ -219,7 +219,7 @@ With this style, its power is unlimited. } ``` -=== "Json" +=== "JSON" ```json "input": { @@ -269,7 +269,7 @@ For example:
iconColor: F30000 - ``` + ```hjson recipes: [ { input: ozone/1.5 @@ -299,9 +299,9 @@ For example:
- icon: mono + icon = mono - ``` + ```hjson menu: Simple recipes: [ diff --git a/mkdocs.yml b/mkdocs.yml index 7ec829e..946a42d 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -45,7 +45,7 @@ nav: - Built-in: customize/builtin.md - Drawer: customize/drawer.md - API: - - Multicrafter: api/multicrafter.md + - MultiCrafter: api/multicrafter.md - Drawer: api/drawer.md markdown_extensions: