Search in sources :

Example 1 with ItemHandlerSimple

use of buildcraft.lib.tile.item.ItemHandlerSimple in project BuildCraft by BuildCraft.

the class ItemTransactorTester method testLimitedInventory.

@Test
public void testLimitedInventory() {
    IItemTransactor limited = new ItemHandlerSimple(2, (i, s) -> true, StackInsertionFunction.getInsertionFunction(4), null);
    ItemStack toInsert = new ItemStack(Items.APPLE, 9);
    ItemStack toInsertCopy = toInsert.copy();
    ItemStack supposedLeftOver = new ItemStack(Items.APPLE);
    ItemStack actuallyLeftOver = limited.insert(toInsert, false, false);
    Assert.assertTrue(ItemStack.areItemStacksEqual(toInsert, toInsertCopy));
    Assert.assertTrue(ItemStack.areItemStacksEqual(supposedLeftOver, actuallyLeftOver));
}
Also used : IItemTransactor(buildcraft.api.inventory.IItemTransactor) ItemHandlerSimple(buildcraft.lib.tile.item.ItemHandlerSimple) ItemStack(net.minecraft.item.ItemStack) Test(org.junit.Test)

Example 2 with ItemHandlerSimple

use of buildcraft.lib.tile.item.ItemHandlerSimple in project BuildCraft by BuildCraft.

the class ItemTransactorTester method testSimpleMoving.

@Test
public void testSimpleMoving() {
    IItemTransactor trans = new ItemHandlerSimple(2, null);
    Assert.assertTrue(trans.extract(null, 1, 1, false).isEmpty());
    ItemStack insert = new ItemStack(Items.APPLE);
    ItemStack leftOver = trans.insert(insert.copy(), false, false);
    Assert.assertTrue(leftOver.isEmpty());
    ItemStack extracted = trans.extract(null, 1, 1, false);
    Assert.assertTrue(ItemStack.areItemStacksEqual(insert, extracted));
    extracted = trans.extract(null, 1, 1, false);
    Assert.assertTrue(extracted.isEmpty());
}
Also used : IItemTransactor(buildcraft.api.inventory.IItemTransactor) ItemHandlerSimple(buildcraft.lib.tile.item.ItemHandlerSimple) ItemStack(net.minecraft.item.ItemStack) Test(org.junit.Test)

Aggregations

IItemTransactor (buildcraft.api.inventory.IItemTransactor)2 ItemHandlerSimple (buildcraft.lib.tile.item.ItemHandlerSimple)2 ItemStack (net.minecraft.item.ItemStack)2 Test (org.junit.Test)2