Search in sources :

Example 51 with ItemIdentifierStack

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

the class ClientProxy method openFluidSelectGui.

@Override
public void openFluidSelectGui(final int slotId) {
    if (Minecraft.getMinecraft().currentScreen instanceof LogisticsBaseGuiScreen) {
        final List<ItemIdentifierStack> list = new ArrayList<>();
        for (FluidIdentifier fluid : FluidIdentifier.all()) {
            if (fluid == null) {
                continue;
            }
            list.add(fluid.getItemIdentifier().makeStack(1));
        }
        SelectItemOutOfList subGui = new SelectItemOutOfList(list, slot -> MainProxy.sendPacketToServer(PacketHandler.getPacket(DummyContainerSlotClick.class).setSlotId(slotId).setStack(list.get(slot).makeNormalStack()).setButton(0)));
        LogisticsBaseGuiScreen gui = (LogisticsBaseGuiScreen) Minecraft.getMinecraft().currentScreen;
        if (!gui.hasSubGui()) {
            gui.setSubGui(subGui);
        } else {
            SubGuiScreen nextGui = gui.getSubGui();
            while (nextGui.hasSubGui()) {
                nextGui = nextGui.getSubGui();
            }
            nextGui.setSubGui(subGui);
        }
    } else {
        throw new UnsupportedOperationException(String.valueOf(Minecraft.getMinecraft().currentScreen));
    }
}
Also used : LogisticsBaseGuiScreen(logisticspipes.utils.gui.LogisticsBaseGuiScreen) SelectItemOutOfList(logisticspipes.gui.popup.SelectItemOutOfList) ArrayList(java.util.ArrayList) ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack) FluidIdentifier(logisticspipes.utils.FluidIdentifier) DummyContainerSlotClick(logisticspipes.network.packets.gui.DummyContainerSlotClick) SubGuiScreen(logisticspipes.utils.gui.SubGuiScreen)

Example 52 with ItemIdentifierStack

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

the class DictResource method clone.

@Override
public IResource clone(int multiplier) {
    ItemIdentifierStack stack = this.stack.clone();
    stack.setStackSize(stack.getStackSize() * multiplier);
    DictResource clone = new DictResource(stack, requester);
    clone.use_od = use_od;
    clone.ignore_dmg = ignore_dmg;
    clone.ignore_nbt = ignore_nbt;
    clone.use_category = use_category;
    return clone;
}
Also used : ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack)

Example 53 with ItemIdentifierStack

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

the class DictResource method copyForDisplayWith.

@Override
public IResource copyForDisplayWith(int amount) {
    ItemIdentifierStack stack = this.stack.clone();
    stack.setStackSize(amount);
    DictResource clone = new DictResource(stack, null);
    clone.use_od = use_od;
    clone.ignore_dmg = ignore_dmg;
    clone.ignore_nbt = ignore_nbt;
    clone.use_category = use_category;
    return clone;
}
Also used : ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack)

Example 54 with ItemIdentifierStack

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

the class RequestHandler method refresh.

public static void refresh(EntityPlayer player, CoreRoutedPipe pipe, DisplayOptions option) {
    Map<ItemIdentifier, Integer> _availableItems;
    LinkedList<ItemIdentifier> _craftableItems;
    if (option == DisplayOptions.SupplyOnly || option == DisplayOptions.Both) {
        _availableItems = SimpleServiceLocator.logisticsManager.getAvailableItems(pipe.getRouter().getIRoutersByCost());
    } else {
        _availableItems = new HashMap<>();
    }
    if (option == DisplayOptions.CraftOnly || option == DisplayOptions.Both) {
        _craftableItems = SimpleServiceLocator.logisticsManager.getCraftableItems(pipe.getRouter().getIRoutersByCost());
    } else {
        _craftableItems = new LinkedList<>();
    }
    TreeSet<ItemIdentifierStack> _allItems = new TreeSet<>();
    for (Entry<ItemIdentifier, Integer> item : _availableItems.entrySet()) {
        ItemIdentifierStack newStack = item.getKey().makeStack(item.getValue());
        _allItems.add(newStack);
    }
    for (ItemIdentifier item : _craftableItems) {
        if (_availableItems.containsKey(item)) {
            continue;
        }
        _allItems.add(item.makeStack(0));
    }
    MainProxy.sendPacketToPlayer(PacketHandler.getPacket(OrdererContent.class).setIdentSet(_allItems), player);
}
Also used : ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) TreeSet(java.util.TreeSet) ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack)

