Search in sources :

Example 1 with GridInventory

use of org.spongepowered.api.item.inventory.type.GridInventory in project SpongeCommon by SpongePowered.

the class InventorySetOpsTest method testUnion.

private void testUnion() {
    Inventory chest = Inventory.builder().build(this);
    Inventory firstSlots = chest.query(QueryOperationTypes.INVENTORY_PROPERTY.of(SlotIndex.of(0)));
    Inventory firstRow = chest.query(QueryOperationTypes.INVENTORY_TYPE.of(InventoryRow.class)).first();
    GridInventory grid = chest.query(QueryOperationTypes.INVENTORY_TYPE.of(GridInventory.class));
    InventoryColumn firstCol = grid.getColumn(0).get();
    InventoryColumn secondCol = grid.getColumn(1).get();
    Inventory union = firstSlots.union(firstCol).union(firstRow);
    Inventory union2 = firstCol.union(firstRow);
    Inventory union3 = firstCol.union(secondCol);
    Preconditions.checkState(union.capacity() == 11, "This should include all eleven slot of the first row and column!");
    Preconditions.checkState(union2.capacity() == 11, "This should include all eleven slot of the first row and column!");
    Preconditions.checkState(union3.capacity() == 6, "This should include all six slot of the first 2 columns!");
}
Also used : GridInventory(org.spongepowered.api.item.inventory.type.GridInventory) Inventory(org.spongepowered.api.item.inventory.Inventory) GridInventory(org.spongepowered.api.item.inventory.type.GridInventory) InventoryColumn(org.spongepowered.api.item.inventory.type.InventoryColumn)

Aggregations

Inventory (org.spongepowered.api.item.inventory.Inventory)1 GridInventory (org.spongepowered.api.item.inventory.type.GridInventory)1 InventoryColumn (org.spongepowered.api.item.inventory.type.InventoryColumn)1