From d3348654664a2e8fe30972249ad47b08ce4dcb17 Mon Sep 17 00:00:00 2001 From: Alfie Cleveland Date: Tue, 27 Dec 2016 03:01:41 +0000 Subject: [PATCH] Further optimise hoppers --- ...Improve-Minecraft-Hopper-Performance.patch | 41 ++++++++++++++++++- .../Make-entities-look-for-hoppers.patch | 4 +- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/Spigot-Server-Patches/Improve-Minecraft-Hopper-Performance.patch b/Spigot-Server-Patches/Improve-Minecraft-Hopper-Performance.patch index 7917f6f57a..fb37340278 100644 --- a/Spigot-Server-Patches/Improve-Minecraft-Hopper-Performance.patch +++ b/Spigot-Server-Patches/Improve-Minecraft-Hopper-Performance.patch @@ -5,6 +5,7 @@ Subject: [PATCH] Improve Minecraft Hopper Performance Removes unnecessary extra calls to .update() that are very expensive Also reset cooldown each hopper tick that a hopper is full. +Also don't constantly clone ItemStacks without merit diff --git a/src/main/java/net/minecraft/server/TileEntity.java b/src/main/java/net/minecraft/server/TileEntity.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 @@ -30,6 +31,42 @@ diff --git a/src/main/java/net/minecraft/server/TileEntityHopper.java b/src/main index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/TileEntityHopper.java +++ b/src/main/java/net/minecraft/server/TileEntityHopper.java +@@ -0,0 +0,0 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi + this.setCooldown(world.spigotConfig.hopperTransfer); // Spigot + return false; + } +- int origCount = event.getItem().getAmount(); // Spigot +- ItemStack itemstack1 = addItem(this, iinventory, CraftItemStack.asNMSCopy(event.getItem()), enumdirection); +- ++ // Paper start ++ org.bukkit.inventory.ItemStack eventStack = event.getItem(); ++ int origCount = eventStack.getAmount(); // Spigot ++ ItemStack itemstack1 = addItem(this, iinventory, CraftItemStack.asNMSCopy(eventStack), enumdirection); ++ // Paper end + if (itemstack1.isEmpty()) { +- if (event.getItem().equals(oitemstack)) { ++ if (eventStack.equals(oitemstack)) { // Paper + iinventory.update(); + } else { + this.setItem(i, itemstack); +@@ -0,0 +0,0 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi + } + return false; + } +- int origCount = event.getItem().getAmount(); // Spigot +- ItemStack itemstack2 = addItem(iinventory, ihopper, CraftItemStack.asNMSCopy(event.getItem()), null); +- ++ // Paper start ++ org.bukkit.inventory.ItemStack eventStack = event.getItem(); ++ int origCount = eventStack.getAmount(); // Spigot ++ ItemStack itemstack2 = addItem(iinventory, ihopper, CraftItemStack.asNMSCopy(eventStack), null); ++ // Paper end + if (itemstack2.isEmpty()) { +- if (event.getItem().equals(oitemstack)) { ++ if (eventStack.equals(oitemstack)) { // Paper + iinventory.update(); + } else { + iinventory.setItem(i, itemstack1); @@ -0,0 +0,0 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi boolean flag1 = iinventory1.w_(); @@ -48,4 +85,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 private boolean J() { return this.f > 0; } --- \ No newline at end of file +-- +2.9.3 (Apple Git-75) + diff --git a/Spigot-Server-Patches/Make-entities-look-for-hoppers.patch b/Spigot-Server-Patches/Make-entities-look-for-hoppers.patch index 1d6ebd4250..909c920b16 100644 --- a/Spigot-Server-Patches/Make-entities-look-for-hoppers.patch +++ b/Spigot-Server-Patches/Make-entities-look-for-hoppers.patch @@ -389,4 +389,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 List list = world.getEntities((Entity) null, new AxisAlignedBB(d0 - 0.5D, d1 - 0.5D, d2 - 0.5D, d0 + 0.5D, d1 + 0.5D, d2 + 0.5D), IEntitySelector.c); if (!list.isEmpty()) { --- \ No newline at end of file +-- +2.9.3 (Apple Git-75) +