use of org.spongepowered.common.inventory.lens.impl.comp.EquipmentInventoryLens in project SpongeCommon by SpongePowered.
the class LivingEntityMixin_Inventory method impl$getSpongeSlot.
@SuppressWarnings("ConstantConditions")
protected Slot impl$getSpongeSlot(final EquipmentSlot equipmentSlot) {
final EquipmentType equipmentType = (EquipmentType) (Object) equipmentSlot;
if (this instanceof InventoryBridge) {
final InventoryAdapter adapter = ((InventoryBridge) this).bridge$getAdapter();
final Lens lens = adapter.inventoryAdapter$getRootLens();
if (lens instanceof EquipmentInventoryLens) {
final SlotLens slotLens = ((EquipmentInventoryLens) lens).getSlotLens(equipmentType);
return slotLens.getAdapter(adapter.inventoryAdapter$getFabric(), (Inventory) adapter);
}
throw new IllegalStateException("Expected EquipmentInventoryLens for " + this.getClass().getName() + " Inventory but found: " + lens.getClass().getName());
}
throw new IllegalStateException("Living Entity has no InventoryAdapter: " + this.getClass().getName());
}
Aggregations