Persist hidden items in permission-based ender chest rows (#1774)

Co-authored-by: granny <granny@purpurmc.org>
This commit is contained in:
GoodrichDev
2026-05-01 15:59:31 -07:00
committed by GitHub
parent 1042bc8f07
commit 9982c0e2b0
2 changed files with 32 additions and 1 deletions

View File

@@ -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<ItemStackWithSlot> 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<ItemStackWithSlot> 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

View File

@@ -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);