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