0
0
mirror of https://hub.spigotmc.org/stash/scm/spigot/craftbukkit.git synced 2024-11-25 15:06:14 +00:00
craftbukkit/nms-patches/net/minecraft/world/item/crafting/RecipeItemStack.patch

55 lines
1.8 KiB
Diff

--- a/net/minecraft/world/item/crafting/RecipeItemStack.java
+++ b/net/minecraft/world/item/crafting/RecipeItemStack.java
@@ -42,6 +42,24 @@
private final HolderSet<Item> values;
@Nullable
private List<Holder<Item>> items;
+ // CraftBukkit start
+ @Nullable
+ private List<ItemStack> itemStacks;
+
+ public boolean isExact() {
+ return this.itemStacks != null;
+ }
+
+ public List<ItemStack> itemStacks() {
+ return this.itemStacks;
+ }
+
+ public static RecipeItemStack ofStacks(List<ItemStack> stacks) {
+ RecipeItemStack recipe = RecipeItemStack.of(stacks.stream().map(ItemStack::getItem));
+ recipe.itemStacks = stacks;
+ return recipe;
+ }
+ // CraftBukkit end
private RecipeItemStack(HolderSet<Item> holderset) {
holderset.unwrap().ifRight((list) -> {
@@ -72,6 +90,17 @@
}
public boolean test(ItemStack itemstack) {
+ // CraftBukkit start
+ if (this.isExact()) {
+ for (ItemStack itemstack1 : this.itemStacks()) {
+ if (itemstack1.getItem() == itemstack.getItem() && ItemStack.isSameItemSameComponents(itemstack, itemstack1)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+ // CraftBukkit end
List<Holder<Item>> list = this.items();
for (int i = 0; i < list.size(); ++i) {
@@ -85,7 +114,7 @@
public boolean equals(Object object) {
if (object instanceof RecipeItemStack recipeitemstack) {
- return Objects.equals(this.values, recipeitemstack.values);
+ return Objects.equals(this.values, recipeitemstack.values) && Objects.equals(this.itemStacks, recipeitemstack.itemStacks); // CraftBukkit
} else {
return false;
}