Search in sources :

Example 1 with ItemHandlerInventoryManipulator

use of forestry.core.inventory.ItemHandlerInventoryManipulator in project ForestryMC by ForestryMC.

the class ItemBackpack method receiveFromChest.

private void receiveFromChest(ItemInventoryBackpack backpackInventory, IItemHandler target) {
    ItemHandlerInventoryManipulator manipulator = new ItemHandlerInventoryManipulator(target);
    manipulator.transferStacks(backpackInventory.getItemHandler(), definition.getFilter());
}
Also used : ItemHandlerInventoryManipulator(forestry.core.inventory.ItemHandlerInventoryManipulator)

Example 2 with ItemHandlerInventoryManipulator

use of forestry.core.inventory.ItemHandlerInventoryManipulator in project ForestryMC by ForestryMC.

the class ItemBackpack method tryStowing.

public static void tryStowing(EntityPlayer player, ItemStack backpackStack, ItemStack stack) {
    if (getMode(backpackStack) == BackpackMode.LOCKED) {
        return;
    }
    ItemBackpack backpack = (ItemBackpack) backpackStack.getItem();
    ItemInventory inventory = new ItemInventoryBackpack(player, backpack.getBackpackSize(), backpackStack);
    if (MinecraftForge.EVENT_BUS.post(new BackpackStowEvent(player, backpack.getDefinition(), inventory, stack))) {
        return;
    }
    if (stack.isEmpty()) {
        return;
    }
    IItemHandler itemHandler = inventory.getItemHandler();
    ItemHandlerInventoryManipulator manipulator = new ItemHandlerInventoryManipulator(itemHandler);
    ItemStack remainder = manipulator.addStack(stack);
    stack.setCount(remainder == null ? 0 : remainder.getCount());
}
Also used : BackpackStowEvent(forestry.api.storage.BackpackStowEvent) ItemInventory(forestry.core.inventory.ItemInventory) IItemHandler(net.minecraftforge.items.IItemHandler) ItemInventoryBackpack(forestry.storage.inventory.ItemInventoryBackpack) ItemStack(net.minecraft.item.ItemStack) ItemHandlerInventoryManipulator(forestry.core.inventory.ItemHandlerInventoryManipulator)

Example 3 with ItemHandlerInventoryManipulator

use of forestry.core.inventory.ItemHandlerInventoryManipulator in project ForestryMC by ForestryMC.

the class ItemBackpack method transferToChest.

private static void transferToChest(ItemInventoryBackpack backpackInventory, IItemHandler target) {
    ItemHandlerInventoryManipulator manipulator = new ItemHandlerInventoryManipulator(backpackInventory.getItemHandler());
    manipulator.transferStacks(target, StandardStackFilters.ALL);
}
Also used : ItemHandlerInventoryManipulator(forestry.core.inventory.ItemHandlerInventoryManipulator)

Aggregations

ItemHandlerInventoryManipulator (forestry.core.inventory.ItemHandlerInventoryManipulator)3 BackpackStowEvent (forestry.api.storage.BackpackStowEvent)1 ItemInventory (forestry.core.inventory.ItemInventory)1 ItemInventoryBackpack (forestry.storage.inventory.ItemInventoryBackpack)1 ItemStack (net.minecraft.item.ItemStack)1 IItemHandler (net.minecraftforge.items.IItemHandler)1