ContainerChest .java

net.minecraft.inventory.ContainerChest (class): members: getLowerChestInventory, numRows, lowerChestInventory, onContainerClosed, transferStackInSlot.

net.minecraft.inventoryclass100 linescommonextends Container2.7 KB

API Surface (4)

boolean canInteractWith(EntityPlayer playerIn)
ItemStack transferStackInSlot(EntityPlayer playerIn, int index)
void onContainerClosed(EntityPlayer playerIn)
IInventory getLowerChestInventory()

Fields & Constants (2)

lowerChestInventory
numRows

Code Graph: Dependencies (4)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

ContainerChest.java100 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.inventory;
2
3
import net.minecraft.entity.player.EntityPlayer;
4
import net.minecraft.item.ItemStack;
5
6
public class ContainerChest extends Container
7
{
8
    private IInventory lowerChestInventory;
9
    private int numRows;
10
11
    public ContainerChest(IInventory playerInventory, IInventory chestInventory, EntityPlayer player)
12
    {
13
        this.lowerChestInventory = chestInventory;
14
        this.numRows = chestInventory.getSizeInventory() / 9;
15
        chestInventory.openInventory(player);
16
        int i = (this.numRows - 4) * 18;
17
18
        for (int j = 0; j < this.numRows; ++j)
19
        {
20
            for (int k = 0; k < 9; ++k)
21
            {
22
                this.addSlotToContainer(new Slot(chestInventory, k + j * 9, 8 + k * 18, 18 + j * 18));
23
            }
24
        }
25
26
        for (int l = 0; l < 3; ++l)
27
        {
28
            for (int j1 = 0; j1 < 9; ++j1)
29
            {
30
                this.addSlotToContainer(new Slot(playerInventory, j1 + l * 9 + 9, 8 + j1 * 18, 103 + l * 18 + i));
31
            }
32
        }
33
34
        for (int i1 = 0; i1 < 9; ++i1)
35
        {
36
            this.addSlotToContainer(new Slot(playerInventory, i1, 8 + i1 * 18, 161 + i));
37
        }
38
    }
39
40
    public boolean canInteractWith(EntityPlayer playerIn)
41
    {
42
        return this.lowerChestInventory.isUseableByPlayer(playerIn);
43
    }
44
45
    /**
46
     * Take a stack from the specified inventory slot.
47
     */
48
    public ItemStack transferStackInSlot(EntityPlayer playerIn, int index)
49
    {
50
        ItemStack itemstack = null;
51
        Slot slot = (Slot)this.inventorySlots.get(index);
52
53
        if (slot != null && slot.getHasStack())
54
        {
55
            ItemStack itemstack1 = slot.getStack();
56
            itemstack = itemstack1.copy();
57
58
            if (index < this.numRows * 9)
59
            {
60
                if (!this.mergeItemStack(itemstack1, this.numRows * 9, this.inventorySlots.size(), true))
61
                {
62
                    return null;
63
                }
64
            }
65
            else if (!this.mergeItemStack(itemstack1, 0, this.numRows * 9, false))
66
            {
67
                return null;
68
            }
69
70
            if (itemstack1.stackSize == 0)
71
            {
72
                slot.putStack((ItemStack)null);
73
            }
74
            else
75
            {
76
                slot.onSlotChanged();
77
            }
78
        }
79
80
        return itemstack;
81
    }
82
83
    /**
84
     * Called when the container is closed.
85
     */
86
    public void onContainerClosed(EntityPlayer playerIn)
87
    {
88
        super.onContainerClosed(playerIn);
89
        this.lowerChestInventory.closeInventory(playerIn);
90
    }
91
92
    /**
93
     * Return this chest container's lower chest inventory.
94
     */
95
    public IInventory getLowerChestInventory()
96
    {
97
        return this.lowerChestInventory;
98
    }
99
}
100

Deobfuscated MCP 1.8.9 source of ContainerChest from Marcelektro/MavenMCP-1.8.9 (net/minecraft/inventory/ContainerChest.java), stored verbatim.