mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
219 lines
12 KiB
Diff
219 lines
12 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 23181b6192d3d69f263bf57bfd0d2fac000ce15b..f2fe9a8369b923edf6abe8af01d8a34e995e0b9b 100644
|
|
--- a/net/minecraft/server/players/PlayerList.java
|
|
+++ b/net/minecraft/server/players/PlayerList.java
|
|
@@ -912,6 +912,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 1e14640b74950ecd2abd0ae13a7c83fa6a318703..6a71ec21849b30dd3f0f1ad86ccb01ee472a55b7 100644
|
|
--- a/net/minecraft/world/entity/player/Player.java
|
|
+++ b/net/minecraft/world/entity/player/Player.java
|
|
@@ -182,6 +182,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 0fffa384f928ab84451331380968fb4650eafe26..0399092c9f7a43ac100c11505176ade6d95a39da 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, playerInventory, 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(int containerId, Inventory playerInventory, Container container) {
|
|
return new ChestMenu(MenuType.GENERIC_9x3, containerId, playerInventory, 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(int containerId, Inventory playerInventory, Container container) {
|
|
return new ChestMenu(MenuType.GENERIC_9x6, containerId, playerInventory, container, 6);
|
|
}
|
|
diff --git a/net/minecraft/world/inventory/PlayerEnderChestContainer.java b/net/minecraft/world/inventory/PlayerEnderChestContainer.java
|
|
index 8cf089874a75735be690ab72a01264bac5ff793d..611f78f93b70674b53c025d9151dacb54af3e803 100644
|
|
--- a/net/minecraft/world/inventory/PlayerEnderChestContainer.java
|
|
+++ b/net/minecraft/world/inventory/PlayerEnderChestContainer.java
|
|
@@ -27,11 +27,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.sixRowEnderchestSlotCount < 0 ? super.getContainerSize() : owner.sixRowEnderchestSlotCount;
|
|
+ }
|
|
+ // Purpur end - Barrels and enderchests 6 rows
|
|
+
|
|
public void setActiveChest(EnderChestBlockEntity enderChestBlockEntity) {
|
|
this.activeChest = enderChestBlockEntity;
|
|
}
|
|
diff --git a/net/minecraft/world/level/block/EnderChestBlock.java b/net/minecraft/world/level/block/EnderChestBlock.java
|
|
index 1518e035c4b6fdfc68b77fc42b043dd27f680767..a7b20c0781b0372a36e67c7b5a3eae90476f83e0 100644
|
|
--- a/net/minecraft/world/level/block/EnderChestBlock.java
|
|
+++ b/net/minecraft/world/level/block/EnderChestBlock.java
|
|
@@ -85,8 +85,8 @@ public class EnderChestBlock extends AbstractChestBlock<EnderChestBlockEntity> i
|
|
enderChestInventory.setActiveChest(enderChestBlockEntity); // Needs to happen before ChestMenu.threeRows as it is required for opening animations
|
|
if (level instanceof ServerLevel serverLevel && player.openMenu(
|
|
new SimpleMenuProvider(
|
|
- (containerId, playerInventory, player1) -> ChestMenu.threeRows(containerId, playerInventory, enderChestInventory), CONTAINER_TITLE
|
|
- )
|
|
+ (containerId, playerInventory, player1) -> org.purpurmc.purpur.PurpurConfig.enderChestSixRows ? getEnderChestSixRows(containerId, playerInventory, player, enderChestInventory) : ChestMenu.threeRows(containerId, playerInventory, enderChestInventory), CONTAINER_TITLE
|
|
+ ) // Purpur - Barrels and enderchests 6 rows
|
|
).isPresent()) {
|
|
// Paper end - Fix InventoryOpenEvent cancellation - moved up;
|
|
player.awardStat(Stats.OPEN_ENDERCHEST);
|
|
@@ -100,6 +100,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(BlockPos pos, BlockState state) {
|
|
return new EnderChestBlockEntity(pos, state);
|
|
diff --git a/net/minecraft/world/level/block/entity/BarrelBlockEntity.java b/net/minecraft/world/level/block/entity/BarrelBlockEntity.java
|
|
index f8cad05f5f1692c9a8701ff01f33d83477600c34..a4a4150beab8f2fa409a2d1d495a56679aecbae3 100644
|
|
--- a/net/minecraft/world/level/block/entity/BarrelBlockEntity.java
|
|
+++ b/net/minecraft/world/level/block/entity/BarrelBlockEntity.java
|
|
@@ -58,7 +58,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() {
|
|
@Override
|
|
protected void onOpen(Level level, BlockPos pos, BlockState state) {
|
|
@@ -110,7 +119,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
|
|
@@ -130,7 +148,16 @@ public class BarrelBlockEntity extends RandomizableContainerBlockEntity {
|
|
|
|
@Override
|
|
protected AbstractContainerMenu createMenu(int id, Inventory player) {
|
|
- return ChestMenu.threeRows(id, player, this);
|
|
+ // Purpur start - Barrels and enderchests 6 rows
|
|
+ return switch (org.purpurmc.purpur.PurpurConfig.barrelRows) {
|
|
+ case 6 -> ChestMenu.sixRows(id, player, this);
|
|
+ case 5 -> ChestMenu.fiveRows(id, player, this);
|
|
+ case 4 -> ChestMenu.fourRows(id, player, this);
|
|
+ case 2 -> ChestMenu.twoRows(id, player, this);
|
|
+ case 1 -> ChestMenu.oneRow(id, player, this);
|
|
+ default -> ChestMenu.threeRows(id, player, this);
|
|
+ };
|
|
+ // Purpur end - Barrels and enderchests 6 rows
|
|
}
|
|
|
|
@Override
|