3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-22 14:28:09 +01:00
Paper/nms-patches/InventoryLargeChest.patch
2019-04-23 12:00:00 +10:00

74 Zeilen
2.1 KiB
Diff

--- a/net/minecraft/server/InventoryLargeChest.java
+++ b/net/minecraft/server/InventoryLargeChest.java
@@ -1,10 +1,61 @@
package net.minecraft.server;
+// CraftBukkit start
+import java.util.ArrayList;
+import java.util.List;
+import org.bukkit.Location;
+
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.entity.HumanEntity;
+// CraftBukkit end
+
public class InventoryLargeChest implements IInventory {
public final IInventory left;
public final IInventory right;
+ // CraftBukkit start - add fields and methods
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
+
+ public List<ItemStack> getContents() {
+ List<ItemStack> result = new ArrayList<ItemStack>(this.getSize());
+ for (int i = 0; i < this.getSize(); i++) {
+ result.add(this.getItem(i));
+ }
+ return result;
+ }
+
+ public void onOpen(CraftHumanEntity who) {
+ this.left.onOpen(who);
+ this.right.onOpen(who);
+ transaction.add(who);
+ }
+
+ public void onClose(CraftHumanEntity who) {
+ this.left.onClose(who);
+ this.right.onClose(who);
+ transaction.remove(who);
+ }
+
+ public List<HumanEntity> getViewers() {
+ return transaction;
+ }
+
+ public org.bukkit.inventory.InventoryHolder getOwner() {
+ return null; // This method won't be called since CraftInventoryDoubleChest doesn't defer to here
+ }
+
+ public void setMaxStackSize(int size) {
+ this.left.setMaxStackSize(size);
+ this.right.setMaxStackSize(size);
+ }
+
+ @Override
+ public Location getLocation() {
+ return left.getLocation(); // TODO: right?
+ }
+ // CraftBukkit end
+
public InventoryLargeChest(IInventory iinventory, IInventory iinventory1) {
if (iinventory == null) {
iinventory = iinventory1;
@@ -59,7 +110,7 @@
@Override
public int getMaxStackSize() {
- return this.left.getMaxStackSize();
+ return Math.min(this.left.getMaxStackSize(), this.right.getMaxStackSize()); // CraftBukkit - check both sides
}
@Override