2021-08-07 02:35:42 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
|
|
|
Date: Wed, 7 Jul 2021 16:30:17 -0700
|
|
|
|
Subject: [PATCH] Make hoppers respect inventory max stack size
|
|
|
|
|
|
|
|
|
|
|
|
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
|
2021-08-07 08:55:16 +02:00
|
|
|
index 3b1442bf4c83650369e925d76f07dc67c6cbbc83..a3f0e2ab3eeebeb7c43fda3ddb1f16f8696255d3 100644
|
2021-08-07 02:35:42 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
2021-08-07 08:55:16 +02:00
|
|
|
@@ -588,13 +588,22 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
2021-08-07 02:35:42 +02:00
|
|
|
boolean flag1 = to.isEmpty();
|
|
|
|
|
|
|
|
if (itemstack1.isEmpty()) {
|
|
|
|
+ int originalCount = stack.getCount(); // Paper
|
|
|
|
+ stack.setCount(Math.min(to.getMaxStackSize(), stack.getCount())); // Paper
|
|
|
|
IGNORE_TILE_UPDATES = true; // Paper
|
|
|
|
to.setItem(slot, stack);
|
|
|
|
IGNORE_TILE_UPDATES = false; // Paper
|
|
|
|
+ if (originalCount - stack.getCount() == 0) { // Paper
|
|
|
|
stack = ItemStack.EMPTY;
|
|
|
|
+ // Paper start
|
|
|
|
+ } else {
|
2021-08-07 08:55:16 +02:00
|
|
|
+ stack = stack.copy(); // Paper - copy stack to return leftover stack
|
2021-08-07 02:35:42 +02:00
|
|
|
+ stack.setCount(originalCount - stack.getCount());
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
flag = true;
|
|
|
|
} else if (HopperBlockEntity.canMergeItems(itemstack1, stack)) {
|
|
|
|
- int j = stack.getMaxStackSize() - itemstack1.getCount();
|
|
|
|
+ int j = Math.min(stack.getMaxStackSize(), to.getMaxStackSize()) - itemstack1.getCount(); // Paper
|
|
|
|
int k = Math.min(stack.getCount(), j);
|
|
|
|
|
|
|
|
stack.shrink(k);
|