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);
}
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;
}
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;
}
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;
}
Aggregations