Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-15 11:00:06 +01:00
Further optimise hoppers
Dieser Commit ist enthalten in:
Ursprung
bba27681ba
Commit
043859300f
@ -1,10 +1,11 @@
|
||||
From 8021c1dc974999e3f717f4f181a3623f188be45b Mon Sep 17 00:00:00 2001
|
||||
From 8920ccc3b08ca7c3c6174681d49207bd5a685f17 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.
|
||||
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 d0c0371..d2662ae 100644
|
||||
@ -27,10 +28,46 @@ index d0c0371..d2662ae 100644
|
||||
|
||||
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
|
||||
index f12bc70..7154776 100644
|
||||
index f12bc70..c21c63e 100644
|
||||
--- a/src/main/java/net/minecraft/server/TileEntityHopper.java
|
||||
+++ b/src/main/java/net/minecraft/server/TileEntityHopper.java
|
||||
@@ -455,7 +455,9 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
||||
@@ -216,11 +216,13 @@ 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);
|
||||
@@ -373,11 +375,13 @@ 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);
|
||||
@@ -455,7 +459,9 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
||||
boolean flag1 = iinventory1.w_();
|
||||
|
||||
if (itemstack1.isEmpty()) {
|
||||
@ -40,7 +77,7 @@ index f12bc70..7154776 100644
|
||||
itemstack = ItemStack.a;
|
||||
flag = true;
|
||||
} else if (a(itemstack1, itemstack)) {
|
||||
@@ -558,6 +560,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
||||
@@ -558,6 +564,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
||||
this.f = i;
|
||||
}
|
||||
|
||||
@ -49,5 +86,5 @@ index f12bc70..7154776 100644
|
||||
return this.f > 0;
|
||||
}
|
||||
--
|
||||
2.9.3
|
||||
2.9.3 (Apple Git-75)
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 2804df4eb136c34688021eec0187d06408d507d1 Mon Sep 17 00:00:00 2001
|
||||
From 0d4a74cbfb7372f1947cb1840342fbe514c1c732 Mon Sep 17 00:00:00 2001
|
||||
From: Techcable <Techcable@outlook.com>
|
||||
Date: Sat, 18 Jun 2016 01:01:37 -0500
|
||||
Subject: [PATCH] Make entities look for hoppers
|
||||
@ -144,7 +144,7 @@ index 008ed20..b3c1f55 100644
|
||||
this.b = i;
|
||||
this.c = j;
|
||||
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
||||
index a6f6313..26ab72c 100644
|
||||
index 768d89d..b0d91ce 100644
|
||||
--- a/src/main/java/net/minecraft/server/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/server/Entity.java
|
||||
@@ -80,6 +80,19 @@ public abstract class Entity implements ICommandListener {
|
||||
@ -261,7 +261,7 @@ index 804215a..e830d83 100644
|
||||
+ double G(); default double getZ() { return G(); } // Paper - OBFHELPER
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/TileEntityHopper.java b/src/main/java/net/minecraft/server/TileEntityHopper.java
|
||||
index 7154776..f8339ad 100644
|
||||
index c21c63e..eaf06dd 100644
|
||||
--- a/src/main/java/net/minecraft/server/TileEntityHopper.java
|
||||
+++ b/src/main/java/net/minecraft/server/TileEntityHopper.java
|
||||
@@ -122,6 +122,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
||||
@ -295,7 +295,7 @@ index 7154776..f8339ad 100644
|
||||
private boolean p() {
|
||||
Iterator iterator = this.items.iterator();
|
||||
|
||||
@@ -296,8 +306,15 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
||||
@@ -298,8 +308,15 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -312,7 +312,7 @@ index 7154776..f8339ad 100644
|
||||
|
||||
if (iinventory != null) {
|
||||
EnumDirection enumdirection = EnumDirection.DOWN;
|
||||
@@ -328,8 +345,8 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
||||
@@ -330,8 +347,8 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -323,7 +323,7 @@ index 7154776..f8339ad 100644
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
EntityItem entityitem = (EntityItem) iterator.next();
|
||||
@@ -393,6 +410,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
||||
@@ -397,6 +414,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -331,7 +331,7 @@ index 7154776..f8339ad 100644
|
||||
public static boolean a(IInventory iinventory, IInventory iinventory1, EntityItem entityitem) {
|
||||
boolean flag = false;
|
||||
|
||||
@@ -498,18 +516,44 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
||||
@@ -502,18 +520,44 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
||||
private IInventory I() {
|
||||
EnumDirection enumdirection = BlockHopper.e(this.v());
|
||||
|
||||
@ -380,7 +380,7 @@ index 7154776..f8339ad 100644
|
||||
Object object = null;
|
||||
int i = MathHelper.floor(d0);
|
||||
int j = MathHelper.floor(d1);
|
||||
@@ -529,7 +573,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
||||
@@ -533,7 +577,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
||||
}
|
||||
}
|
||||
|
||||
@ -390,5 +390,5 @@ index 7154776..f8339ad 100644
|
||||
|
||||
if (!list.isEmpty()) {
|
||||
--
|
||||
2.9.3
|
||||
2.9.3 (Apple Git-75)
|
||||
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren