    001    package net.minecraft.client.settings;
    002
    003    import cpw.mods.fml.client.FMLClientHandler;
    004    import cpw.mods.fml.common.Side;
    005    import cpw.mods.fml.common.asm.SideOnly;
    006    import java.io.BufferedReader;
    007    import java.io.File;
    008    import java.io.FileReader;
    009    import java.io.FileWriter;
    010    import java.io.PrintWriter;
    011    import net.minecraft.client.Minecraft;
    012    import net.minecraft.network.packet.Packet204ClientInfo;
    013    import net.minecraft.util.StatCollector;
    014    import net.minecraft.util.StringTranslate;
    015    import org.lwjgl.input.Keyboard;
    016    import org.lwjgl.opengl.Display;
    017
    018    @SideOnly(Side.CLIENT)
    019    public class GameSettings
    020    {
    021        private static final String[] RENDER_DISTANCES = new String[] {"options.renderDistance.far", "options.renderDistance.normal", "options.renderDistance.short", "options.renderDistance.tiny"};
    022        private static final String[] DIFFICULTIES = new String[] {"options.difficulty.peaceful", "options.difficulty.easy", "options.difficulty.normal", "options.difficulty.hard"};
    023
    024        /** GUI scale values */
    025        private static final String[] GUISCALES = new String[] {"options.guiScale.auto", "options.guiScale.small", "options.guiScale.normal", "options.guiScale.large"};
    026        private static final String[] CHAT_VISIBILITIES = new String[] {"options.chat.visibility.full", "options.chat.visibility.system", "options.chat.visibility.hidden"};
    027        private static final String[] PARTICLES = new String[] {"options.particles.all", "options.particles.decreased", "options.particles.minimal"};
    028
    029        /** Limit framerate labels */
    030        private static final String[] LIMIT_FRAMERATES = new String[] {"performance.max", "performance.balanced", "performance.powersaver"};
    031        public float musicVolume = 1.0F;
    032        public float soundVolume = 1.0F;
    033        public float mouseSensitivity = 0.5F;
    034        public boolean invertMouse = false;
    035        public int renderDistance = 0;
    036        public boolean viewBobbing = true;
    037        public boolean anaglyph = false;
    038
    039        /** Advanced OpenGL */
    040        public boolean advancedOpengl = false;
    041        public int limitFramerate = 1;
    042        public boolean fancyGraphics = true;
    043
    044        /** Smooth Lighting */
    045        public boolean ambientOcclusion = true;
    046
    047        /** Clouds flag */
    048        public boolean clouds = true;
    049
    050        /** The name of the selected texture pack. */
    051        public String skin = "Default";
    052        public int chatVisibility = 0;
    053        public boolean chatColours = true;
    054        public boolean chatLinks = true;
    055        public boolean chatLinksPrompt = true;
    056        public float chatOpacity = 1.0F;
    057        public boolean serverTextures = true;
    058        public boolean snooperEnabled = true;
    059        public boolean fullScreen = false;
    060        public boolean enableVsync = true;
    061        public boolean hideServerAddress = false;
    062
    063        /**
    064         * Whether to show advanced information on item tooltips, toggled by F3+H
    065         */
    066        public boolean advancedItemTooltips = false;
    067
    068        /** Whether to pause when the game loses focus, toggled by F3+P */
    069        public boolean pauseOnLostFocus = true;
    070
    071        /** Whether to show your cape */
    072        public boolean showCape = true;
    073        public boolean field_85185_A = false;
    074        public KeyBinding keyBindForward = new KeyBinding("key.forward", 17);
    075        public KeyBinding keyBindLeft = new KeyBinding("key.left", 30);
    076        public KeyBinding keyBindBack = new KeyBinding("key.back", 31);
    077        public KeyBinding keyBindRight = new KeyBinding("key.right", 32);
    078        public KeyBinding keyBindJump = new KeyBinding("key.jump", 57);
    079        public KeyBinding keyBindInventory = new KeyBinding("key.inventory", 18);
    080        public KeyBinding keyBindDrop = new KeyBinding("key.drop", 16);
    081        public KeyBinding keyBindChat = new KeyBinding("key.chat", 20);
    082        public KeyBinding keyBindSneak = new KeyBinding("key.sneak", 42);
    083        public KeyBinding keyBindAttack = new KeyBinding("key.attack", -100);
    084        public KeyBinding keyBindUseItem = new KeyBinding("key.use", -99);
    085        public KeyBinding keyBindPlayerList = new KeyBinding("key.playerlist", 15);
    086        public KeyBinding keyBindPickBlock = new KeyBinding("key.pickItem", -98);
    087        public KeyBinding keyBindCommand = new KeyBinding("key.command", 53);
    088        public KeyBinding[] keyBindings;
    089        protected Minecraft mc;
    090        private File optionsFile;
    091        public int difficulty;
    092        public boolean hideGUI;
    093        public int thirdPersonView;
    094
    095        /** true if debug info should be displayed instead of version */
    096        public boolean showDebugInfo;
    097        public boolean showDebugProfilerChart;
    098
    099        /** The lastServer string. */
    100        public String lastServer;
    101
    102        /** No clipping for singleplayer */
    103        public boolean noclip;
    104
    105        /** Smooth Camera Toggle */
    106        public boolean smoothCamera;
    107        public boolean debugCamEnable;
    108
    109        /** No clipping movement rate */
    110        public float noclipRate;
    111
    112        /** Change rate for debug camera */
    113        public float debugCamRate;
    114        public float fovSetting;
    115        public float gammaSetting;
    116
    117        /** GUI scale */
    118        public int guiScale;
    119
    120        /** Determines amount of particles. 0 = All, 1 = Decreased, 2 = Minimal */
    121        public int particleSetting;
    122
    123        /** Game settings language */
    124        public String language;
    125
    126        public GameSettings(Minecraft par1Minecraft, File par2File)
    127        {
    128            this.keyBindings = new KeyBinding[] {this.keyBindAttack, this.keyBindUseItem, this.keyBindForward, this.keyBindLeft, this.keyBindBack, this.keyBindRight, this.keyBindJump, this.keyBindSneak, this.keyBindDrop, this.keyBindInventory, this.keyBindChat, this.keyBindPlayerList, this.keyBindPickBlock, this.keyBindCommand};
    129            this.difficulty = 2;
    130            this.hideGUI = false;
    131            this.thirdPersonView = 0;
    132            this.showDebugInfo = false;
    133            this.showDebugProfilerChart = false;
    134            this.lastServer = "";
    135            this.noclip = false;
    136            this.smoothCamera = false;
    137            this.debugCamEnable = false;
    138            this.noclipRate = 1.0F;
    139            this.debugCamRate = 1.0F;
    140            this.fovSetting = 0.0F;
    141            this.gammaSetting = 0.0F;
    142            this.guiScale = 0;
    143            this.particleSetting = 0;
    144            this.language = "en_US";
    145            this.mc = par1Minecraft;
    146            this.optionsFile = new File(par2File, "options.txt");
    147            this.loadOptions();
    148        }
    149
    150        public GameSettings()
    151        {
    152            this.keyBindings = new KeyBinding[] {this.keyBindAttack, this.keyBindUseItem, this.keyBindForward, this.keyBindLeft, this.keyBindBack, this.keyBindRight, this.keyBindJump, this.keyBindSneak, this.keyBindDrop, this.keyBindInventory, this.keyBindChat, this.keyBindPlayerList, this.keyBindPickBlock, this.keyBindCommand};
    153            this.difficulty = 2;
    154            this.hideGUI = false;
    155            this.thirdPersonView = 0;
    156            this.showDebugInfo = false;
    157            this.showDebugProfilerChart = false;
    158            this.lastServer = "";
    159            this.noclip = false;
    160            this.smoothCamera = false;
    161            this.debugCamEnable = false;
    162            this.noclipRate = 1.0F;
    163            this.debugCamRate = 1.0F;
    164            this.fovSetting = 0.0F;
    165            this.gammaSetting = 0.0F;
    166            this.guiScale = 0;
    167            this.particleSetting = 0;
    168            this.language = "en_US";
    169        }
    170
    171        public String getKeyBindingDescription(int par1)
    172        {
    173            StringTranslate var2 = StringTranslate.getInstance();
    174            return var2.translateKey(this.keyBindings[par1].keyDescription);
    175        }
    176
    177        /**
    178         * The string that appears inside the button/slider in the options menu.
    179         */
    180        public String getOptionDisplayString(int par1)
    181        {
    182            int var2 = this.keyBindings[par1].keyCode;
    183            return getKeyDisplayString(var2);
    184        }
    185
    186        /**
    187         * Represents a key or mouse button as a string. Args: key
    188         */
    189        public static String getKeyDisplayString(int par0)
    190        {
    191            return par0 < 0 ? StatCollector.translateToLocalFormatted("key.mouseButton", new Object[] {Integer.valueOf(par0 + 101)}): Keyboard.getKeyName(par0);
    192        }
    193
    194        /**
    195         * Sets a key binding.
    196         */
    197        public void setKeyBinding(int par1, int par2)
    198        {
    199            this.keyBindings[par1].keyCode = par2;
    200            this.saveOptions();
    201        }
    202
    203        /**
    204         * If the specified option is controlled by a slider (float value), this will set the float value.
    205         */
    206        public void setOptionFloatValue(EnumOptions par1EnumOptions, float par2)
    207        {
    208            if (par1EnumOptions == EnumOptions.MUSIC)
    209            {
    210                this.musicVolume = par2;
    211                this.mc.sndManager.onSoundOptionsChanged();
    212            }
    213
    214            if (par1EnumOptions == EnumOptions.SOUND)
    215            {
    216                this.soundVolume = par2;
    217                this.mc.sndManager.onSoundOptionsChanged();
    218            }
    219
    220            if (par1EnumOptions == EnumOptions.SENSITIVITY)
    221            {
    222                this.mouseSensitivity = par2;
    223            }
    224
    225            if (par1EnumOptions == EnumOptions.FOV)
    226            {
    227                this.fovSetting = par2;
    228            }
    229
    230            if (par1EnumOptions == EnumOptions.GAMMA)
    231            {
    232                this.gammaSetting = par2;
    233            }
    234
    235            if (par1EnumOptions == EnumOptions.CHAT_OPACITY)
    236            {
    237                this.chatOpacity = par2;
    238            }
    239        }
    240
    241        /**
    242         * For non-float options. Toggles the option on/off, or cycles through the list i.e. render distances.
    243         */
    244        public void setOptionValue(EnumOptions par1EnumOptions, int par2)
    245        {
    246            if (par1EnumOptions == EnumOptions.INVERT_MOUSE)
    247            {
    248                this.invertMouse = !this.invertMouse;
    249            }
    250
    251            if (par1EnumOptions == EnumOptions.RENDER_DISTANCE)
    252            {
    253                this.renderDistance = this.renderDistance + par2 & 3;
    254            }
    255
    256            if (par1EnumOptions == EnumOptions.GUI_SCALE)
    257            {
    258                this.guiScale = this.guiScale + par2 & 3;
    259            }
    260
    261            if (par1EnumOptions == EnumOptions.PARTICLES)
    262            {
    263                this.particleSetting = (this.particleSetting + par2) % 3;
    264            }
    265
    266            if (par1EnumOptions == EnumOptions.VIEW_BOBBING)
    267            {
    268                this.viewBobbing = !this.viewBobbing;
    269            }
    270
    271            if (par1EnumOptions == EnumOptions.RENDER_CLOUDS)
    272            {
    273                this.clouds = !this.clouds;
    274            }
    275
    276            if (par1EnumOptions == EnumOptions.ADVANCED_OPENGL)
    277            {
    278                this.advancedOpengl = !this.advancedOpengl;
    279                this.mc.renderGlobal.loadRenderers();
    280            }
    281
    282            if (par1EnumOptions == EnumOptions.ANAGLYPH)
    283            {
    284                this.anaglyph = !this.anaglyph;
    285                this.mc.renderEngine.refreshTextures();
    286            }
    287
    288            if (par1EnumOptions == EnumOptions.FRAMERATE_LIMIT)
    289            {
    290                this.limitFramerate = (this.limitFramerate + par2 + 3) % 3;
    291            }
    292
    293            if (par1EnumOptions == EnumOptions.DIFFICULTY)
    294            {
    295                this.difficulty = this.difficulty + par2 & 3;
    296            }
    297
    298            if (par1EnumOptions == EnumOptions.GRAPHICS)
    299            {
    300                this.fancyGraphics = !this.fancyGraphics;
    301                this.mc.renderGlobal.loadRenderers();
    302            }
    303
    304            if (par1EnumOptions == EnumOptions.AMBIENT_OCCLUSION)
    305            {
    306                this.ambientOcclusion = !this.ambientOcclusion;
    307                this.mc.renderGlobal.loadRenderers();
    308            }
    309
    310            if (par1EnumOptions == EnumOptions.CHAT_VISIBILITY)
    311            {
    312                this.chatVisibility = (this.chatVisibility + par2) % 3;
    313            }
    314
    315            if (par1EnumOptions == EnumOptions.CHAT_COLOR)
    316            {
    317                this.chatColours = !this.chatColours;
    318            }
    319
    320            if (par1EnumOptions == EnumOptions.CHAT_LINKS)
    321            {
    322                this.chatLinks = !this.chatLinks;
    323            }
    324
    325            if (par1EnumOptions == EnumOptions.CHAT_LINKS_PROMPT)
    326            {
    327                this.chatLinksPrompt = !this.chatLinksPrompt;
    328            }
    329
    330            if (par1EnumOptions == EnumOptions.USE_SERVER_TEXTURES)
    331            {
    332                this.serverTextures = !this.serverTextures;
    333            }
    334
    335            if (par1EnumOptions == EnumOptions.SNOOPER_ENABLED)
    336            {
    337                this.snooperEnabled = !this.snooperEnabled;
    338            }
    339
    340            if (par1EnumOptions == EnumOptions.SHOW_CAPE)
    341            {
    342                this.showCape = !this.showCape;
    343            }
    344
    345            if (par1EnumOptions == EnumOptions.TOUCHSCREEN)
    346            {
    347                this.field_85185_A = !this.field_85185_A;
    348            }
    349
    350            if (par1EnumOptions == EnumOptions.USE_FULLSCREEN)
    351            {
    352                this.fullScreen = !this.fullScreen;
    353
    354                if (this.mc.isFullScreen() != this.fullScreen)
    355                {
    356                    this.mc.toggleFullscreen();
    357                }
    358            }
    359
    360            if (par1EnumOptions == EnumOptions.ENABLE_VSYNC)
    361            {
    362                this.enableVsync = !this.enableVsync;
    363                Display.setVSyncEnabled(this.enableVsync);
    364            }
    365
    366            this.saveOptions();
    367        }
    368
    369        public float getOptionFloatValue(EnumOptions par1EnumOptions)
    370        {
    371            return par1EnumOptions == EnumOptions.FOV ? this.fovSetting : (par1EnumOptions == EnumOptions.GAMMA ? this.gammaSetting : (par1EnumOptions == EnumOptions.MUSIC ? this.musicVolume : (par1EnumOptions == EnumOptions.SOUND ? this.soundVolume : (par1EnumOptions == EnumOptions.SENSITIVITY ? this.mouseSensitivity : (par1EnumOptions == EnumOptions.CHAT_OPACITY ? this.chatOpacity : 0.0F)))));
    372        }
    373
    374        public boolean getOptionOrdinalValue(EnumOptions par1EnumOptions)
    375        {
    376            switch (EnumOptionsHelper.enumOptionsMappingHelperArray[par1EnumOptions.ordinal()])
    377            {
    378                case 1:
    379                    return this.invertMouse;
    380                case 2:
    381                    return this.viewBobbing;
    382                case 3:
    383                    return this.anaglyph;
    384                case 4:
    385                    return this.advancedOpengl;
    386                case 5:
    387                    return this.ambientOcclusion;
    388                case 6:
    389                    return this.clouds;
    390                case 7:
    391                    return this.chatColours;
    392                case 8:
    393                    return this.chatLinks;
    394                case 9:
    395                    return this.chatLinksPrompt;
    396                case 10:
    397                    return this.serverTextures;
    398                case 11:
    399                    return this.snooperEnabled;
    400                case 12:
    401                    return this.fullScreen;
    402                case 13:
    403                    return this.enableVsync;
    404                case 14:
    405                    return this.showCape;
    406                case 15:
    407                    return this.field_85185_A;
    408                default:
    409                    return false;
    410            }
    411        }
    412
    413        /**
    414         * Returns the translation of the given index in the given String array. If the index is smaller than 0 or greater
    415         * than/equal to the length of the String array, it is changed to 0.
    416         */
    417        private static String getTranslation(String[] par0ArrayOfStr, int par1)
    418        {
    419            if (par1 < 0 || par1 >= par0ArrayOfStr.length)
    420            {
    421                par1 = 0;
    422            }
    423
    424            StringTranslate var2 = StringTranslate.getInstance();
    425            return var2.translateKey(par0ArrayOfStr[par1]);
    426        }
    427
    428        /**
    429         * Gets a key binding.
    430         */
    431        public String getKeyBinding(EnumOptions par1EnumOptions)
    432        {
    433            StringTranslate var2 = StringTranslate.getInstance();
    434            String var3 = var2.translateKey(par1EnumOptions.getEnumString()) + ": ";
    435
    436            if (par1EnumOptions.getEnumFloat())
    437            {
    438                float var5 = this.getOptionFloatValue(par1EnumOptions);
    439                return par1EnumOptions == EnumOptions.SENSITIVITY ? (var5 == 0.0F ? var3 + var2.translateKey("options.sensitivity.min") : (var5 == 1.0F ? var3 + var2.translateKey("options.sensitivity.max") : var3 + (int)(var5 * 200.0F) + "%")) : (par1EnumOptions == EnumOptions.FOV ? (var5 == 0.0F ? var3 + var2.translateKey("options.fov.min") : (var5 == 1.0F ? var3 + var2.translateKey("options.fov.max") : var3 + (int)(70.0F + var5 * 40.0F))) : (par1EnumOptions == EnumOptions.GAMMA ? (var5 == 0.0F ? var3 + var2.translateKey("options.gamma.min") : (var5 == 1.0F ? var3 + var2.translateKey("options.gamma.max") : var3 + "+" + (int)(var5 * 100.0F) + "%")) : (par1EnumOptions == EnumOptions.CHAT_OPACITY ? var3 + (int)(var5 * 90.0F + 10.0F) + "%" : (var5 == 0.0F ? var3 + var2.translateKey("options.off") : var3 + (int)(var5 * 100.0F) + "%"))));
    440            }
    441            else if (par1EnumOptions.getEnumBoolean())
    442            {
    443                boolean var4 = this.getOptionOrdinalValue(par1EnumOptions);
    444                return var4 ? var3 + var2.translateKey("options.on") : var3 + var2.translateKey("options.off");
    445            }
    446            else
    447            {
    448                return par1EnumOptions == EnumOptions.RENDER_DISTANCE ? var3 + getTranslation(RENDER_DISTANCES, this.renderDistance) : (par1EnumOptions == EnumOptions.DIFFICULTY ? var3 + getTranslation(DIFFICULTIES, this.difficulty) : (par1EnumOptions == EnumOptions.GUI_SCALE ? var3 + getTranslation(GUISCALES, this.guiScale) : (par1EnumOptions == EnumOptions.CHAT_VISIBILITY ? var3 + getTranslation(CHAT_VISIBILITIES, this.chatVisibility) : (par1EnumOptions == EnumOptions.PARTICLES ? var3 + getTranslation(PARTICLES, this.particleSetting) : (par1EnumOptions == EnumOptions.FRAMERATE_LIMIT ? var3 + getTranslation(LIMIT_FRAMERATES, this.limitFramerate) : (par1EnumOptions == EnumOptions.GRAPHICS ? (this.fancyGraphics ? var3 + var2.translateKey("options.graphics.fancy") : var3 + var2.translateKey("options.graphics.fast")) : var3))))));
    449            }
    450        }
    451
    452        /**
    453         * Loads the options from the options file. It appears that this has replaced the previous 'loadOptions'
    454         */
    455        public void loadOptions()
    456        {
    457            try
    458            {
    459                if (!this.optionsFile.exists())
    460                {
    461                    return;
    462                }
    463
    464                BufferedReader var1 = new BufferedReader(new FileReader(this.optionsFile));
    465                String var2 = "";
    466
    467                while ((var2 = var1.readLine()) != null)
    468                {
    469                    try
    470                    {
    471                        String[] var3 = var2.split(":");
    472
    473                        if (var3[0].equals("music"))
    474                        {
    475                            this.musicVolume = this.parseFloat(var3[1]);
    476                        }
    477
    478                        if (var3[0].equals("sound"))
    479                        {
    480                            this.soundVolume = this.parseFloat(var3[1]);
    481                        }
    482
    483                        if (var3[0].equals("mouseSensitivity"))
    484                        {
    485                            this.mouseSensitivity = this.parseFloat(var3[1]);
    486                        }
    487
    488                        if (var3[0].equals("fov"))
    489                        {
    490                            this.fovSetting = this.parseFloat(var3[1]);
    491                        }
    492
    493                        if (var3[0].equals("gamma"))
    494                        {
    495                            this.gammaSetting = this.parseFloat(var3[1]);
    496                        }
    497
    498                        if (var3[0].equals("invertYMouse"))
    499                        {
    500                            this.invertMouse = var3[1].equals("true");
    501                        }
    502
    503                        if (var3[0].equals("viewDistance"))
    504                        {
    505                            this.renderDistance = Integer.parseInt(var3[1]);
    506                        }
    507
    508                        if (var3[0].equals("guiScale"))
    509                        {
    510                            this.guiScale = Integer.parseInt(var3[1]);
    511                        }
    512
    513                        if (var3[0].equals("particles"))
    514                        {
    515                            this.particleSetting = Integer.parseInt(var3[1]);
    516                        }
    517
    518                        if (var3[0].equals("bobView"))
    519                        {
    520                            this.viewBobbing = var3[1].equals("true");
    521                        }
    522
    523                        if (var3[0].equals("anaglyph3d"))
    524                        {
    525                            this.anaglyph = var3[1].equals("true");
    526                        }
    527
    528                        if (var3[0].equals("advancedOpengl"))
    529                        {
    530                            this.advancedOpengl = var3[1].equals("true");
    531                        }
    532
    533                        if (var3[0].equals("fpsLimit"))
    534                        {
    535                            this.limitFramerate = Integer.parseInt(var3[1]);
    536                        }
    537
    538                        if (var3[0].equals("difficulty"))
    539                        {
    540                            this.difficulty = Integer.parseInt(var3[1]);
    541                        }
    542
    543                        if (var3[0].equals("fancyGraphics"))
    544                        {
    545                            this.fancyGraphics = var3[1].equals("true");
    546                        }
    547
    548                        if (var3[0].equals("ao"))
    549                        {
    550                            this.ambientOcclusion = var3[1].equals("true");
    551                        }
    552
    553                        if (var3[0].equals("clouds"))
    554                        {
    555                            this.clouds = var3[1].equals("true");
    556                        }
    557
    558                        if (var3[0].equals("skin"))
    559                        {
    560                            this.skin = var3[1];
    561                        }
    562
    563                        if (var3[0].equals("lastServer") && var3.length >= 2)
    564                        {
    565                            this.lastServer = var3[1];
    566                        }
    567
    568                        if (var3[0].equals("lang") && var3.length >= 2)
    569                        {
    570                            this.language = var3[1];
    571                        }
    572
    573                        if (var3[0].equals("chatVisibility"))
    574                        {
    575                            this.chatVisibility = Integer.parseInt(var3[1]);
    576                        }
    577
    578                        if (var3[0].equals("chatColors"))
    579                        {
    580                            this.chatColours = var3[1].equals("true");
    581                        }
    582
    583                        if (var3[0].equals("chatLinks"))
    584                        {
    585                            this.chatLinks = var3[1].equals("true");
    586                        }
    587
    588                        if (var3[0].equals("chatLinksPrompt"))
    589                        {
    590                            this.chatLinksPrompt = var3[1].equals("true");
    591                        }
    592
    593                        if (var3[0].equals("chatOpacity"))
    594                        {
    595                            this.chatOpacity = this.parseFloat(var3[1]);
    596                        }
    597
    598                        if (var3[0].equals("serverTextures"))
    599                        {
    600                            this.serverTextures = var3[1].equals("true");
    601                        }
    602
    603                        if (var3[0].equals("snooperEnabled"))
    604                        {
    605                            this.snooperEnabled = var3[1].equals("true");
    606                        }
    607
    608                        if (var3[0].equals("fullscreen"))
    609                        {
    610                            this.fullScreen = var3[1].equals("true");
    611                        }
    612
    613                        if (var3[0].equals("enableVsync"))
    614                        {
    615                            this.enableVsync = var3[1].equals("true");
    616                        }
    617
    618                        if (var3[0].equals("hideServerAddress"))
    619                        {
    620                            this.hideServerAddress = var3[1].equals("true");
    621                        }
    622
    623                        if (var3[0].equals("advancedItemTooltips"))
    624                        {
    625                            this.advancedItemTooltips = var3[1].equals("true");
    626                        }
    627
    628                        if (var3[0].equals("pauseOnLostFocus"))
    629                        {
    630                            this.pauseOnLostFocus = var3[1].equals("true");
    631                        }
    632
    633                        if (var3[0].equals("showCape"))
    634                        {
    635                            this.showCape = var3[1].equals("true");
    636                        }
    637
    638                        if (var3[0].equals("touchscreen"))
    639                        {
    640                            this.field_85185_A = var3[1].equals("true");
    641                        }
    642
    643                        for (int var4 = 0; var4 < this.keyBindings.length; ++var4)
    644                        {
    645                            if (var3[0].equals("key_" + this.keyBindings[var4].keyDescription))
    646                            {
    647                                this.keyBindings[var4].keyCode = Integer.parseInt(var3[1]);
    648                            }
    649                        }
    650                    }
    651                    catch (Exception var5)
    652                    {
    653                        System.out.println("Skipping bad option: " + var2);
    654                    }
    655                }
    656
    657                KeyBinding.resetKeyBindingArrayAndHash();
    658                var1.close();
    659            }
    660            catch (Exception var6)
    661            {
    662                System.out.println("Failed to load options");
    663                var6.printStackTrace();
    664            }
    665        }
    666
    667        /**
    668         * Parses a string into a float.
    669         */
    670        private float parseFloat(String par1Str)
    671        {
    672            return par1Str.equals("true") ? 1.0F : (par1Str.equals("false") ? 0.0F : Float.parseFloat(par1Str));
    673        }
    674
    675        /**
    676         * Saves the options to the options file.
    677         */
    678        public void saveOptions()
    679        {
    680            if (FMLClientHandler.instance().isLoading()) return;
    681            try
    682            {
    683                PrintWriter var1 = new PrintWriter(new FileWriter(this.optionsFile));
    684                var1.println("music:" + this.musicVolume);
    685                var1.println("sound:" + this.soundVolume);
    686                var1.println("invertYMouse:" + this.invertMouse);
    687                var1.println("mouseSensitivity:" + this.mouseSensitivity);
    688                var1.println("fov:" + this.fovSetting);
    689                var1.println("gamma:" + this.gammaSetting);
    690                var1.println("viewDistance:" + this.renderDistance);
    691                var1.println("guiScale:" + this.guiScale);
    692                var1.println("particles:" + this.particleSetting);
    693                var1.println("bobView:" + this.viewBobbing);
    694                var1.println("anaglyph3d:" + this.anaglyph);
    695                var1.println("advancedOpengl:" + this.advancedOpengl);
    696                var1.println("fpsLimit:" + this.limitFramerate);
    697                var1.println("difficulty:" + this.difficulty);
    698                var1.println("fancyGraphics:" + this.fancyGraphics);
    699                var1.println("ao:" + this.ambientOcclusion);
    700                var1.println("clouds:" + this.clouds);
    701                var1.println("skin:" + this.skin);
    702                var1.println("lastServer:" + this.lastServer);
    703                var1.println("lang:" + this.language);
    704                var1.println("chatVisibility:" + this.chatVisibility);
    705                var1.println("chatColors:" + this.chatColours);
    706                var1.println("chatLinks:" + this.chatLinks);
    707                var1.println("chatLinksPrompt:" + this.chatLinksPrompt);
    708                var1.println("chatOpacity:" + this.chatOpacity);
    709                var1.println("serverTextures:" + this.serverTextures);
    710                var1.println("snooperEnabled:" + this.snooperEnabled);
    711                var1.println("fullscreen:" + this.fullScreen);
    712                var1.println("enableVsync:" + this.enableVsync);
    713                var1.println("hideServerAddress:" + this.hideServerAddress);
    714                var1.println("advancedItemTooltips:" + this.advancedItemTooltips);
    715                var1.println("pauseOnLostFocus:" + this.pauseOnLostFocus);
    716                var1.println("showCape:" + this.showCape);
    717                var1.println("touchscreen:" + this.field_85185_A);
    718
    719                for (int var2 = 0; var2 < this.keyBindings.length; ++var2)
    720                {
    721                    var1.println("key_" + this.keyBindings[var2].keyDescription + ":" + this.keyBindings[var2].keyCode);
    722                }
    723
    724                var1.close();
    725            }
    726            catch (Exception var3)
    727            {
    728                System.out.println("Failed to save options");
    729                var3.printStackTrace();
    730            }
    731
    732            this.sendSettingsToServer();
    733        }
    734
    735        /**
    736         * Send a client info packet with settings information to the server
    737         */
    738        public void sendSettingsToServer()
    739        {
    740            if (this.mc.thePlayer != null)
    741            {
    742                this.mc.thePlayer.sendQueue.addToSendQueue(new Packet204ClientInfo(this.language, this.renderDistance, this.chatVisibility, this.chatColours, this.difficulty, this.showCape));
    743            }
    744        }
    745
    746        /**
    747         * Should render clouds
    748         */
    749        public boolean shouldRenderClouds()
    750        {
    751            return this.renderDistance < 2 && this.clouds;
    752        }
    753    }