Search in sources :

Example 1 with ContainerBetterStorage

use of net.mcft.copy.betterstorage.container.ContainerBetterStorage in project BetterStorage by copygirl.

the class TileEntityContainer method openGui.

/** Opens the GUI of this container for the player. */
public void openGui(EntityPlayer player) {
    ContainerBetterStorage container = createContainer(player);
    PlayerUtils.openGui(player, getName(), container.getColumns(), container.getRows(), getCustomTitle(), container);
}
Also used : ContainerBetterStorage(net.mcft.copy.betterstorage.container.ContainerBetterStorage)

Example 2 with ContainerBetterStorage

use of net.mcft.copy.betterstorage.container.ContainerBetterStorage in project BetterStorage by copygirl.

the class TileEnderBackpack method onBlockActivated.

@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
    if (!world.isRemote) {
        TileEntityBackpack backpack = WorldUtils.get(world, x, y, z, TileEntityBackpack.class);
        IInventory inventory = new InventoryTileEntity(backpack, player.getInventoryEnderChest());
        Container container = new ContainerBetterStorage(player, inventory, 9, 3);
        String name = "container." + Constants.modId + ".enderBackpack";
        PlayerUtils.openGui(player, name, 9, 3, backpack.getCustomTitle(), container);
    }
    return true;
}
Also used : IInventory(net.minecraft.inventory.IInventory) ContainerBetterStorage(net.mcft.copy.betterstorage.container.ContainerBetterStorage) Container(net.minecraft.inventory.Container) TileEntityBackpack(net.mcft.copy.betterstorage.tile.entity.TileEntityBackpack) InventoryTileEntity(net.mcft.copy.betterstorage.inventory.InventoryTileEntity)

Example 3 with ContainerBetterStorage

use of net.mcft.copy.betterstorage.container.ContainerBetterStorage 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)

Example 4 with ContainerBetterStorage

use of net.mcft.copy.betterstorage.container.ContainerBetterStorage in project BetterStorage by copygirl.

the class WorldUtils method syncPlayersUsing.

/** Counts and returns the number of players who're accessing a tile entity. */
public static int syncPlayersUsing(TileEntity te, int playersUsing, IInventory playerInventory) {
    if (!te.getWorldObj().isRemote && (playersUsing != 0)) {
        playersUsing = 0;
        List<EntityPlayer> players = te.getWorldObj().getEntitiesWithinAABB(EntityPlayer.class, getAABB(te, 5));
        for (EntityPlayer player : players) {
            if (player.openContainer instanceof ContainerBetterStorage) {
                IInventory inventory = ((ContainerBetterStorage) player.openContainer).inventory;
                if (inventory == playerInventory)
                    playersUsing++;
                else if (inventory instanceof InventoryTileEntity)
                    if (((InventoryTileEntity) inventory).mainTileEntity == te)
                        playersUsing++;
            }
        }
    }
    return playersUsing;
}
Also used : ContainerBetterStorage(net.mcft.copy.betterstorage.container.ContainerBetterStorage) IInventory(net.minecraft.inventory.IInventory) InventoryTileEntity(net.mcft.copy.betterstorage.inventory.InventoryTileEntity) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Aggregations

ContainerBetterStorage (net.mcft.copy.betterstorage.container.ContainerBetterStorage)4 IInventory (net.minecraft.inventory.IInventory)3 InventoryTileEntity (net.mcft.copy.betterstorage.inventory.InventoryTileEntity)2 Container (net.minecraft.inventory.Container)2 InventoryBackpackEquipped (net.mcft.copy.betterstorage.inventory.InventoryBackpackEquipped)1 TileEntityBackpack (net.mcft.copy.betterstorage.tile.entity.TileEntityBackpack)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 ItemStack (net.minecraft.item.ItemStack)1