craftbukkit/nms-patches/net/minecraft/world/item/crafting/RecipeItemStack.patch

53 lines
1.8 KiB
Diff
Raw Normal View History

2021-03-16 09:00:00 +11:00
--- a/net/minecraft/world/item/crafting/RecipeItemStack.java
+++ b/net/minecraft/world/item/crafting/RecipeItemStack.java
2024-10-23 02:15:00 +11:00
@@ -42,6 +42,24 @@
private final HolderSet<Item> values;
2021-11-22 09:00:00 +11:00
@Nullable
2024-10-23 02:15:00 +11:00
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(Stream<ItemStack> stacks) {
+ RecipeItemStack recipe = RecipeItemStack.of(stacks.map(ItemStack::getItem));
+ recipe.itemStacks = stacks.toList();
+ return recipe;
+ }
+ // CraftBukkit end
2024-10-23 02:15:00 +11:00
private RecipeItemStack(HolderSet<Item> holderset) {
holderset.unwrap().ifRight((list) -> {
@@ -72,6 +90,15 @@
}
2024-10-23 02:15:00 +11:00
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;
2022-12-08 03:00:00 +11:00
+ }
2024-10-23 02:15:00 +11:00
+ }
+ }
+ // CraftBukkit end
List<Holder<Item>> list = this.items();
for (int i = 0; i < list.size(); ++i) {
@@ -85,7 +112,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;
}