Skip to content

Commit

Permalink
Add fields to the recipe pages for disabling the linking of the recipe (
Browse files Browse the repository at this point in the history
#769)

* Add fields to the double recipe page for disabling the linking of each recipe
* Add a double recipe page to the recipe_mapping recipe entry
  • Loading branch information
Mrbysco authored Nov 24, 2024
1 parent 9d30390 commit 8eb8e05
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public abstract class PageDoubleRecipe<T> extends PageWithText {

@SerializedName("recipe") ResourceLocation recipeId;
@SerializedName("recipe2") ResourceLocation recipe2Id;
@SerializedName("link_recipe") boolean linkRecipe = true;
@SerializedName("link_recipe2") boolean linkRecipe2 = true;
String title;

protected transient T recipe1, recipe2;
Expand All @@ -25,8 +27,8 @@ public abstract class PageDoubleRecipe<T> extends PageWithText {
public void build(Level level, BookEntry entry, BookContentsBuilder builder, int pageNum) {
super.build(level, entry, builder, pageNum);

recipe1 = loadRecipe(level, builder, entry, recipeId);
recipe2 = loadRecipe(level, builder, entry, recipe2Id);
recipe1 = loadRecipe(level, builder, entry, recipeId, linkRecipe);
recipe2 = loadRecipe(level, builder, entry, recipe2Id, linkRecipe2);

if (recipe1 == null && recipe2 != null) {
recipe1 = recipe2;
Expand Down Expand Up @@ -70,7 +72,7 @@ public boolean shouldRenderText() {
}

protected abstract void drawRecipe(GuiGraphics graphics, T recipe, int recipeX, int recipeY, int mouseX, int mouseY, boolean second);
protected abstract T loadRecipe(Level level, BookContentsBuilder builder, BookEntry entry, ResourceLocation loc);
protected abstract T loadRecipe(Level level, BookContentsBuilder builder, BookEntry entry, ResourceLocation loc, boolean linkRecipe);
protected abstract ItemStack getRecipeOutput(Level level, T recipe);
protected abstract int getRecipeHeight();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ private T getRecipe(Level level, ResourceLocation id) {
}

@Override
protected T loadRecipe(Level level, BookContentsBuilder builder, BookEntry entry, ResourceLocation res) {
protected T loadRecipe(Level level, BookContentsBuilder builder, BookEntry entry, ResourceLocation res, boolean linkRecipe) {
if (res == null || level == null) {
return null;
}
Expand All @@ -39,7 +39,9 @@ protected T loadRecipe(Level level, BookContentsBuilder builder, BookEntry entry
}

if (tempRecipe != null) {
entry.addRelevantStack(builder, tempRecipe.getResultItem(level.registryAccess()), pageNum);
if (linkRecipe) {
entry.addRelevantStack(builder, tempRecipe.getResultItem(level.registryAccess()), pageNum);
}
return tempRecipe;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
"recipe": "minecraft:diamond_sword",
"recipe2": "minecraft:flint_and_steel"
},
{
"type": "patchouli:crafting",
"recipe": "minecraft:fletching_table",
"recipe2": "minecraft:snow",
"link_recipe": false
},
{
"type": "patchouli:smelting",
"recipe": "minecraft:cooked_cod"
Expand Down

0 comments on commit 8eb8e05

Please sign in to comment.