From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Jake Potrebic 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 index d83b0c58ea9fba6ba0060ee20c3e8251561f301a..f98367830e87d5f1428448931f756d9277699563 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 @@ -437,15 +437,17 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen if (itemstack1.isEmpty()) { // Spigot start - SPIGOT-6693, InventorySubcontainer#setItem + ItemStack leftover = ItemStack.EMPTY; // Paper if (!stack.isEmpty() && stack.getCount() > to.getMaxStackSize()) { + leftover = stack; // Paper stack = stack.split(to.getMaxStackSize()); } // Spigot end to.setItem(slot, stack); - stack = ItemStack.EMPTY; + stack = leftover; // Paper 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);