use of org.spongepowered.common.inventory.lens.Lens in project SpongeCommon by SpongePowered.
the class AbstractLens method getSlotLens.
@Override
@Nullable
public SlotLens getSlotLens(Fabric fabric, int ordinal) {
if (ordinal < 0 || ordinal > this.maxOrdinal) {
return null;
}
int offset = 0;
for (final Lens child : this.spanningChildren) {
int count = child.slotCount();
if (ordinal < offset + count) {
return child.getSlotLens(fabric, ordinal - offset);
}
offset += count;
}
return null;
}
use of org.spongepowered.common.inventory.lens.Lens in project SpongeCommon by SpongePowered.
the class AbstractContainerMenuMixin_Adapter_Inventory method inventoryAdapter$getSlot.
@Override
public Optional<org.spongepowered.api.item.inventory.Slot> inventoryAdapter$getSlot(int ordinal) {
org.spongepowered.api.item.inventory.Slot slot = this.impl$slots.get(ordinal);
if (slot == null) {
Lens rootLens = this.inventoryAdapter$getRootLens();
SlotLens slotLens = rootLens.getSlotLens(this.inventoryAdapter$getFabric(), ordinal);
if (slotLens == null) {
return Optional.empty();
}
slot = slotLens.getAdapter(this.inventoryAdapter$getFabric(), ((Inventory) this));
this.impl$slots.put(ordinal, slot);
}
return Optional.of(slot);
}
Aggregations