begin docs

This commit is contained in:
Robin 2024-07-01 21:29:15 +02:00
parent 73f92b223c
commit cc5f73bd12
16 changed files with 675 additions and 1 deletions

View File

@ -31,6 +31,8 @@ val reiVersion: String by project
val jeiVersion: String by project
val jeiMcVersion: String by project
val emiVersion: String by project
val modonomiconVersion: String by project
val commonmarkVersion: String by project
enum class RecipeViewer {
None,
@ -67,6 +69,13 @@ repositories {
url = URI.create("https://maven.terraformersmc.com/")
name = "TerraformersMC"
}
maven {
url = URI.create("https://dl.cloudsmith.io/public/klikli-dev/mods/maven/")
name = "Klikli's Maven"
content {
includeGroup("com.klikli_dev")
}
}
}
base {
@ -185,6 +194,18 @@ runs {
}
val libraries: Configuration = configurations.create("libraries")
configurations {
implementation {
extendsFrom(libraries)
}
runtimeClasspath {
extendsFrom(localRuntime.get())
}
}
dependencies {
implementation ("net.neoforged:neoforge:${neoVersion}")
@ -213,6 +234,16 @@ dependencies {
compileOnly("mezz.jei:jei-${jeiMcVersion}-neoforge-api:${jeiVersion}")
compileOnly("dev.emi:emi-neoforge:${emiVersion}:api")
implementation("com.klikli_dev:modonomicon-$jeiMcVersion-neoforge:${modonomiconVersion}")
libraries ("org.commonmark:commonmark:${commonmarkVersion}")
libraries ("org.commonmark:commonmark-ext-gfm-strikethrough:${commonmarkVersion}")
libraries ("org.commonmark:commonmark-ext-ins:${commonmarkVersion}")
//and include it in the jar
jarJar(group= "org.commonmark", name= "commonmark", version = "[${commonmarkVersion},)")
jarJar(group= "org.commonmark", name= "commonmark-ext-gfm-strikethrough", version= "[${commonmarkVersion},)")
jarJar(group= "org.commonmark", name= "commonmark-ext-ins", version= "[${commonmarkVersion},)")
// Testing
junitImplementation(platform("org.junit:junit-bom:${junitVersion}"))
junitImplementation("org.junit.jupiter:junit-jupiter-params")

View File

@ -48,4 +48,6 @@ topVersion=1.21_neo-12.0.0-1
reiVersion=16.0.729
jeiVersion=19.0.0.11
jeiMcVersion=1.21
emiVersion=1.1.8+1.21
emiVersion=1.1.8+1.21
modonomiconVersion=1.92.2
commonmarkVersion=0.22.0

View File

@ -0,0 +1,5 @@
// 1.21 2024-07-01T21:21:09.215502272 Books: environmenttech
955540622993b181de272a1d153e78d1c1670e0c data/environmenttech/modonomicon/books/introduction/book.json
6bd79338e0bff5cc553bf70174717d651f85b566 data/environmenttech/modonomicon/books/introduction/categories/the_beginning.json
882e14875c35e677d815c2d632eebcc830d2c6dd data/environmenttech/modonomicon/books/introduction/entries/the_beginning/essence.json
1714f7af5aed12ab7a97ac71b9574d2212b19adb data/environmenttech/modonomicon/books/introduction/entries/the_beginning/test_entry.json

View File

@ -0,0 +1,2 @@
// 1.21 2024-07-01T21:23:23.331603552 Languages: en_us
f52d126842ae1f5211f8c1b350fbca4b6121f7f1 assets/modonomicon/lang/en_us.json

View File

@ -0,0 +1,84 @@
{
"book.environmenttech.introduction.name": "An introduction to EnvironmentTech",
"book.environmenttech.introduction.the_beginning.essence.description": "The most important resource in the mod",
"book.environmenttech.introduction.the_beginning.essence.essence.md.text": "\n__hi__\n ~~hi~~\n*hi*",
"book.environmenttech.introduction.the_beginning.essence.essence.md.title": "Environmental Essence",
"book.environmenttech.introduction.the_beginning.essence.name": "Environmental Essence",
"book.environmenttech.introduction.the_beginning.name": "The Beginning",
"book.environmenttech.introduction.the_beginning.test_entry.description": "Test Description",
"book.environmenttech.introduction.the_beginning.test_entry.name": "Test Entry",
"book.environmenttech.introduction.the_beginning.test_entry.page1.text": "Hello and welcome to EnvironmentTech! \nThis is a Tech Mod all about your Environment. \n\nThis is a small Guide on how get started with the mod. \nBut before you begin with anything, you should try to get some basic materials like Wood, Iron, Coal and a Furnace. \nThen you can continue with the next Page. \n",
"book.environmenttech.introduction.the_beginning.test_entry.page1.title": "Your first steps!",
"book.environmenttech.introduction.the_beginning.test_entry.page2.text": "This is the ENV Collector, he is required to get started with the mod.\n",
"book.environmenttech.introduction.tooltip": "A book for beginners to get started with EnvironmentTech.",
"item.modonomicon.modonomicon": "Modonomicon",
"itemGroup.modonomicon": "Modonomicon",
"modonomicon.command.error.load_progress": "Invalid unlock code!",
"modonomicon.command.error.load_progress_client": "Failed to decode unlock code. Make sure to have a valid unlock code in your clipboard! Current Clipboard content: \"%s\"",
"modonomicon.command.error.unknown_book": "Unknown book: %s",
"modonomicon.command.failure": "Modonomicon tried to run a command for you (e.g. because you read an entry for the first time, or clicked a command button or command link). However, it seems you already reached the maximum use limit for this command.",
"modonomicon.command.reload_requested": "Requested reload of resource- and datapacks.",
"modonomicon.command.success.load_progress": "Successfully loaded progress for book: %s.",
"modonomicon.command.success.reload_requested": "Successfully reloaded resource- and datapacks.",
"modonomicon.command.success.reset_book": "Successfully reset book: %s",
"modonomicon.command.success.save_progress": "Saved progress for book: %s. The unlock code has been copied to your clipboard.",
"modonomicon.gui.add_bookmark": "Add Bookmark",
"modonomicon.gui.book.index_list_title": "Categories",
"modonomicon.gui.bookmarks.entry_list_title": "Bookmark Entries",
"modonomicon.gui.bookmarks.info": "To navigate to a bookmark, click on it in this list.\n\\\n\\\nTo add a bookmark, open an entry and click the \"Add Bookmark\" button on the bottom right.\n\\\n\\\nTo remove a bookmark, navigate to it and click the \"Remove Bookmark\" button on the bottom right.\n",
"modonomicon.gui.bookmarks.no_results": "No entries yet.",
"modonomicon.gui.bookmarks.screen.title": "Bookmarks",
"modonomicon.gui.button.back": "Back",
"modonomicon.gui.button.back.tooltip": "Go back to the last page you visited",
"modonomicon.gui.button.exit": "Exit",
"modonomicon.gui.button.next_page": "Next Page",
"modonomicon.gui.button.previous_page": "Previous Page",
"modonomicon.gui.button.read_all": "Mark all entries as read",
"modonomicon.gui.button.read_all.tooltip.none": "There are currently §lno unread§r unlocked entries.",
"modonomicon.gui.button.read_all.tooltip.read_all": "Mark §call§r (even locked) entries as read.",
"modonomicon.gui.button.read_all.tooltip.read_unlocked": "Mark all §aunlocked§r entries as read.",
"modonomicon.gui.button.read_all.tooltip.shift": "Shift-Click to mark §call§r (even locked) entries as read.",
"modonomicon.gui.button.read_all.tooltip.shift_warning": "§l§cWarning:§r This may make it harder to read progress-oriented books.",
"modonomicon.gui.button.visualize": "Show Multiblock Preview",
"modonomicon.gui.button.visualize.tooltip": "Show Multiblock Preview",
"modonomicon.gui.category.index_list_title": "Entries",
"modonomicon.gui.hover.book_entry_link_locked_info": "You need to unlock this entry before you can open the link!",
"modonomicon.gui.hover.book_entry_link_locked_info.hint": "Hint: The entry is in the Category: %s",
"modonomicon.gui.hover.book_link": "Go to: %s",
"modonomicon.gui.hover.book_link_locked": "%s.\n%s",
"modonomicon.gui.hover.book_page_link_locked_info": "You need to unlock this page before you can open the link!",
"modonomicon.gui.hover.book_page_link_locked_info.hint": "Hint: The page is in the Entry %s, under the Category %s",
"modonomicon.gui.hover.command_link": "Click to run linked command. Hold down shift to show command.",
"modonomicon.gui.hover.command_link.unavailable": "You already used this command too many times, you cannot use it again.",
"modonomicon.gui.hover.http_link": "Visit: %s",
"modonomicon.gui.hover.item_link_info": "Click to show recipe in JEI, Shift-Click to show usage.",
"modonomicon.gui.hover.item_link_info.no_jei": "Install JEI to show recipe/usage on click.",
"modonomicon.gui.hover.item_link_info_line2": "Will not do anything, if no recipe/usage is found.",
"modonomicon.gui.no_errors_found": "No errors found. You should not see this page!",
"modonomicon.gui.open_bookmarks": "Open Bookmarks",
"modonomicon.gui.open_search": "Open Search",
"modonomicon.gui.page.entity.loading_error": "Failed to load entity",
"modonomicon.gui.recipe_page.recipe_missing": "Recipe %s was not found! This may be an issue with the mod, or the modpack may have disabled it.",
"modonomicon.gui.remove_bookmark": "Remove Bookmark",
"modonomicon.gui.search.entry.locked": "(Locked)",
"modonomicon.gui.search.entry_list_title": "Entries",
"modonomicon.gui.search.info": "To search for entries, simply start typing what you are looking for.\n",
"modonomicon.gui.search.no_results": "No Results",
"modonomicon.gui.search.sad": ":(",
"modonomicon.gui.search.screen.title": "Search in Book",
"modonomicon.multiblock.complete": "Complete!",
"modonomicon.multiblock.not_anchored": "Right-Click a Block to anchor the Structure.",
"modonomicon.multiblock.remove_blocks": " (Clear blocks marked in red)",
"modonomicon.subtitle.turn_page": "Turn Page",
"tooltip.modonomicon.condition.advancement": "Requires Advancement: %s",
"tooltip.modonomicon.condition.advancement.hidden": "Hidden Advancement",
"tooltip.modonomicon.condition.advancement.loading": "Loading ...",
"tooltip.modonomicon.condition.entry_read": "Requires read Entry: %s\nHint: Mark all entries as read with the \"eye\" button at the top right.",
"tooltip.modonomicon.condition.entry_unlocked": "Requires unlocked Entry: %s",
"tooltip.modonomicon.condition.has_entries": "Requires that category %s has loaded entries",
"tooltip.modonomicon.condition.mod_loaded": "Requires loaded mod: %s",
"tooltip.modonomicon.fluid.amount": "%s mb",
"tooltip.modonomicon.fluid.amount_and_capacity": "%s / %s mb",
"tooltip.modonomicon.no_book_found_for_stack": "No book found for this item in the modonomicon book database! Nbt: %s",
"tooltip.modonomicon.recipe.crafting_shapeless": "Shapeless"
}

View File

@ -0,0 +1,64 @@
{
"auto_add_read_conditions": false,
"book_content_texture": "modonomicon:textures/gui/book_content.png",
"book_overview_texture": "modonomicon:textures/gui/book_overview.png",
"book_text_offset_height": 0,
"book_text_offset_width": -5,
"book_text_offset_x": 5,
"book_text_offset_y": 0,
"bottom_frame_overlay": {
"frame_height": 8,
"frame_width": 72,
"frame_x_offset": 0,
"frame_y_offset": -4,
"texture": "modonomicon:textures/gui/book_frame_bottom_overlay.png",
"texture_height": 256,
"texture_width": 256
},
"category_button_icon_scale": 1.0,
"category_button_x_offset": 0,
"category_button_y_offset": 0,
"crafting_texture": "modonomicon:textures/gui/crafting_textures.png",
"creative_tab": "modonomicon:modonomicon",
"default_title_color": 0,
"description": "",
"display_mode": "node",
"font": "modonomicon:default",
"frame_texture": "modonomicon:textures/gui/book_frame.png",
"generate_book_item": true,
"left_frame_overlay": {
"frame_height": 70,
"frame_width": 7,
"frame_x_offset": 3,
"frame_y_offset": 0,
"texture": "modonomicon:textures/gui/book_frame_left_overlay.png",
"texture_height": 256,
"texture_width": 256
},
"model": "modonomicon:modonomicon_green",
"name": "book.environmenttech.introduction.name",
"page_display_mode": "double_page",
"read_all_button_y_offset": 0,
"right_frame_overlay": {
"frame_height": 70,
"frame_width": 8,
"frame_x_offset": -4,
"frame_y_offset": 0,
"texture": "modonomicon:textures/gui/book_frame_right_overlay.png",
"texture_height": 256,
"texture_width": 256
},
"search_button_x_offset": 0,
"search_button_y_offset": 0,
"single_page_texture": "modonomicon:textures/gui/single_page_entry.png",
"tooltip": "book.environmenttech.introduction.tooltip",
"top_frame_overlay": {
"frame_height": 7,
"frame_width": 72,
"frame_x_offset": 0,
"frame_y_offset": 4,
"texture": "modonomicon:textures/gui/book_frame_top_overlay.png",
"texture_height": 256,
"texture_width": 256
}
}

View File

@ -0,0 +1,16 @@
{
"background": "modonomicon:textures/gui/dark_slate_seamless.png",
"background_height": 512,
"background_parallax_layers": [],
"background_texture_zoom_multiplier": 1.0,
"background_width": 512,
"description": "",
"display_mode": "node",
"entry_textures": "modonomicon:textures/gui/entry_textures.png",
"icon": {
"item": "environmenttech:env_collector"
},
"name": "book.environmenttech.introduction.the_beginning.name",
"show_category_button": true,
"sort_number": 0
}

View File

@ -0,0 +1,36 @@
{
"background_u_index": 0,
"background_v_index": 0,
"category": "environmenttech:the_beginning",
"description": "book.environmenttech.introduction.the_beginning.essence.description",
"hide_while_locked": false,
"icon": {
"item": "environmenttech:environmental_essence"
},
"name": "book.environmenttech.introduction.the_beginning.essence.name",
"pages": [
{
"type": "modonomicon:text",
"anchor": "",
"condition": {
"type": "modonomicon:none"
},
"show_title_separator": true,
"text": "book.environmenttech.introduction.the_beginning.essence.essence.md.text",
"title": "book.environmenttech.introduction.the_beginning.essence.essence.md.title",
"use_markdown_in_title": false
}
],
"parents": [
{
"draw_arrow": true,
"entry": "environmenttech:the_beginning/test_entry",
"line_enabled": true,
"line_reversed": false
}
],
"show_when_any_parent_unlocked": false,
"sort_number": 1,
"x": 2,
"y": 0
}

View File

@ -0,0 +1,39 @@
{
"background_u_index": 0,
"background_v_index": 0,
"category": "environmenttech:the_beginning",
"description": "book.environmenttech.introduction.the_beginning.test_entry.description",
"hide_while_locked": false,
"icon": {
"item": "environmenttech:env_collector"
},
"name": "book.environmenttech.introduction.the_beginning.test_entry.name",
"pages": [
{
"type": "modonomicon:text",
"anchor": "",
"condition": {
"type": "modonomicon:none"
},
"show_title_separator": true,
"text": "book.environmenttech.introduction.the_beginning.test_entry.page1.text",
"title": "book.environmenttech.introduction.the_beginning.test_entry.page1.title",
"use_markdown_in_title": false
},
{
"type": "modonomicon:crafting_recipe",
"anchor": "",
"condition": {
"type": "modonomicon:none"
},
"recipe_id_1": "environmenttech:env_collector_block_item",
"text": "book.environmenttech.introduction.the_beginning.test_entry.page2.text",
"title1": "",
"title2": ""
}
],
"show_when_any_parent_unlocked": false,
"sort_number": 0,
"x": 0,
"y": 0
}

View File

@ -8,6 +8,9 @@ package robaertschi.environmenttech.datagen;
import java.util.concurrent.CompletableFuture;
import com.klikli_dev.modonomicon.api.datagen.LanguageProviderCache;
import com.klikli_dev.modonomicon.api.datagen.NeoBookProvider;
import com.klikli_dev.modonomicon.datagen.EnUsProvider;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.neoforge.common.data.ExistingFileHelper;
@ -17,6 +20,8 @@ import net.minecraft.core.HolderLookup;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.PackOutput;
import robaertschi.environmenttech.datagen.book.DocsBook;
import static robaertschi.environmenttech.ET.MODID;
@EventBusSubscriber(bus = EventBusSubscriber.Bus.MOD, modid = MODID)
@ -42,5 +47,11 @@ public class ETDatagen {
event.includeClient(),
new ETItemModelProvider(output, existingFileHelper)
);
var enUsCache = new LanguageProviderCache("en_us");
generator.addProvider(event.includeServer(), NeoBookProvider.of(event,
new DocsBook(MODID, enUsCache)));
generator.addProvider(event.includeClient(), new EnUsProvider(generator.getPackOutput(), enUsCache));
}
}

View File

@ -0,0 +1,53 @@
/*
* EnvironmentTech Copyright (C) 2024 Robin Bärtschi
* This program comes with ABSOLUTELY NO WARRANTY; for details open the file LICENSE at the root of the source code.
* This is free software, and you are welcome to redistribute it
* under certain conditions; read the LICENSE file at the root of the source code for details.
*/
package robaertschi.environmenttech.datagen.book;
import java.util.function.BiConsumer;
import com.klikli_dev.modonomicon.api.datagen.SingleBookSubProvider;
import com.klikli_dev.modonomicon.api.datagen.book.BookModel;
import net.minecraft.resources.ResourceLocation;
import robaertschi.environmenttech.datagen.book.categories.FirstCategory;
public class DocsBook extends SingleBookSubProvider {
public static final String ID = "introduction";
public DocsBook(String modId, BiConsumer<String, String> defaultLang) {
super(ID, modId, defaultLang);
}
@Override
protected BookModel additionalSetup(BookModel book) {
return book.withModel(ResourceLocation.parse("modonomicon:modonomicon_green"))
.withBookTextOffsetX(5)
.withBookTextOffsetY(0)
.withBookTextOffsetWidth(-5);
}
@Override
protected void registerDefaultMacros() {
}
@Override
protected void generateCategories() {
var testCategory = this.add(new FirstCategory(this).generate());
}
@Override
protected String bookName() {
return "An introduction to EnvironmentTech";
}
@Override
protected String bookTooltip() {
return "A book for beginners to get started with EnvironmentTech.";
}
}

View File

@ -0,0 +1,70 @@
/*
* EnvironmentTech Copyright (C) 2024 Robin Bärtschi
* This program comes with ABSOLUTELY NO WARRANTY; for details open the file LICENSE at the root of the source code.
* This is free software, and you are welcome to redistribute it
* under certain conditions; read the LICENSE file at the root of the source code for details.
*/
package robaertschi.environmenttech.datagen.book.categories;
import com.klikli_dev.modonomicon.api.datagen.book.page.BookRecipePageModel;
import lombok.SneakyThrows;
import java.util.List;
import com.klikli_dev.modonomicon.api.datagen.CategoryProvider;
import com.klikli_dev.modonomicon.api.datagen.ModonomiconProviderBase;
import com.klikli_dev.modonomicon.api.datagen.book.BookIconModel;
import org.apache.commons.lang3.tuple.Pair;
import robaertschi.environmenttech.datagen.book.categories.entries.EnvCollectorEntry;
import robaertschi.environmenttech.datagen.book.categories.entries.MDEntry;
import robaertschi.environmenttech.datagen.book.categories.test.TestEntry;
import robaertschi.environmenttech.level.item.ETItems;
public class FirstCategory extends CategoryProvider {
public static final String ID = "the_beginning";
public FirstCategory(ModonomiconProviderBase parent) {
super(parent);
}
@Override
protected String[] generateEntryMap() {
return new String[]{
"_____________________",
"_____________________",
"__________x_y________",
"_____________________",
"_____________________"
};
}
@SneakyThrows
@Override
protected void generateEntries() {
// var test = this.add();
var collector = this.add(new EnvCollectorEntry(this).generate('x'));
var mdEntry = this.add(new MDEntry(this,
BookIconModel.create(ETItems.ENVIRONMENTAL_ESSENCE_ITEM),
"essence",
"Environmental Essence",
"The most important resource in the mod",
List.of(Pair.of("essence.md", "Environmental Essence"))).generate('y')).withParent(collector);
}
@Override
protected String categoryName() {
return "The Beginning";
}
@Override
protected BookIconModel categoryIcon() {
return BookIconModel.create(ETItems.ENV_COLLECTOR_BLOCK_ITEM.get());
}
@Override
public String categoryId() {
return ID;
}
}

View File

@ -0,0 +1,72 @@
/*
* EnvironmentTech Copyright (C) 2024 Robin Bärtschi
* This program comes with ABSOLUTELY NO WARRANTY; for details open the file LICENSE at the root of the source code.
* This is free software, and you are welcome to redistribute it
* under certain conditions; read the LICENSE file at the root of the source code for details.
*/
package robaertschi.environmenttech.datagen.book.categories.entries;
import com.klikli_dev.modonomicon.api.datagen.CategoryProviderBase;
import com.klikli_dev.modonomicon.api.datagen.EntryBackground;
import com.klikli_dev.modonomicon.api.datagen.EntryProvider;
import com.klikli_dev.modonomicon.api.datagen.book.BookIconModel;
import com.klikli_dev.modonomicon.api.datagen.book.page.BookCraftingRecipePageModel;
import com.klikli_dev.modonomicon.api.datagen.book.page.BookTextPageModel;
import com.mojang.datafixers.util.Pair;
import robaertschi.environmenttech.ET;
import robaertschi.environmenttech.level.item.ETItems;
public class EnvCollectorEntry extends EntryProvider {
public static final String ID = "test_entry";
public EnvCollectorEntry(CategoryProviderBase parent) {
super(parent);
}
@Override
protected void generatePages() {
this.page("page1", () -> BookTextPageModel.create()
.withTitle(this.context().pageTitle())
.withText(this.context().pageText()));
this.pageTitle("Your first steps!");
this.pageText("""
Hello and welcome to EnvironmentTech! \s
This is a Tech Mod all about your Environment. \s
This is a small Guide on how get started with the mod. \s
But before you begin with anything, you should try to get some basic materials like Wood, Iron, Coal and a Furnace. \s
Then you can continue with the next Page. \s
""");
this.page("page2", () -> BookCraftingRecipePageModel.create().withRecipeId1(ET.id("env_collector_block_item")).withText(this.context().pageText()));
this.pageText("""
This is the ENV Collector, he is required to get started with the mod.
""");
}
@Override
protected String entryName() {
return "Test Entry";
}
@Override
protected String entryDescription() {
return "Test Description";
}
@Override
protected Pair<Integer, Integer> entryBackground() {
return EntryBackground.DEFAULT;
}
@Override
protected BookIconModel entryIcon() {
return BookIconModel.create(ETItems.ENV_COLLECTOR_BLOCK_ITEM);
}
@Override
protected String entryId() {
return ID;
}
}

View File

@ -0,0 +1,116 @@
/*
* EnvironmentTech Copyright (C) 2024 Robin Bärtschi
* This program comes with ABSOLUTELY NO WARRANTY; for details open the file LICENSE at the root of the source code.
* This is free software, and you are welcome to redistribute it
* under certain conditions; read the LICENSE file at the root of the source code for details.
*/
package robaertschi.environmenttech.datagen.book.categories.entries;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import com.klikli_dev.modonomicon.api.datagen.CategoryProviderBase;
import com.klikli_dev.modonomicon.api.datagen.EntryBackground;
import com.klikli_dev.modonomicon.api.datagen.EntryProvider;
import com.klikli_dev.modonomicon.api.datagen.book.BookIconModel;
import com.klikli_dev.modonomicon.api.datagen.book.page.BookPageModel;
import com.klikli_dev.modonomicon.api.datagen.book.page.BookTextPageModel;
import org.apache.commons.lang3.tuple.Pair;
import static robaertschi.environmenttech.ET.MODID;
public class MDEntry extends EntryProvider {
public final String id;
public final BookIconModel iconModel;
public final String name;
public final String description;
public final List<Page> pages;
public final List<BookPageModel<?>> otherPages;
public MDEntry(CategoryProviderBase parent,
BookIconModel iconModel,
String id,
String name,
String description,
List<Pair<String, String>> pages
) throws IOException {
this(parent, iconModel, id, name, description, pages, List.of());
}
/**
* The markdown files should be in assets/environmenttech/entries/$id/[name]
* @param parent Parent
* @param id ID for the entry
* @param pages A Pair, first is the markdown file name, second is the page title.
* @throws IOException When transferring from the file to a String fails.
*/
public MDEntry(CategoryProviderBase parent,
BookIconModel iconModel,
String id,
String name,
String description,
List<Pair<String, String>> pages,
List<BookPageModel<?>> otherPages
) throws IOException {
super(parent);
this.id = id;
this.iconModel = iconModel;
this.name = name;
this.description = description;
this.pages = new ArrayList<>();
this.otherPages = otherPages;
for (var page : pages) {
// ResourceLocation.fromNamespaceAndPath(MODID, page.getLeft()).withPrefix("entries/"+id+"/")
try(var stream = getClass().getProtectionDomain().getClassLoader().getResourceAsStream("assets/"+MODID+"/entries/" + id + "/" + page.getLeft())) {
assert stream != null;
var outputStream = new ByteArrayOutputStream();
stream.transferTo(outputStream);
this.pages.add(new Page(page.getLeft(), page.getRight(), outputStream.toString()));
}
}
}
@Override
protected void generatePages() {
for (var page : pages) {
this.page(page.filename(), () -> BookTextPageModel.create()
.withText(this.context.pageText())
.withTitle(this.context.pageTitle()));
this.pageText(page.md());
this.pageTitle(page.title());
}
}
@Override
protected String entryName() {
return name;
}
@Override
protected String entryDescription() {
return description;
}
@Override
protected com.mojang.datafixers.util.Pair<Integer, Integer> entryBackground() {
return EntryBackground.DEFAULT;
}
@Override
protected BookIconModel entryIcon() {
return iconModel;
}
@Override
protected String entryId() {
return id;
}
public record Page(String filename, String title, String md) {}
}

View File

@ -0,0 +1,69 @@
/*
* EnvironmentTech Copyright (C) 2024 Robin Bärtschi
* This program comes with ABSOLUTELY NO WARRANTY; for details open the file LICENSE at the root of the source code.
* This is free software, and you are welcome to redistribute it
* under certain conditions; read the LICENSE file at the root of the source code for details.
*/
package robaertschi.environmenttech.datagen.book.categories.test;
import com.klikli_dev.modonomicon.api.datagen.CategoryProviderBase;
import com.klikli_dev.modonomicon.api.datagen.EntryBackground;
import com.klikli_dev.modonomicon.api.datagen.EntryProvider;
import com.klikli_dev.modonomicon.api.datagen.book.BookIconModel;
import com.klikli_dev.modonomicon.api.datagen.book.page.BookTextPageModel;
import com.mojang.datafixers.util.Pair;
import robaertschi.environmenttech.level.item.ETItems;
public class TestEntry extends EntryProvider {
public static final String ID = "test_entry";
public TestEntry(CategoryProviderBase parent) {
super(parent);
}
@Override
protected void generatePages() {
this.page("page1", () -> BookTextPageModel.create()
.withTitle(this.context().pageTitle())
.withText(this.context().pageText()));
this.pageTitle("Test Entry");
this.pageText("""
**Bold** \s
*Italics* \s
++Underlined++
""");
this.page("page2", () -> BookTextPageModel.create().withText(this.context().pageText()));
this.pageText("""
~~Stricken~~\s
""");
}
@Override
protected String entryName() {
return "Test Entry";
}
@Override
protected String entryDescription() {
return "Test Description";
}
@Override
protected Pair<Integer, Integer> entryBackground() {
return EntryBackground.DEFAULT;
}
@Override
protected BookIconModel entryIcon() {
return BookIconModel.create(ETItems.ENV_COLLECTOR_BLOCK_ITEM);
}
@Override
protected String entryId() {
return ID;
}
}

View File

@ -0,0 +1,4 @@
__hi__
~~hi~~
*hi*