Example 55 with ItemIdentifierStack

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

the class RequestHandler method requestMacrolist.

public static void requestMacrolist(NBTTagCompound itemlist, final CoreRoutedPipe requester, final EntityPlayer player) {
    if (!requester.useEnergy(5)) {
        player.addChatMessage(new ChatComponentTranslation("lp.misc.noenergy"));
        return;
    }
    NBTTagList list = itemlist.getTagList("inventar", 10);
    final List<ItemIdentifierStack> transaction = new ArrayList<>(list.tagCount());
    for (int i = 0; i < list.tagCount(); i++) {
        NBTTagCompound itemnbt = list.getCompoundTagAt(i);
        NBTTagCompound itemNBTContent = itemnbt.getCompoundTag("nbt");
        if (!itemnbt.hasKey("nbt")) {
            itemNBTContent = null;
        }
        ItemIdentifierStack stack = ItemIdentifier.get(Item.getItemById(itemnbt.getInteger("id")), itemnbt.getInteger("data"), itemNBTContent).makeStack(itemnbt.getInteger("amount"));
        transaction.add(stack);
    }
    RequestTree.request(transaction, requester, new RequestLog() {

        @Override
        public void handleMissingItems(List<IResource> resources) {
            MainProxy.sendPacketToPlayer(PacketHandler.getPacket(MissingItems.class).setItems(resources).setFlag(true), player);
        }

        @Override
        public void handleSucessfullRequestOf(IResource item, LinkedLogisticsOrderList parts) {
        }

        @Override
        public void handleSucessfullRequestOfList(List<IResource> resources, LinkedLogisticsOrderList parts) {
            MainProxy.sendPacketToPlayer(PacketHandler.getPacket(MissingItems.class).setItems(resources).setFlag(false), player);
            if (requester instanceof IRequestWatcher) {
                ((IRequestWatcher) requester).handleOrderList(null, parts);
            }
        }
    }, RequestTree.defaultRequestFlags, null);
}
Also used : IRequestWatcher(logisticspipes.interfaces.IRequestWatcher) ArrayList(java.util.ArrayList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) NBTTagList(net.minecraft.nbt.NBTTagList) LinkedLogisticsOrderList(logisticspipes.routing.order.LinkedLogisticsOrderList) ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack) IResource(logisticspipes.request.resources.IResource)

Aggregations

ItemIdentifierStack (logisticspipes.utils.item.ItemIdentifierStack)58 ItemStack (net.minecraft.item.ItemStack)21 ItemIdentifier (logisticspipes.utils.item.ItemIdentifier)18 ArrayList (java.util.ArrayList)9 Pair (logisticspipes.utils.tuples.Pair)8 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)7 LinkedList (java.util.LinkedList)5 NBTTagList (net.minecraft.nbt.NBTTagList)5 List (java.util.List)4 IRoutedItem (logisticspipes.logisticspipes.IRoutedItem)4 CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)4 DictResource (logisticspipes.request.resources.DictResource)4 IResource (logisticspipes.request.resources.IResource)4 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)4 HashMap (java.util.HashMap)3 TreeSet (java.util.TreeSet)3 LogisticsCraftingTableTileEntity (logisticspipes.blocks.crafting.LogisticsCraftingTableTileEntity)3 IAdditionalTargetInformation (logisticspipes.interfaces.routing.IAdditionalTargetInformation)3 ItemResource (logisticspipes.request.resources.ItemResource)3 IRouter (logisticspipes.routing.IRouter)3