Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fields to the recipe pages for disabling the linking of the recipe #769

Merged
merged 2 commits into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading