2017-05-05 01:08:52 +02:00
|
|
|
From b90b6e56102b563fc5dedfd20d1cfc5f901201d4 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.
|
2016-12-27 04:01:41 +01:00
|
|
|
Also don't constantly clone ItemStacks without merit
|
2016-04-28 04:15:57 +02:00
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/TileEntity.java b/src/main/java/net/minecraft/server/TileEntity.java
|
2017-03-25 06:22:02 +01:00
|
|
|
index d0c0371fc..d2662ae14 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
|
2016-11-17 03:23:38 +01:00
|
|
|
@@ -33,6 +33,7 @@ public abstract class TileEntity {
|
|
|
|
return (MinecraftKey) TileEntity.f.b(oclass);
|
2016-04-28 04:15:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
+ static boolean IGNORE_TILE_UPDATES = false; // Paper
|
|
|
|
public World getWorld() {
|
|
|
|
return this.world;
|
|
|
|
}
|
2016-11-17 03:23:38 +01:00
|
|
|
@@ -111,6 +112,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);
|
|
|
|
|
2016-11-17 03:23:38 +01:00
|
|
|
this.g = iblockdata.getBlock().toLegacyData(iblockdata);
|
2016-04-28 04:15:57 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/TileEntityHopper.java b/src/main/java/net/minecraft/server/TileEntityHopper.java
|
2017-03-25 06:22:02 +01:00
|
|
|
index 6acce15e7..44b6ecc5d 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
|
2017-02-11 01:12:58 +01:00
|
|
|
@@ -220,11 +220,13 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
2016-12-27 04:01:41 +01:00
|
|
|
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);
|
2017-02-11 01:12:58 +01:00
|
|
|
@@ -377,11 +379,13 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
2016-12-27 04:01:41 +01:00
|
|
|
}
|
|
|
|
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);
|
2017-02-11 01:12:58 +01:00
|
|
|
@@ -459,7 +463,9 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
2016-11-17 03:23:38 +01:00
|
|
|
boolean flag1 = iinventory1.w_();
|
2016-04-28 04:15:57 +02:00
|
|
|
|
2016-11-17 03:23:38 +01:00
|
|
|
if (itemstack1.isEmpty()) {
|
2016-04-28 04:15:57 +02:00
|
|
|
+ IGNORE_TILE_UPDATES = true; // Paper
|
2016-11-17 03:23:38 +01:00
|
|
|
iinventory1.setItem(i, itemstack);
|
2016-04-28 04:15:57 +02:00
|
|
|
+ IGNORE_TILE_UPDATES = false; // Paper
|
2016-11-17 03:23:38 +01:00
|
|
|
itemstack = ItemStack.a;
|
2016-04-28 04:15:57 +02:00
|
|
|
flag = true;
|
|
|
|
} else if (a(itemstack1, itemstack)) {
|
2017-02-11 01:12:58 +01:00
|
|
|
@@ -562,6 +568,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
2016-11-17 03:23:38 +01:00
|
|
|
this.f = i;
|
2016-04-28 04:15:57 +02:00
|
|
|
}
|
|
|
|
|
2016-11-17 03:23:38 +01:00
|
|
|
+ boolean isCooledDown() { return J(); } // Paper - OBFHELPER
|
|
|
|
private boolean J() {
|
|
|
|
return this.f > 0;
|
2016-04-28 04:15:57 +02:00
|
|
|
}
|
|
|
|
--
|
2017-05-05 01:08:52 +02:00
|
|
|
2.12.2
|
2016-04-28 04:15:57 +02:00
|
|
|
|