use of org.spongepowered.common.inventory.adapter.InventoryAdapter in project SpongeCommon by SpongePowered.
the class AppendQuery method execute.
@Override
public Inventory execute(Inventory inventory, InventoryAdapter adapter) {
Inventory result = new EmptyInventoryImpl(inventory);
if (this.queryList.isEmpty()) {
return result;
}
List<Inventory> results = this.queryList.stream().map(q -> q.execute(inventory)).collect(Collectors.toList());
return new MultiInventoryAdapter(results);
}
use of org.spongepowered.common.inventory.adapter.InventoryAdapter in project SpongeCommon by SpongePowered.
the class SpongeInventoryBuilder method inventory.
public BuildingStep inventory(Inventory inventory) {
InventoryAdapter adapter = (InventoryAdapter) inventory;
this.size += inventory.capacity();
this.lenses.add(adapter.inventoryAdapter$getRootLens());
this.inventories.add(inventory);
return this;
}
use of org.spongepowered.common.inventory.adapter.InventoryAdapter in project SpongeCommon by SpongePowered.
the class SpongeInventoryBuilder method slots.
public BuildingStep slots(int amount) {
this.size += amount;
net.minecraft.world.SimpleContainer adapter = new net.minecraft.world.SimpleContainer(amount);
this.inventories.add((Inventory) adapter);
this.lenses.add(new DefaultIndexedLens(0, amount, ((InventoryAdapter) adapter).inventoryAdapter$getSlotLensProvider()));
return this;
}
use of org.spongepowered.common.inventory.adapter.InventoryAdapter in project SpongeCommon by SpongePowered.
the class LivingEntityMixin_Inventory method impl$getSpongeSlot.
@SuppressWarnings("ConstantConditions")
protected Slot impl$getSpongeSlot(final EquipmentSlot equipmentSlot) {
final EquipmentType equipmentType = (EquipmentType) (Object) equipmentSlot;
if (this instanceof InventoryBridge) {
final InventoryAdapter adapter = ((InventoryBridge) this).bridge$getAdapter();
final Lens lens = adapter.inventoryAdapter$getRootLens();
if (lens instanceof EquipmentInventoryLens) {
final SlotLens slotLens = ((EquipmentInventoryLens) lens).getSlotLens(equipmentType);
return slotLens.getAdapter(adapter.inventoryAdapter$getFabric(), (Inventory) adapter);
}
throw new IllegalStateException("Expected EquipmentInventoryLens for " + this.getClass().getName() + " Inventory but found: " + lens.getClass().getName());
}
throw new IllegalStateException("Living Entity has no InventoryAdapter: " + this.getClass().getName());
}
use of org.spongepowered.common.inventory.adapter.InventoryAdapter in project SpongeCommon by SpongePowered.
the class TraitMixin_ArmorEquipable_Inventory_API method equipped.
@Override
public Optional<ItemStack> equipped(final EquipmentType type) {
final InventoryAdapter inv = ((InventoryBridge) this).bridge$getAdapter();
final EquipmentInventoryLens lens = this.impl$equipmentInventory(inv);
final Fabric fabric = inv.inventoryAdapter$getFabric();
return Optional.of(ItemStackUtil.fromNative(lens.getSlotLens(type).getStack(fabric)));
}
Aggregations