aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDungeonDev <[email protected]>2023-04-11 15:35:54 +0200
committerGitHub <[email protected]>2023-04-11 15:35:54 +0200
commite338793603e7b57ab439a1b925e3092cb623f616 (patch)
tree2448f81a1fb4b4f91cebd56403a44b348828e59d
parent5ffdff88220ef310abbf3f190aee9225ce367de4 (diff)
downloadPaper-e338793603e7b57ab439a1b925e3092cb623f616.tar.gz
Paper-e338793603e7b57ab439a1b925e3092cb623f616.zip
Optimize hoppers by not trying to merge full items. (#9110)
This can skip many very expensive call to ItemStack.tagMatches. Makes canMergeItems return false for merging into ItemStacks that are already full.
-rw-r--r--patches/server/0963-Optimize-Hoppers.patch11
1 files changed, 10 insertions, 1 deletions
diff --git a/patches/server/0963-Optimize-Hoppers.patch b/patches/server/0963-Optimize-Hoppers.patch
index c2d5d3f038..b78a4f581e 100644
--- a/patches/server/0963-Optimize-Hoppers.patch
+++ b/patches/server/0963-Optimize-Hoppers.patch
@@ -68,7 +68,7 @@ index 585d1d1f4b1b212295da36e31ae2670b0d2b06c3..1b248db497500aa6bd346b306dcb908a
}
diff --git a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
-index 789e5458f4a137694563a22612455506807de51b..cba114f554644a37339c93026630c66c43f524b9 100644
+index 789e5458f4a137694563a22612455506807de51b..aac5572c1d40a10cd1d17f89c9eb836718837577 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
@@ -193,6 +193,201 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
@@ -551,6 +551,15 @@ index 789e5458f4a137694563a22612455506807de51b..cba114f554644a37339c93026630c66c
List<Entity> list = world.getEntities((Entity) null, new AABB(x - 0.5D, y - 0.5D, z - 0.5D, x + 0.5D, y + 0.5D, z + 0.5D), EntitySelector.CONTAINER_ENTITY_SELECTOR);
if (!list.isEmpty()) {
+@@ -560,7 +776,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
+ }
+
+ private static boolean canMergeItems(ItemStack first, ItemStack second) {
+- return !first.is(second.getItem()) ? false : (first.getDamageValue() != second.getDamageValue() ? false : (first.getCount() > first.getMaxStackSize() ? false : ItemStack.tagMatches(first, second)));
++ return first.is(second.getItem()) && first.getDamageValue() == second.getDamageValue() && first.getCount() < first.getMaxStackSize() && ItemStack.tagMatches(first, second); // Paper - used to return true for full itemstacks?!
+ }
+
+ @Override
diff --git a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
index b9f0dae1ec96194fe78c086b63d8a18b1d0cfcf7..79b01e32f89defb6b78f4764600d33d4945af592 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java