mirror of
https://github.com/Dreeam-qwq/Gale.git
synced 2025-12-21 15:59:28 +00:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@681c013 Bundle spark (#11093) PaperMC/Paper@5fee9c6 Move configuration option to a system property PaperMC/Paper@aa3b356 Improve server startup logging (#11110) PaperMC/Paper@9aea240 Properly lookup plugin classes when looked up by spark PaperMC/Paper@7e91a2c Update the bundled spark version
36 lines
2.0 KiB
Diff
36 lines
2.0 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
|
Date: Sun, 25 Dec 2022 20:51:32 +0100
|
|
Subject: [PATCH] Optimize matching item checks
|
|
|
|
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
|
Gale - https://galemc.org
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java
|
|
index 96427414e5af8663587a70608d66cf98516cf224..fd939864da9f79c56c8cbfa3c521e2d12e6e33cd 100644
|
|
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
|
|
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
|
|
@@ -851,7 +851,7 @@ public final class ItemStack implements DataComponentHolder {
|
|
}
|
|
|
|
public static boolean matches(ItemStack left, ItemStack right) {
|
|
- return left == right ? true : (left.getCount() != right.getCount() ? false : ItemStack.isSameItemSameComponents(left, right));
|
|
+ return left == right || (left.getCount() == right.getCount() && ItemStack.isSameItemSameComponents(left, right)); // Gale - optimize identical item checks
|
|
}
|
|
|
|
/** @deprecated */
|
|
@@ -871,11 +871,11 @@ public final class ItemStack implements DataComponentHolder {
|
|
}
|
|
|
|
public static boolean isSameItem(ItemStack left, ItemStack right) {
|
|
- return left.is(right.getItem());
|
|
+ return left == right || left.is(right.getItem()); // Gale - optimize identical item checks
|
|
}
|
|
|
|
public static boolean isSameItemSameComponents(ItemStack stack, ItemStack otherStack) {
|
|
- return !stack.is(otherStack.getItem()) ? false : (stack.isEmpty() && otherStack.isEmpty() ? true : Objects.equals(stack.components, otherStack.components));
|
|
+ return stack == otherStack || (stack.is(otherStack.getItem()) && (stack.isEmpty() && otherStack.isEmpty() || Objects.equals(stack.components, otherStack.components))); // Gale - optimize identical item checks
|
|
}
|
|
|
|
public static MapCodec<ItemStack> lenientOptionalFieldOf(String fieldName) {
|