InventoryEnderChest .java

net.minecraft.inventory.InventoryEnderChest (class): members: loadInventoryFromNBT, saveInventoryToNBT, setChestTileEntity, associatedChest, openInventory.

net.minecraft.inventoryclass91 linescommonextends InventoryBasic2.5 KB

API Surface (6)

void setChestTileEntity(TileEntityEnderChest chestTileEntity)
void loadInventoryFromNBT(NBTTagList p_70486_1_)
NBTTagList saveInventoryToNBT()
boolean isUseableByPlayer(EntityPlayer player)
void openInventory(EntityPlayer player)
void closeInventory(EntityPlayer player)

Fields & Constants (1)

associatedChest

String literals (2)

"container.enderchest"
"Slot"

Code Graph: Dependencies (6)

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

Full Source

InventoryEnderChest.java91 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
import net.minecraft.nbt.NBTTagCompound;
6
import net.minecraft.nbt.NBTTagList;
7
import net.minecraft.tileentity.TileEntityEnderChest;
8
9
public class InventoryEnderChest extends InventoryBasic
10
{
11
    private TileEntityEnderChest associatedChest;
12
13
    public InventoryEnderChest()
14
    {
15
        super("container.enderchest", false, 27);
16
    }
17
18
    public void setChestTileEntity(TileEntityEnderChest chestTileEntity)
19
    {
20
        this.associatedChest = chestTileEntity;
21
    }
22
23
    public void loadInventoryFromNBT(NBTTagList p_70486_1_)
24
    {
25
        for (int i = 0; i < this.getSizeInventory(); ++i)
26
        {
27
            this.setInventorySlotContents(i, (ItemStack)null);
28
        }
29
30
        for (int k = 0; k < p_70486_1_.tagCount(); ++k)
31
        {
32
            NBTTagCompound nbttagcompound = p_70486_1_.getCompoundTagAt(k);
33
            int j = nbttagcompound.getByte("Slot") & 255;
34
35
            if (j >= 0 && j < this.getSizeInventory())
36
            {
37
                this.setInventorySlotContents(j, ItemStack.loadItemStackFromNBT(nbttagcompound));
38
            }
39
        }
40
    }
41
42
    public NBTTagList saveInventoryToNBT()
43
    {
44
        NBTTagList nbttaglist = new NBTTagList();
45
46
        for (int i = 0; i < this.getSizeInventory(); ++i)
47
        {
48
            ItemStack itemstack = this.getStackInSlot(i);
49
50
            if (itemstack != null)
51
            {
52
                NBTTagCompound nbttagcompound = new NBTTagCompound();
53
                nbttagcompound.setByte("Slot", (byte)i);
54
                itemstack.writeToNBT(nbttagcompound);
55
                nbttaglist.appendTag(nbttagcompound);
56
            }
57
        }
58
59
        return nbttaglist;
60
    }
61
62
    /**
63
     * Do not make give this method the name canInteractWith because it clashes with Container
64
     */
65
    public boolean isUseableByPlayer(EntityPlayer player)
66
    {
67
        return this.associatedChest != null && !this.associatedChest.canBeUsed(player) ? false : super.isUseableByPlayer(player);
68
    }
69
70
    public void openInventory(EntityPlayer player)
71
    {
72
        if (this.associatedChest != null)
73
        {
74
            this.associatedChest.openChest();
75
        }
76
77
        super.openInventory(player);
78
    }
79
80
    public void closeInventory(EntityPlayer player)
81
    {
82
        if (this.associatedChest != null)
83
        {
84
            this.associatedChest.closeChest();
85
        }
86
87
        super.closeInventory(player);
88
        this.associatedChest = null;
89
    }
90
}
91

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