use of org.spongepowered.common.item.inventory.query.operation.SlotLensQueryOperation 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();
}
Aggregations