9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-28 03:19:21 +00:00
Files
Leaf/leaf-server/minecraft-patches/features/0008-Simpler-ShapelessRecipe-comparison-for-vanilla.patch
Dreeam 8b8cc98e30 Updated Upstream (Paper)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
PaperMC/Paper@cdad49b7 Do not mark plugin tickets as forced; keep correct ticket types
PaperMC/Paper@a1c4fc96 Add generic ticket identifier
PaperMC/Paper@745881bb Update Moonrise common for 1.21.5
PaperMC/Paper@e9d00eb6 Apply Moonrise patch
PaperMC/Paper@ef0f0d10 Copy Moonrise 1.21.5 update over
PaperMC/Paper@cc0f25cb Apply more feature patches
PaperMC/Paper@e7b684ed fix
PaperMC/Paper@71ccae07 Revert "move block data/state impl"
2025-04-02 16:27:31 -04:00

90 lines
3.9 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Wed, 23 Nov 2022 16:22:47 +0100
Subject: [PATCH] Simpler ShapelessRecipe comparison for vanilla
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
Gale - https://galemc.org
This patch is based on the following patch:
"Simpler ShapelessRecipes comparison for Vanilla"
By: Paul Sauve <paul@technove.co>
As part of: Airplane (https://github.com/TECHNOVE/Airplane)
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
* Airplane description *
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 *
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/net/minecraft/world/item/crafting/ShapelessRecipe.java b/net/minecraft/world/item/crafting/ShapelessRecipe.java
index d601b54b1de2f2ae44fe2b20c8116c71a6340e45..6a53e97d27d746621892ced4ca5b4a56b6bc4c23 100644
--- a/net/minecraft/world/item/crafting/ShapelessRecipe.java
+++ b/net/minecraft/world/item/crafting/ShapelessRecipe.java
@@ -23,8 +23,16 @@ public class ShapelessRecipe implements CraftingRecipe {
final List<Ingredient> ingredients;
@Nullable
private PlacementInfo placementInfo;
+ private final boolean isBukkit; // Gale - Airplane - simpler ShapelessRecipe comparison for vanilla
public ShapelessRecipe(String group, CraftingBookCategory category, ItemStack result, List<Ingredient> ingredients) {
+ // Gale start - Airplane - simpler ShapelessRecipe comparison for vanilla
+ this(group, category, result, ingredients, false);
+ }
+
+ public ShapelessRecipe(String group, CraftingBookCategory category, ItemStack result, List<Ingredient> ingredients, boolean isBukkit) {
+ this.isBukkit = isBukkit;
+ // Gale end - Airplane - simpler ShapelessRecipe comparison for vanilla
this.group = group;
this.category = category;
this.result = result;
@@ -72,6 +80,29 @@ public class ShapelessRecipe implements CraftingRecipe {
@Override
public boolean matches(CraftingInput input, Level level) {
+ // Gale start - Airplane - simpler ShapelessRecipe comparison for vanilla
+ if (!this.isBukkit) {
+ java.util.List<Ingredient> ingredients = com.google.common.collect.Lists.newArrayList(this.ingredients.toArray(new Ingredient[0]));
+
+ inventory:
+ for (int index = 0; index < input.size(); index++) {
+ ItemStack itemStack = input.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();
+ }
+ // Gale end - Airplane - simpler ShapelessRecipe comparison for vanilla
// Paper start - Improve exact choice recipe ingredients & unwrap ternary
if (input.ingredientCount() != this.ingredients.size()) {
return false;