Search in sources :

Example 1 with EquipmentInventoryLensImpl

use of org.spongepowered.common.item.inventory.lens.impl.comp.EquipmentInventoryLensImpl in project SpongeCommon by SpongePowered.

the class PlayerInventoryLens method init.

@Override
protected void init(SlotProvider<IInventory, ItemStack> slots) {
    // Adding slots
    for (int ord = 0, slot = this.base; ord < this.size; ord++, slot++) {
        this.addChild(slots.getSlot(slot), new SlotIndex(ord));
    }
    int base = 0;
    this.main = new MainPlayerInventoryLensImpl(base, slots, false);
    base += this.main.slotCount();
    this.equipment = new EquipmentInventoryLensImpl(this.player, base, EQUIPMENT, 1, slots, false);
    base += EQUIPMENT;
    this.offhand = slots.getSlot(base);
    // TODO Hotbar in Vanilla is part of the main inventory (first 9 slots) ; maybe wrap it in a Lens?
    this.addSpanningChild(this.main);
    this.addSpanningChild(this.equipment);
    this.addSpanningChild(this.offhand);
    // Additional Slots for bigger modded inventories
    int additionalSlots = this.size - base - 1;
    if (additionalSlots > 0) {
        this.addSpanningChild(new OrderedInventoryLensImpl(base, additionalSlots, 1, slots));
    }
}
Also used : MainPlayerInventoryLensImpl(org.spongepowered.common.item.inventory.lens.impl.comp.MainPlayerInventoryLensImpl) EquipmentInventoryLensImpl(org.spongepowered.common.item.inventory.lens.impl.comp.EquipmentInventoryLensImpl) OrderedInventoryLensImpl(org.spongepowered.common.item.inventory.lens.impl.comp.OrderedInventoryLensImpl) SlotIndex(org.spongepowered.api.item.inventory.property.SlotIndex)

Example 2 with EquipmentInventoryLensImpl

use of org.spongepowered.common.item.inventory.lens.impl.comp.EquipmentInventoryLensImpl in project SpongeCommon by SpongePowered.

the class ContainerPlayerInventoryLens method init.

@Override
protected void init(SlotProvider<IInventory, ItemStack> slots) {
    // 1
    int base = CRAFTING_OUTPUT;
    final CraftingInventoryLensImpl crafting = new CraftingInventoryLensImpl(0, base, CRAFTING_GRID, CRAFTING_GRID, slots);
    // 4
    base += CRAFTING_GRID * CRAFTING_GRID;
    // TODO pass player for carrier to EquipmentInventory
    final EquipmentInventoryLensImpl armor = new EquipmentInventoryLensImpl(null, base, EQUIPMENT, 1, slots, true);
    // 4
    base += EQUIPMENT;
    final MainPlayerInventoryLensImpl main = new MainPlayerInventoryLensImpl(base, slots, true);
    // 9
    base += MAIN_INVENTORY_HEIGHT * INVENTORY_WIDTH + HOTBAR * INVENTORY_WIDTH;
    final SlotLens<IInventory, ItemStack> offHand = slots.getSlot(base);
    base += OFFHAND;
    this.viewedInventories = new ArrayList<>(Arrays.asList(crafting, armor, offHand, main));
    int additionalSlots = this.size - base - 1;
    if (additionalSlots > 0) {
        viewedInventories.add(new OrderedInventoryLensImpl(base, additionalSlots, 1, slots));
    }
    // TODO actual Container order is:
    // CraftingOutput (1) -> Crafting (4) -> ArmorSlots (4) -> MainInventory (27) -> Hotbar (9) -> Offhand (1)
    // how to handle issues like in #939? ; e.g. Inventory#offer using a different insertion order
    super.init(slots);
}
Also used : IInventory(net.minecraft.inventory.IInventory) MainPlayerInventoryLensImpl(org.spongepowered.common.item.inventory.lens.impl.comp.MainPlayerInventoryLensImpl) EquipmentInventoryLensImpl(org.spongepowered.common.item.inventory.lens.impl.comp.EquipmentInventoryLensImpl) OrderedInventoryLensImpl(org.spongepowered.common.item.inventory.lens.impl.comp.OrderedInventoryLensImpl) CraftingInventoryLensImpl(org.spongepowered.common.item.inventory.lens.impl.comp.CraftingInventoryLensImpl) ItemStack(net.minecraft.item.ItemStack)

Aggregations

EquipmentInventoryLensImpl (org.spongepowered.common.item.inventory.lens.impl.comp.EquipmentInventoryLensImpl)2 MainPlayerInventoryLensImpl (org.spongepowered.common.item.inventory.lens.impl.comp.MainPlayerInventoryLensImpl)2 OrderedInventoryLensImpl (org.spongepowered.common.item.inventory.lens.impl.comp.OrderedInventoryLensImpl)2 IInventory (net.minecraft.inventory.IInventory)1 ItemStack (net.minecraft.item.ItemStack)1 SlotIndex (org.spongepowered.api.item.inventory.property.SlotIndex)1 CraftingInventoryLensImpl (org.spongepowered.common.item.inventory.lens.impl.comp.CraftingInventoryLensImpl)1