diff --git a/src/main/java/org/moddingx/libx/datagen/provider/patchouli/CategoryBuilder.java b/src/main/java/org/moddingx/libx/datagen/provider/patchouli/CategoryBuilder.java index b8709460..09607629 100644 --- a/src/main/java/org/moddingx/libx/datagen/provider/patchouli/CategoryBuilder.java +++ b/src/main/java/org/moddingx/libx/datagen/provider/patchouli/CategoryBuilder.java @@ -5,6 +5,7 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.ItemLike; import org.moddingx.libx.datagen.provider.patchouli.page.PageJson; +import org.moddingx.libx.mod.ModX; import java.util.ArrayList; import java.util.List; @@ -16,6 +17,7 @@ */ public class CategoryBuilder { + public final ModX mod; public final ResourceLocation id; private String name; private String description; @@ -24,7 +26,8 @@ public class CategoryBuilder { private int sort; private final List> postProcessors; - public CategoryBuilder(ResourceLocation id) { + public CategoryBuilder(ModX mod, ResourceLocation id) { + this.mod = mod; this.id = id; this.sort = -1; this.postProcessors = new ArrayList<>(); @@ -82,8 +85,8 @@ JsonObject build(BiFunction, String> translations, int num) if (this.description == null) throw new IllegalStateException("Category description not set: " + this.id); if (this.icon == null) throw new IllegalStateException("Category icon not set: " + this.id); JsonObject json = new JsonObject(); - json.addProperty("name", translations.apply(this.name, List.of("category", this.id.getNamespace(), this.id.getPath(), "name"))); - json.addProperty("description", translations.apply(this.description, List.of("category", this.id.getNamespace(), this.id.getPath(), "description"))); + json.addProperty("name", translations.apply(this.name, List.of("category", this.mod.modid, this.id.getNamespace(), this.id.getPath(), "name"))); + json.addProperty("description", translations.apply(this.description, List.of("category", this.mod.modid, this.id.getNamespace(), this.id.getPath(), "description"))); json.add("icon", PageJson.stack(this.icon)); json.addProperty("sortnum", this.sort < 0 ? num : this.sort); diff --git a/src/main/java/org/moddingx/libx/datagen/provider/patchouli/EntryBuilder.java b/src/main/java/org/moddingx/libx/datagen/provider/patchouli/EntryBuilder.java index 25181639..c45450cf 100644 --- a/src/main/java/org/moddingx/libx/datagen/provider/patchouli/EntryBuilder.java +++ b/src/main/java/org/moddingx/libx/datagen/provider/patchouli/EntryBuilder.java @@ -14,6 +14,7 @@ import org.moddingx.libx.datagen.provider.patchouli.page.PageBuilder; import org.moddingx.libx.datagen.provider.patchouli.page.PageJson; import org.moddingx.libx.impl.datagen.patchouli.content.*; +import org.moddingx.libx.mod.ModX; import java.util.ArrayList; import java.util.Arrays; @@ -26,6 +27,7 @@ */ public class EntryBuilder { + public final ModX mod; public final String id; public final ResourceLocation category; private String name; @@ -34,7 +36,8 @@ public class EntryBuilder { private Content content; private final List> postProcessors; - public EntryBuilder(String id, ResourceLocation category) { + public EntryBuilder(ModX mod, String id, ResourceLocation category) { + this.mod = mod; this.id = id; this.category = category; this.name = null; @@ -72,7 +75,7 @@ public EntryBuilder icon(ItemStack icon) { * entry belongs to. */ public EntryBuilder advancement(String path) { - return this.advancement(this.category.getNamespace(), path); + return this.advancement(this.mod.modid, path); } /** @@ -124,7 +127,7 @@ public EntryBuilder flip(String anchor) { * Adds some images to the entry. The image namespaces are set to the namespace of the category, this entry belongs to. */ public EntryBuilder image(String title, String... images) { - return this.image(title, Arrays.stream(images).map(s -> new ResourceLocation(this.category.getNamespace(), s)).toArray(ResourceLocation[]::new)); + return this.image(title, Arrays.stream(images).map(s -> new ResourceLocation(this.mod.modid, s)).toArray(ResourceLocation[]::new)); } /** @@ -139,7 +142,7 @@ public EntryBuilder image(String title, ResourceLocation... images) { * and form a double recipe page. */ public EntryBuilder crafting(String path) { - return this.crafting(this.category.getNamespace(), path); + return this.crafting(this.mod.modid, path); } /** @@ -163,7 +166,7 @@ public EntryBuilder crafting(ResourceLocation id) { * and form a double recipe page. */ public EntryBuilder smelting(String path) { - return this.smelting(this.category.getNamespace(), path); + return this.smelting(this.mod.modid, path); } /** @@ -246,7 +249,7 @@ JsonObject build(BiFunction, String> translations, Existing if (this.name == null) throw new IllegalStateException("Entry name not set: " + this.category + "/" + this.id); if (this.icon == null) throw new IllegalStateException("Entry icon not set: " + this.category + "/" + this.id); JsonObject json = new JsonObject(); - json.addProperty("name", translations.apply(this.name, List.of("entry", this.category.getNamespace(), this.category.getPath(), this.id))); + json.addProperty("name", translations.apply(this.name, List.of("entry", this.mod.modid, this.category.getNamespace(), this.category.getPath(), this.id))); json.addProperty("category", this.category.toString()); json.add("icon", PageJson.stack(this.icon)); if (this.advancement != null) { @@ -291,7 +294,7 @@ public void addAnchor(String name) { @Override public String translate(String localized) { - return translations.apply(localized, List.of("entry", EntryBuilder.this.category.getNamespace(), EntryBuilder.this.category.getPath(), EntryBuilder.this.id, "page" + this.page, "text" + (this.key++))); + return translations.apply(localized, List.of("entry", EntryBuilder.this.mod.modid, EntryBuilder.this.category.getNamespace(), EntryBuilder.this.category.getPath(), EntryBuilder.this.id, "page" + this.page, "text" + (this.key++))); } @Override diff --git a/src/main/java/org/moddingx/libx/datagen/provider/patchouli/PatchouliProviderBase.java b/src/main/java/org/moddingx/libx/datagen/provider/patchouli/PatchouliProviderBase.java index 193a7101..b3c6ad90 100644 --- a/src/main/java/org/moddingx/libx/datagen/provider/patchouli/PatchouliProviderBase.java +++ b/src/main/java/org/moddingx/libx/datagen/provider/patchouli/PatchouliProviderBase.java @@ -64,7 +64,7 @@ public PatchouliProviderBase(DatagenContext ctx, BookProperties properties) { * @see CategoryBuilder */ public CategoryBuilder category(String id) { - CategoryBuilder builder = new CategoryBuilder(new ResourceLocation(this.bookNamespace, id)); + CategoryBuilder builder = new CategoryBuilder(this.mod, new ResourceLocation(this.bookNamespace, id)); this.categories.add(builder); this.categoryIds.add(id); return builder; @@ -105,7 +105,7 @@ private EntryBuilder entry(String id, String category, boolean foreignEntry) { } else { if (!this.categoryIds.contains(category)) throw new IllegalArgumentException("Unknown category: " + category); } - EntryBuilder builder = new EntryBuilder(id, new ResourceLocation(this.bookNamespace, category)); + EntryBuilder builder = new EntryBuilder(this.mod, id, new ResourceLocation(this.bookNamespace, category)); this.entries.add(builder); return builder; }