mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-06-21 09:47:45 +02:00
246 lines
14 KiB
Diff
246 lines
14 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
|
Date: Thu, 23 May 2019 21:50:37 -0500
|
|
Subject: [PATCH] Barrels and enderchests 6 rows
|
|
|
|
|
|
diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java
|
|
index 5da9ae5617568aaadfe2bf90e3a358d271e0c2c2..e33f57caf9640e891b87a0e9bdcd5a44911bec73 100644
|
|
--- a/net/minecraft/server/players/PlayerList.java
|
|
+++ b/net/minecraft/server/players/PlayerList.java
|
|
@@ -885,6 +885,27 @@ public abstract class PlayerList {
|
|
player.getBukkitEntity().recalculatePermissions(); // CraftBukkit
|
|
this.server.getCommands().sendCommands(player);
|
|
} // Paper - Add sendOpLevel API
|
|
+
|
|
+ // Purpur start - Barrels and enderchests 6 rows
|
|
+ if (org.purpurmc.purpur.PurpurConfig.enderChestSixRows && org.purpurmc.purpur.PurpurConfig.enderChestPermissionRows) {
|
|
+ org.bukkit.craftbukkit.entity.CraftHumanEntity bukkit = player.getBukkitEntity();
|
|
+ if (bukkit.hasPermission("purpur.enderchest.rows.six")) {
|
|
+ player.sixRowEnderchestSlotCount = 54;
|
|
+ } else if (bukkit.hasPermission("purpur.enderchest.rows.five")) {
|
|
+ player.sixRowEnderchestSlotCount = 45;
|
|
+ } else if (bukkit.hasPermission("purpur.enderchest.rows.four")) {
|
|
+ player.sixRowEnderchestSlotCount = 36;
|
|
+ } else if (bukkit.hasPermission("purpur.enderchest.rows.three")) {
|
|
+ player.sixRowEnderchestSlotCount = 27;
|
|
+ } else if (bukkit.hasPermission("purpur.enderchest.rows.two")) {
|
|
+ player.sixRowEnderchestSlotCount = 18;
|
|
+ } else if (bukkit.hasPermission("purpur.enderchest.rows.one")) {
|
|
+ player.sixRowEnderchestSlotCount = 9;
|
|
+ }
|
|
+ } else {
|
|
+ player.sixRowEnderchestSlotCount = -1;
|
|
+ }
|
|
+ // Purpur end - Barrels and enderchests 6 rows
|
|
}
|
|
|
|
// Paper start - whitelist verify event / login event
|
|
diff --git a/net/minecraft/world/entity/player/Player.java b/net/minecraft/world/entity/player/Player.java
|
|
index 3b0a0525cdca3ea5b91834e04b42696a7cedde10..4d80fd91a1f610e5af0ad258f94dc16f2f77ef0d 100644
|
|
--- a/net/minecraft/world/entity/player/Player.java
|
|
+++ b/net/minecraft/world/entity/player/Player.java
|
|
@@ -175,6 +175,7 @@ public abstract class Player extends Avatar implements ContainerUser {
|
|
public net.kyori.adventure.util.TriState flyingFallDamage = net.kyori.adventure.util.TriState.NOT_SET; // Paper - flying fall damage
|
|
public int burpDelay = 0; // Purpur - Burp delay
|
|
public boolean canPortalInstant = false; // Purpur - Add portal permission bypass
|
|
+ public int sixRowEnderchestSlotCount = -1; // Purpur - Barrels and enderchests 6 rows
|
|
|
|
// CraftBukkit start
|
|
public boolean fauxSleeping;
|
|
diff --git a/net/minecraft/world/inventory/ChestMenu.java b/net/minecraft/world/inventory/ChestMenu.java
|
|
index e77bfcd31cdcfd5836dc5db561e3fe2bc552a4b1..afa2ead0548766669201526d83f351c227c97e87 100644
|
|
--- a/net/minecraft/world/inventory/ChestMenu.java
|
|
+++ b/net/minecraft/world/inventory/ChestMenu.java
|
|
@@ -66,10 +66,30 @@ public class ChestMenu extends AbstractContainerMenu {
|
|
return new ChestMenu(MenuType.GENERIC_9x6, containerId, inventory, 6);
|
|
}
|
|
|
|
+ // Purpur start - Barrels and enderchests 6 rows
|
|
+ public static ChestMenu oneRow(int syncId, Inventory playerInventory, Container inventory) {
|
|
+ return new ChestMenu(MenuType.GENERIC_9x1, syncId, playerInventory, inventory, 1);
|
|
+ }
|
|
+
|
|
+ public static ChestMenu twoRows(int syncId, Inventory playerInventory, Container inventory) {
|
|
+ return new ChestMenu(MenuType.GENERIC_9x2, syncId, playerInventory, inventory, 2);
|
|
+ }
|
|
+ // Purpur end - Barrels and enderchests 6 rows
|
|
+
|
|
public static ChestMenu threeRows(final int containerId, final Inventory inventory, final Container container) {
|
|
return new ChestMenu(MenuType.GENERIC_9x3, containerId, inventory, container, 3);
|
|
}
|
|
|
|
+ // Purpur start - Barrels and enderchests 6 rows
|
|
+ public static ChestMenu fourRows(int syncId, Inventory playerInventory, Container inventory) {
|
|
+ return new ChestMenu(MenuType.GENERIC_9x4, syncId, playerInventory, inventory, 4);
|
|
+ }
|
|
+
|
|
+ public static ChestMenu fiveRows(int syncId, Inventory playerInventory, Container inventory) {
|
|
+ return new ChestMenu(MenuType.GENERIC_9x5, syncId, playerInventory, inventory, 5);
|
|
+ }
|
|
+ // Purpur end - Barrels and enderchests 6 rows
|
|
+
|
|
public static ChestMenu sixRows(final int containerId, final Inventory inventory, final Container container) {
|
|
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..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 {
|
|
}
|
|
|
|
public PlayerEnderChestContainer(Player owner) {
|
|
- super(27);
|
|
+ super(org.purpurmc.purpur.PurpurConfig.enderChestSixRows ? 54 : 27); // Purpur - Barrels and enderchests 6 rows
|
|
this.owner = owner;
|
|
// CraftBukkit end
|
|
}
|
|
|
|
+ // Purpur start - Barrels and enderchests 6 rows
|
|
+ @Override
|
|
+ public int getContainerSize() {
|
|
+ return owner == null || owner.sixRowEnderchestSlotCount < 0 ? super.getContainerSize() : owner.sixRowEnderchestSlotCount;
|
|
+ }
|
|
+ // Purpur end - Barrels and enderchests 6 rows
|
|
+
|
|
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 f70a729ab3678fd22d0229bc15d289ddc49b9d01..6a1ea62c737eba6ea30605be89255fb6c221c204 100644
|
|
--- a/net/minecraft/world/level/block/EnderChestBlock.java
|
|
+++ b/net/minecraft/world/level/block/EnderChestBlock.java
|
|
@@ -89,7 +89,7 @@ public class EnderChestBlock extends AbstractChestBlock<EnderChestBlockEntity> i
|
|
// Paper start - Fix InventoryOpenEvent cancellation - moved up;
|
|
container.setActiveChest(enderChest); // Needs to happen before ChestMenu.threeRows as it is required for opening animations
|
|
if (level instanceof ServerLevel serverLevel && player.openMenu(
|
|
- new SimpleMenuProvider((containerId, inventory, p) -> ChestMenu.threeRows(containerId, inventory, container), CONTAINER_TITLE)
|
|
+ new SimpleMenuProvider((containerId, inventory, p) -> org.purpurmc.purpur.PurpurConfig.enderChestSixRows ? getEnderChestSixRows(containerId, inventory, player, container) : ChestMenu.threeRows(containerId, inventory, container), CONTAINER_TITLE) // Purpur - Barrels and enderchests 6 rows
|
|
).isPresent()) {
|
|
// Paper end - Fix InventoryOpenEvent cancellation - moved up;
|
|
player.awardStat(Stats.OPEN_ENDERCHEST);
|
|
@@ -102,6 +102,35 @@ public class EnderChestBlock extends AbstractChestBlock<EnderChestBlockEntity> i
|
|
}
|
|
}
|
|
|
|
+ // Purpur start - Barrels and enderchests 6 rows
|
|
+ private ChestMenu getEnderChestSixRows(int syncId, net.minecraft.world.entity.player.Inventory inventory, Player player, PlayerEnderChestContainer playerEnderChestContainer) {
|
|
+ if (org.purpurmc.purpur.PurpurConfig.enderChestPermissionRows) {
|
|
+ org.bukkit.craftbukkit.entity.CraftHumanEntity bukkitPlayer = player.getBukkitEntity();
|
|
+ if (bukkitPlayer.hasPermission("purpur.enderchest.rows.six")) {
|
|
+ player.sixRowEnderchestSlotCount = 54;
|
|
+ return ChestMenu.sixRows(syncId, inventory, playerEnderChestContainer);
|
|
+ } else if (bukkitPlayer.hasPermission("purpur.enderchest.rows.five")) {
|
|
+ player.sixRowEnderchestSlotCount = 45;
|
|
+ return ChestMenu.fiveRows(syncId, inventory, playerEnderChestContainer);
|
|
+ } else if (bukkitPlayer.hasPermission("purpur.enderchest.rows.four")) {
|
|
+ player.sixRowEnderchestSlotCount = 36;
|
|
+ return ChestMenu.fourRows(syncId, inventory, playerEnderChestContainer);
|
|
+ } else if (bukkitPlayer.hasPermission("purpur.enderchest.rows.three")) {
|
|
+ player.sixRowEnderchestSlotCount = 27;
|
|
+ return ChestMenu.threeRows(syncId, inventory, playerEnderChestContainer);
|
|
+ } else if (bukkitPlayer.hasPermission("purpur.enderchest.rows.two")) {
|
|
+ player.sixRowEnderchestSlotCount = 18;
|
|
+ return ChestMenu.twoRows(syncId, inventory, playerEnderChestContainer);
|
|
+ } else if (bukkitPlayer.hasPermission("purpur.enderchest.rows.one")) {
|
|
+ player.sixRowEnderchestSlotCount = 9;
|
|
+ return ChestMenu.oneRow(syncId, inventory, playerEnderChestContainer);
|
|
+ }
|
|
+ }
|
|
+ player.sixRowEnderchestSlotCount = -1;
|
|
+ return ChestMenu.sixRows(syncId, inventory, playerEnderChestContainer);
|
|
+ }
|
|
+ // Purpur end - Barrels and enderchests 6 rows
|
|
+
|
|
@Override
|
|
public BlockEntity newBlockEntity(final BlockPos worldPosition, final BlockState blockState) {
|
|
return new EnderChestBlockEntity(worldPosition, blockState);
|
|
diff --git a/net/minecraft/world/level/block/entity/BarrelBlockEntity.java b/net/minecraft/world/level/block/entity/BarrelBlockEntity.java
|
|
index 5ba46020b47edfc886ecd5c33483ebb0fa57e5dc..b62a024d2ba1d5d09c81c5060e4eb1a04095681f 100644
|
|
--- a/net/minecraft/world/level/block/entity/BarrelBlockEntity.java
|
|
+++ b/net/minecraft/world/level/block/entity/BarrelBlockEntity.java
|
|
@@ -59,7 +59,16 @@ public class BarrelBlockEntity extends RandomizableContainerBlockEntity {
|
|
}
|
|
// CraftBukkit end
|
|
private static final Component DEFAULT_NAME = Component.translatable("container.barrel");
|
|
- private NonNullList<ItemStack> items = NonNullList.withSize(27, ItemStack.EMPTY);
|
|
+ // Purpur start - Barrels and enderchests 6 rows
|
|
+ private NonNullList<ItemStack> items = NonNullList.withSize(switch (org.purpurmc.purpur.PurpurConfig.barrelRows) {
|
|
+ case 6 -> 54;
|
|
+ case 5 -> 45;
|
|
+ case 4 -> 36;
|
|
+ case 2 -> 18;
|
|
+ case 1 -> 9;
|
|
+ default -> 27;
|
|
+ }, ItemStack.EMPTY);
|
|
+ // Purpur end - Barrels and enderchests 6 rows
|
|
public final ContainerOpenersCounter openersCounter = new ContainerOpenersCounter() {
|
|
// Paper start - delay open/close callbacks
|
|
@Override
|
|
@@ -118,7 +127,16 @@ public class BarrelBlockEntity extends RandomizableContainerBlockEntity {
|
|
|
|
@Override
|
|
public int getContainerSize() {
|
|
- return 27;
|
|
+ // Purpur start - Barrels and enderchests 6 rows
|
|
+ return switch (org.purpurmc.purpur.PurpurConfig.barrelRows) {
|
|
+ case 6 -> 54;
|
|
+ case 5 -> 45;
|
|
+ case 4 -> 36;
|
|
+ case 2 -> 18;
|
|
+ case 1 -> 9;
|
|
+ default -> 27;
|
|
+ };
|
|
+ // Purpur end - Barrels and enderchests 6 rows
|
|
}
|
|
|
|
@Override
|
|
@@ -138,7 +156,16 @@ public class BarrelBlockEntity extends RandomizableContainerBlockEntity {
|
|
|
|
@Override
|
|
protected AbstractContainerMenu createMenu(final int containerId, final Inventory inventory) {
|
|
- return ChestMenu.threeRows(containerId, inventory, this);
|
|
+ // Purpur start - Barrels and enderchests 6 rows
|
|
+ return switch (org.purpurmc.purpur.PurpurConfig.barrelRows) {
|
|
+ case 6 -> ChestMenu.sixRows(containerId, inventory, this);
|
|
+ case 5 -> ChestMenu.fiveRows(containerId, inventory, this);
|
|
+ case 4 -> ChestMenu.fourRows(containerId, inventory, this);
|
|
+ case 2 -> ChestMenu.twoRows(containerId, inventory, this);
|
|
+ case 1 -> ChestMenu.oneRow(containerId, inventory, this);
|
|
+ default -> ChestMenu.threeRows(containerId, inventory, this);
|
|
+ };
|
|
+ // Purpur end - Barrels and enderchests 6 rows
|
|
}
|
|
|
|
@Override
|