2016-05-28 03:35:28 +02:00
|
|
|
From 6a110c2813f8b97f35921b67d31e6e2f3f21df4a Mon Sep 17 00:00:00 2001
|
2016-04-28 04:15:57 +02:00
|
|
|
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-05-12 04:07:46 +02:00
|
|
|
index f59e6f8..85f97cc 100644
|
2016-04-28 04:15:57 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/TileEntity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/TileEntity.java
|
|
|
|
@@ -36,6 +36,7 @@ public abstract class TileEntity {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ static boolean IGNORE_TILE_UPDATES = false; // Paper
|
|
|
|
public World getWorld() {
|
|
|
|
return this.world;
|
|
|
|
}
|
2016-05-12 04:07:46 +02:00
|
|
|
@@ -110,6 +111,7 @@ public abstract class TileEntity {
|
2016-04-28 04:15:57 +02:00
|
|
|
|
|
|
|
public void update() {
|
|
|
|
if (this.world != null) {
|
|
|
|
+ if (IGNORE_TILE_UPDATES) return; // Paper
|
|
|
|
IBlockData iblockdata = this.world.getType(this.position);
|
|
|
|
|
|
|
|
this.h = 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-05-12 04:07:46 +02:00
|
|
|
index de458c8..ec0b1ca 100644
|
2016-04-28 04:15:57 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/TileEntityHopper.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/TileEntityHopper.java
|
2016-05-12 04:07:46 +02:00
|
|
|
@@ -190,12 +190,15 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
2016-04-28 04:15:57 +02:00
|
|
|
}
|
|
|
|
// Paper end
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ if (!isCooledDown() && isFull()) { setCooldown(world.spigotConfig.hopperTransfer); } // Paper
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ boolean isFull() { return q(); } // Paper // OBFHELPER
|
|
|
|
private boolean q() {
|
|
|
|
ItemStack[] aitemstack = this.items;
|
|
|
|
int i = aitemstack.length;
|
2016-05-12 04:07:46 +02:00
|
|
|
@@ -490,7 +493,9 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
2016-04-28 04:15:57 +02:00
|
|
|
boolean flag = false;
|
|
|
|
|
|
|
|
if (itemstack1 == null) {
|
|
|
|
+ IGNORE_TILE_UPDATES = true; // Paper
|
|
|
|
iinventory.setItem(i, itemstack);
|
|
|
|
+ IGNORE_TILE_UPDATES = false; // Paper
|
|
|
|
itemstack = null;
|
|
|
|
flag = true;
|
|
|
|
} else if (a(itemstack1, itemstack)) {
|
2016-05-12 04:07:46 +02:00
|
|
|
@@ -510,7 +515,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
2016-04-28 04:22:35 +02:00
|
|
|
tileentityhopper.setCooldown(tileentityhopper.world.spigotConfig.hopperTransfer); // Spigot
|
|
|
|
}
|
2016-04-28 04:15:57 +02:00
|
|
|
|
2016-04-28 04:22:35 +02:00
|
|
|
- iinventory.update();
|
|
|
|
+ //iinventory.update(); // Paper
|
|
|
|
}
|
2016-04-28 04:15:57 +02:00
|
|
|
|
2016-04-28 04:22:35 +02:00
|
|
|
iinventory.update();
|
2016-05-12 04:07:46 +02:00
|
|
|
@@ -585,6 +590,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
2016-04-28 04:15:57 +02:00
|
|
|
this.g = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ boolean isCooledDown() { return o(); } // Paper // OBFHELPER
|
|
|
|
public boolean o() {
|
|
|
|
return this.g > 0;
|
|
|
|
}
|
|
|
|
--
|
2016-05-28 03:35:28 +02:00
|
|
|
2.7.4 (Apple Git-66)
|
2016-04-28 04:15:57 +02:00
|
|
|
|