// Path: src/main/java/guichaguri/betterfps/UpdateChecker.java
// public class UpdateChecker implements Runnable {
// 
//     private static boolean updateCheck = false;
//     private static boolean done = false;
//     private static String updateVersion = null;
//     private static String updateDownload = null;
// 
//     public static void check() {
//         if(!BetterFpsHelper.getConfig().updateChecker) {
//             done = true;
//             return;
//         }
//         if(!updateCheck) {
//             updateCheck = true;
//             checkForced();
//         }
//     }
// 
//     public static void checkForced() {
//         done = false;
//         Thread thread = new Thread(new UpdateChecker(), "BetterFps Update Checker");
//         thread.setDaemon(true);
//         thread.start();
//     }
// 
//     public static void showChat(EntityPlayerSP player) {
//         if(!done) return;
//         if(updateVersion == null && updateDownload == null) return;
//         if(!BetterFps.CLIENT) return;
// 
//         TextComponentTranslation title = new TextComponentTranslation("betterfps.update.available", updateVersion);
//         title.setStyle(title.getStyle().setColor(TextFormatting.GREEN).setBold(true));
// 
//         TextComponentString buttons = new TextComponentString("  ");
//         buttons.setStyle(buttons.getStyle().setColor(TextFormatting.YELLOW));
//         buttons.appendSibling(createButton(updateDownload, "betterfps.update.button.download"));
//         buttons.appendText("  ");
//         buttons.appendSibling(createButton(BetterFps.URL, "betterfps.update.button.more"));
// 
//         int phrase = (int)(Math.random() * 12) + 1;
//         TextComponentTranslation desc = new TextComponentTranslation("betterfps.update.phrase." + phrase);
//         desc.setStyle(desc.getStyle().setColor(TextFormatting.GRAY));
// 
//         if(updateVersion.length() < 8) {
//             title.appendSibling(buttons);
//             player.sendStatusMessage(title, false);
//             player.sendStatusMessage(desc, false);
//         } else {
//             player.sendStatusMessage(title, false);
//             player.sendStatusMessage(buttons, false);
//             player.sendStatusMessage(desc, false);
//         }
// 
//         updateVersion = null;
//         updateDownload = null;
//     }
// 
//     private static void showConsole() {
//         if(!done) return;
//         if(updateVersion == null && updateDownload == null) return;
// 
//         BetterFpsHelper.LOG.info("BetterFps " + updateVersion + " is available");
//         BetterFpsHelper.LOG.info("Download: " + updateDownload);
//         BetterFpsHelper.LOG.info("More: " + BetterFps.URL);
// 
//         updateVersion = null;
//         updateDownload = null;
//     }
// 
//     private static TextComponentTranslation createButton(String link, String key) {
//         TextComponentTranslation sib = new TextComponentTranslation(key);
//         Style style = sib.getStyle();
//         style.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, link));
//         TextComponentTranslation h = new TextComponentTranslation(key + ".info");
//         h.setStyle(h.getStyle().setColor(TextFormatting.RED));
//         style.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, h));
//         sib.setStyle(style);
//         return sib;
//     }
// 
//     @Override
//     public void run() {
//         try {
//             URL url = new URL(BetterFps.UPDATE_URL);
//             InputStream in = url.openStream();
//             JsonParser parser = new JsonParser();
//             JsonObject obj = parser.parse(new InputStreamReader(in)).getAsJsonObject();
//             JsonObject versions = obj.getAsJsonObject("versions");
// 
//             if(!versions.has(BetterFps.MC_VERSION)) return;
//             JsonArray array = versions.getAsJsonArray(BetterFps.MC_VERSION);
//             if(array.size() == 0) return;
// 
//             JsonObject latest = array.get(0).getAsJsonObject();
//             String version = latest.get("name").getAsString();
// 
//             if(!version.contains(BetterFps.VERSION)) {
//                 updateVersion = version;
//                 updateDownload = latest.get("url").getAsString();
//             }
// 
//             done = true;
// 
//             if(!BetterFps.CLIENT) {
//                 showConsole();
//             } else {
//                 if(Minecraft.getMinecraft().player != null) {
//                     showChat(Minecraft.getMinecraft().player);
//                 }
//             }
//         } catch(Exception ex) {
//             BetterFpsHelper.LOG.warn("Could not check for updates: " + ex.getMessage());
//         } finally {
//             done = true;
//         }
//     }
// }


import guichaguri.betterfps.UpdateChecker;
import guichaguri.betterfps.transformers.annotations.Copy;
import guichaguri.betterfps.transformers.annotations.Copy.Mode;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.network.NetHandlerPlayClient;
import net.minecraft.stats.RecipeBook;
import net.minecraft.stats.StatisticsManager;
import net.minecraft.world.World;
package guichaguri.betterfps.patches.misc;


/**
 * @author Guilherme Chaguri
 */
public abstract class ClientPlayerPatch extends EntityPlayerSP {

    public ClientPlayerPatch(Minecraft p_i47378_1_, World p_i47378_2_, NetHandlerPlayClient p_i47378_3_, StatisticsManager p_i47378_4_, RecipeBook p_i47378_5_) {
        super(p_i47378_1_, p_i47378_2_, p_i47378_3_, p_i47378_4_, p_i47378_5_);
    }

