summaryrefslogtreecommitdiffstats
path: root/src/main/java/net/minecraft/server/InventoryLargeChest.java
blob: 88cfdcce3044208c116c7de0d654857185a62bb2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
package net.minecraft.server;

// CraftBukkit start
import java.util.ArrayList;
import java.util.List;

import org.bukkit.craftbukkit.entity.CraftHumanEntity;
import org.bukkit.entity.HumanEntity;
import org.bukkit.inventory.InventoryHolder;
// CraftBukkit end

public class InventoryLargeChest implements IInventory {

    private String a;
    public IInventory b; // CraftBukkit - private -> public
    public IInventory c; // CraftBukkit - private -> public

    // CraftBukkit start
    public List<HumanEntity> transaction = new ArrayList<HumanEntity>();
    
    public ItemStack[] getContents() {
        ItemStack[] result = new ItemStack[this.getSize()];
        for (int i = 0; i < result.length; i++) {
            result[i] = this.getItem(i);
        }
        return result;
    }

    public void onOpen(CraftHumanEntity who) {
        b.onOpen(who);
        c.onOpen(who);
        transaction.add(who);
    }

    public void onClose(CraftHumanEntity who) {
        b.onClose(who);
        c.onClose(who);
        transaction.remove(who);
    }
    
    public List<HumanEntity> getViewers() {
        return transaction;
    }
    
    public InventoryHolder getOwner() {
        return null; // Double chests technically have multiple owners, so there's no sensible way to pick one
    }
    // CraftBukkit end

    public InventoryLargeChest(String s, IInventory iinventory, IInventory iinventory1) {
        this.a = s;
        if (iinventory == null) {
            iinventory = iinventory1;
        }

        if (iinventory1 == null) {
            iinventory1 = iinventory;
        }

        this.b = iinventory;
        this.c = iinventory1;
    }

    public int getSize() {
        return this.b.getSize() + this.c.getSize();
    }

    public String getName() {
        return this.a;
    }

    public ItemStack getItem(int i) {
        return i >= this.b.getSize() ? this.c.getItem(i - this.b.getSize()) : this.b.getItem(i);
    }

    public ItemStack splitStack(int i, int j) {
        return i >= this.b.getSize() ? this.c.splitStack(i - this.b.getSize(), j) : this.b.splitStack(i, j);
    }

    public void setItem(int i, ItemStack itemstack) {
        if (i >= this.b.getSize()) {
            this.c.setItem(i - this.b.getSize(), itemstack);
        } else {
            this.b.setItem(i, itemstack);
        }
    }

    public int getMaxStackSize() {
        return this.b.getMaxStackSize();
    }

    public void update() {
        this.b.update();
        this.c.update();
    }

    public boolean a(EntityHuman entityhuman) {
        return this.b.a(entityhuman) && this.c.a(entityhuman);
    }

    public void f() {
        this.b.f();
        this.c.f();
    }

    public void g() {
        this.b.g();
        this.c.g();
    }
}