Search in sources :

Example 6 with PlayerInventoryLens

use of org.spongepowered.common.inventory.lens.impl.minecraft.PlayerInventoryLens 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;
}
Also used : EquipmentInventoryAdapter(org.spongepowered.common.inventory.adapter.impl.comp.EquipmentInventoryAdapter) PrimaryPlayerInventoryAdapter(org.spongepowered.common.inventory.adapter.impl.comp.PrimaryPlayerInventoryAdapter) InventoryAdapter(org.spongepowered.common.inventory.adapter.InventoryAdapter) PlayerInventoryLens(org.spongepowered.common.inventory.lens.impl.minecraft.PlayerInventoryLens) PlayerInventoryLens(org.spongepowered.common.inventory.lens.impl.minecraft.PlayerInventoryLens) Lens(org.spongepowered.common.inventory.lens.Lens) Fabric(org.spongepowered.common.inventory.fabric.Fabric)

Example 7 with PlayerInventoryLens

use of org.spongepowered.common.inventory.lens.impl.minecraft.PlayerInventoryLens in project SpongeCommon by SpongePowered.

the class ContainerPlayerInventoryLens method lenses.

private static List<Lens> lenses(int size, SlotLensProvider slots) {
    // 1
    int base = ContainerPlayerInventoryLens.CRAFTING_OUTPUT;
    final CraftingInventoryLens crafting = new CraftingInventoryLens(0, base, ContainerPlayerInventoryLens.CRAFTING_GRID, ContainerPlayerInventoryLens.CRAFTING_GRID, slots);
    // 4
    base += ContainerPlayerInventoryLens.CRAFTING_GRID * ContainerPlayerInventoryLens.CRAFTING_GRID;
    final PlayerInventoryLens player = new PlayerInventoryLens(base, size - base, slots);
    return Arrays.asList(crafting, player);
}
Also used : CraftingInventoryLens(org.spongepowered.common.inventory.lens.impl.comp.CraftingInventoryLens) PlayerInventoryLens(org.spongepowered.common.inventory.lens.impl.minecraft.PlayerInventoryLens)

Aggregations

PlayerInventoryLens (org.spongepowered.common.inventory.lens.impl.minecraft.PlayerInventoryLens)7 Lens (org.spongepowered.common.inventory.lens.Lens)6 InventoryAdapter (org.spongepowered.common.inventory.adapter.InventoryAdapter)5 Fabric (org.spongepowered.common.inventory.fabric.Fabric)5 EquipmentInventoryAdapter (org.spongepowered.common.inventory.adapter.impl.comp.EquipmentInventoryAdapter)4 PrimaryPlayerInventoryAdapter (org.spongepowered.common.inventory.adapter.impl.comp.PrimaryPlayerInventoryAdapter)4 CraftingInventoryLens (org.spongepowered.common.inventory.lens.impl.comp.CraftingInventoryLens)2 CraftingContainer (net.minecraft.world.inventory.CraftingContainer)1 ResultContainer (net.minecraft.world.inventory.ResultContainer)1 Slot (net.minecraft.world.inventory.Slot)1 EquipmentType (org.spongepowered.api.item.inventory.equipment.EquipmentType)1 ResultSlotAccessor (org.spongepowered.common.accessor.world.inventory.ResultSlotAccessor)1 PlayerInventoryBridge (org.spongepowered.common.bridge.world.entity.player.PlayerInventoryBridge)1 CompoundLens (org.spongepowered.common.inventory.lens.impl.CompoundLens)1 DelegatingLens (org.spongepowered.common.inventory.lens.impl.DelegatingLens)1 GridInventoryLens (org.spongepowered.common.inventory.lens.impl.comp.GridInventoryLens)1 PrimaryPlayerInventoryLens (org.spongepowered.common.inventory.lens.impl.comp.PrimaryPlayerInventoryLens)1 SingleGridLens (org.spongepowered.common.inventory.lens.impl.minecraft.SingleGridLens)1 ContainerLens (org.spongepowered.common.inventory.lens.impl.minecraft.container.ContainerLens)1 SlotLens (org.spongepowered.common.inventory.lens.slots.SlotLens)1