Search in sources :

Example 1 with OrderedInventoryLensImpl

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

the class MixinSlot method parent.

@Override
public Inventory parent() {
    if (this.inventory instanceof Inventory) {
        return ((Inventory) this.inventory);
    }
    if (this.parentAdapter == null) {
        OrderedInventoryLensImpl lens = new OrderedInventoryLensImpl(0, this.fabric.getSize(), 1, new SlotCollection.Builder().add(this.fabric.getSize()).build());
        this.parentAdapter = new OrderedInventoryAdapter(this.fabric, lens);
    }
    return this.parentAdapter;
}
Also used : SlotCollection(org.spongepowered.common.item.inventory.lens.impl.collections.SlotCollection) OrderedInventoryAdapter(org.spongepowered.common.item.inventory.adapter.impl.comp.OrderedInventoryAdapter) OrderedInventoryLensImpl(org.spongepowered.common.item.inventory.lens.impl.comp.OrderedInventoryLensImpl) Inventory(org.spongepowered.api.item.inventory.Inventory) IInventory(net.minecraft.inventory.IInventory)

Example 2 with OrderedInventoryLensImpl

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

the class DelegatingLens method init.

@Override
protected void init(SlotProvider<IInventory, ItemStack> slots) {
    this.addSpanningChild(new OrderedInventoryLensImpl(this.base, this.size, 1, slots));
    this.addChild(delegate);
}
Also used : OrderedInventoryLensImpl(org.spongepowered.common.item.inventory.lens.impl.comp.OrderedInventoryLensImpl)

Example 3 with OrderedInventoryLensImpl

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

the class FurnaceInventoryLens method init.

@Override
protected void init(SlotProvider<IInventory, ItemStack> slots) {
    this.addChild(new OrderedInventoryLensImpl(0, 3, 1, slots));
    this.input = new InputSlotLensImpl(0, (i) -> true, (i) -> true);
    // TODO SlotFurnaceFuel
    this.fuel = new FuelSlotLensImpl(1, (i) -> true, (i) -> true);
    // SlotFurnaceOutput
    this.output = new OutputSlotLensImpl(2, (i) -> false, (i) -> false);
    this.addSpanningChild(this.input, new SlotIndex(0));
    this.addSpanningChild(this.fuel, new SlotIndex(1));
    this.addSpanningChild(this.output, new SlotIndex(2));
}
Also used : ItemStack(net.minecraft.item.ItemStack) InventoryAdapter(org.spongepowered.common.item.inventory.adapter.InventoryAdapter) SlotProvider(org.spongepowered.common.item.inventory.lens.SlotProvider) InputSlotLensImpl(org.spongepowered.common.item.inventory.lens.impl.slots.InputSlotLensImpl) IInventory(net.minecraft.inventory.IInventory) FuelSlotLensImpl(org.spongepowered.common.item.inventory.lens.impl.slots.FuelSlotLensImpl) OrderedInventoryLensImpl(org.spongepowered.common.item.inventory.lens.impl.comp.OrderedInventoryLensImpl) SlotIndex(org.spongepowered.api.item.inventory.property.SlotIndex) RealLens(org.spongepowered.common.item.inventory.lens.impl.RealLens) OutputSlotLensImpl(org.spongepowered.common.item.inventory.lens.impl.slots.OutputSlotLensImpl) OrderedInventoryLensImpl(org.spongepowered.common.item.inventory.lens.impl.comp.OrderedInventoryLensImpl) InputSlotLensImpl(org.spongepowered.common.item.inventory.lens.impl.slots.InputSlotLensImpl) SlotIndex(org.spongepowered.api.item.inventory.property.SlotIndex) FuelSlotLensImpl(org.spongepowered.common.item.inventory.lens.impl.slots.FuelSlotLensImpl) OutputSlotLensImpl(org.spongepowered.common.item.inventory.lens.impl.slots.OutputSlotLensImpl)

Example 4 with OrderedInventoryLensImpl

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

the class CustomLens method addLensFor.

private int addLensFor(InventoryProperty<?, ?> size, int base, SlotProvider<IInventory, ItemStack> slots) {
    Lens<IInventory, ItemStack> lens;
    int slotCount;
    if (size instanceof InventoryDimension) {
        InventoryDimension dimension = ((InventoryDimension) size);
        slotCount = dimension.getColumns() * dimension.getRows();
        lens = new GridInventoryLensImpl(base, dimension.getColumns(), dimension.getRows(), dimension.getColumns(), slots);
    } else if (size instanceof InventoryCapacity) {
        InventoryCapacity capacity = ((InventoryCapacity) size);
        slotCount = capacity.getValue();
        lens = new OrderedInventoryLensImpl(base, capacity.getValue(), 1, slots);
    } else {
        throw new IllegalStateException("Unknown Inventory Size Property " + size.getClass().getName());
    }
    this.addSpanningChild(lens);
    return slotCount;
}
Also used : IInventory(net.minecraft.inventory.IInventory) InventoryCapacity(org.spongepowered.api.item.inventory.property.InventoryCapacity) OrderedInventoryLensImpl(org.spongepowered.common.item.inventory.lens.impl.comp.OrderedInventoryLensImpl) InventoryDimension(org.spongepowered.api.item.inventory.property.InventoryDimension) ItemStack(net.minecraft.item.ItemStack) GridInventoryLensImpl(org.spongepowered.common.item.inventory.lens.impl.comp.GridInventoryLensImpl)

Example 5 with OrderedInventoryLensImpl

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

the class MixinEntityMinecartHopper method onConstructed.

@Inject(method = "<init>*", at = @At("RETURN"))
public void onConstructed(CallbackInfo ci) {
    this.fabric = new IInventoryFabric(this);
    this.slots = new SlotCollection.Builder().add(5).build();
    this.lens = new OrderedInventoryLensImpl(0, 5, 1, this.slots);
}
Also used : IInventoryFabric(org.spongepowered.common.item.inventory.lens.impl.fabric.IInventoryFabric) SlotCollection(org.spongepowered.common.item.inventory.lens.impl.collections.SlotCollection) OrderedInventoryLensImpl(org.spongepowered.common.item.inventory.lens.impl.comp.OrderedInventoryLensImpl) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

OrderedInventoryLensImpl (org.spongepowered.common.item.inventory.lens.impl.comp.OrderedInventoryLensImpl)16 SlotCollection (org.spongepowered.common.item.inventory.lens.impl.collections.SlotCollection)9 IInventory (net.minecraft.inventory.IInventory)8 ItemStack (net.minecraft.item.ItemStack)7 SlotProvider (org.spongepowered.common.item.inventory.lens.SlotProvider)4 SlotIndex (org.spongepowered.api.item.inventory.property.SlotIndex)3 Inject (org.spongepowered.asm.mixin.injection.Inject)3 InventoryAdapter (org.spongepowered.common.item.inventory.adapter.InventoryAdapter)3 Lens (org.spongepowered.common.item.inventory.lens.Lens)3 MainPlayerInventoryLensImpl (org.spongepowered.common.item.inventory.lens.impl.comp.MainPlayerInventoryLensImpl)3 IInventoryFabric (org.spongepowered.common.item.inventory.lens.impl.fabric.IInventoryFabric)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Optional (java.util.Optional)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)2 Fabric (org.spongepowered.common.item.inventory.lens.Fabric)2 LensProvider (org.spongepowered.common.item.inventory.lens.LensProvider)2 DefaultEmptyLens (org.spongepowered.common.item.inventory.lens.impl.DefaultEmptyLens)2 ReusableLens (org.spongepowered.common.item.inventory.lens.impl.ReusableLens)2