Search in sources :

Example 1 with BackpackMode

use of forestry.storage.BackpackMode in project ForestryMC by ForestryMC.

the class ItemBackpack method addInformation.

@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack itemstack, @Nullable World world, List<String> list, ITooltipFlag flag) {
    super.addInformation(itemstack, world, list, flag);
    int occupied = ItemInventory.getOccupiedSlotCount(itemstack);
    BackpackMode mode = getMode(itemstack);
    String infoKey = mode.getUnlocalizedInfo();
    if (infoKey != null) {
        list.add(Translator.translateToLocal(infoKey));
    }
    list.add(Translator.translateToLocal("for.gui.slots").replaceAll("%USED", String.valueOf(occupied)).replaceAll("%SIZE", String.valueOf(getBackpackSize())));
}
Also used : BackpackMode(forestry.storage.BackpackMode) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 2 with BackpackMode

use of forestry.storage.BackpackMode in project ForestryMC by ForestryMC.

the class ItemBackpack method switchMode.

private static void switchMode(ItemStack itemstack) {
    BackpackMode mode = getMode(itemstack);
    int nextMode = mode.ordinal() + 1;
    if (!Config.enableBackpackResupply && nextMode == BackpackMode.RESUPPLY.ordinal()) {
        nextMode++;
    }
    nextMode %= BackpackMode.values().length;
    itemstack.setItemDamage(nextMode);
}
Also used : BackpackMode(forestry.storage.BackpackMode)

Example 3 with BackpackMode

use of forestry.storage.BackpackMode in project ForestryMC by ForestryMC.

the class ItemBackpack method evaluateTileHit.

private boolean evaluateTileHit(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side) {
    // Shift right-clicking on an inventory tile will attempt to transfer
    // items contained in the backpack
    IItemHandler inventory = getInventoryHit(world, pos, side);
    // Process only inventories
    if (inventory != null) {
        // Must have inventory slots
        if (inventory.getSlots() <= 0) {
            return true;
        }
        if (!world.isRemote) {
            // Create our own backpack inventory
            ItemInventoryBackpack backpackInventory = new ItemInventoryBackpack(player, getBackpackSize(), stack);
            BackpackMode mode = getMode(stack);
            if (mode == BackpackMode.RECEIVE) {
                receiveFromChest(backpackInventory, inventory);
            } else {
                transferToChest(backpackInventory, inventory);
            }
        }
        return true;
    }
    return false;
}
Also used : IItemHandler(net.minecraftforge.items.IItemHandler) ItemInventoryBackpack(forestry.storage.inventory.ItemInventoryBackpack) BackpackMode(forestry.storage.BackpackMode)

Aggregations

BackpackMode (forestry.storage.BackpackMode)3 ItemInventoryBackpack (forestry.storage.inventory.ItemInventoryBackpack)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1 IItemHandler (net.minecraftforge.items.IItemHandler)1