Paper/Spigot-Server-Patches/0223-Implement-ensureServerConversions-API.patch
Aikar 094bb03a37
Optimize Hoppers
- 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
2018-02-12 23:26:02 -05:00

28 lines
1.1 KiB
Diff

From 1c57bc166a4c5abdc981ac6b43a6763494ce0524 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Wed, 4 May 2016 22:43:12 -0400
Subject: [PATCH] Implement ensureServerConversions API
This will take a Bukkit ItemStack and run it through any conversions a server process would perform on it,
to ensure it meets latest minecraft expectations.
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
index 49ebad22e..eb6987338 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
@@ -194,4 +194,11 @@ public final class CraftItemFactory implements ItemFactory {
public Color getDefaultLeatherColor() {
return DEFAULT_LEATHER_COLOR;
}
+
+ // Paper start
+ @Override
+ public ItemStack ensureServerConversions(ItemStack item) {
+ return CraftItemStack.asCraftMirror(CraftItemStack.asNMSCopy(item));
+ }
+ // Paper end
}
--
2.16.1