9
0
mirror of https://github.com/Dreeam-qwq/Gale.git synced 2025-12-19 14:59:29 +00:00
Files
Gale/gale-server/minecraft-patches/features/0090-Optimize-matching-item-checks.patch
2025-01-27 09:45:41 -05:00

27 lines
1.4 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/net/minecraft/world/item/ItemStack.java b/net/minecraft/world/item/ItemStack.java
index f6c0f9275dd737c0142d6e4be07be71ad50b4732..7fbfbe7777cc66170cc616565a8b94f2081da50f 100644
--- a/net/minecraft/world/item/ItemStack.java
+++ b/net/minecraft/world/item/ItemStack.java
@@ -884,11 +884,11 @@ public final class ItemStack implements DataComponentHolder {
}
public static boolean isSameItem(ItemStack stack, ItemStack other) {
- return stack.is(other.getItem());
+ return stack == other || stack.is(other.getItem()); // Gale - optimize identical item checks
}
public static boolean isSameItemSameComponents(ItemStack stack, ItemStack other) {
- return stack.is(other.getItem()) && (stack.isEmpty() && other.isEmpty() || Objects.equals(stack.components, other.components));
+ return stack == other || stack.is(other.getItem()) && (stack.isEmpty() && other.isEmpty() || Objects.equals(stack.components, other.components)); // Gale - optimize identical item checks
}
public static MapCodec<ItemStack> lenientOptionalFieldOf(String fieldName) {