papermc/Spigot-Server-Patches/0127-Improve-Minecraft-Hopper-Performance.patch

54 lines
2.1 KiB
Diff
Raw Normal View History

2016-12-20 22:34:27 +00:00
From 8021c1dc974999e3f717f4f181a3623f188be45b Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Wed, 27 Apr 2016 22:09:52 -0400
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.
diff --git a/src/main/java/net/minecraft/server/TileEntity.java b/src/main/java/net/minecraft/server/TileEntity.java
2016-12-20 22:34:27 +00:00
index d0c0371..d2662ae 100644
--- a/src/main/java/net/minecraft/server/TileEntity.java
+++ b/src/main/java/net/minecraft/server/TileEntity.java
2016-11-17 02:23:38 +00:00
@@ -33,6 +33,7 @@ public abstract class TileEntity {
return (MinecraftKey) TileEntity.f.b(oclass);
}
+ static boolean IGNORE_TILE_UPDATES = false; // Paper
public World getWorld() {
return this.world;
}
2016-11-17 02:23:38 +00:00
@@ -111,6 +112,7 @@ public abstract class TileEntity {
public void update() {
if (this.world != null) {
+ if (IGNORE_TILE_UPDATES) return; // Paper
IBlockData iblockdata = this.world.getType(this.position);
2016-11-17 02:23:38 +00:00
this.g = iblockdata.getBlock().toLegacyData(iblockdata);
diff --git a/src/main/java/net/minecraft/server/TileEntityHopper.java b/src/main/java/net/minecraft/server/TileEntityHopper.java
2016-11-28 21:32:05 +00:00
index f12bc70..7154776 100644
--- a/src/main/java/net/minecraft/server/TileEntityHopper.java
+++ b/src/main/java/net/minecraft/server/TileEntityHopper.java
2016-11-17 02:23:38 +00:00
@@ -455,7 +455,9 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
boolean flag1 = iinventory1.w_();
2016-11-17 02:23:38 +00:00
if (itemstack1.isEmpty()) {
+ IGNORE_TILE_UPDATES = true; // Paper
2016-11-17 02:23:38 +00:00
iinventory1.setItem(i, itemstack);
+ IGNORE_TILE_UPDATES = false; // Paper
2016-11-17 02:23:38 +00:00
itemstack = ItemStack.a;
flag = true;
} else if (a(itemstack1, itemstack)) {
2016-11-17 02:23:38 +00:00
@@ -558,6 +560,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
this.f = i;
}
2016-11-17 02:23:38 +00:00
+ boolean isCooledDown() { return J(); } // Paper - OBFHELPER
private boolean J() {
return this.f > 0;
}
--
2016-12-10 23:50:31 +00:00
2.9.3