Search in sources :

Example 1 with InventoryBackpackEquipped

use of net.mcft.copy.betterstorage.inventory.InventoryBackpackEquipped in project BetterStorage by copygirl.

the class ItemBackpack method openBackpack.

/** Opens the carrier's equipped backpack for the player.
	 *  Returns if it was successfully opened. */
public static boolean openBackpack(EntityPlayer player, EntityLivingBase carrier) {
    ItemStack backpack = ItemBackpack.getBackpack(carrier);
    if (backpack == null)
        return false;
    ItemBackpack backpackType = (ItemBackpack) backpack.getItem();
    IInventory inventory = ItemBackpack.getBackpackItems(carrier, player);
    inventory = new InventoryBackpackEquipped(carrier, player, inventory);
    if (!inventory.isUseableByPlayer(player))
        return false;
    int columns = backpackType.getBackpackColumns();
    int rows = backpackType.getBackpackRows();
    Container container = new ContainerBetterStorage(player, inventory, columns, rows);
    String title = StackUtils.get(backpack, "", "display", "Name");
    PlayerUtils.openGui(player, inventory.getInventoryName(), columns, rows, title, container);
    return true;
}
Also used : IInventory(net.minecraft.inventory.IInventory) ContainerBetterStorage(net.mcft.copy.betterstorage.container.ContainerBetterStorage) Container(net.minecraft.inventory.Container) InventoryBackpackEquipped(net.mcft.copy.betterstorage.inventory.InventoryBackpackEquipped) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ContainerBetterStorage (net.mcft.copy.betterstorage.container.ContainerBetterStorage)1 InventoryBackpackEquipped (net.mcft.copy.betterstorage.inventory.InventoryBackpackEquipped)1 Container (net.minecraft.inventory.Container)1 IInventory (net.minecraft.inventory.IInventory)1 ItemStack (net.minecraft.item.ItemStack)1