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

Make CraftComplexRecipe extend CraftingRecipe #11114

Merged
merged 5 commits into from
Jul 19, 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
@@ -0,0 +1,27 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Bjarne Koll <lynxplay101@gmail.com>
Date: Fri, 19 Jul 2024 19:09:21 +0200
Subject: [PATCH] Move CraftComplexRecipe to extend CraftingRecipe

A craft complex recipe wraps a CustomRecipe, which itself is a
CraftingRecipe.
As such, this complex recipe should also be a crafting recipe.

diff --git a/src/main/java/org/bukkit/inventory/CraftingRecipe.java b/src/main/java/org/bukkit/inventory/CraftingRecipe.java
index 37024b4736dd3897490ca51d08cf07901b01d59f..afa3de9ab78d01c448d450d8afbc7b1e7e62754c 100644
--- a/src/main/java/org/bukkit/inventory/CraftingRecipe.java
+++ b/src/main/java/org/bukkit/inventory/CraftingRecipe.java
@@ -11,8 +11,11 @@ import org.jetbrains.annotations.NotNull;
* Represents a shaped or shapeless crafting recipe.
*/
public abstract class CraftingRecipe implements Recipe, Keyed {
- private final NamespacedKey key;
- private final ItemStack output;
+ // Paper - make CraftComplexRecipe extend CraftingRecipe - start
+ protected NamespacedKey key;
+ protected ItemStack output;
+ protected CraftingRecipe() {}
+ // Paper - make CraftComplexRecipe extend CraftingRecipe - end
private String group = "";
private CraftingBookCategory category = CraftingBookCategory.MISC;

Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Bjarne Koll <lynxplay101@gmail.com>
Date: Fri, 19 Jul 2024 17:27:38 +0200
Subject: [PATCH] Move CraftComplexRecipe to extend CraftingRecipe

A craft complex recipe wraps a CustomRecipe, which itself is a
CraftingRecipe.
As such, this complex recipe should also be a crafting recipe.

diff --git a/src/main/java/net/minecraft/world/item/crafting/CustomRecipe.java b/src/main/java/net/minecraft/world/item/crafting/CustomRecipe.java
index b57a2ba09f160409b5df9a2ae7ec159af3e4bf93..69a7e500c725e9da950df30f2cc4ff5f72e527d0 100644
--- a/src/main/java/net/minecraft/world/item/crafting/CustomRecipe.java
+++ b/src/main/java/net/minecraft/world/item/crafting/CustomRecipe.java
@@ -34,7 +34,12 @@ public abstract class CustomRecipe implements CraftingRecipe {
// CraftBukkit start
@Override
public Recipe toBukkitRecipe(NamespacedKey id) {
- return new org.bukkit.craftbukkit.inventory.CraftComplexRecipe(id, this);
+ // Paper - make CraftComplexRecipe extend CraftingRecipe - start
+ final org.bukkit.craftbukkit.inventory.CraftComplexRecipe recipe = new org.bukkit.craftbukkit.inventory.CraftComplexRecipe(id, this);
+ recipe.setGroup(this.getGroup());
+ recipe.setCategory(org.bukkit.craftbukkit.inventory.CraftRecipe.getCategory(this.category()));
+ return recipe;
+ // Paper - make CraftComplexRecipe extend CraftingRecipe - end
}
// CraftBukkit end
}
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftComplexRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftComplexRecipe.java
index dcaeaa3367351eb54e2cf8e62be19ecc125a4bb4..05f42ec6177218960b22dc2c224f63cbf37d696f 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftComplexRecipe.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftComplexRecipe.java
@@ -9,12 +9,17 @@ import org.bukkit.craftbukkit.util.CraftNamespacedKey;
import org.bukkit.inventory.ComplexRecipe;
import org.bukkit.inventory.ItemStack;

-public class CraftComplexRecipe implements CraftRecipe, ComplexRecipe {
+public class CraftComplexRecipe extends org.bukkit.inventory.CraftingRecipe implements CraftRecipe, ComplexRecipe { // Paper - make CraftComplexRecipe extend CraftingRecipe

private final NamespacedKey key;
private final CustomRecipe recipe;

public CraftComplexRecipe(NamespacedKey key, CustomRecipe recipe) {
+ // Paper - make CraftComplexRecipe extend CraftingRecipe - start
+ super();
+ super.key = key;
+ super.output = ItemStack.empty();
+ // Paper - make CraftComplexRecipe extend CraftingRecipe - end
this.key = key;
this.recipe = recipe;
}
Loading