use of org.spongepowered.common.item.inventory.lens.ReusableLensProvider in project SpongeCommon by SpongePowered.
the class MixinTraitAdapter method getReusableLens.
@SuppressWarnings("unchecked")
private ReusableLens<?> getReusableLens() {
if (this.reusableLens != null) {
return this.reusableLens;
}
if (this instanceof ReusableLensProvider) {
return ((ReusableLensProvider<IInventory, ItemStack>) this).generateLens(this.getFabric(), this);
}
if (this instanceof LensProvider) {
this.slots = ((LensProvider) this).slotProvider(this.getFabric(), this);
Lens lens = ((LensProvider) this).rootLens(this.getFabric(), this);
return new ReusableLens<>(this.slots, lens);
}
SlotCollection slots = new SlotCollection.Builder().add(this.getFabric().getSize()).build();
Lens<IInventory, ItemStack> lens;
if (this.getFabric().getSize() == 0) {
lens = new DefaultEmptyLens<>(this);
} else {
lens = new OrderedInventoryLensImpl(0, this.getFabric().getSize(), 1, slots);
}
return new ReusableLens<>(slots, lens);
}
Aggregations