Skip to content

Commit

Permalink
docs: add better datapack docs
Browse files Browse the repository at this point in the history
  • Loading branch information
klikli-dev committed Sep 10, 2024
1 parent 04edd55 commit 30358fb
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 6 deletions.
8 changes: 8 additions & 0 deletions docs/basics/structure/book.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,14 @@ The book will be treated as a book in index mode (that means, no big "node view"

See also [Leaflets](/docs/advanced/leaflets) for more information.

### **allow_open_book_with_invalid_links** (Boolean, _optional_)

Default value: `false`.

If set to `true`, the book will not throw an error when trying to open a book with invalid book links. Instead, the link will be rendered in red with a tooltip explaining that the link is invalid.

The main use for this is for mods that have external translators for their books, where translations might be outdated after entries have been removed or moved.

## Usage Examples

`/data/<mod_id>/modonomicon/books/<book_id>/book.json`:
Expand Down
8 changes: 3 additions & 5 deletions docs/getting-started/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@ Even for modpack creators it is recommended to follow this process. Datagen is a

## Manually creating books

:::warn
:::warning

It is not recommended to manually create books. It is much more convenient and error-free to use datagen.
It is not recommended to manually create books. It is much more convenient and error-free to use datagen. JSON is not a great format for text editing, and can be annoying to properly format text.

:::

If you instead want to manually create a book by editign JSON files directly there is currently no guide, however you can look at the generated results of the demo book **[here](https://github.com/klikli-dev/modonomicon/tree/HEAD/neo/src/generated/resources/data/modonomicon/modonomicon/books)**.

Further, you can reference the [Structure](../basics/structure/) section to learn about the file structures.
If you instead want to manually create a book by creating and editing JSON files directly, follow **[Step by Step Guide for a Book via Datapack](./step-by-step-with-datapack/)**.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ sidebar_position: 10
# Step by Step Guide for Book Datagen

This page will guide you through the recommended and most convenient way to create a book.
It uses the Demo Book modonomicon provides as a starting point.
It uses the [Demo Book](https://github.com/klikli-dev/modonomicon/tree/HEAD/neo/src/generated/resources/data/modonomicon/modonomicon/books) modonomicon provides as a starting point.

:::tip

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
sidebar_position: 10
---

# Step by Step Guide for a Book via Datapack

This page will guide you through a reasonably easy way to create a book _without_ datagen.
It uses the [Demo Book](https://github.com/klikli-dev/modonomicon/tree/HEAD/neo/src/generated/resources/data/modonomicon/modonomicon/books) modonomicon provides as a starting point.

:::tip

If you run into any issues or have any questions, join our Discord: **https://dsc.gg/klikli**

:::

:::warning

It is not recommended to manually create books. It is much more convenient and error-free to use [datagen](../step-by-step-with-datagen/). JSON is not a great format for text editing, and can be annoying to properly format text.

:::


The best approach is to create a datapack from the demo book, and then modify and extend it to your needs. This saves you a lot of time and effort in manually creating a valid file structure for your book.

:::tip

If you are already well-versed with datapacks you can look at the demo book **[here](https://github.com/klikli-dev/modonomicon/tree/HEAD/neo/src/generated/resources/data/modonomicon/modonomicon/books)** and the demo multiblocks used by the book **[here](https://github.com/klikli-dev/modonomicon/tree/HEAD/neo/src/generated/resources/data/modonomicon/modonomicon/multiblocks)** and simply download the individual files you want to use as a reference.

:::

First, download the modonomicon source code, as it contains the demo book:
1. Start by visiting https://github.com/klikli-dev/modonomicon
2. Find the green "Code" button and click it. Then click "Download ZIP" at the bottom of the dropdown menu.
3. Extract the ZIP file to a location of your choice.
17 changes: 17 additions & 0 deletions docs/getting-started/step-by-step-with-datapack/step1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
sidebar_position: 10
---

# Step 1: Set up an empty datapack

1. Set up a folder structure as required by minecraft: https://minecraft.wiki/w/Data_pack#Folder_structure.
1. You do not need to create all the subfolders of the `data` folder, you can keep `data` empty in the first step.

2. Now create a folder for your namespace. Usually your namespace is your mod id or modpack id (e.g. the modpack name in all lowercase with no spaces) (See also https://minecraft.wiki/w/Resource_location#Namespaces)

3. In your namespace folder, create a folder `/modonomicon/`.

4. In the `/modonomicon/` folder, create a folder `/books/` and `/multiblocks/`:
:::info
If you do not plan on having any multiblocks or multiblock pages, you can skip the `/multiblocks/` folder.
:::
22 changes: 22 additions & 0 deletions docs/getting-started/step-by-step-with-datapack/step2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
sidebar_position: 20
---

# Step 2: Copy demo content into your datapack


1. In your file explorer go to the folder you extracted and then into `<extracted_folder>\neo\src\generated\resources\data\modonomicon\modonomicon\books\`.

2. Copy the `demo` folder (or if you want to make a leaflet, the `demo_leaflet` folder) and paste it in your datapack's `/modonomicon/books/` folder.

3. In your file explorer go to the folder you extracted and then into `<extracted_folder>\neo\src\generated\resources\data\modonomicon\modonomicon\multiblocks\`.

4. Copy all `.json` files and paste them in your datapack's `/modonomicon/multiblocks/` folder.
:::info
If you do not plan on having any multiblocks or multiblock pages, you can skip copying the contents of the `/multiblocks/` folder.
:::

5. If you did not set up multiblocks, go into your datapack folder `<your datapack>/data/<your namespace>/modonomicon/books/demo/entries/features/` and delete the `multiblock.json` file.
:::info
If you do not delete that file, this multiblock entry will look for the multiblocks in the `/multiblocks/` folder and will throw an error if it does not find them.
:::
18 changes: 18 additions & 0 deletions docs/getting-started/step-by-step-with-datapack/step3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
sidebar_position: 30
---

# Step 3: Test and extend the Demo Book

You can now test your datapack in game. An item named `book.modonomicon.demo.name` should be available in the Modonomicon creative tab and JEI/REI/EMI.

When you first open the book, it will not have proper texts instead it will have contents like `book.modonomicon.demo.features.spotlight.description`.

Both the weird book name and weird content texts happen because the demo book uses the minecraft translation system. You can either create a resource pack with a language file (you can copy individual lines or the entire file from https://github.com/klikli-dev/modonomicon/blob/version/1.21.1/neo/src/generated/resources/assets/modonomicon/lang/en_us.json), or you can directly type your desired text in the json files.

:::tip
It is recommended to use the translation system, otherwise it is impossible for others to translate your book.
:::

**You can now edit the demo book to your liking to make your own book**.
Reference the [Basics](../basics/) and [Advanced](../advanced/) sections to learn about the valid JSON keys and structures.

0 comments on commit 30358fb

Please sign in to comment.