use of pneumaticCraft.client.gui.IGuiDrone in project PneumaticCraft by MineMaarten.
the class ClientEventHandler method onItemTooltip.
@SubscribeEvent
public void onItemTooltip(ItemTooltipEvent event) {
if (event.itemStack.getItem() instanceof IProgrammable) {
IProgrammable programmable = (IProgrammable) event.itemStack.getItem();
if (programmable.canProgram(event.itemStack) && programmable.showProgramTooltip()) {
boolean hasInvalidPrograms = false;
List<String> addedEntries = new ArrayList<String>();
Map<String, Integer> widgetMap = getPuzzleSummary(TileEntityProgrammer.getProgWidgets(event.itemStack));
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 = EnumChatFormatting.RED + "";
hasInvalidPrograms = true;
}
}
addedEntries.add(prefix + "-" + entry.getValue() + "x " + I18n.format("programmingPuzzle." + entry.getKey() + ".name"));
}
if (hasInvalidPrograms) {
event.toolTip.add(EnumChatFormatting.RED + I18n.format("gui.tooltip.programmable.invalidPieces"));
}
Collections.sort(addedEntries);
event.toolTip.addAll(addedEntries);
}
}
}
Aggregations