Search in sources :

Example 1 with CompoundLens

use of org.spongepowered.common.item.inventory.lens.impl.CompoundLens in project SpongeCommon by SpongePowered.

the class MinecraftInventoryAdapter method union.

@Override
default Inventory union(Inventory inventory) {
    CompoundLens.Builder lensBuilder = CompoundLens.builder().add(getRootLens());
    CompoundFabric fabric = new CompoundFabric((MinecraftFabric) getFabric(), (MinecraftFabric) ((InventoryAdapter) inventory).getFabric());
    CompoundSlotProvider provider = new CompoundSlotProvider().add(this);
    for (Object inv : inventory) {
        lensBuilder.add(((InventoryAdapter) inv).getRootLens());
        provider.add((InventoryAdapter) inv);
    }
    CompoundLens lens = lensBuilder.build(provider);
    InventoryAdapter<IInventory, net.minecraft.item.ItemStack> compoundAdapter = lens.getAdapter(fabric, this);
    return Query.compile(compoundAdapter, new SlotLensQueryOperation(ImmutableSet.of(compoundAdapter))).execute();
}
Also used : IInventory(net.minecraft.inventory.IInventory) CompoundSlotProvider(org.spongepowered.common.item.inventory.lens.CompoundSlotProvider) CompoundFabric(org.spongepowered.common.item.inventory.lens.impl.fabric.CompoundFabric) InventoryAdapter(org.spongepowered.common.item.inventory.adapter.InventoryAdapter) CompoundLens(org.spongepowered.common.item.inventory.lens.impl.CompoundLens) ItemStack(org.spongepowered.api.item.inventory.ItemStack) SlotLensQueryOperation(org.spongepowered.common.item.inventory.query.operation.SlotLensQueryOperation)

Aggregations

IInventory (net.minecraft.inventory.IInventory)1 ItemStack (org.spongepowered.api.item.inventory.ItemStack)1 InventoryAdapter (org.spongepowered.common.item.inventory.adapter.InventoryAdapter)1 CompoundSlotProvider (org.spongepowered.common.item.inventory.lens.CompoundSlotProvider)1 CompoundLens (org.spongepowered.common.item.inventory.lens.impl.CompoundLens)1 CompoundFabric (org.spongepowered.common.item.inventory.lens.impl.fabric.CompoundFabric)1 SlotLensQueryOperation (org.spongepowered.common.item.inventory.query.operation.SlotLensQueryOperation)1