use of org.spongepowered.api.item.inventory.property.SlotIndex in project LanternServer by LanternPowered.
the class InventorySnapshot method offerTo.
public void offerTo(Inventory inventory) {
for (Slot slot : inventory.<Slot>slots()) {
// noinspection ConstantConditions
final SlotIndex index = inventory.getProperty(slot, SlotIndex.class, null).get();
final ItemStackSnapshot itemStackSnapshot = this.itemStackSnapshots.get(index.getValue());
if (itemStackSnapshot != null) {
slot.set(itemStackSnapshot.createStack());
}
}
}
use of org.spongepowered.api.item.inventory.property.SlotIndex in project SpongeCommon by SpongePowered.
the class EquipmentInventoryLensImpl method initInventory.
private void initInventory(SlotProvider<IInventory, ItemStack> slots) {
int index = this.base;
int ord = 0;
this.addSpanningChild(slots.getSlot(index), new SlotIndex(ord++), EquipmentSlotType.of(EquipmentTypes.BOOTS));
index += this.stride;
this.addSpanningChild(slots.getSlot(index), new SlotIndex(ord++), EquipmentSlotType.of(EquipmentTypes.LEGGINGS));
index += this.stride;
this.addSpanningChild(slots.getSlot(index), new SlotIndex(ord++), EquipmentSlotType.of(EquipmentTypes.CHESTPLATE));
index += this.stride;
this.addSpanningChild(slots.getSlot(index), new SlotIndex(ord), EquipmentSlotType.of(EquipmentTypes.HEADWEAR));
this.cache();
}
use of org.spongepowered.api.item.inventory.property.SlotIndex in project SpongeCommon by SpongePowered.
the class EquipmentInventoryLensImpl method initContainer.
private void initContainer(SlotProvider<IInventory, ItemStack> slots) {
int index = this.base;
int ord = 0;
this.addSpanningChild(slots.getSlot(index), new SlotIndex(ord++), EquipmentSlotType.of(EquipmentTypes.HEADWEAR));
index += this.stride;
this.addSpanningChild(slots.getSlot(index), new SlotIndex(ord++), EquipmentSlotType.of(EquipmentTypes.CHESTPLATE));
index += this.stride;
this.addSpanningChild(slots.getSlot(index), new SlotIndex(ord++), EquipmentSlotType.of(EquipmentTypes.LEGGINGS));
index += this.stride;
this.addSpanningChild(slots.getSlot(index), new SlotIndex(ord), EquipmentSlotType.of(EquipmentTypes.BOOTS));
this.cache();
}
use of org.spongepowered.api.item.inventory.property.SlotIndex in project SpongeCommon by SpongePowered.
the class LargeChestInventoryLens method initLargeChest.
private void initLargeChest(SlotProvider<IInventory, ItemStack> slots) {
// add grids
int base = 0;
this.addSpanningChild(new GridInventoryLensImpl(base, 9, this.upperChest / 9, 9, (Class) TileEntityChest.class, slots));
base += this.upperChest;
this.addSpanningChild(new GridInventoryLensImpl(base, 9, this.lowerChest / 9, 9, (Class) TileEntityChest.class, slots));
base += this.lowerChest;
this.addChild(new GridInventoryLensImpl(0, 9, (this.upperChest + this.lowerChest) / 9, 9, slots));
// add slot childs for grids
for (int ord = 0, slot = this.base; ord < base; ord++, slot++) {
this.addChild(slots.getSlot(slot), new SlotIndex(ord));
}
// handle possible extension by mods:
for (int i = base; i < this.slotCount(); i++) {
this.addSpanningChild(new SlotLensImpl(i), SlotIndex.of(i));
}
}
use of org.spongepowered.api.item.inventory.property.SlotIndex 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));
}
}
Aggregations