2026-07-09 00:03:09 +08:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
|
From: MrHua269 <mrhua269@gmail.com>
|
|
|
|
|
Date: Thu, 4 Jun 2026 17:34:43 +0800
|
|
|
|
|
Subject: [PATCH] Gale: Optimize matching item checks
|
|
|
|
|
|
|
|
|
|
License: GPL-3.0-only (https://www.gnu.org/licenses/gpl-3.0.html)
|
|
|
|
|
Gale - https://github.com/GaleMC/Gale
|
|
|
|
|
|
|
|
|
|
diff --git a/net/minecraft/world/item/ItemStack.java b/net/minecraft/world/item/ItemStack.java
|
2026-07-14 15:09:17 +08:00
|
|
|
index b507be6db077a0c9b77270f3359b0908c9298c71..a2c178c400e54807e2da0b45ca166ac4d3d26971 100644
|
2026-07-09 00:03:09 +08:00
|
|
|
--- a/net/minecraft/world/item/ItemStack.java
|
|
|
|
|
+++ b/net/minecraft/world/item/ItemStack.java
|
|
|
|
|
@@ -841,11 +841,11 @@ public final class ItemStack implements DataComponentHolder, ItemInstance, Chang
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static boolean isSameItem(final ItemStack a, final ItemStack b) {
|
|
|
|
|
- return a.is(b.getItem());
|
|
|
|
|
+ return a == b || a.is(b.getItem()); // Gale - optimize identical item checks
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static boolean isSameItemSameComponents(final ItemStack a, final ItemStack b) {
|
|
|
|
|
- return a.is(b.getItem()) && (a.isEmpty() && b.isEmpty() || Objects.equals(a.components, b.components));
|
|
|
|
|
+ return a == b || a.is(b.getItem()) && (a.isEmpty() && b.isEmpty() || Objects.equals(a.components, b.components)); // Gale - optimize identical item checks
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static boolean matchesIgnoringComponents(final ItemStack a, final ItemStack b, final Predicate<DataComponentType<?>> ignoredPredicate) {
|