use of org.spongepowered.common.item.inventory.lens.impl.ReusableLens 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);
}
use of org.spongepowered.common.item.inventory.lens.impl.ReusableLens in project SpongeCommon by SpongePowered.
the class MixinTileEntityLockable method generateLens.
@Override
public ReusableLens<?> generateLens(Fabric<IInventory> fabric, InventoryAdapter<IInventory, ItemStack> adapter) {
SlotCollection slots = new SlotCollection.Builder().add(this.getSizeInventory()).build();
OrderedInventoryLensImpl lens = new OrderedInventoryLensImpl(0, this.getSizeInventory(), 1, slots);
return new ReusableLens<>(slots, lens);
}
Aggregations