ContainerDispenser .java

net.minecraft.inventory.ContainerDispenser (class, 86 lines): members: dispenserInventory, transferStackInSlot, canInteractWith. imports: ItemStack.

net.minecraft.inventoryclass86 linescommonextends Container2.2 KB

API Surface (2)

boolean canInteractWith(EntityPlayer playerIn)
ItemStack transferStackInSlot(EntityPlayer playerIn, int index)

Fields & Constants (1)

dispenserInventory

Code Graph: Dependencies (4)

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

Full Source

ContainerDispenser.java86 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 ContainerDispenser extends Container
7
{
8
    private IInventory dispenserInventory;
9
10
    public ContainerDispenser(IInventory playerInventory, IInventory dispenserInventoryIn)
11
    {
12
        this.dispenserInventory = dispenserInventoryIn;
13
14
        for (int i = 0; i < 3; ++i)
15
        {
16
            for (int j = 0; j < 3; ++j)
17
            {
18
                this.addSlotToContainer(new Slot(dispenserInventoryIn, j + i * 3, 62 + j * 18, 17 + i * 18));
19
            }
20
        }
21
22
        for (int k = 0; k < 3; ++k)
23
        {
24
            for (int i1 = 0; i1 < 9; ++i1)
25
            {
26
                this.addSlotToContainer(new Slot(playerInventory, i1 + k * 9 + 9, 8 + i1 * 18, 84 + k * 18));
27
            }
28
        }
29
30
        for (int l = 0; l < 9; ++l)
31
        {
32
            this.addSlotToContainer(new Slot(playerInventory, l, 8 + l * 18, 142));
33
        }
34
    }
35
36
    public boolean canInteractWith(EntityPlayer playerIn)
37
    {
38
        return this.dispenserInventory.isUseableByPlayer(playerIn);
39
    }
40
41
    /**
42
     * Take a stack from the specified inventory slot.
43
     */
44
    public ItemStack transferStackInSlot(EntityPlayer playerIn, int index)
45
    {
46
        ItemStack itemstack = null;
47
        Slot slot = (Slot)this.inventorySlots.get(index);
48
49
        if (slot != null && slot.getHasStack())
50
        {
51
            ItemStack itemstack1 = slot.getStack();
52
            itemstack = itemstack1.copy();
53
54
            if (index < 9)
55
            {
56
                if (!this.mergeItemStack(itemstack1, 9, 45, true))
57
                {
58
                    return null;
59
                }
60
            }
61
            else if (!this.mergeItemStack(itemstack1, 0, 9, false))
62
            {
63
                return null;
64
            }
65
66
            if (itemstack1.stackSize == 0)
67
            {
68
                slot.putStack((ItemStack)null);
69
            }
70
            else
71
            {
72
                slot.onSlotChanged();
73
            }
74
75
            if (itemstack1.stackSize == itemstack.stackSize)
76
            {
77
                return null;
78
            }
79
80
            slot.onPickupFromSlot(playerIn, itemstack1);
81
        }
82
83
        return itemstack;
84
    }
85
}
86

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