use of org.spongepowered.common.inventory.lens.impl.CompoundLens 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);
}
use of org.spongepowered.common.inventory.lens.impl.CompoundLens in project SpongeCommon by SpongePowered.
the class ReverseQuery method execute.
@Override
public Inventory execute(Inventory parent, InventoryAdapter inventory) {
List<Slot> slots = new ArrayList<>(((Inventory) inventory).slots());
Collections.reverse(slots);
CompoundSlotLensProvider slotProvider = new CompoundSlotLensProvider();
slots.forEach(s -> slotProvider.add((InventoryAdapter) s));
InventoryAdapter adapter = ((InventoryBridge) inventory).bridge$getAdapter();
CompoundLens lens = CompoundLens.builder().add(adapter.inventoryAdapter$getRootLens()).build(slotProvider);
return lens.getAdapter(adapter.inventoryAdapter$getFabric(), (Inventory) inventory);
}
Aggregations