Search in sources :

Example 1 with CompoundFabric

use of org.spongepowered.common.inventory.fabric.CompoundFabric in project SpongeCommon by SpongePowered.

the class UnionQuery method execute.

@Override
public Inventory execute(Inventory inventory, InventoryAdapter adapter) {
    final CompoundLens.Builder lensBuilder = CompoundLens.builder().add(adapter.inventoryAdapter$getRootLens());
    final CompoundFabric fabric = new CompoundFabric(adapter.inventoryAdapter$getFabric(), ((InventoryBridge) this.other).bridge$getAdapter().inventoryAdapter$getFabric());
    final CompoundSlotLensProvider provider = new CompoundSlotLensProvider().add(adapter);
    for (final Inventory inv : this.other.children()) {
        lensBuilder.add(((InventoryAdapter) inv).inventoryAdapter$getRootLens());
        provider.add((InventoryAdapter) inv);
    }
    final CompoundLens lens = lensBuilder.build(provider);
    return lens.getAdapter(fabric, inventory);
}
Also used : CompoundFabric(org.spongepowered.common.inventory.fabric.CompoundFabric) InventoryBridge(org.spongepowered.common.bridge.world.inventory.InventoryBridge) CompoundSlotLensProvider(org.spongepowered.common.inventory.lens.CompoundSlotLensProvider) CompoundLens(org.spongepowered.common.inventory.lens.impl.CompoundLens) Inventory(org.spongepowered.api.item.inventory.Inventory)

Aggregations

Inventory (org.spongepowered.api.item.inventory.Inventory)1 InventoryBridge (org.spongepowered.common.bridge.world.inventory.InventoryBridge)1 CompoundFabric (org.spongepowered.common.inventory.fabric.CompoundFabric)1 CompoundSlotLensProvider (org.spongepowered.common.inventory.lens.CompoundSlotLensProvider)1 CompoundLens (org.spongepowered.common.inventory.lens.impl.CompoundLens)1