aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/api/0439-Remove-unnecessary-durability-check-in-ItemStack-isS.patch
diff options
context:
space:
mode:
authorShane Freeder <[email protected]>2024-05-09 14:51:33 +0100
committerShane Freeder <[email protected]>2024-05-09 14:51:33 +0100
commit3693bbdc6b65e68db10375d3eeab70f06708b729 (patch)
tree4a71a5e6e5f50b3e2937053a5d4b4196ef67665b /patches/api/0439-Remove-unnecessary-durability-check-in-ItemStack-isS.patch
parentf2512b12385961f8ca1f69efebe5ed0e00c0caa8 (diff)
downloadPaper-timings/use-internals.tar.gz
Paper-timings/use-internals.zip
Use internals for getting block/entity countstimings/use-internals
For a long time I've been meaning to move some of this logic internally as this would allow us to avoid hitting systems like block state snapshots which can create issues as many of the spigot implementations of this stuff are increasingly broken, leading to unexpected crashes during ticking, even if the API cannot properly interact with these such states/items, it's generally more preferable to not crash the server in the course, and just let those interactions fail more gracefully.
Diffstat (limited to 'patches/api/0439-Remove-unnecessary-durability-check-in-ItemStack-isS.patch')
-rw-r--r--patches/api/0439-Remove-unnecessary-durability-check-in-ItemStack-isS.patch23
1 files changed, 23 insertions, 0 deletions
diff --git a/patches/api/0439-Remove-unnecessary-durability-check-in-ItemStack-isS.patch b/patches/api/0439-Remove-unnecessary-durability-check-in-ItemStack-isS.patch
new file mode 100644
index 0000000000..4974a88a57
--- /dev/null
+++ b/patches/api/0439-Remove-unnecessary-durability-check-in-ItemStack-isS.patch
@@ -0,0 +1,23 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: MrPowerGamerBR <[email protected]>
+Date: Sun, 26 Nov 2023 20:00:50 -0300
+Subject: [PATCH] Remove unnecessary durability check in
+ "ItemStack#isSimilar(...)"
+
+By removing this check we avoid unnecessarily allocating useless `ItemMeta` objects if we are comparing two items, or one of the two items, that don't have any durability. Don't worry, the durability of the item is checked when it checks if both item metas are equal.
+
+This is a leftover from when checking for the item's durability was "free" because the durability was stored in the `ItemStack` itself, this [was changed in Minecraft 1.13](https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/commits/f8b2086d60942eb2cd7ac25a2a1408cb790c222c#src/main/java/org/bukkit/inventory/ItemStack.java).
+
+diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java
+index 7cecb04de7d55dcdec1fa3dd255c844e92b1abdb..a1d0e479b9f28378f858f86ba8b0e9b7ddf71446 100644
+--- a/src/main/java/org/bukkit/inventory/ItemStack.java
++++ b/src/main/java/org/bukkit/inventory/ItemStack.java
+@@ -298,7 +298,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat
+ return true;
+ }
+ Material comparisonType = (this.type.isLegacy()) ? Bukkit.getUnsafe().fromLegacy(this.getData(), true) : this.type; // This may be called from legacy item stacks, try to get the right material
+- return comparisonType == stack.getType() && getDurability() == stack.getDurability() && hasItemMeta() == stack.hasItemMeta() && (hasItemMeta() ? Bukkit.getItemFactory().equals(getItemMeta(), stack.getItemMeta()) : true);
++ return comparisonType == stack.getType() && /* getDurability() == stack.getDurability() && */hasItemMeta() == stack.hasItemMeta() && (hasItemMeta() ? Bukkit.getItemFactory().equals(getItemMeta(), stack.getItemMeta()) : true); // Paper - remove redundant item durability check
+ }
+
+ @NotNull