mirror of https://github.com/YatopiaMC/Yatopia.git
88 lines
4.3 KiB
Diff
88 lines
4.3 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Paul Sauve <paul@technove.co>
|
|
Date: Sat, 31 Oct 2020 18:51:38 -0500
|
|
Subject: [PATCH] Simpler ShapelessRecipes comparison for Vanilla
|
|
|
|
Paper added a fancy sorting comparison due to Bukkit recipes breaking
|
|
the vanilla one, however this is far more advanced than what you need
|
|
for all the vanilla recipes.
|
|
|
|
Airplane
|
|
Copyright (C) 2020 Technove LLC
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/item/crafting/ShapelessRecipes.java b/src/main/java/net/minecraft/world/item/crafting/ShapelessRecipes.java
|
|
index e112d149fc3a7af7f0c9a5280c94c9b03b2aba2d..d2afc367fb393c6206f9cd599d4603294d457608 100644
|
|
--- a/src/main/java/net/minecraft/world/item/crafting/ShapelessRecipes.java
|
|
+++ b/src/main/java/net/minecraft/world/item/crafting/ShapelessRecipes.java
|
|
@@ -26,8 +26,16 @@ public class ShapelessRecipes implements RecipeCrafting {
|
|
private final String group;
|
|
private final ItemStack result;
|
|
private final NonNullList<RecipeItemStack> ingredients;
|
|
+ private final boolean isBukkit; // Airplane
|
|
|
|
+ // Airplane start - add isBukkit constructor param
|
|
public ShapelessRecipes(MinecraftKey minecraftkey, String s, ItemStack itemstack, NonNullList<RecipeItemStack> nonnulllist) {
|
|
+ this(minecraftkey, s, itemstack, nonnulllist, false);
|
|
+ }
|
|
+
|
|
+ public ShapelessRecipes(MinecraftKey minecraftkey, String s, ItemStack itemstack, NonNullList<RecipeItemStack> nonnulllist, boolean isBukkit) {
|
|
+ this.isBukkit = isBukkit;
|
|
+ // Airplane end
|
|
this.key = minecraftkey;
|
|
this.group = s;
|
|
this.result = itemstack;
|
|
@@ -69,6 +77,28 @@ public class ShapelessRecipes implements RecipeCrafting {
|
|
}
|
|
|
|
public boolean a(InventoryCrafting inventorycrafting, World world) {
|
|
+ // Airplane start
|
|
+ if (!this.isBukkit) {
|
|
+ java.util.List<RecipeItemStack> ingredients = com.google.common.collect.Lists.newArrayList(this.ingredients.toArray(new RecipeItemStack[0]));
|
|
+
|
|
+ inventory: for (int index = 0; index < inventorycrafting.getSize(); index++) {
|
|
+ ItemStack itemStack = inventorycrafting.getItem(index);
|
|
+
|
|
+ if (!itemStack.isEmpty()) {
|
|
+ for (int i = 0; i < ingredients.size(); i++) {
|
|
+ if (ingredients.get(i).test(itemStack)) {
|
|
+ ingredients.remove(i);
|
|
+ continue inventory;
|
|
+ }
|
|
+ }
|
|
+ return false;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ return ingredients.isEmpty();
|
|
+ }
|
|
+ // Airplane end
|
|
+
|
|
AutoRecipeStackManager autorecipestackmanager = new AutoRecipeStackManager();
|
|
int i = 0;
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java
|
|
index de9c5ed6b03a290fe77eec719f0079fd7bd9b7f5..8c02f6fdffb59153712a3be778f9c454fd87b73b 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java
|
|
@@ -44,6 +44,6 @@ public class CraftShapelessRecipe extends ShapelessRecipe implements CraftRecipe
|
|
data.set(i, toNMS(ingred.get(i), true));
|
|
}
|
|
|
|
- MinecraftServer.getServer().getCraftingManager().addRecipe(new ShapelessRecipes(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), CraftItemStack.asNMSCopy(this.getResult()), data));
|
|
+ MinecraftServer.getServer().getCraftingManager().addRecipe(new ShapelessRecipes(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), CraftItemStack.asNMSCopy(this.getResult()), data, true)); // Airplane
|
|
}
|
|
}
|