@@ -0,0 +1,2291 @@
+package com.enderio.core.client.gui.button;%0A%0Aimport java.util.List;%0A%0Aimport lombok.Getter;%0Aimport net.minecraft.client.Minecraft;%0A%0Aimport com.enderio.core.api.client.gui.IGuiScreen;%0Aimport com.enderio.core.api.client.render.IWidgetIcon;%0Aimport com.enderio.core.client.gui.button.CycleButton.ICycleEnum;%0Aimport com.google.common.base.Throwables;%0Aimport com.google.common.collect.Lists;%0A%0Aimport cpw.mods.fml.relauncher.ReflectionHelper;%0A%0A/**%0A * A button which automatically parses enum constants and cycles between them%0A * when clicked.%0A *%0A * @param %3CT%3E%0A *          The enum type for this button.%0A */%0Apublic class CycleButton%3CT extends Enum%3CT%3E & ICycleEnum%3E extends IconButton %7B%0A%0A  public interface ICycleEnum %7B%0A%0A    /**%0A     * @return The icon to display when the button has selected this mode.%0A     */%0A    IWidgetIcon getIcon();%0A%0A    /**%0A     * @return Localized tooltip lines.%0A     */%0A    List%3CString%3E getTooltipLines();%0A  %7D%0A%0A  private T%5B%5D modes;%0A%0A  @Getter%0A  private T mode;%0A%0A  @SuppressWarnings(%22unchecked%22)%0A  public CycleButton(IGuiScreen gui, int id, int x, int y, Class%3CT%3E enumClass) %7B%0A    super(gui, id, x, y, null);%0A    try %7B%0A      modes = (T%5B%5D) ReflectionHelper.findMethod(enumClass, null, new String%5B%5D %7B %22values%22 %7D).invoke(null);%0A    %7D catch (Exception e) %7B%0A      Throwables.propagate(e);%0A    %7D%0A    setMode(modes%5B0%5D);%0A  %7D%0A%0A  @Override%0A  public boolean mousePressed(Minecraft par1Minecraft, int par2, int par3) %7B%0A    boolean result = super.mousePressed(par1Minecraft, par2, par3);%0A    if (result) %7B%0A      nextMode();%0A    %7D%0A    return result;%0A  %7D%0A%0A  @Override%0A  public boolean mousePressedButton(Minecraft mc, int x, int y, int button) %7B%0A    boolean result = button == 1 && super.checkMousePress(mc, x, y);%0A    if (result) %7B%0A      prevMode();%0A    %7D%0A    return result;%0A  %7D%0A%0A  private void nextMode() %7B%0A    setMode(modes%5B(mode.ordinal() + 1) %25 modes.length%5D);%0A  %7D%0A%0A  private void prevMode() %7B%0A    int ord = mode.ordinal() - 1;%0A    if (ord %3C 0) %7B%0A      ord = modes.length - 1;%0A    %7D%0A    setMode(modes%5Bord%5D);%0A  %7D%0A%0A  public void setMode(T newMode) %7B%0A    if (mode == newMode) %7B%0A      return;%0A    %7D%0A    mode = newMode;%0A    List%3CString%3E tooltip = Lists.newArrayList(mode.getTooltipLines());%0A    setToolTip(tooltip.toArray(new String%5Btooltip.size()%5D));%0A%0A    this.icon = mode.getIcon();%0A  %7D%0A%7D%0A

Add CycleButton