Skip to content

Commit

Permalink
chore(guide-book): refactor guide book datagen
Browse files Browse the repository at this point in the history
  • Loading branch information
Elenterius committed Nov 3, 2023
1 parent d575148 commit cdb2308
Show file tree
Hide file tree
Showing 9 changed files with 151 additions and 125 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static void gatherData(final GatherDataEvent event) {
generator.addProvider(true, new ModAdvancementProvider(generator, existingFileHelper, translationProvider));

//guide book
generator.addProvider(false, new GuideBookProvider(generator, translationProvider)); //TODO: re-enable when ready
generator.addProvider(true, new GuideBookProvider(generator, translationProvider)); //TODO: re-enable when ready

generator.addProvider(true, translationProvider);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.phys.Vec2;

public class GuideBookProvider extends AbstractBookProvider {

Expand All @@ -33,31 +34,31 @@ private ResourceLocation entryId(BookLangHelper helper) {

@Override
protected void generate() {
BookLangHelper langHelper = ModonomiconAPI.get().getLangHelper(modId);

BookLangHelper helper = ModonomiconAPI.get().getLangHelper(modId);
helper.book("guide_book");
langHelper.book("guide_book");
BookModel book = BookModel.create(GuideBookItem.GUIDE_BOOK_ID, langHelper.bookName())
.withTooltip(langHelper.bookTooltip())
.withCustomBookItem(ModItems.GUIDE_BOOK.getId()).withGenerateBookItem(false)
.withCraftingTexture(BiomancyMod.createRL("textures/gui/modonomicon/crafting_textures.png"))
.withBookContentTexture(BiomancyMod.createRL("textures/gui/modonomicon/book_content.png"))
.withBookOverviewTexture(BiomancyMod.createRL("textures/gui/modonomicon/book_overview.png"));

BookCategoryModel featuresCategory = makeFeaturesCategory(helper);
lang.add(book.getName(), "Biomancy Index");
lang.add(book.getTooltip(), "A book to test Modonomicon features for Biomancy.");

BookModel demoBook = BookModel.create(GuideBookItem.GUIDE_BOOK_ID, helper.bookName())
.withTooltip(helper.bookTooltip())
.withCustomBookItem(ModItems.GUIDE_BOOK.getId()).withGenerateBookItem(false)
.withCategories(featuresCategory)
.withCraftingTexture(BiomancyMod.createRL("textures/gui/crafting_textures.png"))
.withBookContentTexture(BiomancyMod.createRL("textures/gui/book_content.png"))
.withBookOverviewTexture(BiomancyMod.createRL("textures/gui/book_overview.png"));
BookCategoryModel featuresCategory = makeFeaturesCategory(langHelper);

lang.add(demoBook.getName(), "Biomancy Index");
lang.add(demoBook.getTooltip(), "A book to test Modonomicon features for Biomancy.");
book.withCategories(featuresCategory);

add(demoBook);
add(book);
}

private BookCategoryModel makeFeaturesCategory(BookLangHelper helper) {
helper.category("features");
private BookCategoryModel makeFeaturesCategory(BookLangHelper langHelper) {
langHelper.category("features");

EntryLocationHelper entryHelper = ModonomiconAPI.get().getEntryLocationHelper();
entryHelper.setMap(
EntryLocationHelper locationHelper = ModonomiconAPI.get().getEntryLocationHelper();
locationHelper.setMap(
"_____________________",
"__________e_d________",
"_____________________",
Expand All @@ -66,187 +67,189 @@ private BookCategoryModel makeFeaturesCategory(BookLangHelper helper) {
"_____________________"
);

var primordialCradleRecipe = makeCradleEntry(helper, entryHelper, 'p');
BookEntryModel primordialCradleRecipe = makeCradleEntry(langHelper, locationHelper.get('p')).build();

var spotlightEntry = makeSpotlightEntry(helper, entryHelper, 's');
BookEntryModel spotlightTestEntry = makeSpotlightTestEntry(langHelper, locationHelper.get('s')).build();

var entityEntry = makeEntityEntry(helper, entryHelper, 'e')
BookEntryModel fleshBlobEntry = makeFleshBlobEntry(langHelper, locationHelper.get('e'))
.withParent(BookEntryParentModel.builder().withEntryId(primordialCradleRecipe.getId()).build())
.build();

var decomposerEntry = makeDecomposerEntry(helper, entryHelper, 'd')
.withParent(BookEntryParentModel.builder().withEntryId(entityEntry.getId()).build())
BookEntryModel decomposerEntry = makeDecomposerEntry(langHelper, locationHelper.get('d'))
.withParent(BookEntryParentModel.builder().withEntryId(fleshBlobEntry.getId()).build())
.build();

BookCategoryModel categoryModel = BookCategoryModel.create(modLoc(helper.category), helper.categoryName())
.withIcon("biomancy:living_flesh")
.withEntries(primordialCradleRecipe)
.withEntries(decomposerEntry)
.withEntries(spotlightEntry)
.withEntries(entityEntry)
.withEntryTextures(BiomancyMod.createRL("textures/gui/entry_textures.png"))
.withBackground(BiomancyMod.createRL("textures/gui/category1_background.png"));
lang.add(helper.categoryName(), "Fleshy Constructs");

return categoryModel;
}

BookCategoryModel category = BookCategoryModel.create(modLoc(langHelper.category), langHelper.categoryName())
.withIcon(ModItems.LIVING_FLESH.get())
.withEntryTextures(BiomancyMod.createRL("textures/gui/modonomicon/entry_textures.png"))
.withBackground(BiomancyMod.createRL("textures/gui/modonomicon/main_background.png"))
.withEntries(primordialCradleRecipe, decomposerEntry, fleshBlobEntry)
.withEntries(spotlightTestEntry);
lang.add(langHelper.categoryName(), "Fleshy Constructs");

return category;
}

private BookEntryModel makeSpotlightEntry(BookLangHelper helper, EntryLocationHelper entryHelper, char location) {
helper.entry("spotlight");
private BookEntryModel.Builder makeSpotlightTestEntry(BookLangHelper langHelper, Vec2 location) {
langHelper.entry("spotlight");

helper.page("intro");
langHelper.page("intro");
var introPage = BookTextPageModel.builder()
.withText(helper.pageText())
.withTitle(helper.pageTitle())
.withText(langHelper.pageText())
.withTitle(langHelper.pageTitle())
.build();
lang.add(helper.pageTitle(), "Spotlight Entry");
lang.add(helper.pageText(), "Spotlight pages allow to show items (actually, ingredients).");
lang.add(langHelper.pageTitle(), "[PH] Spotlight Entry");
lang.add(langHelper.pageText(), "[PH] Spotlight pages allow to show items (actually, ingredients).");

helper.page("spotlight1");
langHelper.page("spotlight1");
var spotlight1 = BookSpotlightPageModel.builder()
.withTitle(helper.pageTitle())
.withText(helper.pageText())
.withTitle(langHelper.pageTitle())
.withText(langHelper.pageText())
.withItem(Ingredient.of(Items.APPLE))
.build();
lang.add(helper.pageTitle(), "Custom Title");
lang.add(helper.pageText(), "A sample spotlight page with custom title.");
lang.add(langHelper.pageTitle(), "[PH] Custom Title");
lang.add(langHelper.pageText(), "[PH] A sample spotlight page with custom title.");

helper.page("spotlight2");
langHelper.page("spotlight2");
var spotlight2 = BookSpotlightPageModel.builder()
.withText(helper.pageText())
.withText(langHelper.pageText())
.withItem(Ingredient.of(Items.DIAMOND))
.build();
lang.add(helper.pageText(), "A sample spotlight page with automatic title.");
lang.add(langHelper.pageText(), "[PH] A sample spotlight page with automatic title.");

var builder = BookEntryModel.builder()
.withId(entryId(helper))
.withName(helper.entryName())
.withDescription(helper.entryDescription())
.withIcon("minecraft:beacon")
.withLocation(entryHelper.get(location))
.withPages(introPage, spotlight1, spotlight2)
.build();
lang.add(helper.entryName(), "Spotlight Entry");
lang.add(helper.entryDescription(), "An entry showcasing spotlight pages.");
.withId(entryId(langHelper))
.withName(langHelper.entryName())
.withDescription(langHelper.entryDescription())
.withIcon(Items.BEACON)
.withLocation(location)
.withPages(introPage, spotlight1, spotlight2);

lang.add(langHelper.entryName(), "[PH] Spotlight Entry");
lang.add(langHelper.entryDescription(), "[PH] An entry showcasing spotlight pages.");

return builder;
}

private BookEntryModel.Builder makeEntityEntry(BookLangHelper helper, EntryLocationHelper entryHelper, char location) {
helper.entry("entity");
private BookEntryModel.Builder makeFleshBlobEntry(BookLangHelper langHelper, Vec2 location) {
langHelper.entry("mob");

helper.page("living_flesh_spotlight");
langHelper.page("living_flesh_spotlight");
var livingFleshSpotlight = BookSpotlightPageModel.builder()
.withText(helper.pageText())
.withText(langHelper.pageText())
.withItem(Ingredient.of(ModItems.LIVING_FLESH.get()))
.build();
lang.add(helper.pageText(), """
lang.add(langHelper.pageText(), """
Living Flesh is the remains of a Flesh Blob after is has been killed.
\\
It's most definitely alive, although it lacks any real intelligence or selfish will.
\\
++That isn't necessarily a bad thing though...++""");

helper.page("flesh_blob");
langHelper.page("flesh_blob");
BookEntityPageModel fleshBlobPage = BookEntityPageModel.builder()
.withText(helper.pageText())
.withEntityId(ModEntityTypes.FLESH_BLOB.getId().toString())
.withScale(1f)
.build();
lang.add(helper.pageText(), """

langHelper.page("flesh_blob_page");
BookTextPageModel fleshBlobText = BookTextPageModel.builder()
.withText(langHelper.pageText())
.build();
lang.add(langHelper.pageText(), """
A regular Flesh Blob is formed with just typical raw meat and healing agents.
\\
Has no redeeming qualities, but makes for a good house pet.""");

helper.page("hungry_flesh_blob");
langHelper.page("hungry_flesh_blob");
BookEntityPageModel hungryFleshBlobPage = BookEntityPageModel.builder()
.withEntityId(ModEntityTypes.HUNGRY_FLESH_BLOB.getId().toString())
.withScale(1f)
.build();

helper.page("hungry_flesh_blob_text");
langHelper.page("hungry_flesh_blob_text");
BookTextPageModel hungryFleshBlobText = BookTextPageModel.builder()
.withText(helper.pageText())
.withText(langHelper.pageText())
.build();
lang.add(helper.pageText(), """
lang.add(langHelper.pageText(), """
A Hungry Flesh Blob is formed by adding a few Sharp Fangs into the cradle with some raw meat and a healing agent.
\\
Maybe don't try petting this one...""");

var entryModel = BookEntryModel.builder()
.withId(entryId(helper))
.withName(helper.entryName())
.withDescription(helper.entryDescription())
.withIcon("biomancy:living_flesh")
.withLocation(entryHelper.get(location))
.withPages(livingFleshSpotlight, fleshBlobPage, fleshBlobText, hungryFleshBlobPage, hungryFleshBlobText);
lang.add(helper.entryName(), "Flesh Blobs");
lang.add(helper.entryDescription(), "Bouncy lil guys");

return entryModel;
var builder = BookEntryModel.builder()
.withId(entryId(langHelper))
.withName(langHelper.entryName())
.withDescription(langHelper.entryDescription())
.withIcon(ModItems.LIVING_FLESH.get())
.withLocation(location)
.withPages(
fleshBlobPage, fleshBlobText,
hungryFleshBlobPage, hungryFleshBlobText,
livingFleshSpotlight
);
lang.add(langHelper.entryName(), "Flesh Blobs");
lang.add(langHelper.entryDescription(), "Bouncy lil guys");

return builder;
}

private BookEntryModel.Builder makeDecomposerEntry(BookLangHelper helper, EntryLocationHelper entryHelper, char location) {
helper.entry("decomposer");
private BookEntryModel.Builder makeDecomposerEntry(BookLangHelper langHelper, Vec2 location) {
langHelper.entry("decomposer");

helper.page("spotlight");
langHelper.page("spotlight");
var introPage = BookSpotlightPageModel.builder()
.withText(helper.pageText())
.withText(langHelper.pageText())
.withItem(Ingredient.of(ModItems.DECOMPOSER.get()))
.build();
lang.add(helper.pageText(), """
By giving a Living Flesh some more meat, a few Sharp Fangs, and a Bile Gland, you make a creature that will chew up items and give you useful components for the Bio-Forge""");
lang.add(langHelper.pageText(), "By giving a Living Flesh some more meat, a few Sharp Fangs, and a Bile Gland, you make a creature that will chew up items and give you useful components for the Bio-Forge");

helper.page("crafting");
langHelper.page("crafting");
var crafting = BookCraftingRecipePageModel.builder()
.withRecipeId1("biomancy:decomposer")
.build();

var entryModel = BookEntryModel.builder()
.withId(entryId(helper))
.withName(helper.entryName())
.withDescription(helper.entryDescription())
.withIcon("biomancy:decomposer")
.withLocation(entryHelper.get(location))
var builder = BookEntryModel.builder()
.withId(entryId(langHelper))
.withName(langHelper.entryName())
.withDescription(langHelper.entryDescription())
.withIcon(ModItems.DECOMPOSER.get())
.withLocation(location)
.withPages(introPage, crafting);
lang.add(helper.entryName(), "Decomposer");
lang.add(helper.entryDescription(), "Munch, munch!");
lang.add(langHelper.entryName(), "Decomposer");
lang.add(langHelper.entryDescription(), "Munch, munch!");

return entryModel;
return builder;
}

private BookEntryModel makeCradleEntry(BookLangHelper helper, EntryLocationHelper entryHelper, char location) {
helper.entry("primordialcradleentry");
private BookEntryModel.Builder makeCradleEntry(BookLangHelper langHelper, Vec2 location) {
langHelper.entry("primordial_cradle");

helper.page("intro");
langHelper.page("intro");
var introPage = BookTextPageModel.builder()
.withText(helper.pageText())
.withTitle(helper.pageTitle())
.withText(langHelper.pageText())
.withTitle(langHelper.pageTitle())
.build();
lang.add(helper.pageTitle(), "The Primordial Cradle");
lang.add(helper.pageText(), "By filling the cradle with raw flesh and a healing agent (Instant Health Potions, Healing Additive, or Regenerative Fluid) you gain the ability to form new living beings");
lang.add(langHelper.pageTitle(), "The Primordial Cradle");
lang.add(langHelper.pageText(), "By filling the cradle with raw flesh and a healing agent (Instant Health Potions, Healing Additive, or Regenerative Fluid) you gain the ability to form new living beings");

helper.page("crafting");
langHelper.page("crafting");
var crafting = BookCraftingRecipePageModel.builder()
.withRecipeId1("biomancy:primordial_cradle")
.withRecipeId2("biomancy:primordial_living_oculus")
.withText(helper.pageText())
.withRecipeId1("biomancy:primordial_core")
.withRecipeId2("biomancy:primordial_cradle")
.withText(langHelper.pageText())
.build();
lang.add(helper.pageText(), "Primordial Cradle Recipe");

BookEntryModel entryModel = BookEntryModel.builder()
.withId(entryId(helper))
.withName(helper.entryName())
.withDescription(helper.entryDescription())
.withIcon("biomancy:primordial_cradle") //we use primordial cradle as icon
.withLocation(entryHelper.get(location)) //and we place it at the location we defined earlier in the entry helper mapping
.withPages(introPage, crafting) //finally we add our pages to the entry
.build();
lang.add(helper.entryName(), "The Primordial Cradle");
lang.add(helper.entryDescription(), "The Fun Begins");
lang.add(langHelper.pageText(), "Primordial Cradle Recipe");

return entryModel;
var builder = BookEntryModel.builder()
.withId(entryId(langHelper))
.withName(langHelper.entryName())
.withDescription(langHelper.entryDescription())
.withIcon(ModItems.PRIMORDIAL_CRADLE.get())
.withLocation(location)
.withPages(introPage, crafting);
lang.add(langHelper.entryName(), "The Primordial Cradle");
lang.add(langHelper.entryDescription(), "The Fun Begins");

return builder;
}

}
25 changes: 24 additions & 1 deletion src/generated/resources/assets/biomancy/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -433,5 +433,28 @@
"advancements.biomancy.exotic_compounds.title": "Exotic Bio-Alchemy",
"advancements.biomancy.exotic_compounds.description": "Combine organic things with exotic compounds to create cures and cleansing fluids.",
"advancements.biomancy.genetic_compounds.title": "Genetic Bio-Alchemy",
"advancements.biomancy.genetic_compounds.description": "Combine organic things with genetic compounds to create fluids that influence growth and fertility."
"advancements.biomancy.genetic_compounds.description": "Combine organic things with genetic compounds to create fluids that influence growth and fertility.",
"book.biomancy.guide_book.features.primordial_cradle.intro.title": "The Primordial Cradle",
"book.biomancy.guide_book.features.primordial_cradle.intro.text": "By filling the cradle with raw flesh and a healing agent (Instant Health Potions, Healing Additive, or Regenerative Fluid) you gain the ability to form new living beings",
"book.biomancy.guide_book.features.primordial_cradle.crafting.text": "Primordial Cradle Recipe",
"book.biomancy.guide_book.features.primordial_cradle.name": "The Primordial Cradle",
"book.biomancy.guide_book.features.primordial_cradle.description": "The Fun Begins",
"book.biomancy.guide_book.features.spotlight.intro.title": "Spotlight Entry",
"book.biomancy.guide_book.features.spotlight.intro.text": "Spotlight pages allow to show items (actually, ingredients).",
"book.biomancy.guide_book.features.spotlight.spotlight1.title": "Custom Title",
"book.biomancy.guide_book.features.spotlight.spotlight1.text": "A sample spotlight page with custom title.",
"book.biomancy.guide_book.features.spotlight.spotlight2.text": "A sample spotlight page with automatic title.",
"book.biomancy.guide_book.features.spotlight.name": "Spotlight Entry",
"book.biomancy.guide_book.features.spotlight.description": "An entry showcasing spotlight pages.",
"book.biomancy.guide_book.features.mob.living_flesh_spotlight.text": "Living Flesh is the remains of a Flesh Blob after is has been killed.\n\\\nIt's most definitely alive, although it lacks any real intelligence or selfish will.\n\\\n++That isn't necessarily a bad thing though...++",
"book.biomancy.guide_book.features.mob.flesh_blob_page.text": "A regular Flesh Blob is formed with just typical raw meat and healing agents.\n\\\nHas no redeeming qualities, but makes for a good house pet.",
"book.biomancy.guide_book.features.mob.hungry_flesh_blob_text.text": "A Hungry Flesh Blob is formed by adding a few Sharp Fangs into the cradle with some raw meat and a healing agent.\n\\\nMaybe don't try petting this one...",
"book.biomancy.guide_book.features.mob.name": "Flesh Blobs",
"book.biomancy.guide_book.features.mob.description": "Bouncy lil guys",
"book.biomancy.guide_book.features.decomposer.spotlight.text": "By giving a Living Flesh some more meat, a few Sharp Fangs, and a Bile Gland, you make a creature that will chew up items and give you useful components for the Bio-Forge",
"book.biomancy.guide_book.features.decomposer.name": "Decomposer",
"book.biomancy.guide_book.features.decomposer.description": "Munch, munch!",
"book.biomancy.guide_book.features.name": "Fleshy Constructs",
"book.biomancy.guide_book.name": "Biomancy Index",
"book.biomancy.guide_book.tooltip": "A book to test Modonomicon features for Biomancy."
}

0 comments on commit cdb2308

Please sign in to comment.