use of org.spongepowered.common.inventory.lens.impl.minecraft.SingleIndexedLens in project SpongeCommon by SpongePowered.
the class LensRegistrar method generateLens.
@SuppressWarnings("unchecked")
private static Lens generateLens(Object inventory, int size, SlotLensProvider slotLensProvider) {
if (size == 0) {
return new DefaultEmptyLens();
}
LensFactory lensFactory = LensRegistrar.lensFactories.get(inventory.getClass());
Lens lens = null;
if (lensFactory != null) {
lens = lensFactory.apply(inventory.getClass(), size, slotLensProvider);
if (lens != null) {
return lens;
}
}
if (inventory instanceof CraftingContainer) {
lens = LensRegistrar.lensCraftingInventory(size, ((CraftingContainer) inventory).getWidth(), ((CraftingContainer) inventory).getHeight(), slotLensProvider);
} else if (inventory instanceof AbstractContainerMenu) {
lens = ContainerUtil.generateLens(((AbstractContainerMenu) inventory), slotLensProvider);
} else if (size == 1) {
return slotLensProvider.getSlotLens(0);
}
if (lens != null) {
return lens;
}
return new SingleIndexedLens(0, size, (Class<? extends Inventory>) inventory.getClass(), slotLensProvider);
}
Aggregations