use of org.spongepowered.common.inventory.fabric.Fabric in project SpongeCommon by SpongePowered.
the class InventoryMixin_Inventory_API method armor.
@Override
public EquipmentInventory armor() {
if (this.api$armor == null && ((InventoryAdapter) this).inventoryAdapter$getRootLens() instanceof PlayerInventoryLens) {
final Lens lens = ((InventoryAdapter) this).inventoryAdapter$getRootLens();
final Fabric fabric = ((InventoryAdapter) this).inventoryAdapter$getFabric();
this.api$armor = (EquipmentInventoryAdapter) ((PlayerInventoryLens) lens).getArmorLens().getAdapter(fabric, this);
}
return this.api$armor;
}
use of org.spongepowered.common.inventory.fabric.Fabric in project SpongeCommon by SpongePowered.
the class InventoryMixin_Inventory_API method primary.
@Override
public PrimaryPlayerInventory primary() {
if (this.api$primary == null && ((InventoryAdapter) this).inventoryAdapter$getRootLens() instanceof PlayerInventoryLens) {
final Lens lens = ((InventoryAdapter) this).inventoryAdapter$getRootLens();
final Fabric fabric = ((InventoryAdapter) this).inventoryAdapter$getFabric();
this.api$primary = (PrimaryPlayerInventoryAdapter) ((PlayerInventoryLens) lens).getPrimaryInventoryLens().getAdapter(fabric, this);
}
return this.api$primary;
}
use of org.spongepowered.common.inventory.fabric.Fabric in project SpongeCommon by SpongePowered.
the class ItemStackQuery method matches.
@Override
public boolean matches(Lens lens, Lens parent, Inventory inventory) {
if (lens instanceof SlotLens) {
Fabric fabric = ((InventoryBridge) inventory).bridge$getAdapter().inventoryAdapter$getFabric();
ItemStack stack = ItemStackUtil.fromNative(((SlotLens) lens).getStack(fabric));
if (stack == null) {
return false;
}
return this.matches(stack, this.arg);
}
return false;
}
use of org.spongepowered.common.inventory.fabric.Fabric in project SpongeCommon by SpongePowered.
the class KeyValueMatcherQuery method execute.
@Override
public Inventory execute(final Inventory inventory, final InventoryAdapter adapter) {
final Fabric fabric = adapter.inventoryAdapter$getFabric();
final Lens lens = adapter.inventoryAdapter$getRootLens();
if (this.matches(lens, null, inventory)) {
return lens.getAdapter(fabric, inventory);
}
return this.toResult(inventory, fabric, this.reduce(fabric, lens, this.search(inventory, lens)));
}
use of org.spongepowered.common.inventory.fabric.Fabric in project SpongeCommon by SpongePowered.
the class SpongeDepthQuery method execute.
public Inventory execute(Inventory inventory, InventoryAdapter adapter) {
final Fabric fabric = adapter.inventoryAdapter$getFabric();
final Lens lens = adapter.inventoryAdapter$getRootLens();
if (this.matches(lens, null, inventory)) {
return lens.getAdapter(fabric, inventory);
}
return this.toResult(inventory, fabric, this.reduce(fabric, lens, this.depthFirstSearch(inventory, lens)));
}
Aggregations