mirror of
https://github.com/Dreeam-qwq/Gale.git
synced 2025-12-22 16:29:26 +00:00
Use platform math functions
This commit is contained in:
31
patches/server/0136-Optimize-matching-item-checks.patch
Normal file
31
patches/server/0136-Optimize-matching-item-checks.patch
Normal file
@@ -0,0 +1,31 @@
|
||||
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: AGPL-3.0 (https://www.gnu.org/licenses/agpl-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 3d589c9698129ab2a09093425d0bb97c5a3897f9..0116eeff6de9948c398486c4f910d58862f88eb9 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||
@@ -754,15 +754,15 @@ public final class ItemStack {
|
||||
}
|
||||
|
||||
public static boolean matches(ItemStack left, ItemStack right) {
|
||||
- return left == right ? true : (left.getCount() != right.getCount() ? false : ItemStack.isSameItemSameTags(left, right));
|
||||
+ return left == right || (left.getCount() == right.getCount() && ItemStack.isSameItemSameTags(left, right)); // Gale - optimize identical item checks
|
||||
}
|
||||
|
||||
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 isSameItemSameTags(ItemStack stack, ItemStack otherStack) {
|
||||
- return !stack.is(otherStack.getItem()) ? false : (stack.isEmpty() && otherStack.isEmpty() ? true : Objects.equals(stack.tag, otherStack.tag));
|
||||
+ return stack == otherStack || (stack.is(otherStack.getItem()) && (stack.isEmpty() && otherStack.isEmpty() || Objects.equals(stack.tag, otherStack.tag))); // Gale - optimize identical item checks
|
||||
}
|
||||
|
||||
public String getDescriptionId() {
|
||||
Reference in New Issue
Block a user