mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 23:38:25 +01:00
3d9d0a7227
- Lots of itemstack cloning removed. Only clone if the item is actually moved - Return true when a plugin cancels inventory move item event instead of false, as false causes pulls to cycle through all items. However, pushes do not exhibit the same behavior, so this is not something plugins could of been relying on. - Add option (Default on) to cooldown hoppers when they fail to move an item due to full inventory - Skip subsequent InventoryMoveItemEvents if a plugin does not use the item after first event fire for an iteration
29 lines
No EOL
1.3 KiB
Diff
29 lines
No EOL
1.3 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Wed, 21 Dec 2016 03:48:29 -0500
|
|
Subject: [PATCH] Optimize ItemStack.isEmpty()
|
|
|
|
Remove hashMap lookup every check, simplify code to remove ternary
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/ItemStack.java b/src/main/java/net/minecraft/server/ItemStack.java
|
|
index a8f7ff98f..9465f4c16 100644
|
|
--- a/src/main/java/net/minecraft/server/ItemStack.java
|
|
+++ b/src/main/java/net/minecraft/server/ItemStack.java
|
|
@@ -0,0 +0,0 @@ public final class ItemStack {
|
|
this.F();
|
|
}
|
|
|
|
+ // Paper start - optimize isEmpty
|
|
+ private static Item airItem;
|
|
public boolean isEmpty() {
|
|
- return this == ItemStack.a ? true : (this.item != null && this.item != Item.getItemOf(Blocks.AIR) ? (this.count <= 0 ? true : this.damage < -32768 || this.damage > '\uffff') : true);
|
|
+ if (airItem == null) {
|
|
+ airItem = Item.REGISTRY.get(new MinecraftKey("air"));
|
|
+ }
|
|
+ return this == ItemStack.a || this.item == null || this.item == airItem || (this.count <= 0 || (this.damage < -32768 || this.damage > '\uffff'));
|
|
}
|
|
+ // Paper end
|
|
|
|
public static void a(DataConverterManager dataconvertermanager) {
|
|
dataconvertermanager.a(DataConverterTypes.ITEM_INSTANCE, (DataInspector) (new DataInspectorBlockEntity()));
|
|
--
|