Search in sources :

Example 1 with InventoryTileEntity

use of net.mcft.copy.betterstorage.inventory.InventoryTileEntity 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 2 with InventoryTileEntity

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

the class TileEntityCraftingStation method makePlayerInventory.

@Override
public InventoryTileEntity makePlayerInventory() {
    // Workaround because instance variables get initialized AFTER the
    // parent constructor. This gets called IN the parent constructor.
    crafting = new ItemStack[9];
    output = new ItemStack[9];
    stationInventory = new InventoryCraftingStation(this);
    return new InventoryTileEntity(this, stationInventory);
}
Also used : InventoryTileEntity(net.mcft.copy.betterstorage.inventory.InventoryTileEntity) InventoryCraftingStation(net.mcft.copy.betterstorage.inventory.InventoryCraftingStation)

Example 3 with InventoryTileEntity

use of net.mcft.copy.betterstorage.inventory.InventoryTileEntity 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

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