Skip to content

Commit

Permalink
Fix hopper updates source slot twice
Browse files Browse the repository at this point in the history
  • Loading branch information
nostalfinals committed Jan 10, 2025
1 parent 4007171 commit d64c644
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions paper-server/patches/features/0029-Optimize-Hoppers.patch
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ index 0000000000000000000000000000000000000000..24a2090e068ad3c0d08705050944abdf
+ }
+}
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
index 6dbae12bbfd47cd4e75bc3089561e8e226e9e604..9c859025302ddb2c20cf6457fa4e4eaf7fbafdd7 100644
index 9ebfbbd4b04c392c1d81922a6a29d61e8d5862f0..107aa863bd4448628b013d0ccd49b6a956aeffef 100644
--- a/net/minecraft/server/MinecraftServer.java
+++ b/net/minecraft/server/MinecraftServer.java
@@ -1707,6 +1707,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
Expand All @@ -60,7 +60,7 @@ index 6dbae12bbfd47cd4e75bc3089561e8e226e9e604..9c859025302ddb2c20cf6457fa4e4eaf
/* Drop global time updates
if (this.tickCount % 20 == 0) {
diff --git a/net/minecraft/world/item/ItemStack.java b/net/minecraft/world/item/ItemStack.java
index c255e11cb0981bd7e0456d4fd401beb5257be597..d6361863d6a1e364de262d6199373cbd68d1c699 100644
index 0eb9811e573f0c38de3eeb17099872efcbb4c2dd..b511fe8295369ac4014beb351cd2e3f770c10170 100644
--- a/net/minecraft/world/item/ItemStack.java
+++ b/net/minecraft/world/item/ItemStack.java
@@ -808,10 +808,16 @@ public final class ItemStack implements DataComponentHolder {
Expand Down Expand Up @@ -103,7 +103,7 @@ index 2ebdf1ad323bb53dfe9eed319e25856b35a1443c..77618757c0e678532dbab814aceed83f
}
}
diff --git a/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/net/minecraft/world/level/block/entity/HopperBlockEntity.java
index e58a32593e8b42bfc534d13457240860293dd3f4..5cd1326ad5d046c88b2b3449d610a78fa880b4cd 100644
index e58a32593e8b42bfc534d13457240860293dd3f4..709a547a9f710350c1aeed81eaf27e90f27fd738 100644
--- a/net/minecraft/world/level/block/entity/HopperBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/HopperBlockEntity.java
@@ -139,18 +139,56 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
Expand Down Expand Up @@ -618,7 +618,7 @@ index e58a32593e8b42bfc534d13457240860293dd3f4..5cd1326ad5d046c88b2b3449d610a78f
ItemStack itemStack = item.getItem().copy();
ItemStack itemStack1 = addItem(null, container, itemStack, null);
if (itemStack1.isEmpty()) {
@@ -431,7 +678,9 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
@@ -431,12 +678,15 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
stack = stack.split(destination.getMaxStackSize());
}
// Spigot end
Expand All @@ -628,7 +628,13 @@ index e58a32593e8b42bfc534d13457240860293dd3f4..5cd1326ad5d046c88b2b3449d610a78f
stack = leftover; // Paper - Make hoppers respect inventory max stack size
flag = true;
} else if (canMergeItems(item, stack)) {
@@ -519,13 +768,19 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
int i = Math.min(stack.getMaxStackSize(), destination.getMaxStackSize()) - item.getCount(); // Paper - Make hoppers respect inventory max stack size
int min = Math.min(stack.getCount(), i);
+ stack = stack.copy(true); // Paper - Perf: Optimize Hoppers
stack.shrink(min);
item.grow(min);
flag = min > 0;
@@ -519,13 +769,19 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen

@Nullable
public static Container getContainerAt(Level level, BlockPos pos) {
Expand All @@ -650,7 +656,7 @@ index e58a32593e8b42bfc534d13457240860293dd3f4..5cd1326ad5d046c88b2b3449d610a78f
blockContainer = getEntityContainer(level, x, y, z);
}

@@ -551,14 +806,14 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
@@ -551,14 +807,14 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen

@Nullable
private static Container getEntityContainer(Level level, double x, double y, double z) {
Expand Down

0 comments on commit d64c644

Please sign in to comment.