    @Copy(Mode.REPLACE)
    @Override
    public void preparePlayerToSpawn() {
// Path: src/main/java/guichaguri/betterfps/UpdateChecker.java
// public class UpdateChecker implements Runnable {
// 
//     private static boolean updateCheck = false;
//     private static boolean done = false;
//     private static String updateVersion = null;
//     private static String updateDownload = null;
// 
//     public static void check() {
//         if(!BetterFpsHelper.getConfig().updateChecker) {
//             done = true;
//             return;
//         }
//         if(!updateCheck) {
//             updateCheck = true;
//             checkForced();
//         }
//     }
// 
//     public static void checkForced() {
//         done = false;
//         Thread thread = new Thread(new UpdateChecker(), "BetterFps Update Checker");
//         thread.setDaemon(true);
//         thread.start();
//     }
// 
//     public static void showChat(EntityPlayerSP player) {
//         if(!done) return;
//         if(updateVersion == null && updateDownload == null) return;
//         if(!BetterFps.CLIENT) return;
// 
//         TextComponentTranslation title = new TextComponentTranslation("betterfps.update.available", updateVersion);
//         title.setStyle(title.getStyle().setColor(TextFormatting.GREEN).setBold(true));
// 
//         TextComponentString buttons = new TextComponentString("  ");
//         buttons.setStyle(buttons.getStyle().setColor(TextFormatting.YELLOW));
//         buttons.appendSibling(createButton(updateDownload, "betterfps.update.button.download"));
//         buttons.appendText("  ");
//         buttons.appendSibling(createButton(BetterFps.URL, "betterfps.update.button.more"));
// 
//         int phrase = (int)(Math.random() * 12) + 1;
//         TextComponentTranslation desc = new TextComponentTranslation("betterfps.update.phrase." + phrase);
//         desc.setStyle(desc.getStyle().setColor(TextFormatting.GRAY));
// 
//         if(updateVersion.length() < 8) {
//             title.appendSibling(buttons);
//             player.sendStatusMessage(title, false);
//             player.sendStatusMessage(desc, false);
//         } else {
//             player.sendStatusMessage(title, false);
//             player.sendStatusMessage(buttons, false);
//             player.sendStatusMessage(desc, false);
//         }
// 
//         updateVersion = null;
//         updateDownload = null;
//     }
// 
//     private static void showConsole() {
//         if(!done) return;
//         if(updateVersion == null && updateDownload == null) return;
// 
//         BetterFpsHelper.LOG.info("BetterFps " + updateVersion + " is available");
//         BetterFpsHelper.LOG.info("Download: " + updateDownload);
//         BetterFpsHelper.LOG.info("More: " + BetterFps.URL);
// 
//         updateVersion = null;
//         updateDownload = null;
//     }
// 
//     private static TextComponentTranslation createButton(String link, String key) {
//         TextComponentTranslation sib = new TextComponentTranslation(key);
//         Style style = sib.getStyle();
//         style.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, link));
//         TextComponentTranslation h = new TextComponentTranslation(key + ".info");
//         h.setStyle(h.getStyle().setColor(TextFormatting.RED));
//         style.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, h));
//         sib.setStyle(style);
//         return sib;
//     }
// 
//     @Override
//     public void run() {
//         try {
//             URL url = new URL(BetterFps.UPDATE_URL);
//             InputStream in = url.openStream();
//             JsonParser parser = new JsonParser();
//             JsonObject obj = parser.parse(new InputStreamReader(in)).getAsJsonObject();
//             JsonObject versions = obj.getAsJsonObject("versions");
// 
//             if(!versions.has(BetterFps.MC_VERSION)) return;
//             JsonArray array = versions.getAsJsonArray(BetterFps.MC_VERSION);
//             if(array.size() == 0) return;
// 
//             JsonObject latest = array.get(0).getAsJsonObject();
//             String version = latest.get("name").getAsString();
// 
//             if(!version.contains(BetterFps.VERSION)) {
//                 updateVersion = version;
//                 updateDownload = latest.get("url").getAsString();
//             }
// 
//             done = true;
// 
//             if(!BetterFps.CLIENT) {
//                 showConsole();
//             } else {
//                 if(Minecraft.getMinecraft().player != null) {
//                     showChat(Minecraft.getMinecraft().player);
//                 }
//             }
//         } catch(Exception ex) {
//             BetterFpsHelper.LOG.warn("Could not check for updates: " + ex.getMessage());
//         } finally {
//             done = true;
//         }
//     }
// }


// Path: src/main/java/guichaguri/betterfps/patches/misc/ClientPlayerPatch.java
import guichaguri.betterfps.UpdateChecker;
import guichaguri.betterfps.transformers.annotations.Copy;
import guichaguri.betterfps.transformers.annotations.Copy.Mode;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.network.NetHandlerPlayClient;
import net.minecraft.stats.RecipeBook;
import net.minecraft.stats.StatisticsManager;
import net.minecraft.world.World;

package guichaguri.betterfps.patches.misc;


/**
 * @author Guilherme Chaguri
 */
public abstract class ClientPlayerPatch extends EntityPlayerSP {

    public ClientPlayerPatch(Minecraft p_i47378_1_, World p_i47378_2_, NetHandlerPlayClient p_i47378_3_, StatisticsManager p_i47378_4_, RecipeBook p_i47378_5_) {
        super(p_i47378_1_, p_i47378_2_, p_i47378_3_, p_i47378_4_, p_i47378_5_);
    }

    @Copy(Mode.REPLACE)
    @Override
    public void preparePlayerToSpawn() {
        UpdateChecker.showChat(this);