下面列出了怎么用net.minecraft.inventory.InventoryLargeChest的API类实例代码及写法,或者点击链接到github查看源代码。
public CraftInventoryDoubleChest(InventoryLargeChest largeChest) {
super(largeChest);
if (largeChest.upperChest instanceof InventoryLargeChest) {
left = new CraftInventoryDoubleChest((InventoryLargeChest) largeChest.upperChest);
} else {
left = new CraftInventory(largeChest.upperChest);
}
if (largeChest.lowerChest instanceof InventoryLargeChest) {
right = new CraftInventoryDoubleChest((InventoryLargeChest) largeChest.lowerChest);
} else {
right = new CraftInventory(largeChest.lowerChest);
}
}
public static IInventory getChest(TileEntityChest chest) {
for (EnumFacing fside : Plane.HORIZONTAL) {
if (chest.getWorld().getBlockState(chest.getPos().offset(fside)).getBlock() == chest.getBlockType())
return new InventoryLargeChest("container.chestDouble",
(TileEntityChest) chest.getWorld().getTileEntity(chest.getPos().offset(fside)), chest);
}
return chest;
}
public static IInventory checkForDoubleChest(World worldObj, IInventory te, int x, int y, int z) {
for(ForgeDirection dir : chestDirections) {
if(worldObj.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ) == Blocks.chest) {
TileEntity otherTe = worldObj.getTileEntity(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
if(otherTe instanceof IInventory) {
return new InventoryLargeChest("Large Chest", te, (IInventory)otherTe);
}
}
}
// Not a large chest, so just return the single chest.
return te;
}
public CraftInventoryDoubleChest(CraftInventory left, CraftInventory right) {
super(new InventoryLargeChest("Large chest", (ILockableContainer) left.getInventory(), (ILockableContainer) right.getInventory()));
this.left = left;
this.right = right;
}