Search in sources :

Example 66 with ItemIdentifier

use of logisticspipes.utils.item.ItemIdentifier in project LogisticsPipes by RS485.

the class FuzzyInventoryUtil method getItems.

@Override
public Set<ItemIdentifier> getItems() {
    Set<ItemIdentifier> items = new TreeSet<>();
    for (int i = 0; i < _inventory.getSizeInventory(); i++) {
        ItemStack stack = _inventory.getStackInSlot(i);
        if (stack == null) {
            continue;
        }
        items.add(ItemIdentifier.get(stack).getIgnoringNBT());
    }
    return items;
}
Also used : ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) TreeSet(java.util.TreeSet) ItemStack(net.minecraft.item.ItemStack)

Example 67 with ItemIdentifier

use of logisticspipes.utils.item.ItemIdentifier in project LogisticsPipes by RS485.

the class InventoryUtil method getItems.

@Override
public Set<ItemIdentifier> getItems() {
    Set<ItemIdentifier> items = new TreeSet<>();
    for (int i = _cropStart; i < _inventory.getSizeInventory() - _cropEnd; i++) {
        ItemStack stack = _inventory.getStackInSlot(i);
        if (stack == null) {
            continue;
        }
        items.add(ItemIdentifier.get(stack));
    }
    return items;
}
Also used : ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) TreeSet(java.util.TreeSet) ItemStack(net.minecraft.item.ItemStack)

Example 68 with ItemIdentifier

use of logisticspipes.utils.item.ItemIdentifier in project LogisticsPipes by RS485.

the class DummyContainer method handleDummyClick.

