Files
CatServer/patches/net/minecraft/inventory/InventoryLargeChest.java.patch
2018-07-20 01:14:44 +08:00

69 lines
2.5 KiB
Diff

--- ../src-base/minecraft/net/minecraft/inventory/InventoryLargeChest.java
+++ ../src-work/minecraft/net/minecraft/inventory/InventoryLargeChest.java
@@ -7,14 +7,61 @@
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextComponentTranslation;
+import net.minecraft.world.IInteractionObject;
import net.minecraft.world.ILockableContainer;
import net.minecraft.world.LockCode;
-public class InventoryLargeChest implements ILockableContainer
-{
+import java.util.List;
+import org.bukkit.Location;
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.entity.HumanEntity;
+
+
+public class InventoryLargeChest implements IInventory, ILockableContainer, IInteractionObject {
private final String name;
- private final ILockableContainer upperChest;
- private final ILockableContainer lowerChest;
+ public final ILockableContainer upperChest;
+ public final ILockableContainer lowerChest;
+ // CraftBukkit start - add fields and methods
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
+
+ public ItemStack[] getContents() {
+ ItemStack[] result = new ItemStack[this.getSizeInventory()];
+ for (int i = 0; i < result.length; i++) {
+ result[i] = this.getStackInSlot(i);
+ }
+ return result;
+ }
+
+ public void onOpen(CraftHumanEntity who) {
+ ((IInventory) this.upperChest).onOpen(who);
+ ((IInventory) this.lowerChest).onOpen(who);
+ transaction.add(who);
+ }
+
+ public void onClose(CraftHumanEntity who) {
+ ((IInventory) this.upperChest).onClose(who);
+ ((IInventory) this.lowerChest).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) {
+ ((IInventory) this.upperChest).setMaxStackSize(size);
+ ((IInventory) this.lowerChest).setMaxStackSize(size);
+ }
+
+ @Override
+ public Location getLocation() {
+ return ((IInventory) upperChest).getLocation(); // TODO: right?
+ }
+ // CraftBukkit end
public InventoryLargeChest(String nameIn, ILockableContainer upperChestIn, ILockableContainer lowerChestIn)
{