use of org.spongepowered.common.inventory.lens.impl.QueryLens in project SpongeCommon by SpongePowered.
the class SpongeQuery method toResult.
protected Inventory toResult(Inventory inventory, Fabric fabric, Map<Lens, Integer> matches) {
if (matches.isEmpty()) {
return new EmptyInventoryImpl(inventory);
}
if (matches.size() == 1) {
final Map.Entry<Lens, Integer> entry = matches.entrySet().iterator().next();
if (entry.getValue() == 0) {
return entry.getKey().getAdapter(fabric, inventory);
}
final LensRegistrar.BasicSlotLensProvider slotProvider = new LensRegistrar.BasicSlotLensProvider(entry.getKey().slotCount());
// TODO check correct slotprovider
final DelegatingLens delegate = new DelegatingLens(entry.getValue(), entry.getKey(), slotProvider);
return delegate.getAdapter(fabric, inventory);
}
final QueryLens lens = new QueryLens(matches, this);
return lens.getAdapter(fabric, inventory);
}
Aggregations