From 9982c0e2b0cf855a3eb0ce291aa12edd0eacfbc5 Mon Sep 17 00:00:00 2001 From: GoodrichDev <147654894+GoodrichDev@users.noreply.github.com> Date: Fri, 1 May 2026 15:59:31 -0700 Subject: [PATCH] Persist hidden items in permission-based ender chest rows (#1774) Co-authored-by: granny --- .../0003-Barrels-and-enderchests-6-rows.patch | 31 ++++++++++++++++++- .../org/purpurmc/purpur/PurpurConfig.java | 2 ++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/purpur-server/minecraft-patches/features/0003-Barrels-and-enderchests-6-rows.patch b/purpur-server/minecraft-patches/features/0003-Barrels-and-enderchests-6-rows.patch index 50577b741..b1cdbe6c5 100644 --- a/purpur-server/minecraft-patches/features/0003-Barrels-and-enderchests-6-rows.patch +++ b/purpur-server/minecraft-patches/features/0003-Barrels-and-enderchests-6-rows.patch @@ -84,7 +84,7 @@ index e77bfcd31cdcfd5836dc5db561e3fe2bc552a4b1..afa2ead0548766669201526d83f351c2 return new ChestMenu(MenuType.GENERIC_9x6, containerId, inventory, container, 6); } diff --git a/net/minecraft/world/inventory/PlayerEnderChestContainer.java b/net/minecraft/world/inventory/PlayerEnderChestContainer.java -index 4df3a32faf85595372f4b250482d852c985ea3ab..8347150af55119d772b797e79be412f7e17a0f1f 100644 +index 4df3a32faf85595372f4b250482d852c985ea3ab..33c4c2cc8b488df5276d21e0f4e29cc0072a7682 100644 --- a/net/minecraft/world/inventory/PlayerEnderChestContainer.java +++ b/net/minecraft/world/inventory/PlayerEnderChestContainer.java @@ -26,11 +26,18 @@ public class PlayerEnderChestContainer extends SimpleContainer { @@ -107,6 +107,35 @@ index 4df3a32faf85595372f4b250482d852c985ea3ab..8347150af55119d772b797e79be412f7 public void setActiveChest(final EnderChestBlockEntity activeChest) { this.activeChest = activeChest; } +@@ -40,19 +47,25 @@ public class PlayerEnderChestContainer extends SimpleContainer { + } + + public void fromSlots(final ValueInput.TypedInputList list) { +- for (int i = 0; i < this.getContainerSize(); i++) { ++ // Purpur start - Barrels and enderchests 6 rows ++ int storageSlotCount = org.purpurmc.purpur.PurpurConfig.enderChestSixRows && org.purpurmc.purpur.PurpurConfig.enderChestPersistHiddenRows ? 54 : this.getContainerSize(); ++ for (int i = 0; i < storageSlotCount; i++) { ++ // Purpur end - Barrels and enderchests 6 rows + this.setItem(i, ItemStack.EMPTY); + } + + for (ItemStackWithSlot item : list) { +- if (item.isValidInContainer(this.getContainerSize())) { ++ if (item.isValidInContainer(storageSlotCount)) { // Purpur - Barrels and enderchests 6 rows + this.setItem(item.slot(), item.stack()); + } + } + } + + public void storeAsSlots(final ValueOutput.TypedOutputList output) { +- for (int i = 0; i < this.getContainerSize(); i++) { ++ // Purpur start - Barrels and enderchests 6 rows ++ int storageSlotCount = org.purpurmc.purpur.PurpurConfig.enderChestSixRows && org.purpurmc.purpur.PurpurConfig.enderChestPersistHiddenRows ? 54 : this.getContainerSize(); // Purpur - Barrels and enderchests 6 rows ++ for (int i = 0; i < storageSlotCount; i++) { ++ // Purpur end - Barrels and enderchests 6 rows + ItemStack itemStack = this.getItem(i); + if (!itemStack.isEmpty()) { + output.add(new ItemStackWithSlot(i, itemStack)); diff --git a/net/minecraft/world/level/block/EnderChestBlock.java b/net/minecraft/world/level/block/EnderChestBlock.java index 24a2c411da0ebbb7f97d621bb76ff686621f9aae..7ba9e8f6414246b589ff423fac63f80505326505 100644 --- a/net/minecraft/world/level/block/EnderChestBlock.java diff --git a/purpur-server/src/main/java/org/purpurmc/purpur/PurpurConfig.java b/purpur-server/src/main/java/org/purpurmc/purpur/PurpurConfig.java index a337df7cd..7e0c527a1 100644 --- a/purpur-server/src/main/java/org/purpurmc/purpur/PurpurConfig.java +++ b/purpur-server/src/main/java/org/purpurmc/purpur/PurpurConfig.java @@ -329,6 +329,7 @@ public class PurpurConfig { public static int barrelRows = 3; public static boolean enderChestSixRows = false; public static boolean enderChestPermissionRows = false; + public static boolean enderChestPersistHiddenRows = true; public static boolean cryingObsidianValidForPortalFrame = false; public static int beeInsideBeeHive = 3; public static boolean anvilCumulativeCost = true; @@ -373,6 +374,7 @@ public class PurpurConfig { enderChestSixRows = getBoolean("settings.blocks.ender_chest.six-rows", enderChestSixRows); org.bukkit.event.inventory.InventoryType.ENDER_CHEST.setDefaultSize(enderChestSixRows ? 54 : 27); enderChestPermissionRows = getBoolean("settings.blocks.ender_chest.use-permissions-for-rows", enderChestPermissionRows); + enderChestPersistHiddenRows = getBoolean("settings.blocks.ender_chest.persist-hidden-rows", enderChestPersistHiddenRows); cryingObsidianValidForPortalFrame = getBoolean("settings.blocks.crying_obsidian.valid-for-portal-frame", cryingObsidianValidForPortalFrame); beeInsideBeeHive = getInt("settings.blocks.beehive.max-bees-inside", beeInsideBeeHive); anvilCumulativeCost = getBoolean("settings.blocks.anvil.cumulative-cost", anvilCumulativeCost);