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());
}
}
}
}
Aggregations