Skip to content

Commit 23fdaa6

Browse files
committed
docs: add documentation version for 1.21.10
1 parent c5cca75 commit 23fdaa6

61 files changed

Lines changed: 3714 additions & 1 deletion

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/advanced/item-properties.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
---
2+
sidebar_position: 60
3+
---
4+
5+
# Item Properties
6+
7+
Item properties let item models change depending on runtime conditions. Modonomicon exposes a property you can use to change a book item's model depending on whether the Modonomicon UI is open for the player.
8+
9+
## Open state
10+
11+
### 1) Custom book item requirement
12+
13+
This only works when using a custom book item (an item you register yourself). It does *not* work with the automatically generated book item.
14+
15+
### 2) Java helper / Occultism example
16+
17+
Occultism demonstrates a common approach: their [GuideBookItem](https://github.com/klikli-dev/occultism/blob/version/1.21.1/src/main/java/com/klikli_dev/occultism/common/item/tool/GuideBookItem.java) shows how to use `ModonomiconCustomItemBase` to obtain the same default Modonomicon behavior on your own item. `ModonomiconCustomItemBase` handles the DataComponents and registers the item property for you, which is why using it is recommended.
18+
19+
:::tip
20+
Tip: extending `ModonomiconCustomItemBase` is the easiest route because it wires up the required DataComponents handling and property registration automatically.
21+
:::
22+
23+
### 3) Registering the item
24+
25+
Register your custom item as you would any other item. For reference see Occultism's item registration (their [OccultismItems](https://github.com/klikli-dev/occultism/blob/version/1.21.1/src/main/java/com/klikli_dev/occultism/registry/OccultismItems.java#L55) class) — the book item is just a normal item registration.
26+
27+
### 4) Disable auto-generated book and datagen
28+
29+
If you normally generate a book item from datagen, disable that generation and tell Modonomicon about your custom item. In `book.json` set:
30+
31+
```json
32+
"generate_book_item": false,
33+
"custom_book_item": "<your_item_id>"
34+
```
35+
36+
Or in datagen via the `BookModel` helpers:
37+
38+
```java
39+
.withGenerateBookItem(false)
40+
.withCustomBookItem(this.modLoc("<your_item_id>"))
41+
```
42+
43+
### 5) Client item: changing the model when open
44+
45+
Modonomicon exposes the ConditionalItemModelProperty `modonomicon:is_book_open`. The value is `true` while the Modonomicon UI is open for the player and `false` otherwise. Use that in your client item to change model when the book is open. The following example shows a green book when closed and a purple book when open:
46+
47+
```json
48+
{
49+
"model": {
50+
"type": "minecraft:condition",
51+
52+
"property": "modonomicon:is_book_open",
53+
54+
"on_true": {
55+
"type": "minecraft:model",
56+
"model": "modonomicon:item/modonomicon_purple"
57+
},
58+
"on_false": {
59+
"type": "minecraft:model",
60+
"model": "modonomicon:item/modonomicon_green"
61+
}
62+
}
63+
}
64+
```
65+
66+
:::info
67+
See also https://docs.neoforged.net/docs/1.21.4/resources/client/models/items
68+
:::
69+
70+
:::tip
71+
This example points at the `modonomicon:item/modonomicon_purple` and `modonomicon:item/modonomicon_green` models shipped by Modonomicon. If you want to use your own open-state model make sure the model JSON is present and loaded (register the model file or force-load it). A texture alone is not enough — Minecraft loads models, not raw textures.
72+
:::
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
sidebar_position: 30
3+
---
4+
5+
# Advanced
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
sidebar_position: 40
3+
---
4+
5+
# Custom Conditions
6+
7+
Mods can add custom conditions that can be used to lock entries or categories. To this end you need to:
8+
9+
1. Create ResourceLocation for the new condition (e.g. "mymod:my_condition")
10+
2. Create a custom condition class
11+
3. Register the custom condition
12+
4. For datagen: create a condition model class
13+
5. Finally use the condition in your book
14+
15+
:::tip
16+
17+
The ResourceLocation is what you will use in your entries and categories to gate them behind your custom condition.
18+
19+
:::
20+
21+
## Condition Class
22+
23+
Conditions need to extend `BookCondition` in the package `com.klikli_dev.modonomicon.book.conditions`.
24+
In addition to implementing the interface methods that your IDE will suggest you need two static methods `fromJson` and `fromNetwork` which you will need when registering the condition.
25+
26+
in `getType()` return your ResourceLocation.
27+
28+
See https://github.com/klikli-dev/modonomicon/tree/version/1.21.1/common/src/main/java/com/klikli_dev/modonomicon/book/conditions/BookAdvancementCondition.java for an example condition.
29+
30+
## Condition Registration
31+
32+
To register the condition call LoaderRegistry.registerConditionLoader(...).
33+
For the BookAdvancementCondition this call looks as follows: `registerConditionLoader(Condition.ADVANCEMENT, BookAdvancementCondition::fromJson, BookAdvancementCondition::fromNetwork);`
34+
35+
This needs to be called from both the client and server side mod initialization.
36+
In Fabric: Call in `onInitialize` in your `ModInitializer`.
37+
In (Neo)Forge: Call in `onCommonSetup` (your `FMLCommonSetupEvent` handler).
38+
39+
## Condition Datagen Model
40+
41+
The model class helps you to generate the condition json files via DataGen.
42+
43+
See https://github.com/klikli-dev/modonomicon/blob/2a067357bacaf3e15a5f490520a4headaf64807fe83e/common/src/main/java/com/klikli_dev/modonomicon/api/datagen/book/condition/BookAdvancementConditionModel.java for a reference model class.
44+
45+
(On 1.20.1 it looks a bit more complicated:
46+
https://github.com/klikli-dev/modonomicon/blob/bdf639c835908393198f695999c70f2ac53e154c/common/src/main/java/com/klikli_dev/modonomicon/api/datagen/book/condition/BookAdvancementConditionModel.java )
47+
48+
:::tip
49+
You need not register the model.
50+
:::
51+
52+
## Usage
53+
54+
On your entry or category, add:
55+
56+
```json
57+
{
58+
...
59+
"condition": {
60+
"type": "mymod:my_condition"
61+
},
62+
...
63+
}
64+
```
65+
66+
See also [Unlock Conditions](../basics/unlock-conditions) for more information on how to use conditions.
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
---
2+
sidebar_position: 20
3+
---
4+
5+
# Error Handling
6+
7+
Depending on the type of error there are different ways Modonomicon will handle them.
8+
Syntax errors in the JSON files representing your book will be caught by Minecraft's `SimpleJsonResourceReloadListener`, while any errors later in the loading process will be caught by the Modonomicon's own error handler.
9+
10+
## JSON Syntax Errors
11+
12+
- will show up as `ERROR` in the log files.
13+
14+
:::danger
15+
16+
JSON Syntax Errors will in most cases not be shown in-game, only in the log, leading to "silent failures"!
17+
Make sure to check your log files for errors before releasing your book.
18+
19+
:::
20+
21+
Any errors in the json syntax will generally only show up in the log files, because they occur in Minecraft's loading logic, before Modonomicon receives the file content. In some cases they can cause follow-up errors (e.g. because an entry is missing) in Modonomicon's error handler and will be shown in-game.
22+
23+
In Singleplayer you will find the error log in your `/logs/latest.log` file in your Minecraft installation directory. In Multiplayer that's in the `/logs/latest.log` file in your server's `/logs` directory.
24+
25+
The log could be e.g. as follows for an extra comma where there shouldn't be one:
26+
```
27+
[minecraft/SimpleJsonResourceReloadListener]: Couldn't parse data file modonomicon:test/entries/test_category/test_entry_child from modonomicon:modonomicon/books/test/entries/test_category/test_entry_child.json
28+
com.google.gson.JsonParseException: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 30 column 4 path $.pages[3]
29+
```
30+
31+
:::caution
32+
33+
If loading a JSON file fails server-side, there will not be any log on the client side (Minecraft loads the JSONs only server-side).
34+
Make sure to test your book in both SP and MP.
35+
36+
:::
37+
38+
### Finding JSON Syntax Errors in the Log
39+
40+
Search log files for:
41+
42+
- `minecraft/SimpleJsonResourceReloadListener`
43+
- `com.google.gson.JsonParseException`
44+
45+
to find any errors handled by Minecraft that never reach Modonomicon.
46+
47+
48+
## Errors handled by Modonomicon
49+
50+
- will show up as `WARN` in the log files.
51+
52+
Modonomicon will attempt to handle errors gracefully - that means, the player will not crash, but instead will see a book screen with the error message, and a hint to check the log for further errors.
53+
54+
Errors come with as much context as possible, that means the error handler will attempt to include the book, category, entry, page and potentially even page content element the error is associated with.
55+
56+
For example, an invalid link within a book page could produce the following error message:
57+
```
58+
[<time>] [Render thread/WARN] [co.kl.mo.Modonomicon/]: BookErrorManager.error() called for book: modonomicon:test with error: BookErrorInfo{
59+
errorMessage='Failed to render markdown for book 'modonomicon:test'',
60+
context='Link: entry://modonomicon:test/test_category/test_entry@test_anchor,
61+
Category: modonomicon:test_category,
62+
Entry: modonomicon:test_category/test_entry_child,
63+
Page: 2',
64+
exception='java.lang.IllegalArgumentException: Invalid entry link, anchor not found in entry: modonomicon:test/test_category/test_entry@test_anchor'
65+
}
66+
```
67+
68+
:::caution
69+
70+
If you notice any issues such as crashes or log entries, but no Modonomicon error log in the above format or no Modonomicon error screen shown, please report this at https://github.com/klikli-dev/modonomicon/issues
71+
72+
:::
73+
74+
### Finding Modonomicon Errors in the Log
75+
76+
Search log files for `BookErrorManager.error() called for book` to find any errors handled by Modonomicon.
77+
78+
### Error Screen
79+
80+
The error screen for the above error message would look like this:
81+
82+
![Error Screen](/img/docs/advanced/error-handling/error-window.png)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
sidebar_position: 30
3+
---
4+
5+
# Integrations with other Mods
6+
7+
## Patchouli
8+
9+
Modonomicon can provide links to Patchouli Pages and open them on click.
10+
11+
See **[Patchouli Links](../basics/formatting#patchouli-links)**.
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
---
2+
sidebar_position: 60
3+
---
4+
5+
# Item Properties
6+
7+
Item properties let item models change depending on runtime conditions. Modonomicon exposes a property you can use to change a book item's model depending on whether the Modonomicon UI is open for the player.
8+
9+
## Open state
10+
11+
### 1) Custom book item requirement
12+
13+
This only works when using a custom book item (an item you register yourself). It does *not* work with the automatically generated book item.
14+
15+
### 2) Java helper / Occultism example
16+
17+
Occultism demonstrates a common approach: their [GuideBookItem](https://github.com/klikli-dev/occultism/blob/version/1.21.1/src/main/java/com/klikli_dev/occultism/common/item/tool/GuideBookItem.java) shows how to use `ModonomiconCustomItemBase` to obtain the same default Modonomicon behavior on your own item. `ModonomiconCustomItemBase` handles the DataComponents and registers the item property for you, which is why using it is recommended.
18+
19+
:::tip
20+
Tip: extending `ModonomiconCustomItemBase` is the easiest route because it wires up the required DataComponents handling and property registration automatically.
21+
:::
22+
23+
### 3) Registering the item
24+
25+
Register your custom item as you would any other item. For reference see Occultism's item registration (their [OccultismItems](https://github.com/klikli-dev/occultism/blob/version/1.21.1/src/main/java/com/klikli_dev/occultism/registry/OccultismItems.java#L55) class) — the book item is just a normal item registration.
26+
27+
### 4) Disable auto-generated book and datagen
28+
29+
If you normally generate a book item from datagen, disable that generation and tell Modonomicon about your custom item. In `book.json` set:
30+
31+
```json
32+
"generate_book_item": false,
33+
"custom_book_item": "<your_item_id>"
34+
```
35+
36+
Or in datagen via the `BookModel` helpers:
37+
38+
```java
39+
.withGenerateBookItem(false)
40+
.withCustomBookItem(this.modLoc("<your_item_id>"))
41+
```
42+
43+
### 5) Client item: changing the model when open
44+
45+
Modonomicon exposes the ConditionalItemModelProperty `modonomicon:is_book_open`. The value is `true` while the Modonomicon UI is open for the player and `false` otherwise. Use that in your client item to change model when the book is open. The following example shows a green book when closed and a purple book when open:
46+
47+
```json
48+
{
49+
"model": {
50+
"type": "minecraft:condition",
51+
52+
"property": "modonomicon:is_book_open",
53+
54+
"on_true": {
55+
"type": "minecraft:model",
56+
"model": "modonomicon:item/modonomicon_purple"
57+
},
58+
"on_false": {
59+
"type": "minecraft:model",
60+
"model": "modonomicon:item/modonomicon_green"
61+
}
62+
}
63+
}
64+
```
65+
66+
:::info
67+
See also https://docs.neoforged.net/docs/1.21.4/resources/client/models/items
68+
:::
69+
70+
:::tip
71+
This example points at the `modonomicon:item/modonomicon_purple` and `modonomicon:item/modonomicon_green` models shipped by Modonomicon. If you want to use your own open-state model make sure the model JSON is present and loaded (register the model file or force-load it). A texture alone is not enough — Minecraft loads models, not raw textures.
72+
:::
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
sidebar_position: 50
3+
---
4+
5+
# Leaflets
6+
7+
Leaflets are single-entry books. That means there is no book overview, if you click the book you immediately see text.
8+
As a leaflet consists of an entry, it can still hold multiple pages, and within these pages use all features available to entries/pages in a normal book.
9+
10+
The book will be treated as a book in index mode (that means, no big "node view" background will be shown behind the entry).
11+
12+
## Creating a leaflet
13+
14+
To create a leaflet book, you need a normal book structure including `book.json`, a single category, and within that category an entry.
15+
The book needs to have `leaflet_entry` set to the ResourceLocation of the single entry in the single category.
16+
Additional content can be added to the book, but will not be displayed.
17+
18+
The best way to create a leaflet is to use the leaflet datagen. It is demonstrated in (and can be copied from) https://github.com/klikli-dev/modonomicon/tree/version/1.21/common/src/main/java/com/klikli_dev/modonomicon/datagen/book/DemoLeaflet.java
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
sidebar_position: 10
3+
---
4+
5+
# Localization
6+
7+
All in-game texts should be supplied as DescriptionIds (= Translation Keys) with a corresponding entry in the language file to provide the actual content and (markdown) formatting. Modonomicon adds some helper functionality to make providing book texts more easy.
8+
9+
See for example https://github.com/klikli-dev/modonomicon/tree/version/1.21.1/common/src/main/java/com/klikli_dev/modonomicon/datagen/book/demo/formatting/AdvancedFormattingEntry.java
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
sidebar_position: 10
3+
---
4+
5+
# Basics

0 commit comments

Comments
 (0)