use of mods.railcraft.common.util.inventory.InventoryAdvanced in project Railcraft by Railcraft.
the class InventoryTest method buildAdapters.
@Test
void buildAdapters() {
InventoryComposite invBasic = InventoryComposite.of(new InventoryBasic("Test", true, 4));
testComposite("InventoryBasic", invBasic);
InventoryComposite invAdvanced = InventoryComposite.of(new InventoryAdvanced(4));
testComposite("InventoryAdvanced", invAdvanced);
InventoryComposite invCap = InventoryComposite.of(new ICapabilityProvider() {
@Override
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
return true;
}
@Override
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
// noinspection unchecked
return (T) new InvWrapper(new InventoryAdvanced(4));
}
});
testComposite("IItemHandler", invCap);
}
use of mods.railcraft.common.util.inventory.InventoryAdvanced in project Railcraft by Railcraft.
the class InventoryTest method canFit.
@Test
void canFit() {
ItemStack stackFull = new ItemStack(Items.APPLE, 64);
InventoryAdvanced invFull = new InventoryAdvanced(1);
invFull.addStack(stackFull);
InventoryAdvanced invRoom = new InventoryAdvanced(2);
invRoom.addStack(stackFull);
invRoom.addStack(new ItemStack(Items.CARROT, 63));
ItemStack stackApple = new ItemStack(Items.APPLE);
ItemStack stackCarrot = new ItemStack(Items.CARROT);
Assertions.assertFalse(invFull.canFit(stackApple));
Assertions.assertFalse(invFull.canFit(stackCarrot));
Assertions.assertFalse(invRoom.canFit(stackApple));
Assertions.assertTrue(invRoom.canFit(stackCarrot));
}
use of mods.railcraft.common.util.inventory.InventoryAdvanced in project Railcraft by Railcraft.
the class InventoryTest method removeOneItem.
@Test
void removeOneItem() {
ItemStack stack = new ItemStack(Items.APPLE, 32);
InventoryAdvanced inv = new InventoryAdvanced(6);
inv.setInventorySlotContents(3, stack);
ItemStack result = inv.removeOneItem(StackFilters.of(Items.APPLE));
Assertions.assertEquals(1, result.getCount());
Assertions.assertEquals(31, inv.countItems());
}
use of mods.railcraft.common.util.inventory.InventoryAdvanced in project Railcraft by Railcraft.
the class InventoryTest method addStack.
@Test
void addStack() {
ItemStack stack = new ItemStack(Items.APPLE, 32);
InventoryAdvanced inv = new InventoryAdvanced(6);
ItemStack resultStack = inv.addStack(stack);
Assertions.assertTrue(resultStack.isEmpty());
Assertions.assertTrue(inv.contains(stack));
}
use of mods.railcraft.common.util.inventory.InventoryAdvanced in project Railcraft by Railcraft.
the class InventoryTest method removeItems.
@Test
void removeItems() {
ItemStack stack = new ItemStack(Items.APPLE, 32);
InventoryAdvanced inv = new InventoryAdvanced(6);
inv.setInventorySlotContents(3, stack);
Assertions.assertTrue(inv.removeItems(8, StackFilters.of(Items.APPLE)));
Assertions.assertFalse(inv.removeItems(8, StackFilters.of(Items.CARROT)));
Assertions.assertEquals(24, inv.countItems());
}
Aggregations