Skip to content

Commit 8eb8e05

Browse files
authored
Add fields to the recipe pages for disabling the linking of the recipe (#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
1 parent 9d30390 commit 8eb8e05

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

Xplat/src/main/java/vazkii/patchouli/client/book/page/abstr/PageDoubleRecipe.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ public abstract class PageDoubleRecipe<T> extends PageWithText {
1616

1717
@SerializedName("recipe") ResourceLocation recipeId;
1818
@SerializedName("recipe2") ResourceLocation recipe2Id;
19+
@SerializedName("link_recipe") boolean linkRecipe = true;
20+
@SerializedName("link_recipe2") boolean linkRecipe2 = true;
1921
String title;
2022

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

28-
recipe1 = loadRecipe(level, builder, entry, recipeId);
29-
recipe2 = loadRecipe(level, builder, entry, recipe2Id);
30+
recipe1 = loadRecipe(level, builder, entry, recipeId, linkRecipe);
31+
recipe2 = loadRecipe(level, builder, entry, recipe2Id, linkRecipe2);
3032

3133
if (recipe1 == null && recipe2 != null) {
3234
recipe1 = recipe2;
@@ -70,7 +72,7 @@ public boolean shouldRenderText() {
7072
}
7173

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

Xplat/src/main/java/vazkii/patchouli/client/book/page/abstr/PageDoubleRecipeRegistry.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ private T getRecipe(Level level, ResourceLocation id) {
2828
}
2929

3030
@Override
31-
protected T loadRecipe(Level level, BookContentsBuilder builder, BookEntry entry, ResourceLocation res) {
31+
protected T loadRecipe(Level level, BookContentsBuilder builder, BookEntry entry, ResourceLocation res, boolean linkRecipe) {
3232
if (res == null || level == null) {
3333
return null;
3434
}
@@ -39,7 +39,9 @@ protected T loadRecipe(Level level, BookContentsBuilder builder, BookEntry entry
3939
}
4040

4141
if (tempRecipe != null) {
42-
entry.addRelevantStack(builder, tempRecipe.getResultItem(level.registryAccess()), pageNum);
42+
if (linkRecipe) {
43+
entry.addRelevantStack(builder, tempRecipe.getResultItem(level.registryAccess()), pageNum);
44+
}
4345
return tempRecipe;
4446
}
4547

Xplat/src/main/resources/assets/patchouli/patchouli_books/comprehensive_test_book/en_us/entries/recipe_mapping/recipe.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
"recipe": "minecraft:diamond_sword",
99
"recipe2": "minecraft:flint_and_steel"
1010
},
11+
{
12+
"type": "patchouli:crafting",
13+
"recipe": "minecraft:fletching_table",
14+
"recipe2": "minecraft:snow",
15+
"link_recipe": false
16+
},
1117
{
1218
"type": "patchouli:smelting",
1319
"recipe": "minecraft:cooked_cod"

0 commit comments

Comments
 (0)