aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches/0144-Improve-Minecraft-Hopper-Performance.patch
blob: a2cb60b7ad2bed983d059bf433818755905ebb80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
From 25164352de96cb913f1bdf3f97257621ac6c70c3 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
index f59e6f8..85f97cc 100644
--- 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;
     }
@@ -110,6 +111,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);
 
             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
index de458c8..a695207 100644
--- a/src/main/java/net/minecraft/server/TileEntityHopper.java
+++ b/src/main/java/net/minecraft/server/TileEntityHopper.java
@@ -190,6 +190,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
                 }
                 // Paper end
             }
+
             return false;
         } else {
             return false;
@@ -490,7 +491,9 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
             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)) {
@@ -510,7 +513,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
                         tileentityhopper.setCooldown(tileentityhopper.world.spigotConfig.hopperTransfer); // Spigot
                     }
 
-                    iinventory.update();
+                    //iinventory.update(); // Paper
                 }
 
                 iinventory.update();
@@ -585,6 +588,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
         this.g = i;
     }
 
+    boolean isCooledDown() { return o(); } // Paper // OBFHELPER
     public boolean o() {
         return this.g > 0;
     }
-- 
2.8.3