Search in sources :

Example 1 with IGuiDrone

use of me.desht.pneumaticcraft.client.gui.IGuiDrone in project pnc-repressurized by TeamPneumatic.

the class ClientEventHandler method handleProgrammableTooltip.

private void handleProgrammableTooltip(ItemTooltipEvent event) {
    IProgrammable programmable = (IProgrammable) event.getItemStack().getItem();
    if (programmable.canProgram(event.getItemStack()) && programmable.showProgramTooltip()) {
        boolean hasInvalidPrograms = false;
        List<String> addedEntries = new ArrayList<>();
        List<IProgWidget> widgets = TileEntityProgrammer.getProgWidgets(event.getItemStack());
        Map<String, Integer> widgetMap = getPuzzleSummary(widgets);
        for (Map.Entry<String, Integer> entry : widgetMap.entrySet()) {
            IProgWidget widget = ItemProgrammingPuzzle.getWidgetForName(entry.getKey());
            String prefix = "";
            GuiScreen curScreen = Minecraft.getMinecraft().currentScreen;
            if (curScreen instanceof IGuiDrone) {
                if (!((IGuiDrone) curScreen).getDrone().isProgramApplicable(widget)) {
                    prefix = TextFormatting.RED + "";
                    hasInvalidPrograms = true;
                }
            }
            addedEntries.add(prefix + "- " + entry.getValue() + "x " + I18n.format("programmingPuzzle." + entry.getKey() + ".name"));
        }
        if (hasInvalidPrograms) {
            event.getToolTip().add(TextFormatting.RED + I18n.format("gui.tooltip.programmable.invalidPieces"));
        }
        Collections.sort(addedEntries);
        event.getToolTip().addAll(addedEntries);
        if (PneumaticCraftRepressurized.proxy.isSneakingInGui() && !widgets.isEmpty()) {
            Map<Integer, Integer> widgetColorMap = TileEntityProgrammer.getPuzzleSummary(widgets);
            event.getToolTip().add(TextFormatting.WHITE + I18n.format("gui.tooltip.programmable.requiredPieces"));
            for (int color : widgetColorMap.keySet()) {
                ItemStack stack = ItemProgrammingPuzzle.getStackForColor(color);
                stack.setCount(widgetColorMap.get(color));
                event.getToolTip().add("- " + widgetColorMap.get(color) + " x " + stack.getDisplayName());
            }
        }
    }
}
Also used : IProgrammable(me.desht.pneumaticcraft.api.item.IProgrammable) IProgWidget(me.desht.pneumaticcraft.common.progwidgets.IProgWidget) IGuiDrone(me.desht.pneumaticcraft.client.gui.IGuiDrone) GuiScreen(net.minecraft.client.gui.GuiScreen) ItemStack(net.minecraft.item.ItemStack)

Aggregations

IProgrammable (me.desht.pneumaticcraft.api.item.IProgrammable)1 IGuiDrone (me.desht.pneumaticcraft.client.gui.IGuiDrone)1 IProgWidget (me.desht.pneumaticcraft.common.progwidgets.IProgWidget)1 GuiScreen (net.minecraft.client.gui.GuiScreen)1 ItemStack (net.minecraft.item.ItemStack)1