mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-23 19:15:32 +01:00
e4d10a6d67
Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 122289ff Add FaceAttachable interface to handle Grindstone facing in common with Switches a6db750e SPIGOT-5647: ZombieVillager entity should have getVillagerType() CraftBukkit Changes:bbe3d58e
SPIGOT-5650: Lectern.setPage(int) causes a NullPointerException3075579f
Add FaceAttachable interface to handle Grindstone facing in common with Switches95bd4238
SPIGOT-5647: ZombieVillager entity should have getVillagerType()4d975ac3
SPIGOT-5617: setBlockData does not work when NotPlayEvent is called by redstone current
69 lines
2.9 KiB
Diff
69 lines
2.9 KiB
Diff
From ee7d60b9b3c1f68c95c61c3822229dc61b9f2919 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Fri, 18 Jan 2019 00:08:15 -0500
|
|
Subject: [PATCH] Fix Custom Shapeless Custom Crafting Recipes
|
|
|
|
Mojang implemented Shapeless different than Shaped
|
|
|
|
This made the Bukkit RecipeChoice API not work for Shapeless.
|
|
|
|
This reimplements vanilla logic using the same test logic as Shaped
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/ShapelessRecipes.java b/src/main/java/net/minecraft/server/ShapelessRecipes.java
|
|
index fe03a35cc8..fb481e6586 100644
|
|
--- a/src/main/java/net/minecraft/server/ShapelessRecipes.java
|
|
+++ b/src/main/java/net/minecraft/server/ShapelessRecipes.java
|
|
@@ -63,16 +63,46 @@ public class ShapelessRecipes implements RecipeCrafting {
|
|
AutoRecipeStackManager autorecipestackmanager = new AutoRecipeStackManager();
|
|
int i = 0;
|
|
|
|
+ // Paper start
|
|
+ java.util.List<ItemStack> providedItems = new java.util.ArrayList<>();
|
|
+ co.aikar.util.Counter<ItemStack> matchedProvided = new co.aikar.util.Counter<>();
|
|
+ co.aikar.util.Counter<RecipeItemStack> matchedIngredients = new co.aikar.util.Counter<>();
|
|
+ // Paper end
|
|
for (int j = 0; j < inventorycrafting.getSize(); ++j) {
|
|
ItemStack itemstack = inventorycrafting.getItem(j);
|
|
|
|
if (!itemstack.isEmpty()) {
|
|
- ++i;
|
|
- autorecipestackmanager.a(itemstack, 1);
|
|
+ // Paper start
|
|
+ itemstack = itemstack.cloneItemStack();
|
|
+ providedItems.add(itemstack);
|
|
+ for (RecipeItemStack ingredient : ingredients) {
|
|
+ if (ingredient.test(itemstack)) {
|
|
+ matchedProvided.increment(itemstack);
|
|
+ matchedIngredients.increment(ingredient);
|
|
+ }
|
|
+ }
|
|
+ // Paper end
|
|
}
|
|
}
|
|
|
|
- return i == this.ingredients.size() && autorecipestackmanager.a(this, (IntList) null);
|
|
+ // Paper start
|
|
+ java.util.List<RecipeItemStack> ingredients = new java.util.ArrayList<>(this.ingredients);
|
|
+ providedItems.sort(java.util.Comparator.comparingInt((ItemStack c) -> (int) matchedProvided.getCount(c)).reversed());
|
|
+ ingredients.sort(java.util.Comparator.comparingInt((RecipeItemStack c) -> (int) matchedIngredients.getCount(c)));
|
|
+
|
|
+ PROVIDED:
|
|
+ for (ItemStack provided : providedItems) {
|
|
+ for (Iterator<RecipeItemStack> itIngredient = ingredients.iterator(); itIngredient.hasNext(); ) {
|
|
+ RecipeItemStack ingredient = itIngredient.next();
|
|
+ if (ingredient.test(provided)) {
|
|
+ itIngredient.remove();
|
|
+ continue PROVIDED;
|
|
+ }
|
|
+ }
|
|
+ return false;
|
|
+ }
|
|
+ return ingredients.isEmpty();
|
|
+ // Paper end
|
|
}
|
|
|
|
public ItemStack a(InventoryCrafting inventorycrafting) {
|
|
--
|
|
2.25.1
|
|
|