public void handleDummyClick(Slot slot, int slotId, ItemStack currentlyEquippedStack, int mouseButton, int isShift, EntityPlayer entityplayer) {
    if (slot instanceof FluidSlot) {
        if (currentlyEquippedStack != null) {
            FluidStack liquidId = FluidContainerRegistry.getFluidForFilledItem(currentlyEquippedStack);
            if (liquidId != null) {
                FluidIdentifier ident = FluidIdentifier.get(liquidId);
                if (mouseButton == 0) {
                    if (ident == null) {
                        slot.putStack(null);
                    } else {
                        slot.putStack(ident.getItemIdentifier().unsafeMakeNormalStack(1));
                    }
                } else {
                    slot.putStack(null);
                }
                return;
            }
            FluidIdentifier ident = FluidIdentifier.get(currentlyEquippedStack);
            if (ident != null) {
                if (mouseButton == 0) {
                    slot.putStack(ident.getItemIdentifier().unsafeMakeNormalStack(1));
                } else {
                    slot.putStack(null);
                }
                return;
            }
        }
        FluidIdentifier ident = null;
        if (slot.getStack() != null) {
            ident = FluidIdentifier.get(ItemIdentifier.get(slot.getStack()));
        }
        if (ident == null) {
            if (MainProxy.isClient(entityplayer.getEntityWorld())) {
                MainProxy.proxy.openFluidSelectGui(slotId);
            }
        }
        slot.putStack(null);
        return;
    }
    if (slot instanceof ColorSlot) {
        MinecraftColor equipped = MinecraftColor.getColor(currentlyEquippedStack);
        MinecraftColor color = MinecraftColor.getColor(slot.getStack());
        if (MinecraftColor.BLANK.equals(equipped)) {
            if (mouseButton == 0) {
                color = color.getNext();
            } else if (mouseButton == 1) {
                color = color.getPrev();
            } else {
                color = MinecraftColor.BLANK;
            }
            slot.putStack(color.getItemStack());
        } else {
            if (mouseButton == 1) {
                slot.putStack(MinecraftColor.BLANK.getItemStack());
            } else {
                slot.putStack(equipped.getItemStack());
            }
        }
        if (entityplayer instanceof EntityPlayerMP && MainProxy.isServer(entityplayer.worldObj)) {
            ((EntityPlayerMP) entityplayer).sendSlotContents(this, slotId, slot.getStack());
        }
        return;
    }
    if (slot instanceof DummySlot) {
        ((DummySlot) slot).setRedirectCall(true);
    }
    if (currentlyEquippedStack == null) {
        if (slot.getStack() != null && mouseButton == 1) {
            ItemStack tstack = slot.getStack();
            if (isShift == 1) {
                tstack.stackSize = Math.min(slot.getSlotStackLimit(), tstack.stackSize * 2);
            } else {
                tstack.stackSize /= 2;
                if (tstack.stackSize <= 0) {
                    tstack = null;
                }
            }
            slot.putStack(tstack);
        } else {
            slot.putStack(null);
        }
        if (slot instanceof DummySlot) {
            ((DummySlot) slot).setRedirectCall(false);
        }
        return;
    }
    if (!slot.getHasStack()) {
        ItemStack tstack = currentlyEquippedStack.copy();
        if (mouseButton == 1) {
            tstack.stackSize = 1;
        }
        if (tstack.stackSize > slot.getSlotStackLimit()) {
            tstack.stackSize = slot.getSlotStackLimit();
        }
        slot.putStack(tstack);
        if (slot instanceof DummySlot) {
            ((DummySlot) slot).setRedirectCall(false);
        }
        return;
    }
    ItemIdentifier currentItem = ItemIdentifier.get(currentlyEquippedStack);
    ItemIdentifier slotItem = ItemIdentifier.get(slot.getStack());
    if (currentItem.equals(slotItem)) {
        ItemStack tstack = slot.getStack();
        // Do manual shift-checking to play nice with NEI
        int counter = isShift == 1 ? 10 : 1;
        if (mouseButton == 1) {
            if (tstack.stackSize + counter <= slot.getSlotStackLimit()) {
                tstack.stackSize += counter;
            } else {
                tstack.stackSize = slot.getSlotStackLimit();
            }
            slot.putStack(tstack);
        } else if (mouseButton == 0) {
            tstack.stackSize -= counter;
            if (tstack.stackSize <= 0) {
                tstack = null;
            }
            slot.putStack(tstack);
        }
        if (slot instanceof DummySlot) {
            ((DummySlot) slot).setRedirectCall(false);
        }
        return;
    }
    ItemStack tstack = currentlyEquippedStack.copy();
    if (tstack.stackSize > slot.getSlotStackLimit()) {
        tstack.stackSize = slot.getSlotStackLimit();
    }
    slot.putStack(tstack);
    if (slot instanceof DummySlot) {
        ((DummySlot) slot).setRedirectCall(false);
    }
    return;
}
Also used : MinecraftColor(logisticspipes.utils.MinecraftColor) ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) FluidStack(net.minecraftforge.fluids.FluidStack) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) FluidIdentifier(logisticspipes.utils.FluidIdentifier) ItemStack(net.minecraft.item.ItemStack)

Example 69 with ItemIdentifier

use of logisticspipes.utils.item.ItemIdentifier in project LogisticsPipes by RS485.

the class LPDataIOWrapper method readItemIdentifierStack.

@Override
public ItemIdentifierStack readItemIdentifierStack() {
    int stacksize = readInt();
    if (stacksize == -1) {
        return null;
    }
    ItemIdentifier item = readItemIdentifier();
    return new ItemIdentifierStack(item, stacksize);
}
Also used : ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack)

Aggregations

ItemIdentifier (logisticspipes.utils.item.ItemIdentifier)69 ItemStack (net.minecraft.item.ItemStack)37 ArrayList (java.util.ArrayList)23 ItemIdentifierStack (logisticspipes.utils.item.ItemIdentifierStack)23 HashMap (java.util.HashMap)14 IInventoryUtil (logisticspipes.interfaces.IInventoryUtil)13 TreeSet (java.util.TreeSet)12 IFilter (logisticspipes.interfaces.routing.IFilter)11 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)11 LinkedList (java.util.LinkedList)10 List (java.util.List)10 Map (java.util.Map)10 SinkReply (logisticspipes.utils.SinkReply)10 CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)9 IRouter (logisticspipes.routing.IRouter)9 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)9 BitSet (java.util.BitSet)8 Entry (java.util.Map.Entry)7 LogisticsModule (logisticspipes.modules.abstractmodules.LogisticsModule)7 SimpleServiceLocator (logisticspipes.proxy.SimpleServiceLocator)7