use of org.spongepowered.common.inventory.lens.impl.slot.HeldHandSlotLens in project SpongeCommon by SpongePowered.
the class PlayerInventoryLens method init.
protected void init(SlotLensProvider slots) {
// Adding slots
for (int ord = 0, slot = this.base; ord < this.size; ord++, slot++) {
this.addChild(slots.getSlotLens(slot), KeyValuePair.slotIndex(ord));
}
int base = this.base;
Map<EquipmentType, SlotLens> equipmentLenses = new LinkedHashMap<>();
if (this.isContainer) {
this.armor = new ArmorInventoryLens(base, slots, true);
equipmentLenses.put(EquipmentTypes.HEAD.get(), slots.getSlotLens(base + 0));
equipmentLenses.put(EquipmentTypes.CHEST.get(), slots.getSlotLens(base + 1));
equipmentLenses.put(EquipmentTypes.LEGS.get(), slots.getSlotLens(base + 2));
equipmentLenses.put(EquipmentTypes.FEET.get(), slots.getSlotLens(base + 3));
// 4
base += PlayerInventoryLens.ARMOR;
this.primary = new PrimaryPlayerInventoryLens(base, slots, true);
base += this.primary.slotCount();
this.offhand = slots.getSlotLens(base);
base += PlayerInventoryLens.OFFHAND;
equipmentLenses.put(EquipmentTypes.OFF_HAND.get(), this.offhand);
this.addSpanningChild(this.armor);
this.addSpanningChild(this.primary);
this.addSpanningChild(this.offhand);
} else {
this.primary = new PrimaryPlayerInventoryLens(base, slots, false);
base += this.primary.slotCount();
this.armor = new ArmorInventoryLens(base, slots, false);
equipmentLenses.put(EquipmentTypes.FEET.get(), slots.getSlotLens(base + 0));
equipmentLenses.put(EquipmentTypes.LEGS.get(), slots.getSlotLens(base + 1));
equipmentLenses.put(EquipmentTypes.CHEST.get(), slots.getSlotLens(base + 2));
equipmentLenses.put(EquipmentTypes.HEAD.get(), slots.getSlotLens(base + 3));
base += PlayerInventoryLens.ARMOR;
this.offhand = slots.getSlotLens(base);
base += PlayerInventoryLens.OFFHAND;
equipmentLenses.put(EquipmentTypes.OFF_HAND.get(), this.offhand);
this.addSpanningChild(this.primary);
this.addSpanningChild(this.armor);
this.addSpanningChild(this.offhand);
}
equipmentLenses.put(EquipmentTypes.MAIN_HAND.get(), new HeldHandSlotLens(this.primary.getHotbar()));
this.equipment = new EquipmentInventoryLens(equipmentLenses);
for (Map.Entry<EquipmentType, SlotLens> entry : equipmentLenses.entrySet()) {
this.addChild(entry.getValue(), KeyValuePair.of(Keys.EQUIPMENT_TYPE, entry.getKey()));
}
this.addChild(this.equipment);
this.addMissingSpanningSlots(base, slots);
}
Aggregations