    001    package net.minecraft.client;
    002
    003    import cpw.mods.fml.client.FMLClientHandler;
    004    import cpw.mods.fml.common.FMLCommonHandler;
    005    import cpw.mods.fml.common.Side;
    006    import cpw.mods.fml.common.asm.SideOnly;
    007    import cpw.mods.fml.common.registry.GameData;
    008    import cpw.mods.fml.common.registry.GameRegistry;
    009    import cpw.mods.fml.common.registry.ItemData;
    010    import cpw.mods.fml.relauncher.ArgsWrapper;
    011    import cpw.mods.fml.relauncher.FMLRelauncher;
    012
    013    import java.awt.BorderLayout;
    014    import java.awt.Canvas;
    015    import java.awt.Color;
    016    import java.awt.Component;
    017    import java.awt.Dimension;
    018    import java.awt.Frame;
    019    import java.awt.Graphics;
    020    import java.io.File;
    021    import java.io.IOException;
    022    import java.nio.ByteBuffer;
    023    import java.text.DecimalFormat;
    024    import java.util.HashMap;
    025    import java.util.List;
    026    import javax.swing.JPanel;
    027    import net.minecraft.block.Block;
    028    import net.minecraft.client.audio.SoundManager;
    029    import net.minecraft.client.entity.EntityClientPlayerMP;
    030    import net.minecraft.client.gui.FontRenderer;
    031    import net.minecraft.client.gui.GuiChat;
    032    import net.minecraft.client.gui.GuiErrorScreen;
    033    import net.minecraft.client.gui.GuiGameOver;
    034    import net.minecraft.client.gui.GuiIngame;
    035    import net.minecraft.client.gui.GuiIngameMenu;
    036    import net.minecraft.client.gui.GuiMainMenu;
    037    import net.minecraft.client.gui.GuiMemoryErrorScreen;
    038    import net.minecraft.client.gui.GuiScreen;
    039    import net.minecraft.client.gui.GuiSleepMP;
    040    import net.minecraft.client.gui.LoadingScreenRenderer;
    041    import net.minecraft.client.gui.ScaledResolution;
    042    import net.minecraft.client.gui.achievement.GuiAchievement;
    043    import net.minecraft.client.gui.inventory.GuiInventory;
    044    import net.minecraft.client.multiplayer.GuiConnecting;
    045    import net.minecraft.client.multiplayer.NetClientHandler;
    046    import net.minecraft.client.multiplayer.PlayerControllerMP;
    047    import net.minecraft.client.multiplayer.ServerData;
    048    import net.minecraft.client.multiplayer.WorldClient;
    049    import net.minecraft.client.particle.EffectRenderer;
    050    import net.minecraft.client.renderer.CallableParticleScreenName;
    051    import net.minecraft.client.renderer.EntityRenderer;
    052    import net.minecraft.client.renderer.GLAllocation;
    053    import net.minecraft.client.renderer.ItemRenderer;
    054    import net.minecraft.client.renderer.OpenGlHelper;
    055    import net.minecraft.client.renderer.RenderBlocks;
    056    import net.minecraft.client.renderer.RenderEngine;
    057    import net.minecraft.client.renderer.RenderGlobal;
    058    import net.minecraft.client.renderer.Tessellator;
    059    import net.minecraft.client.renderer.WorldRenderer;
    060    import net.minecraft.client.renderer.entity.RenderManager;
    061    import net.minecraft.client.renderer.texturefx.TextureCompassFX;
    062    import net.minecraft.client.renderer.texturefx.TextureFlamesFX;
    063    import net.minecraft.client.renderer.texturefx.TextureLavaFX;
    064    import net.minecraft.client.renderer.texturefx.TextureLavaFlowFX;
    065    import net.minecraft.client.renderer.texturefx.TexturePortalFX;
    066    import net.minecraft.client.renderer.texturefx.TextureWatchFX;
    067    import net.minecraft.client.renderer.texturefx.TextureWaterFX;
    068    import net.minecraft.client.renderer.texturefx.TextureWaterFlowFX;
    069    import net.minecraft.client.settings.EnumOptions;
    070    import net.minecraft.client.settings.GameSettings;
    071    import net.minecraft.client.settings.KeyBinding;
    072    import net.minecraft.client.texturepacks.TexturePackList;
    073    import net.minecraft.crash.CrashReport;
    074    import net.minecraft.crash.CrashReportCategory;
    075    import net.minecraft.entity.EntityList;
    076    import net.minecraft.entity.EntityLiving;
    077    import net.minecraft.entity.item.EntityBoat;
    078    import net.minecraft.entity.item.EntityItemFrame;
    079    import net.minecraft.entity.item.EntityMinecart;
    080    import net.minecraft.entity.item.EntityPainting;
    081    import net.minecraft.item.Item;
    082    import net.minecraft.item.ItemStack;
    083    import net.minecraft.network.INetworkManager;
    084    import net.minecraft.network.MemoryConnection;
    085    import net.minecraft.network.packet.Packet3Chat;
    086    import net.minecraft.profiler.IPlayerUsage;
    087    import net.minecraft.profiler.PlayerUsageSnooper;
    088    import net.minecraft.profiler.Profiler;
    089    import net.minecraft.profiler.ProfilerResult;
    090    import net.minecraft.server.integrated.IntegratedServer;
    091    import net.minecraft.stats.AchievementList;
    092    import net.minecraft.stats.StatFileWriter;
    093    import net.minecraft.stats.StatList;
    094    import net.minecraft.util.AxisAlignedBB;
    095    import net.minecraft.util.EnumMovingObjectType;
    096    import net.minecraft.util.EnumOS;
    097    import net.minecraft.util.HttpUtil;
    098    import net.minecraft.util.MathHelper;
    099    import net.minecraft.util.MinecraftError;
    100    import net.minecraft.util.MouseHelper;
    101    import net.minecraft.util.MovementInputFromOptions;
    102    import net.minecraft.util.MovingObjectPosition;
    103    import net.minecraft.util.ReportedException;
    104    import net.minecraft.util.ScreenShotHelper;
    105    import net.minecraft.util.Session;
    106    import net.minecraft.util.StatCollector;
    107    import net.minecraft.util.StringTranslate;
    108    import net.minecraft.util.ThreadDownloadResources;
    109    import net.minecraft.util.Timer;
    110    import net.minecraft.world.ColorizerFoliage;
    111    import net.minecraft.world.ColorizerGrass;
    112    import net.minecraft.world.ColorizerWater;
    113    import net.minecraft.world.WorldSettings;
    114    import net.minecraft.world.chunk.storage.AnvilSaveConverter;
    115    import net.minecraft.world.storage.ISaveFormat;
    116    import net.minecraft.world.storage.ISaveHandler;
    117    import net.minecraft.world.storage.WorldInfo;
    118    import org.lwjgl.LWJGLException;
    119    import org.lwjgl.Sys;
    120    import org.lwjgl.input.Keyboard;
    121    import org.lwjgl.input.Mouse;
    122    import org.lwjgl.opengl.ContextCapabilities;
    123    import org.lwjgl.opengl.Display;
    124    import org.lwjgl.opengl.DisplayMode;
    125    import org.lwjgl.opengl.GL11;
    126    import org.lwjgl.opengl.GL20;
    127    import org.lwjgl.opengl.GLContext;
    128    import org.lwjgl.opengl.PixelFormat;
    129    import org.lwjgl.util.glu.GLU;
    130
    131    import com.google.common.collect.MapDifference;
    132
    133    import net.minecraftforge.common.ForgeHooks;
    134    import net.minecraftforge.event.ForgeEventFactory;
    135    import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action;
    136
    137    @SideOnly(Side.CLIENT)
    138    public abstract class Minecraft implements Runnable, IPlayerUsage
    139    {
    140        /** A 10MiB preallocation to ensure the heap is reasonably sized. */
    141        public static byte[] memoryReserve = new byte[10485760];
    142        private ServerData currentServerData;
    143
    144        /**
    145         * Set to 'this' in Minecraft constructor; used by some settings get methods
    146         */
    147        private static Minecraft theMinecraft;
    148        public PlayerControllerMP playerController;
    149        private boolean fullscreen = false;
    150        private boolean hasCrashed = false;
    151
    152        /** Instance of CrashReport. */
    153        private CrashReport crashReporter;
    154        public int displayWidth;
    155        public int displayHeight;
    156        private Timer timer = new Timer(20.0F);
    157
    158        /** Instance of PlayerUsageSnooper. */
    159        private PlayerUsageSnooper usageSnooper = new PlayerUsageSnooper("client", this);
    160        public WorldClient theWorld;
    161        public RenderGlobal renderGlobal;
    162        public EntityClientPlayerMP thePlayer;
    163
    164        /**
    165         * The Entity from which the renderer determines the render viewpoint. Currently is always the parent Minecraft
    166         * class's 'thePlayer' instance. Modification of its location, rotation, or other settings at render time will
    167         * modify the camera likewise, with the caveat of triggering chunk rebuilds as it moves, making it unsuitable for
    168         * changing the viewpoint mid-render.
    169         */
    170        public EntityLiving renderViewEntity;
    171        public EffectRenderer effectRenderer;
    172        public Session session = null;
    173        public String minecraftUri;
    174        public Canvas mcCanvas;
    175
    176        /** a boolean to hide a Quit button from the main menu */
    177        public boolean hideQuitButton = false;
    178        public volatile boolean isGamePaused = false;
    179
    180        /** The RenderEngine instance used by Minecraft */
    181        public RenderEngine renderEngine;
    182
    183        /** The font renderer used for displaying and measuring text. */
    184        public FontRenderer fontRenderer;
    185        public FontRenderer standardGalacticFontRenderer;
    186
    187        /** The GuiScreen that's being displayed at the moment. */
    188        public GuiScreen currentScreen = null;
    189        public LoadingScreenRenderer loadingScreen;
    190        public EntityRenderer entityRenderer;
    191
    192        /** Reference to the download resources thread. */
    193        private ThreadDownloadResources downloadResourcesThread;
    194
    195        /** Mouse left click counter */
    196        private int leftClickCounter = 0;
    197
    198        /** Display width */
    199        private int tempDisplayWidth;
    200
    201        /** Display height */
    202        private int tempDisplayHeight;
    203
    204        /** Instance of IntegratedServer. */
    205        private IntegratedServer theIntegratedServer;
    206
    207        /** Gui achievement */
    208        public GuiAchievement guiAchievement = new GuiAchievement(this);
    209        public GuiIngame ingameGUI;
    210
    211        /** Skip render world */
    212        public boolean skipRenderWorld = false;
    213
    214        /** The ray trace hit that the mouse is over. */
    215        public MovingObjectPosition objectMouseOver = null;
    216
    217        /** The game settings that currently hold effect. */
    218        public GameSettings gameSettings;
    219        protected MinecraftApplet mcApplet;
    220        public SoundManager sndManager = new SoundManager();
    221
    222        /** Mouse helper instance. */
    223        public MouseHelper mouseHelper;
    224
    225        /** The TexturePackLister used by this instance of Minecraft... */
    226        public TexturePackList texturePackList;
    227        public File mcDataDir;
    228        private ISaveFormat saveLoader;
    229
    230        /**
    231         * This is set to fpsCounter every debug screen update, and is shown on the debug screen. It's also sent as part of
    232         * the usage snooping.
    233         */
    234        private static int debugFPS;
    235
    236        /**
    237         * When you place a block, it's set to 6, decremented once per tick, when it's 0, you can place another block.
    238         */
    239        private int rightClickDelayTimer = 0;
    240
    241        /**
    242         * Checked in Minecraft's while(running) loop, if true it's set to false and the textures refreshed.
    243         */
    244        private boolean refreshTexturePacksScheduled;
    245
    246        /** Stat file writer */
    247        public StatFileWriter statFileWriter;
    248        private String serverName;
    249        private int serverPort;
    250        private TextureWaterFX textureWaterFX = new TextureWaterFX();
    251        private TextureLavaFX textureLavaFX = new TextureLavaFX();
    252
    253        /**
    254         * Makes sure it doesn't keep taking screenshots when both buttons are down.
    255         */
    256        boolean isTakingScreenshot = false;
    257
    258        /**
    259         * Does the actual gameplay have focus. If so then mouse and keys will effect the player instead of menus.
    260         */
    261        public boolean inGameHasFocus = false;
    262        long systemTime = getSystemTime();
    263
    264        /** Join player counter */
    265        private int joinPlayerCounter = 0;
    266        private boolean isDemo;
    267        private INetworkManager myNetworkManager;
    268        private boolean integratedServerIsRunning;
    269
    270        /** The profiler instance */
    271        public final Profiler mcProfiler = new Profiler();
    272        private long field_83002_am = -1L;
    273
    274        /** The working dir (OS specific) for minecraft */
    275        private static File minecraftDir = null;
    276
    277        /**
    278         * Set to true to keep the game loop running. Set to false by shutdown() to allow the game loop to exit cleanly.
    279         */
    280        public volatile boolean running = true;
    281
    282        /** String that shows the debug information */
    283        public String debug = "";
    284
    285        /** Approximate time (in ms) of last update to debug string */
    286        long debugUpdateTime = getSystemTime();
    287
    288        /** holds the current fps */
    289        int fpsCounter = 0;
    290        long prevFrameTime = -1L;
    291
    292        /** Profiler currently displayed in the debug screen pie chart */
    293        private String debugProfilerName = "root";
    294
    295        public Minecraft(Canvas par1Canvas, MinecraftApplet par2MinecraftApplet, int par3, int par4, boolean par5)
    296        {
    297            StatList.nopInit();
    298            this.tempDisplayHeight = par4;
    299            this.fullscreen = par5;
    300            this.mcApplet = par2MinecraftApplet;
    301            Packet3Chat.maxChatLength = 32767;
    302            this.startTimerHackThread();
    303            this.mcCanvas = par1Canvas;
    304            this.displayWidth = par3;
    305            this.displayHeight = par4;
    306            this.fullscreen = par5;
    307            theMinecraft = this;
    308        }
    309
    310        private void startTimerHackThread()
    311        {
    312            ThreadClientSleep var1 = new ThreadClientSleep(this, "Timer hack thread");
    313            var1.setDaemon(true);
    314            var1.start();
    315        }
    316
    317        public void crashed(CrashReport par1CrashReport)
    318        {
    319            this.hasCrashed = true;
    320            this.crashReporter = par1CrashReport;
    321        }
    322
    323        /**
    324         * Wrapper around displayCrashReportInternal
    325         */
    326        public void displayCrashReport(CrashReport par1CrashReport)
    327        {
    328            this.hasCrashed = true;
    329            this.displayCrashReportInternal(par1CrashReport);
    330        }
    331
    332        public abstract void displayCrashReportInternal(CrashReport var1);
    333
    334        public void setServer(String par1Str, int par2)
    335        {
    336            this.serverName = par1Str;
    337            this.serverPort = par2;
    338        }
    339
    340        /**
    341         * Starts the game: initializes the canvas, the title, the settings, etcetera.
    342         */
    343        public void startGame() throws LWJGLException
    344        {
    345            if (this.mcCanvas != null)
    346            {
    347                Graphics var1 = this.mcCanvas.getGraphics();
    348
    349                if (var1 != null)
    350                {
    351                    var1.setColor(Color.BLACK);
    352                    var1.fillRect(0, 0, this.displayWidth, this.displayHeight);
    353                    var1.dispose();
    354                }
    355
    356                Display.setParent(this.mcCanvas);
    357            }
    358            else if (this.fullscreen)
    359            {
    360                Display.setFullscreen(true);
    361                this.displayWidth = Display.getDisplayMode().getWidth();
    362                this.displayHeight = Display.getDisplayMode().getHeight();
    363
    364                if (this.displayWidth <= 0)
    365                {
    366                    this.displayWidth = 1;
    367                }
    368
    369                if (this.displayHeight <= 0)
    370                {
    371                    this.displayHeight = 1;
    372                }
    373            }
    374            else
    375            {
    376                Display.setDisplayMode(new DisplayMode(this.displayWidth, this.displayHeight));
    377            }
    378
    379            Display.setTitle("Minecraft Minecraft 1.4.5");
    380            System.out.println("LWJGL Version: " + Sys.getVersion());
    381
    382            try
    383            {
    384                Display.create((new PixelFormat()).withDepthBits(24));
    385            }
    386            catch (LWJGLException var5)
    387            {
    388                var5.printStackTrace();
    389
    390                try
    391                {
    392                    Thread.sleep(1000L);
    393                }
    394                catch (InterruptedException var4)
    395                {
    396                    ;
    397                }
    398
    399                Display.create();
    400            }
    401
    402            OpenGlHelper.initializeTextures();
    403            this.mcDataDir = getMinecraftDir();
    404            this.saveLoader = new AnvilSaveConverter(new File(this.mcDataDir, "saves"));
    405            this.gameSettings = new GameSettings(this, this.mcDataDir);
    406            this.texturePackList = new TexturePackList(this.mcDataDir, this);
    407            this.renderEngine = new RenderEngine(this.texturePackList, this.gameSettings);
    408            this.loadScreen();
    409            this.fontRenderer = new FontRenderer(this.gameSettings, "/font/default.png", this.renderEngine, false);
    410            this.standardGalacticFontRenderer = new FontRenderer(this.gameSettings, "/font/alternate.png", this.renderEngine, false);
    411
    412            FMLClientHandler.instance().beginMinecraftLoading(this);
    413
    414            if (this.gameSettings.language != null)
    415            {
    416                StringTranslate.getInstance().setLanguage(this.gameSettings.language);
    417                this.fontRenderer.setUnicodeFlag(StringTranslate.getInstance().isUnicode());
    418                this.fontRenderer.setBidiFlag(StringTranslate.isBidirectional(this.gameSettings.language));
    419            }
    420
    421            ColorizerWater.setWaterBiomeColorizer(this.renderEngine.getTextureContents("/misc/watercolor.png"));
    422            ColorizerGrass.setGrassBiomeColorizer(this.renderEngine.getTextureContents("/misc/grasscolor.png"));
    423            ColorizerFoliage.setFoliageBiomeColorizer(this.renderEngine.getTextureContents("/misc/foliagecolor.png"));
    424            this.entityRenderer = new EntityRenderer(this);
    425            RenderManager.instance.itemRenderer = new ItemRenderer(this);
    426            this.statFileWriter = new StatFileWriter(this.session, this.mcDataDir);
    427            AchievementList.openInventory.setStatStringFormatter(new StatStringFormatKeyInv(this));
    428            this.loadScreen();
    429            Mouse.create();
    430            this.mouseHelper = new MouseHelper(this.mcCanvas, this.gameSettings);
    431            this.checkGLError("Pre startup");
    432            GL11.glEnable(GL11.GL_TEXTURE_2D);
    433            GL11.glShadeModel(GL11.GL_SMOOTH);
    434            GL11.glClearDepth(1.0D);
    435            GL11.glEnable(GL11.GL_DEPTH_TEST);
    436            GL11.glDepthFunc(GL11.GL_LEQUAL);
    437            GL11.glEnable(GL11.GL_ALPHA_TEST);
    438            GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
    439            GL11.glCullFace(GL11.GL_BACK);
    440            GL11.glMatrixMode(GL11.GL_PROJECTION);
    441            GL11.glLoadIdentity();
    442            GL11.glMatrixMode(GL11.GL_MODELVIEW);
    443            this.checkGLError("Startup");
    444            this.sndManager.loadSoundSettings(this.gameSettings);
    445            this.renderEngine.registerTextureFX(this.textureLavaFX);
    446            this.renderEngine.registerTextureFX(this.textureWaterFX);
    447            this.renderEngine.registerTextureFX(new TexturePortalFX());
    448            this.renderEngine.registerTextureFX(new TextureCompassFX(this));
    449            this.renderEngine.registerTextureFX(new TextureWatchFX(this));
    450            this.renderEngine.registerTextureFX(new TextureWaterFlowFX());
    451            this.renderEngine.registerTextureFX(new TextureLavaFlowFX());
    452            this.renderEngine.registerTextureFX(new TextureFlamesFX(0));
    453            this.renderEngine.registerTextureFX(new TextureFlamesFX(1));
    454            this.renderGlobal = new RenderGlobal(this, this.renderEngine);
    455            GL11.glViewport(0, 0, this.displayWidth, this.displayHeight);
    456            this.effectRenderer = new EffectRenderer(this.theWorld, this.renderEngine);
    457
    458            FMLClientHandler.instance().finishMinecraftLoading();
    459
    460            try
    461            {
    462                this.downloadResourcesThread = new ThreadDownloadResources(this.mcDataDir, this);
    463                this.downloadResourcesThread.start();
    464            }
    465            catch (Exception var3)
    466            {
    467                ;
    468            }
    469
    470            this.checkGLError("Post startup");
    471            this.ingameGUI = new GuiIngame(this);
    472
    473            if (this.serverName != null)
    474            {
    475                this.displayGuiScreen(new GuiConnecting(this, this.serverName, this.serverPort));
    476            }
    477            else
    478            {
    479                this.displayGuiScreen(new GuiMainMenu());
    480            }
    481
    482            this.loadingScreen = new LoadingScreenRenderer(this);
    483
    484            if (this.gameSettings.fullScreen && !this.fullscreen)
    485            {
    486                this.toggleFullscreen();
    487            }
    488
    489            FMLClientHandler.instance().onInitializationComplete();
    490        }
    491
    492        /**
    493         * Displays a new screen.
    494         */
    495        private void loadScreen() throws LWJGLException
    496        {
    497            ScaledResolution var1 = new ScaledResolution(this.gameSettings, this.displayWidth, this.displayHeight);
    498            GL11.glClear(16640);
    499            GL11.glMatrixMode(GL11.GL_PROJECTION);
    500            GL11.glLoadIdentity();
    501            GL11.glOrtho(0.0D, var1.getScaledWidth_double(), var1.getScaledHeight_double(), 0.0D, 1000.0D, 3000.0D);
    502            GL11.glMatrixMode(GL11.GL_MODELVIEW);
    503            GL11.glLoadIdentity();
    504            GL11.glTranslatef(0.0F, 0.0F, -2000.0F);
    505            GL11.glViewport(0, 0, this.displayWidth, this.displayHeight);
    506            GL11.glClearColor(0.0F, 0.0F, 0.0F, 0.0F);
    507            GL11.glDisable(GL11.GL_LIGHTING);
    508            GL11.glEnable(GL11.GL_TEXTURE_2D);
    509            GL11.glDisable(GL11.GL_FOG);
    510            Tessellator var2 = Tessellator.instance;
    511            GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.renderEngine.getTexture("/title/mojang.png"));
    512            var2.startDrawingQuads();
    513            var2.setColorOpaque_I(16777215);
    514            var2.addVertexWithUV(0.0D, (double)this.displayHeight, 0.0D, 0.0D, 0.0D);
    515            var2.addVertexWithUV((double)this.displayWidth, (double)this.displayHeight, 0.0D, 0.0D, 0.0D);
    516            var2.addVertexWithUV((double)this.displayWidth, 0.0D, 0.0D, 0.0D, 0.0D);
    517            var2.addVertexWithUV(0.0D, 0.0D, 0.0D, 0.0D, 0.0D);
    518            var2.draw();
    519            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    520            var2.setColorOpaque_I(16777215);
    521            short var3 = 256;
    522            short var4 = 256;
    523            this.scaledTessellator((var1.getScaledWidth() - var3) / 2, (var1.getScaledHeight() - var4) / 2, 0, 0, var3, var4);
    524            GL11.glDisable(GL11.GL_LIGHTING);
    525            GL11.glDisable(GL11.GL_FOG);
    526            GL11.glEnable(GL11.GL_ALPHA_TEST);
    527            GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
    528            Display.swapBuffers();
    529        }
    530
    531        /**
    532         * Loads Tessellator with a scaled resolution
    533         */
    534        public void scaledTessellator(int par1, int par2, int par3, int par4, int par5, int par6)
    535        {
    536            float var7 = 0.00390625F;
    537            float var8 = 0.00390625F;
    538            Tessellator var9 = Tessellator.instance;
    539            var9.startDrawingQuads();
    540            var9.addVertexWithUV((double)(par1 + 0), (double)(par2 + par6), 0.0D, (double)((float)(par3 + 0) * var7), (double)((float)(par4 + par6) * var8));
    541            var9.addVertexWithUV((double)(par1 + par5), (double)(par2 + par6), 0.0D, (double)((float)(par3 + par5) * var7), (double)((float)(par4 + par6) * var8));
    542            var9.addVertexWithUV((double)(par1 + par5), (double)(par2 + 0), 0.0D, (double)((float)(par3 + par5) * var7), (double)((float)(par4 + 0) * var8));
    543            var9.addVertexWithUV((double)(par1 + 0), (double)(par2 + 0), 0.0D, (double)((float)(par3 + 0) * var7), (double)((float)(par4 + 0) * var8));
    544            var9.draw();
    545        }
    546
    547        /**
    548         * gets the working dir (OS specific) for minecraft
    549         */
    550        public static File getMinecraftDir()
    551        {
    552            if (minecraftDir == null)
    553            {
    554                minecraftDir = getAppDir("minecraft");
    555            }
    556
    557            return minecraftDir;
    558        }
    559
    560        /**
    561         * gets the working dir (OS specific) for the specific application (which is always minecraft)
    562         */
    563        public static File getAppDir(String par0Str)
    564        {
    565            String var1 = System.getProperty("user.home", ".");
    566            File var2;
    567
    568            switch (EnumOSHelper.field_90049_a[getOs().ordinal()])
    569            {
    570                case 1:
    571                case 2:
    572                    var2 = new File(var1, '.' + par0Str + '/');
    573                    break;
    574                case 3:
    575                    String var3 = System.getenv("APPDATA");
    576
    577                    if (var3 != null)
    578                    {
    579                        var2 = new File(var3, "." + par0Str + '/');
    580                    }
    581                    else
    582                    {
    583                        var2 = new File(var1, '.' + par0Str + '/');
    584                    }
    585
    586                    break;
    587                case 4:
    588                    var2 = new File(var1, "Library/Application Support/" + par0Str);
    589                    break;
    590                default:
    591                    var2 = new File(var1, par0Str + '/');
    592            }
    593
    594            if (!var2.exists() && !var2.mkdirs())
    595            {
    596                throw new RuntimeException("The working directory could not be created: " + var2);
    597            }
    598            else
    599            {
    600                return var2;
    601            }
    602        }
    603
    604        public static EnumOS getOs()
    605        {
    606            String var0 = System.getProperty("os.name").toLowerCase();
    607            return var0.contains("win") ? EnumOS.WINDOWS : (var0.contains("mac") ? EnumOS.MACOS : (var0.contains("solaris") ? EnumOS.SOLARIS : (var0.contains("sunos") ? EnumOS.SOLARIS : (var0.contains("linux") ? EnumOS.LINUX : (var0.contains("unix") ? EnumOS.LINUX : EnumOS.UNKNOWN)))));
    608        }
    609
    610        /**
    611         * Returns the save loader that is currently being used
    612         */
    613        public ISaveFormat getSaveLoader()
    614        {
    615            return this.saveLoader;
    616        }
    617
    618        /**
    619         * Sets the argument GuiScreen as the main (topmost visible) screen.
    620         */
    621        public void displayGuiScreen(GuiScreen par1GuiScreen)
    622        {
    623            if (!(this.currentScreen instanceof GuiErrorScreen))
    624            {
    625                if (this.currentScreen != null)
    626                {
    627                    this.currentScreen.onGuiClosed();
    628                }
    629
    630                this.statFileWriter.syncStats();
    631
    632                if (par1GuiScreen == null && this.theWorld == null)
    633                {
    634                    par1GuiScreen = new GuiMainMenu();
    635                }
    636                else if (par1GuiScreen == null && this.thePlayer.getHealth() <= 0)
    637                {
    638                    par1GuiScreen = new GuiGameOver();
    639                }
    640
    641                if (par1GuiScreen instanceof GuiMainMenu)
    642                {
    643                    this.gameSettings.showDebugInfo = false;
    644                    this.ingameGUI.getChatGUI().func_73761_a();
    645                }
    646
    647                this.currentScreen = (GuiScreen)par1GuiScreen;
    648
    649                if (par1GuiScreen != null)
    650                {
    651                    this.setIngameNotInFocus();
    652                    ScaledResolution var2 = new ScaledResolution(this.gameSettings, this.displayWidth, this.displayHeight);
    653                    int var3 = var2.getScaledWidth();
    654                    int var4 = var2.getScaledHeight();
    655                    ((GuiScreen)par1GuiScreen).setWorldAndResolution(this, var3, var4);
    656                    this.skipRenderWorld = false;
    657                }
    658                else
    659                {
    660                    this.setIngameFocus();
    661                }
    662            }
    663        }
    664
    665        /**
    666         * Checks for an OpenGL error. If there is one, prints the error ID and error string.
    667         */
    668        private void checkGLError(String par1Str)
    669        {
    670            int var2 = GL11.glGetError();
    671
    672            if (var2 != 0)
    673            {
    674                String var3 = GLU.gluErrorString(var2);
    675                System.out.println("########## GL ERROR ##########");
    676                System.out.println("@ " + par1Str);
    677                System.out.println(var2 + ": " + var3);
    678            }
    679        }
    680
    681        /**
    682         * Shuts down the minecraft applet by stopping the resource downloads, and clearing up GL stuff; called when the
    683         * application (or web page) is exited.
    684         */
    685        public void shutdownMinecraftApplet()
    686        {
    687            try
    688            {
    689                this.statFileWriter.syncStats();
    690
    691                try
    692                {
    693                    if (this.downloadResourcesThread != null)
    694                    {
    695                        this.downloadResourcesThread.closeMinecraft();
    696                    }
    697                }
    698                catch (Exception var9)
    699                {
    700                    ;
    701                }
    702
    703                System.out.println("Stopping!");
    704
    705                try
    706                {
    707                    this.loadWorld((WorldClient)null);
    708                }
    709                catch (Throwable var8)
    710                {
    711                    ;
    712                }
    713
    714                try
    715                {
    716                    GLAllocation.deleteTexturesAndDisplayLists();
    717                }
    718                catch (Throwable var7)
    719                {
    720                    ;
    721                }
    722
    723                this.sndManager.closeMinecraft();
    724                Mouse.destroy();
    725                Keyboard.destroy();
    726            }
    727            finally
    728            {
    729                Display.destroy();
    730
    731                if (!this.hasCrashed)
    732                {
    733                    System.exit(0);
    734                }
    735            }
    736
    737            System.gc();
    738        }
    739
    740        public void run()
    741        {
    742            this.running = true;
    743
    744            try
    745            {
    746                this.startGame();
    747            }
    748            catch (Exception var11)
    749            {
    750                var11.printStackTrace();
    751                this.displayCrashReport(this.addGraphicsAndWorldToCrashReport(new CrashReport("Failed to start game", var11)));
    752                return;
    753            }
    754
    755            try
    756            {
    757                while (this.running)
    758                {
    759                    if (this.hasCrashed && this.crashReporter != null)
    760                    {
    761                        this.displayCrashReport(this.crashReporter);
    762                        return;
    763                    }
    764
    765                    if (this.refreshTexturePacksScheduled)
    766                    {
    767                        this.refreshTexturePacksScheduled = false;
    768                        this.renderEngine.refreshTextures();
    769                    }
    770
    771                    try
    772                    {
    773                        this.runGameLoop();
    774                    }
    775                    catch (OutOfMemoryError var10)
    776                    {
    777                        this.freeMemory();
    778                        this.displayGuiScreen(new GuiMemoryErrorScreen());
    779                        System.gc();
    780                    }
    781                }
    782            }
    783            catch (MinecraftError var12)
    784            {
    785                ;
    786            }
    787            catch (ReportedException var13)
    788            {
    789                this.addGraphicsAndWorldToCrashReport(var13.getCrashReport());
    790                this.freeMemory();
    791                var13.printStackTrace();
    792                this.displayCrashReport(var13.getCrashReport());
    793            }
    794            catch (Throwable var14)
    795            {
    796                CrashReport var2 = this.addGraphicsAndWorldToCrashReport(new CrashReport("Unexpected error", var14));
    797                this.freeMemory();
    798                var14.printStackTrace();
    799                this.displayCrashReport(var2);
    800            }
    801            finally
    802            {
    803                this.shutdownMinecraftApplet();
    804            }
    805        }
    806
    807        /**
    808         * Called repeatedly from run()
    809         */
    810        private void runGameLoop()
    811        {
    812            if (this.mcApplet != null && !this.mcApplet.isActive())
    813            {
    814                this.running = false;
    815            }
    816            else
    817            {
    818                AxisAlignedBB.getAABBPool().cleanPool();
    819
    820                if (this.theWorld != null)
    821                {
    822                    this.theWorld.getWorldVec3Pool().clear();
    823                }
    824
    825                this.mcProfiler.startSection("root");
    826
    827                if (this.mcCanvas == null && Display.isCloseRequested())
    828                {
    829                    this.shutdown();
    830                }
    831
    832                if (this.isGamePaused && this.theWorld != null)
    833                {
    834                    float var1 = this.timer.renderPartialTicks;
    835                    this.timer.updateTimer();
    836                    this.timer.renderPartialTicks = var1;
    837                }
    838                else
    839                {
    840                    this.timer.updateTimer();
    841                }
    842
    843                long var6 = System.nanoTime();
    844                this.mcProfiler.startSection("tick");
    845
    846                for (int var3 = 0; var3 < this.timer.elapsedTicks; ++var3)
    847                {
    848                    this.runTick();
    849                }
    850
    851                this.mcProfiler.endStartSection("preRenderErrors");
    852                long var7 = System.nanoTime() - var6;
    853                this.checkGLError("Pre render");
    854                RenderBlocks.fancyGrass = this.gameSettings.fancyGraphics;
    855                this.mcProfiler.endStartSection("sound");
    856                this.sndManager.setListener(this.thePlayer, this.timer.renderPartialTicks);
    857                this.mcProfiler.endSection();
    858                this.mcProfiler.startSection("render");
    859                this.mcProfiler.startSection("display");
    860                GL11.glEnable(GL11.GL_TEXTURE_2D);
    861
    862                if (!Keyboard.isKeyDown(65))
    863                {
    864                    Display.update();
    865                }
    866
    867                if (this.thePlayer != null && this.thePlayer.isEntityInsideOpaqueBlock())
    868                {
    869                    this.gameSettings.thirdPersonView = 0;
    870                }
    871
    872                this.mcProfiler.endSection();
    873
    874                if (!this.skipRenderWorld)
    875                {
    876                    FMLCommonHandler.instance().onRenderTickStart(this.timer.renderPartialTicks);
    877                    this.mcProfiler.endStartSection("gameRenderer");
    878                    this.entityRenderer.updateCameraAndRender(this.timer.renderPartialTicks);
    879                    this.mcProfiler.endSection();
    880                    FMLCommonHandler.instance().onRenderTickEnd(this.timer.renderPartialTicks);
    881                }
    882
    883                GL11.glFlush();
    884                this.mcProfiler.endSection();
    885
    886                if (!Display.isActive() && this.fullscreen)
    887                {
    888                    this.toggleFullscreen();
    889                }
    890
    891                if (this.gameSettings.showDebugInfo && this.gameSettings.showDebugProfilerChart)
    892                {
    893                    if (!this.mcProfiler.profilingEnabled)
    894                    {
    895                        this.mcProfiler.clearProfiling();
    896                    }
    897
    898                    this.mcProfiler.profilingEnabled = true;
    899                    this.displayDebugInfo(var7);
    900                }
    901                else
    902                {
    903                    this.mcProfiler.profilingEnabled = false;
    904                    this.prevFrameTime = System.nanoTime();
    905                }
    906
    907                this.guiAchievement.updateAchievementWindow();
    908                this.mcProfiler.startSection("root");
    909                Thread.yield();
    910
    911                if (Keyboard.isKeyDown(65))
    912                {
    913                    Display.update();
    914                }
    915
    916                this.screenshotListener();
    917
    918                if (this.mcCanvas != null && !this.fullscreen && (this.mcCanvas.getWidth() != this.displayWidth || this.mcCanvas.getHeight() != this.displayHeight))
    919                {
    920                    this.displayWidth = this.mcCanvas.getWidth();
    921                    this.displayHeight = this.mcCanvas.getHeight();
    922
    923                    if (this.displayWidth <= 0)
    924                    {
    925                        this.displayWidth = 1;
    926                    }
    927
    928                    if (this.displayHeight <= 0)
    929                    {
    930                        this.displayHeight = 1;
    931                    }
    932
    933                    this.resize(this.displayWidth, this.displayHeight);
    934                }
    935
    936                this.checkGLError("Post render");
    937                ++this.fpsCounter;
    938                boolean var5 = this.isGamePaused;
    939                this.isGamePaused = this.isSingleplayer() && this.currentScreen != null && this.currentScreen.doesGuiPauseGame() && !this.theIntegratedServer.getPublic();
    940
    941                if (this.isIntegratedServerRunning() && this.thePlayer != null && this.thePlayer.sendQueue != null && this.isGamePaused != var5)
    942                {
    943                    ((MemoryConnection)this.thePlayer.sendQueue.getNetManager()).setGamePaused(this.isGamePaused);
    944                }
    945
    946                while (getSystemTime() >= this.debugUpdateTime + 1000L)
    947                {
    948                    debugFPS = this.fpsCounter;
    949                    this.debug = debugFPS + " fps, " + WorldRenderer.chunksUpdated + " chunk updates";
    950                    WorldRenderer.chunksUpdated = 0;
    951                    this.debugUpdateTime += 1000L;
    952                    this.fpsCounter = 0;
    953                    this.usageSnooper.addMemoryStatsToSnooper();
    954
    955                    if (!this.usageSnooper.isSnooperRunning())
    956                    {
    957                        this.usageSnooper.startSnooper();
    958                    }
    959                }
    960
    961                this.mcProfiler.endSection();
    962
    963                if (this.func_90020_K() > 0)
    964                {
    965                    Display.sync(EntityRenderer.func_78465_a(this.func_90020_K()));
    966                }
    967            }
    968        }
    969
    970        private int func_90020_K()
    971        {
    972            return this.currentScreen != null && this.currentScreen instanceof GuiMainMenu ? 2 : this.gameSettings.limitFramerate;
    973        }
    974
    975        public void freeMemory()
    976        {
    977            try
    978            {
    979                memoryReserve = new byte[0];
    980                this.renderGlobal.func_72728_f();
    981            }
    982            catch (Throwable var4)
    983            {
    984                ;
    985            }
    986
    987            try
    988            {
    989                System.gc();
    990                AxisAlignedBB.getAABBPool().clearPool();
    991                this.theWorld.getWorldVec3Pool().clearAndFreeCache();
    992            }
    993            catch (Throwable var3)
    994            {
    995                ;
    996            }
    997
    998            try
    999            {
    1000                System.gc();
    1001                this.loadWorld((WorldClient)null);
    1002            }
    1003            catch (Throwable var2)
    1004            {
    1005                ;
    1006            }
    1007
    1008            System.gc();
    1009        }
    1010
    1011        /**
    1012         * checks if keys are down
    1013         */
    1014        private void screenshotListener()
    1015        {
    1016            if (Keyboard.isKeyDown(60))
    1017            {
    1018                if (!this.isTakingScreenshot)
    1019                {
    1020                    this.isTakingScreenshot = true;
    1021                    this.ingameGUI.getChatGUI().printChatMessage(ScreenShotHelper.saveScreenshot(minecraftDir, this.displayWidth, this.displayHeight));
    1022                }
    1023            }
    1024            else
    1025            {
    1026                this.isTakingScreenshot = false;
    1027            }
    1028        }
    1029
    1030        /**
    1031         * Update debugProfilerName in response to number keys in debug screen
    1032         */
    1033        private void updateDebugProfilerName(int par1)
    1034        {
    1035            List var2 = this.mcProfiler.getProfilingData(this.debugProfilerName);
    1036
    1037            if (var2 != null && !var2.isEmpty())
    1038            {
    1039                ProfilerResult var3 = (ProfilerResult)var2.remove(0);
    1040
    1041                if (par1 == 0)
    1042                {
    1043                    if (var3.field_76331_c.length() > 0)
    1044                    {
    1045                        int var4 = this.debugProfilerName.lastIndexOf(".");
    1046
    1047                        if (var4 >= 0)
    1048                        {
    1049                            this.debugProfilerName = this.debugProfilerName.substring(0, var4);
    1050                        }
    1051                    }
    1052                }
    1053                else
    1054                {
    1055                    --par1;
    1056
    1057                    if (par1 < var2.size() && !((ProfilerResult)var2.get(par1)).field_76331_c.equals("unspecified"))
    1058                    {
    1059                        if (this.debugProfilerName.length() > 0)
    1060                        {
    1061                            this.debugProfilerName = this.debugProfilerName + ".";
    1062                        }
    1063
    1064                        this.debugProfilerName = this.debugProfilerName + ((ProfilerResult)var2.get(par1)).field_76331_c;
    1065                    }
    1066                }
    1067            }
    1068        }
    1069
    1070        private void displayDebugInfo(long par1)
    1071        {
    1072            if (this.mcProfiler.profilingEnabled)
    1073            {
    1074                List var3 = this.mcProfiler.getProfilingData(this.debugProfilerName);
    1075                ProfilerResult var4 = (ProfilerResult)var3.remove(0);
    1076                GL11.glClear(256);
    1077                GL11.glMatrixMode(GL11.GL_PROJECTION);
    1078                GL11.glEnable(GL11.GL_COLOR_MATERIAL);
    1079                GL11.glLoadIdentity();
    1080                GL11.glOrtho(0.0D, (double)this.displayWidth, (double)this.displayHeight, 0.0D, 1000.0D, 3000.0D);
    1081                GL11.glMatrixMode(GL11.GL_MODELVIEW);
    1082                GL11.glLoadIdentity();
    1083                GL11.glTranslatef(0.0F, 0.0F, -2000.0F);
    1084                GL11.glLineWidth(1.0F);
    1085                GL11.glDisable(GL11.GL_TEXTURE_2D);
    1086                Tessellator var5 = Tessellator.instance;
    1087                short var6 = 160;
    1088                int var7 = this.displayWidth - var6 - 10;
    1089                int var8 = this.displayHeight - var6 * 2;
    1090                GL11.glEnable(GL11.GL_BLEND);
    1091                var5.startDrawingQuads();
    1092                var5.setColorRGBA_I(0, 200);
    1093                var5.addVertex((double)((float)var7 - (float)var6 * 1.1F), (double)((float)var8 - (float)var6 * 0.6F - 16.0F), 0.0D);
    1094                var5.addVertex((double)((float)var7 - (float)var6 * 1.1F), (double)(var8 + var6 * 2), 0.0D);
    1095                var5.addVertex((double)((float)var7 + (float)var6 * 1.1F), (double)(var8 + var6 * 2), 0.0D);
    1096                var5.addVertex((double)((float)var7 + (float)var6 * 1.1F), (double)((float)var8 - (float)var6 * 0.6F - 16.0F), 0.0D);
    1097                var5.draw();
    1098                GL11.glDisable(GL11.GL_BLEND);
    1099                double var9 = 0.0D;
    1100                int var13;
    1101
    1102                for (int var11 = 0; var11 < var3.size(); ++var11)
    1103                {
    1104                    ProfilerResult var12 = (ProfilerResult)var3.get(var11);
    1105                    var13 = MathHelper.floor_double(var12.field_76332_a / 4.0D) + 1;
    1106                    var5.startDrawing(6);
    1107                    var5.setColorOpaque_I(var12.func_76329_a());
    1108                    var5.addVertex((double)var7, (double)var8, 0.0D);
    1109                    int var14;
    1110                    float var15;
    1111                    float var17;
    1112                    float var16;
    1113
    1114                    for (var14 = var13; var14 >= 0; --var14)
    1115                    {
    1116                        var15 = (float)((var9 + var12.field_76332_a * (double)var14 / (double)var13) * Math.PI * 2.0D / 100.0D);
    1117                        var16 = MathHelper.sin(var15) * (float)var6;
    1118                        var17 = MathHelper.cos(var15) * (float)var6 * 0.5F;
    1119                        var5.addVertex((double)((float)var7 + var16), (double)((float)var8 - var17), 0.0D);
    1120                    }
    1121
    1122                    var5.draw();
    1123                    var5.startDrawing(5);
    1124                    var5.setColorOpaque_I((var12.func_76329_a() & 16711422) >> 1);
    1125
    1126                    for (var14 = var13; var14 >= 0; --var14)
    1127                    {
    1128                        var15 = (float)((var9 + var12.field_76332_a * (double)var14 / (double)var13) * Math.PI * 2.0D / 100.0D);
    1129                        var16 = MathHelper.sin(var15) * (float)var6;
    1130                        var17 = MathHelper.cos(var15) * (float)var6 * 0.5F;
    1131                        var5.addVertex((double)((float)var7 + var16), (double)((float)var8 - var17), 0.0D);
    1132                        var5.addVertex((double)((float)var7 + var16), (double)((float)var8 - var17 + 10.0F), 0.0D);
    1133                    }
    1134
    1135                    var5.draw();
    1136                    var9 += var12.field_76332_a;
    1137                }
    1138
    1139                DecimalFormat var19 = new DecimalFormat("##0.00");
    1140                GL11.glEnable(GL11.GL_TEXTURE_2D);
    1141                String var18 = "";
    1142
    1143                if (!var4.field_76331_c.equals("unspecified"))
    1144                {
    1145                    var18 = var18 + "[0] ";
    1146                }
    1147
    1148                if (var4.field_76331_c.length() == 0)
    1149                {
    1150                    var18 = var18 + "ROOT ";
    1151                }
    1152                else
    1153                {
    1154                    var18 = var18 + var4.field_76331_c + " ";
    1155                }
    1156
    1157                var13 = 16777215;
    1158                this.fontRenderer.drawStringWithShadow(var18, var7 - var6, var8 - var6 / 2 - 16, var13);
    1159                this.fontRenderer.drawStringWithShadow(var18 = var19.format(var4.field_76330_b) + "%", var7 + var6 - this.fontRenderer.getStringWidth(var18), var8 - var6 / 2 - 16, var13);
    1160
    1161                for (int var21 = 0; var21 < var3.size(); ++var21)
    1162                {
    1163                    ProfilerResult var20 = (ProfilerResult)var3.get(var21);
    1164                    String var22 = "";
    1165
    1166                    if (var20.field_76331_c.equals("unspecified"))
    1167                    {
    1168                        var22 = var22 + "[?] ";
    1169                    }
    1170                    else
    1171                    {
    1172                        var22 = var22 + "[" + (var21 + 1) + "] ";
    1173                    }
    1174
    1175                    var22 = var22 + var20.field_76331_c;
    1176                    this.fontRenderer.drawStringWithShadow(var22, var7 - var6, var8 + var6 / 2 + var21 * 8 + 20, var20.func_76329_a());
    1177                    this.fontRenderer.drawStringWithShadow(var22 = var19.format(var20.field_76332_a) + "%", var7 + var6 - 50 - this.fontRenderer.getStringWidth(var22), var8 + var6 / 2 + var21 * 8 + 20, var20.func_76329_a());
    1178                    this.fontRenderer.drawStringWithShadow(var22 = var19.format(var20.field_76330_b) + "%", var7 + var6 - this.fontRenderer.getStringWidth(var22), var8 + var6 / 2 + var21 * 8 + 20, var20.func_76329_a());
    1179                }
    1180            }
    1181        }
    1182
    1183        /**
    1184         * Called when the window is closing. Sets 'running' to false which allows the game loop to exit cleanly.
    1185         */
    1186        public void shutdown()
    1187        {
    1188            this.running = false;
    1189        }
    1190
    1191        /**
    1192         * Will set the focus to ingame if the Minecraft window is the active with focus. Also clears any GUI screen
    1193         * currently displayed
    1194         */
    1195        public void setIngameFocus()
    1196        {
    1197            if (Display.isActive())
    1198            {
    1199                if (!this.inGameHasFocus)
    1200                {
    1201                    this.inGameHasFocus = true;
    1202                    this.mouseHelper.grabMouseCursor();
    1203                    this.displayGuiScreen((GuiScreen)null);
    1204                    this.leftClickCounter = 10000;
    1205                }
    1206            }
    1207        }
    1208
    1209        /**
    1210         * Resets the player keystate, disables the ingame focus, and ungrabs the mouse cursor.
    1211         */
    1212        public void setIngameNotInFocus()
    1213        {
    1214            if (this.inGameHasFocus)
    1215            {
    1216                KeyBinding.unPressAllKeys();
    1217                this.inGameHasFocus = false;
    1218                this.mouseHelper.ungrabMouseCursor();
    1219            }
    1220        }
    1221
    1222        /**
    1223         * Displays the ingame menu
    1224         */
    1225        public void displayInGameMenu()
    1226        {
    1227            if (this.currentScreen == null)
    1228            {
    1229                this.displayGuiScreen(new GuiIngameMenu());
    1230
    1231                if (this.isSingleplayer() && !this.theIntegratedServer.getPublic())
    1232                {
    1233                    this.sndManager.pauseAllSounds();
    1234                }
    1235            }
    1236        }
    1237
    1238        private void sendClickBlockToController(int par1, boolean par2)
    1239        {
    1240            if (!par2)
    1241            {
    1242                this.leftClickCounter = 0;
    1243            }
    1244
    1245            if (par1 != 0 || this.leftClickCounter <= 0)
    1246            {
    1247                if (par2 && this.objectMouseOver != null && this.objectMouseOver.typeOfHit == EnumMovingObjectType.TILE && par1 == 0)
    1248                {
    1249                    int var3 = this.objectMouseOver.blockX;
    1250                    int var4 = this.objectMouseOver.blockY;
    1251                    int var5 = this.objectMouseOver.blockZ;
    1252                    this.playerController.onPlayerDamageBlock(var3, var4, var5, this.objectMouseOver.sideHit);
    1253
    1254                    if (this.thePlayer.canCurrentToolHarvestBlock(var3, var4, var5))
    1255                    {
    1256                        this.effectRenderer.addBlockHitEffects(var3, var4, var5, this.objectMouseOver);
    1257                        this.thePlayer.swingItem();
    1258                    }
    1259                }
    1260                else
    1261                {
    1262                    this.playerController.resetBlockRemoving();
    1263                }
    1264            }
    1265        }
    1266
    1267        /**
    1268         * Called whenever the mouse is clicked. Button clicked is 0 for left clicking and 1 for right clicking. Args:
    1269         * buttonClicked
    1270         */
    1271        private void clickMouse(int par1)
    1272        {
    1273            if (par1 != 0 || this.leftClickCounter <= 0)
    1274            {
    1275                if (par1 == 0)
    1276                {
    1277                    this.thePlayer.swingItem();
    1278                }
    1279
    1280                if (par1 == 1)
    1281                {
    1282                    this.rightClickDelayTimer = 4;
    1283                }
    1284
    1285                boolean var2 = true;
    1286                ItemStack var3 = this.thePlayer.inventory.getCurrentItem();
    1287
    1288                if (this.objectMouseOver == null)
    1289                {
    1290                    if (par1 == 0 && this.playerController.isNotCreative())
    1291                    {
    1292                        this.leftClickCounter = 10;
    1293                    }
    1294                }
    1295                else if (this.objectMouseOver.typeOfHit == EnumMovingObjectType.ENTITY)
    1296                {
    1297                    if (par1 == 0)
    1298                    {
    1299                        this.playerController.attackEntity(this.thePlayer, this.objectMouseOver.entityHit);
    1300                    }
    1301
    1302                    if (par1 == 1 && this.playerController.func_78768_b(this.thePlayer, this.objectMouseOver.entityHit))
    1303                    {
    1304                        var2 = false;
    1305                    }
    1306                }
    1307                else if (this.objectMouseOver.typeOfHit == EnumMovingObjectType.TILE)
    1308                {
    1309                    int var4 = this.objectMouseOver.blockX;
    1310                    int var5 = this.objectMouseOver.blockY;
    1311                    int var6 = this.objectMouseOver.blockZ;
    1312                    int var7 = this.objectMouseOver.sideHit;
    1313
    1314                    if (par1 == 0)
    1315                    {
    1316                        this.playerController.clickBlock(var4, var5, var6, this.objectMouseOver.sideHit);
    1317                    }
    1318                    else
    1319                    {
    1320                        int var8 = var3 != null ? var3.stackSize : 0;
    1321
    1322                        boolean result = !ForgeEventFactory.onPlayerInteract(thePlayer, Action.RIGHT_CLICK_BLOCK, var4, var5, var6, var7).isCanceled();
    1323                        if (result && this.playerController.onPlayerRightClick(this.thePlayer, this.theWorld, var3, var4, var5, var6, var7, this.objectMouseOver.hitVec))
    1324                        {
    1325                            var2 = false;
    1326                            this.thePlayer.swingItem();
    1327                        }
    1328
    1329                        if (var3 == null)
    1330                        {
    1331                            return;
    1332                        }
    1333
    1334                        if (var3.stackSize == 0)
    1335                        {
    1336                            this.thePlayer.inventory.mainInventory[this.thePlayer.inventory.currentItem] = null;
    1337                        }
    1338                        else if (var3.stackSize != var8 || this.playerController.isInCreativeMode())
    1339                        {
    1340                            this.entityRenderer.itemRenderer.func_78444_b();
    1341                        }
    1342                    }
    1343                }
    1344
    1345                if (var2 && par1 == 1)
    1346                {
    1347                    ItemStack var9 = this.thePlayer.inventory.getCurrentItem();
    1348
    1349                    boolean result = !ForgeEventFactory.onPlayerInteract(thePlayer, Action.RIGHT_CLICK_AIR, 0, 0, 0, -1).isCanceled();
    1350                    if (result && var9 != null && this.playerController.sendUseItem(this.thePlayer, this.theWorld, var9))
    1351                    {
    1352                        this.entityRenderer.itemRenderer.func_78445_c();
    1353                    }
    1354                }
    1355            }
    1356        }
    1357
    1358        /**
    1359         * Toggles fullscreen mode.
    1360         */
    1361        public void toggleFullscreen()
    1362        {
    1363            try
    1364            {
    1365                this.fullscreen = !this.fullscreen;
    1366
    1367                if (this.fullscreen)
    1368                {
    1369                    Display.setDisplayMode(Display.getDesktopDisplayMode());
    1370                    this.displayWidth = Display.getDisplayMode().getWidth();
    1371                    this.displayHeight = Display.getDisplayMode().getHeight();
    1372
    1373                    if (this.displayWidth <= 0)
    1374                    {
    1375                        this.displayWidth = 1;
    1376                    }
    1377
    1378                    if (this.displayHeight <= 0)
    1379                    {
    1380                        this.displayHeight = 1;
    1381                    }
    1382                }
    1383                else
    1384                {
    1385                    if (this.mcCanvas != null)
    1386                    {
    1387                        this.displayWidth = this.mcCanvas.getWidth();
    1388                        this.displayHeight = this.mcCanvas.getHeight();
    1389                    }
    1390                    else
    1391                    {
    1392                        this.displayWidth = this.tempDisplayWidth;
    1393                        this.displayHeight = this.tempDisplayHeight;
    1394                    }
    1395
    1396                    if (this.displayWidth <= 0)
    1397                    {
    1398                        this.displayWidth = 1;
    1399                    }
    1400
    1401                    if (this.displayHeight <= 0)
    1402                    {
    1403                        this.displayHeight = 1;
    1404                    }
    1405                }
    1406
    1407                if (this.currentScreen != null)
    1408                {
    1409                    this.resize(this.displayWidth, this.displayHeight);
    1410                }
    1411
    1412                Display.setFullscreen(this.fullscreen);
    1413                Display.setVSyncEnabled(this.gameSettings.enableVsync);
    1414                Display.update();
    1415            }
    1416            catch (Exception var2)
    1417            {
    1418                var2.printStackTrace();
    1419            }
    1420        }
    1421
    1422        /**
    1423         * Called to resize the current screen.
    1424         */
    1425        private void resize(int par1, int par2)
    1426        {
    1427            this.displayWidth = par1 <= 0 ? 1 : par1;
    1428            this.displayHeight = par2 <= 0 ? 1 : par2;
    1429
    1430            if (this.currentScreen != null)
    1431            {
    1432                ScaledResolution var3 = new ScaledResolution(this.gameSettings, par1, par2);
    1433                int var4 = var3.getScaledWidth();
    1434                int var5 = var3.getScaledHeight();
    1435                this.currentScreen.setWorldAndResolution(this, var4, var5);
    1436            }
    1437        }
    1438
    1439        /**
    1440         * Runs the current tick.
    1441         */
    1442        public void runTick()
    1443        {
    1444            FMLCommonHandler.instance().rescheduleTicks(Side.CLIENT);
    1445
    1446            if (this.rightClickDelayTimer > 0)
    1447            {
    1448                --this.rightClickDelayTimer;
    1449            }
    1450
    1451            FMLCommonHandler.instance().onPreClientTick();
    1452
    1453            this.mcProfiler.startSection("stats");
    1454            this.statFileWriter.func_77449_e();
    1455            this.mcProfiler.endStartSection("gui");
    1456
    1457            if (!this.isGamePaused)
    1458            {
    1459                this.ingameGUI.updateTick();
    1460            }
    1461
    1462            this.mcProfiler.endStartSection("pick");
    1463            this.entityRenderer.getMouseOver(1.0F);
    1464            this.mcProfiler.endStartSection("gameMode");
    1465
    1466            if (!this.isGamePaused && this.theWorld != null)
    1467            {
    1468                this.playerController.updateController();
    1469            }
    1470
    1471            GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.renderEngine.getTexture("/terrain.png"));
    1472            this.mcProfiler.endStartSection("textures");
    1473
    1474            if (!this.isGamePaused)
    1475            {
    1476                this.renderEngine.updateDynamicTextures();
    1477            }
    1478
    1479            if (this.currentScreen == null && this.thePlayer != null)
    1480            {
    1481                if (this.thePlayer.getHealth() <= 0)
    1482                {
    1483                    this.displayGuiScreen((GuiScreen)null);
    1484                }
    1485                else if (this.thePlayer.isPlayerSleeping() && this.theWorld != null)
    1486                {
    1487                    this.displayGuiScreen(new GuiSleepMP());
    1488                }
    1489            }
    1490            else if (this.currentScreen != null && this.currentScreen instanceof GuiSleepMP && !this.thePlayer.isPlayerSleeping())
    1491            {
    1492                this.displayGuiScreen((GuiScreen)null);
    1493            }
    1494
    1495            if (this.currentScreen != null)
    1496            {
    1497                this.leftClickCounter = 10000;
    1498            }
    1499
    1500            CrashReport var2;
    1501            CrashReportCategory var3;
    1502
    1503            if (this.currentScreen != null)
    1504            {
    1505                try
    1506                {
    1507                    this.currentScreen.handleInput();
    1508                }
    1509                catch (Throwable var6)
    1510                {
    1511                    var2 = CrashReport.func_85055_a(var6, "Updating screen events");
    1512                    var3 = var2.func_85058_a("Affected screen");
    1513                    var3.addCrashSectionCallable("Screen name", new CallableUpdatingScreenName(this));
    1514                    throw new ReportedException(var2);
    1515                }
    1516
    1517                if (this.currentScreen != null)
    1518                {
    1519                    try
    1520                    {
    1521                        this.currentScreen.guiParticles.update();
    1522                    }
    1523                    catch (Throwable var5)
    1524                    {
    1525                        var2 = CrashReport.func_85055_a(var5, "Ticking screen particles");
    1526                        var3 = var2.func_85058_a("Affected screen");
    1527                        var3.addCrashSectionCallable("Screen name", new CallableParticleScreenName(this));
    1528                        throw new ReportedException(var2);
    1529                    }
    1530
    1531                    try
    1532                    {
    1533                        this.currentScreen.updateScreen();
    1534                    }
    1535                    catch (Throwable var4)
    1536                    {
    1537                        var2 = CrashReport.func_85055_a(var4, "Ticking screen");
    1538                        var3 = var2.func_85058_a("Affected screen");
    1539                        var3.addCrashSectionCallable("Screen name", new CallableTickingScreenName(this));
    1540                        throw new ReportedException(var2);
    1541                    }
    1542                }
    1543            }
    1544
    1545            if (this.currentScreen == null || this.currentScreen.allowUserInput)
    1546            {
    1547                this.mcProfiler.endStartSection("mouse");
    1548
    1549                while (Mouse.next())
    1550                {
    1551                    KeyBinding.setKeyBindState(Mouse.getEventButton() - 100, Mouse.getEventButtonState());
    1552
    1553                    if (Mouse.getEventButtonState())
    1554                    {
    1555                        KeyBinding.onTick(Mouse.getEventButton() - 100);
    1556                    }
    1557
    1558                    long var1 = getSystemTime() - this.systemTime;
    1559
    1560                    if (var1 <= 200L)
    1561                    {
    1562                        int var10 = Mouse.getEventDWheel();
    1563
    1564                        if (var10 != 0)
    1565                        {
    1566                            this.thePlayer.inventory.changeCurrentItem(var10);
    1567
    1568                            if (this.gameSettings.noclip)
    1569                            {
    1570                                if (var10 > 0)
    1571                                {
    1572                                    var10 = 1;
    1573                                }
    1574
    1575                                if (var10 < 0)
    1576                                {
    1577                                    var10 = -1;
    1578                                }
    1579
    1580                                this.gameSettings.noclipRate += (float)var10 * 0.25F;
    1581                            }
    1582                        }
    1583
    1584                        if (this.currentScreen == null)
    1585                        {
    1586                            if (!this.inGameHasFocus && Mouse.getEventButtonState())
    1587                            {
    1588                                this.setIngameFocus();
    1589                            }
    1590                        }
    1591                        else if (this.currentScreen != null)
    1592                        {
    1593                            this.currentScreen.handleMouseInput();
    1594                        }
    1595                    }
    1596                }
    1597
    1598                if (this.leftClickCounter > 0)
    1599                {
    1600                    --this.leftClickCounter;
    1601                }
    1602
    1603                this.mcProfiler.endStartSection("keyboard");
    1604                boolean var8;
    1605
    1606                while (Keyboard.next())
    1607                {
    1608                    KeyBinding.setKeyBindState(Keyboard.getEventKey(), Keyboard.getEventKeyState());
    1609
    1610                    if (Keyboard.getEventKeyState())
    1611                    {
    1612                        KeyBinding.onTick(Keyboard.getEventKey());
    1613                    }
    1614
    1615                    if (this.field_83002_am > 0L)
    1616                    {
    1617                        if (getSystemTime() - this.field_83002_am >= 6000L)
    1618                        {
    1619                            throw new ReportedException(new CrashReport("Manually triggered debug crash", new Throwable()));
    1620                        }
    1621
    1622                        if (!Keyboard.isKeyDown(46) || !Keyboard.isKeyDown(61))
    1623                        {
    1624                            this.field_83002_am = -1L;
    1625                        }
    1626                    }
    1627                    else if (Keyboard.isKeyDown(46) && Keyboard.isKeyDown(61))
    1628                    {
    1629                        this.field_83002_am = getSystemTime();
    1630                    }
    1631
    1632                    if (Keyboard.getEventKeyState())
    1633                    {
    1634                        if (Keyboard.getEventKey() == 87)
    1635                        {
    1636                            this.toggleFullscreen();
    1637                        }
    1638                        else
    1639                        {
    1640                            if (this.currentScreen != null)
    1641                            {
    1642                                this.currentScreen.handleKeyboardInput();
    1643                            }
    1644                            else
    1645                            {
    1646                                if (Keyboard.getEventKey() == 1)
    1647                                {
    1648                                    this.displayInGameMenu();
    1649                                }
    1650
    1651                                if (Keyboard.getEventKey() == 31 && Keyboard.isKeyDown(61))
    1652                                {
    1653                                    this.forceReload();
    1654                                }
    1655
    1656                                if (Keyboard.getEventKey() == 20 && Keyboard.isKeyDown(61))
    1657                                {
    1658                                    this.renderEngine.refreshTextures();
    1659                                }
    1660
    1661                                if (Keyboard.getEventKey() == 33 && Keyboard.isKeyDown(61))
    1662                                {
    1663                                    var8 = Keyboard.isKeyDown(42) | Keyboard.isKeyDown(54);
    1664                                    this.gameSettings.setOptionValue(EnumOptions.RENDER_DISTANCE, var8 ? -1 : 1);
    1665                                }
    1666
    1667                                if (Keyboard.getEventKey() == 30 && Keyboard.isKeyDown(61))
    1668                                {
    1669                                    this.renderGlobal.loadRenderers();
    1670                                }
    1671
    1672                                if (Keyboard.getEventKey() == 35 && Keyboard.isKeyDown(61))
    1673                                {
    1674                                    this.gameSettings.advancedItemTooltips = !this.gameSettings.advancedItemTooltips;
    1675                                    this.gameSettings.saveOptions();
    1676                                }
    1677
    1678                                if (Keyboard.getEventKey() == 48 && Keyboard.isKeyDown(61))
    1679                                {
    1680                                    RenderManager.field_85095_o = !RenderManager.field_85095_o;
    1681                                }
    1682
    1683                                if (Keyboard.getEventKey() == 25 && Keyboard.isKeyDown(61))
    1684                                {
    1685                                    this.gameSettings.pauseOnLostFocus = !this.gameSettings.pauseOnLostFocus;
    1686                                    this.gameSettings.saveOptions();
    1687                                }
    1688
    1689                                if (Keyboard.getEventKey() == 59)
    1690                                {
    1691                                    this.gameSettings.hideGUI = !this.gameSettings.hideGUI;
    1692                                }
    1693
    1694                                if (Keyboard.getEventKey() == 61)
    1695                                {
    1696                                    this.gameSettings.showDebugInfo = !this.gameSettings.showDebugInfo;
    1697                                    this.gameSettings.showDebugProfilerChart = GuiScreen.isShiftKeyDown();
    1698                                }
    1699
    1700                                if (Keyboard.getEventKey() == 63)
    1701                                {
    1702                                    ++this.gameSettings.thirdPersonView;
    1703
    1704                                    if (this.gameSettings.thirdPersonView > 2)
    1705                                    {
    1706                                        this.gameSettings.thirdPersonView = 0;
    1707                                    }
    1708                                }
    1709
    1710                                if (Keyboard.getEventKey() == 66)
    1711                                {
    1712                                    this.gameSettings.smoothCamera = !this.gameSettings.smoothCamera;
    1713                                }
    1714                            }
    1715
    1716                            int var9;
    1717
    1718                            for (var9 = 0; var9 < 9; ++var9)
    1719                            {
    1720                                if (Keyboard.getEventKey() == 2 + var9)
    1721                                {
    1722                                    this.thePlayer.inventory.currentItem = var9;
    1723                                }
    1724                            }
    1725
    1726                            if (this.gameSettings.showDebugInfo && this.gameSettings.showDebugProfilerChart)
    1727                            {
    1728                                if (Keyboard.getEventKey() == 11)
    1729                                {
    1730                                    this.updateDebugProfilerName(0);
    1731                                }
    1732
    1733                                for (var9 = 0; var9 < 9; ++var9)
    1734                                {
    1735                                    if (Keyboard.getEventKey() == 2 + var9)
    1736                                    {
    1737                                        this.updateDebugProfilerName(var9 + 1);
    1738                                    }
    1739                                }
    1740                            }
    1741                        }
    1742                    }
    1743                }
    1744
    1745                var8 = this.gameSettings.chatVisibility != 2;
    1746
    1747                while (this.gameSettings.keyBindInventory.isPressed())
    1748                {
    1749                    this.displayGuiScreen(new GuiInventory(this.thePlayer));
    1750                }
    1751
    1752                while (this.gameSettings.keyBindDrop.isPressed())
    1753                {
    1754                    this.thePlayer.dropOneItem();
    1755                }
    1756
    1757                while (this.gameSettings.keyBindChat.isPressed() && var8)
    1758                {
    1759                    this.displayGuiScreen(new GuiChat());
    1760                }
    1761
    1762                if (this.currentScreen == null && this.gameSettings.keyBindCommand.isPressed() && var8)
    1763                {
    1764                    this.displayGuiScreen(new GuiChat("/"));
    1765                }
    1766
    1767                if (this.thePlayer.isUsingItem())
    1768                {
    1769                    if (!this.gameSettings.keyBindUseItem.pressed)
    1770                    {
    1771                        this.playerController.onStoppedUsingItem(this.thePlayer);
    1772                    }
    1773
    1774                    label379:
    1775
    1776                    while (true)
    1777                    {
    1778                        if (!this.gameSettings.keyBindAttack.isPressed())
    1779                        {
    1780                            while (this.gameSettings.keyBindUseItem.isPressed())
    1781                            {
    1782                                ;
    1783                            }
    1784
    1785                            while (true)
    1786                            {
    1787                                if (this.gameSettings.keyBindPickBlock.isPressed())
    1788                                {
    1789                                    continue;
    1790                                }
    1791
    1792                                break label379;
    1793                            }
    1794                        }
    1795                    }
    1796                }
    1797                else
    1798                {
    1799                    while (this.gameSettings.keyBindAttack.isPressed())
    1800                    {
    1801                        this.clickMouse(0);
    1802                    }
    1803
    1804                    while (this.gameSettings.keyBindUseItem.isPressed())
    1805                    {
    1806                        this.clickMouse(1);
    1807                    }
    1808
    1809                    while (this.gameSettings.keyBindPickBlock.isPressed())
    1810                    {
    1811                        this.clickMiddleMouseButton();
    1812                    }
    1813                }
    1814
    1815                if (this.gameSettings.keyBindUseItem.pressed && this.rightClickDelayTimer == 0 && !this.thePlayer.isUsingItem())
    1816                {
    1817                    this.clickMouse(1);
    1818                }
    1819
    1820                this.sendClickBlockToController(0, this.currentScreen == null && this.gameSettings.keyBindAttack.pressed && this.inGameHasFocus);
    1821            }
    1822
    1823            if (this.theWorld != null)
    1824            {
    1825                if (this.thePlayer != null)
    1826                {
    1827                    ++this.joinPlayerCounter;
    1828
    1829                    if (this.joinPlayerCounter == 30)
    1830                    {
    1831                        this.joinPlayerCounter = 0;
    1832                        this.theWorld.joinEntityInSurroundings(this.thePlayer);
    1833                    }
    1834                }
    1835
    1836                this.mcProfiler.endStartSection("gameRenderer");
    1837
    1838                if (!this.isGamePaused)
    1839                {
    1840                    this.entityRenderer.updateRenderer();
    1841                }
    1842
    1843                this.mcProfiler.endStartSection("levelRenderer");
    1844
    1845                if (!this.isGamePaused)
    1846                {
    1847                    this.renderGlobal.updateClouds();
    1848                }
    1849
    1850                this.mcProfiler.endStartSection("level");
    1851
    1852                if (!this.isGamePaused)
    1853                {
    1854                    if (this.theWorld.lightningFlash > 0)
    1855                    {
    1856                        --this.theWorld.lightningFlash;
    1857                    }
    1858
    1859                    this.theWorld.updateEntities();
    1860                }
    1861
    1862                if (!this.isGamePaused)
    1863                {
    1864                    this.theWorld.setAllowedSpawnTypes(this.theWorld.difficultySetting > 0, true);
    1865
    1866                    try
    1867                    {
    1868                        this.theWorld.tick();
    1869                    }
    1870                    catch (Throwable var7)
    1871                    {
    1872                        var2 = CrashReport.func_85055_a(var7, "Exception in world tick");
    1873
    1874                        if (this.theWorld == null)
    1875                        {
    1876                            var3 = var2.func_85058_a("Affected level");
    1877                            var3.addCrashSection("Problem", "Level is null!");
    1878                        }
    1879                        else
    1880                        {
    1881                            this.theWorld.addWorldInfoToCrashReport(var2);
    1882                        }
    1883
    1884                        throw new ReportedException(var2);
    1885                    }
    1886                }
    1887
    1888                this.mcProfiler.endStartSection("animateTick");
    1889
    1890                if (!this.isGamePaused && this.theWorld != null)
    1891                {
    1892                    this.theWorld.func_73029_E(MathHelper.floor_double(this.thePlayer.posX), MathHelper.floor_double(this.thePlayer.posY), MathHelper.floor_double(this.thePlayer.posZ));
    1893                }
    1894
    1895                this.mcProfiler.endStartSection("particles");
    1896
    1897                if (!this.isGamePaused)
    1898                {
    1899                    this.effectRenderer.updateEffects();
    1900                }
    1901            }
    1902            else if (this.myNetworkManager != null)
    1903            {
    1904                this.mcProfiler.endStartSection("pendingConnection");
    1905                this.myNetworkManager.processReadPackets();
    1906            }
    1907
    1908            FMLCommonHandler.instance().onPostClientTick();
    1909
    1910            this.mcProfiler.endSection();
    1911            this.systemTime = getSystemTime();
    1912        }
    1913
    1914        /**
    1915         * Forces a reload of the sound manager and all the resources. Called in game by holding 'F3' and pressing 'S'.
    1916         */
    1917        private void forceReload()
    1918        {
    1919            System.out.println("FORCING RELOAD!");
    1920
    1921            if (this.sndManager != null)
    1922            {
    1923                this.sndManager.stopAllSounds();
    1924            }
    1925
    1926            this.sndManager = new SoundManager();
    1927            this.sndManager.loadSoundSettings(this.gameSettings);
    1928            this.downloadResourcesThread.reloadResources();
    1929        }
    1930
    1931        /**
    1932         * Arguments: World foldername,  World ingame name, WorldSettings
    1933         */
    1934        public void launchIntegratedServer(String par1Str, String par2Str, WorldSettings par3WorldSettings)
    1935        {
    1936            this.loadWorld((WorldClient)null);
    1937            System.gc();
    1938            ISaveHandler var4 = this.saveLoader.getSaveLoader(par1Str, false);
    1939            WorldInfo var5 = var4.loadWorldInfo();
    1940
    1941            if (var5 == null && par3WorldSettings != null)
    1942            {
    1943                this.statFileWriter.readStat(StatList.createWorldStat, 1);
    1944                var5 = new WorldInfo(par3WorldSettings, par1Str);
    1945                var4.saveWorldInfo(var5);
    1946            }
    1947
    1948            if (par3WorldSettings == null)
    1949            {
    1950                par3WorldSettings = new WorldSettings(var5);
    1951            }
    1952
    1953            this.statFileWriter.readStat(StatList.startGameStat, 1);
    1954
    1955            GameData.initializeServerGate(2);
    1956
    1957            this.theIntegratedServer = new IntegratedServer(this, par1Str, par2Str, par3WorldSettings);
    1958            this.theIntegratedServer.startServerThread();
    1959
    1960            MapDifference<Integer, ItemData> idDifferences = GameData.gateWorldLoadingForValidation();
    1961            if (idDifferences!=null)
    1962            {
    1963                FMLClientHandler.instance().warnIDMismatch(idDifferences, true);
    1964            }
    1965            else
    1966            {
    1967                GameData.releaseGate(true);
    1968                continueWorldLoading();
    1969            }
    1970
    1971        }
    1972
    1973        public void continueWorldLoading()
    1974        {
    1975            this.integratedServerIsRunning = true;
    1976            this.loadingScreen.displayProgressMessage(StatCollector.translateToLocal("menu.loadingLevel"));
    1977
    1978            while (!this.theIntegratedServer.serverIsInRunLoop())
    1979            {
    1980                String var6 = this.theIntegratedServer.getUserMessage();
    1981
    1982                if (var6 != null)
    1983                {
    1984                    this.loadingScreen.resetProgresAndWorkingMessage(StatCollector.translateToLocal(var6));
    1985                }
    1986                else
    1987                {
    1988                    this.loadingScreen.resetProgresAndWorkingMessage("");
    1989                }
    1990
    1991                try
    1992                {
    1993                    Thread.sleep(200L);
    1994                }
    1995                catch (InterruptedException var9)
    1996                {
    1997                    ;
    1998                }
    1999            }
    2000
    2001            this.displayGuiScreen((GuiScreen)null);
    2002
    2003            try
    2004            {
    2005                NetClientHandler var10 = new NetClientHandler(this, this.theIntegratedServer);
    2006                this.myNetworkManager = var10.getNetManager();
    2007            }
    2008            catch (IOException var8)
    2009            {
    2010                this.displayCrashReport(this.addGraphicsAndWorldToCrashReport(new CrashReport("Connecting to integrated server", var8)));
    2011            }
    2012        }
    2013
    2014        /**
    2015         * unloads the current world first
    2016         */
    2017        public void loadWorld(WorldClient par1WorldClient)
    2018        {
    2019            this.loadWorld(par1WorldClient, "");
    2020        }
    2021
    2022        /**
    2023         * par2Str is displayed on the loading screen to the user unloads the current world first
    2024         */
    2025        public void loadWorld(WorldClient par1WorldClient, String par2Str)
    2026        {
    2027            this.statFileWriter.syncStats();
    2028
    2029            if (par1WorldClient == null)
    2030            {
    2031                NetClientHandler var3 = this.getSendQueue();
    2032
    2033                if (var3 != null)
    2034                {
    2035                    var3.cleanup();
    2036                }
    2037
    2038                if (this.myNetworkManager != null)
    2039                {
    2040                    this.myNetworkManager.closeConnections();
    2041                }
    2042
    2043                if (this.theIntegratedServer != null)
    2044                {
    2045                    this.theIntegratedServer.initiateShutdown();
    2046                    if (loadingScreen!=null)
    2047                    {
    2048                        this.loadingScreen.resetProgresAndWorkingMessage("Shutting down internal server...");
    2049                    }
    2050                    while (!theIntegratedServer.isServerStopped())
    2051                    {
    2052                        try
    2053                        {
    2054                            Thread.sleep(10);
    2055                        }
    2056                        catch (InterruptedException ie) {}
    2057                    }
    2058                }
    2059
    2060                this.theIntegratedServer = null;
    2061            }
    2062
    2063            this.renderViewEntity = null;
    2064            this.myNetworkManager = null;
    2065
    2066            if (this.loadingScreen != null)
    2067            {
    2068                this.loadingScreen.resetProgressAndMessage(par2Str);
    2069                this.loadingScreen.resetProgresAndWorkingMessage("");
    2070            }
    2071
    2072            if (par1WorldClient == null && this.theWorld != null)
    2073            {
    2074                if (this.texturePackList.getIsDownloading())
    2075                {
    2076                    this.texturePackList.onDownloadFinished();
    2077                }
    2078
    2079                this.setServerData((ServerData)null);
    2080                this.integratedServerIsRunning = false;
    2081            }
    2082
    2083            this.sndManager.playStreaming((String)null, 0.0F, 0.0F, 0.0F);
    2084            this.sndManager.stopAllSounds();
    2085            this.theWorld = par1WorldClient;
    2086
    2087            if (par1WorldClient != null)
    2088            {
    2089                if (this.renderGlobal != null)
    2090                {
    2091                    this.renderGlobal.setWorldAndLoadRenderers(par1WorldClient);
    2092                }
    2093
    2094                if (this.effectRenderer != null)
    2095                {
    2096                    this.effectRenderer.clearEffects(par1WorldClient);
    2097                }
    2098
    2099                if (this.thePlayer == null)
    2100                {
    2101                    this.thePlayer = this.playerController.func_78754_a(par1WorldClient);
    2102                    this.playerController.flipPlayer(this.thePlayer);
    2103                }
    2104
    2105                this.thePlayer.preparePlayerToSpawn();
    2106                par1WorldClient.spawnEntityInWorld(this.thePlayer);
    2107                this.thePlayer.movementInput = new MovementInputFromOptions(this.gameSettings);
    2108                this.playerController.setPlayerCapabilities(this.thePlayer);
    2109                this.renderViewEntity = this.thePlayer;
    2110            }
    2111            else
    2112            {
    2113                this.saveLoader.flushCache();
    2114                this.thePlayer = null;
    2115            }
    2116
    2117            System.gc();
    2118            this.systemTime = 0L;
    2119        }
    2120
    2121        /**
    2122         * Installs a resource. Currently only sounds are download so this method just adds them to the SoundManager.
    2123         */
    2124        public void installResource(String par1Str, File par2File)
    2125        {
    2126            int var3 = par1Str.indexOf("/");
    2127            String var4 = par1Str.substring(0, var3);
    2128            par1Str = par1Str.substring(var3 + 1);
    2129
    2130            if (var4.equalsIgnoreCase("sound3"))
    2131            {
    2132                this.sndManager.addSound(par1Str, par2File);
    2133            }
    2134            else if (var4.equalsIgnoreCase("streaming"))
    2135            {
    2136                this.sndManager.addStreaming(par1Str, par2File);
    2137            }
    2138            else if (var4.equalsIgnoreCase("music") || var4.equalsIgnoreCase("newmusic"))
    2139            {
    2140                this.sndManager.addMusic(par1Str, par2File);
    2141            }
    2142        }
    2143
    2144        /**
    2145         * A String of renderGlobal.getDebugInfoRenders
    2146         */
    2147        public String debugInfoRenders()
    2148        {
    2149            return this.renderGlobal.getDebugInfoRenders();
    2150        }
    2151
    2152        /**
    2153         * Gets the information in the F3 menu about how many entities are infront/around you
    2154         */
    2155        public String getEntityDebug()
    2156        {
    2157            return this.renderGlobal.getDebugInfoEntities();
    2158        }
    2159
    2160        /**
    2161         * Gets the name of the world's current chunk provider
    2162         */
    2163        public String getWorldProviderName()
    2164        {
    2165            return this.theWorld.getProviderName();
    2166        }
    2167
    2168        /**
    2169         * A String of how many entities are in the world
    2170         */
    2171        public String debugInfoEntities()
    2172        {
    2173            return "P: " + this.effectRenderer.getStatistics() + ". T: " + this.theWorld.getDebugLoadedEntities();
    2174        }
    2175
    2176        public void setDimensionAndSpawnPlayer(int par1)
    2177        {
    2178            this.theWorld.setSpawnLocation();
    2179            this.theWorld.removeAllEntities();
    2180            int var2 = 0;
    2181
    2182            if (this.thePlayer != null)
    2183            {
    2184                var2 = this.thePlayer.entityId;
    2185                this.theWorld.setEntityDead(this.thePlayer);
    2186            }
    2187
    2188            this.renderViewEntity = null;
    2189            this.thePlayer = this.playerController.func_78754_a(this.theWorld);
    2190            this.thePlayer.dimension = par1;
    2191            this.renderViewEntity = this.thePlayer;
    2192            this.thePlayer.preparePlayerToSpawn();
    2193            this.theWorld.spawnEntityInWorld(this.thePlayer);
    2194            this.playerController.flipPlayer(this.thePlayer);
    2195            this.thePlayer.movementInput = new MovementInputFromOptions(this.gameSettings);
    2196            this.thePlayer.entityId = var2;
    2197            this.playerController.setPlayerCapabilities(this.thePlayer);
    2198
    2199            if (this.currentScreen instanceof GuiGameOver)
    2200            {
    2201                this.displayGuiScreen((GuiScreen)null);
    2202            }
    2203        }
    2204
    2205        /**
    2206         * Sets whether this is a demo or not.
    2207         */
    2208        void setDemo(boolean par1)
    2209        {
    2210            this.isDemo = par1;
    2211        }
    2212
    2213        /**
    2214         * Gets whether this is a demo or not.
    2215         */
    2216        public final boolean isDemo()
    2217        {
    2218            return this.isDemo;
    2219        }
    2220
    2221        /**
    2222         * get the client packet send queue
    2223         */
    2224        public NetClientHandler getSendQueue()
    2225        {
    2226            return this.thePlayer != null ? this.thePlayer.sendQueue : null;
    2227        }
    2228
    2229        public static void main(String[] par0ArrayOfStr)
    2230        {
    2231            FMLRelauncher.handleClientRelaunch(new ArgsWrapper(par0ArrayOfStr));
    2232        }
    2233
    2234        public static void fmlReentry(ArgsWrapper wrapper)
    2235        {
    2236            String[] par0ArrayOfStr = wrapper.args;
    2237            HashMap var1 = new HashMap();
    2238            boolean var2 = false;
    2239            boolean var3 = true;
    2240            boolean var4 = false;
    2241            String var5 = "Player" + getSystemTime() % 1000L;
    2242
    2243            if (par0ArrayOfStr.length > 0)
    2244            {
    2245                var5 = par0ArrayOfStr[0];
    2246            }
    2247
    2248            String var6 = "-";
    2249
    2250            if (par0ArrayOfStr.length > 1)
    2251            {
    2252                var6 = par0ArrayOfStr[1];
    2253            }
    2254
    2255            for (int var7 = 2; var7 < par0ArrayOfStr.length; ++var7)
    2256            {
    2257                String var8 = par0ArrayOfStr[var7];
    2258                String var9 = var7 == par0ArrayOfStr.length - 1 ? null : par0ArrayOfStr[var7 + 1];
    2259                boolean var10 = false;
    2260
    2261                if (!var8.equals("-demo") && !var8.equals("--demo"))
    2262                {
    2263                    if (var8.equals("--applet"))
    2264                    {
    2265                        var3 = false;
    2266                    }
    2267                    else if (var8.equals("--password") && var9 != null)
    2268                    {
    2269                        String[] var11 = HttpUtil.func_82718_a(var5, var9);
    2270
    2271                        if (var11 != null)
    2272                        {
    2273                            var5 = var11[0];
    2274                            var6 = var11[1];
    2275                            System.out.println("Logged in insecurely as " + var5 + " - sessionId is " + var6);
    2276                        }
    2277                        else
    2278                        {
    2279                            System.out.println("Could not log in as " + var5 + " with given password");
    2280                        }
    2281
    2282                        var10 = true;
    2283                    }
    2284                }
    2285                else
    2286                {
    2287                    var2 = true;
    2288                }
    2289
    2290                if (var10)
    2291                {
    2292                    ++var7;
    2293                }
    2294            }
    2295
    2296            var1.put("demo", "" + var2);
    2297            var1.put("stand-alone", "" + var3);
    2298            var1.put("username", var5);
    2299            var1.put("fullscreen", "" + var4);
    2300            var1.put("sessionid", var6);
    2301            Frame var13 = new Frame();
    2302            var13.setTitle("Minecraft");
    2303            var13.setBackground(Color.BLACK);
    2304            JPanel var12 = new JPanel();
    2305            var13.setLayout(new BorderLayout());
    2306            var12.setPreferredSize(new Dimension(854, 480));
    2307            var13.add(var12, "Center");
    2308            var13.pack();
    2309            var13.setLocationRelativeTo((Component)null);
    2310            var13.setVisible(true);
    2311            var13.addWindowListener(new GameWindowListener());
    2312            MinecraftFakeLauncher var14 = new MinecraftFakeLauncher(var1);
    2313            MinecraftApplet var15 = new MinecraftApplet();
    2314            var15.setStub(var14);
    2315            var14.setLayout(new BorderLayout());
    2316            var14.add(var15, "Center");
    2317            var14.validate();
    2318            var13.removeAll();
    2319            var13.setLayout(new BorderLayout());
    2320            var13.add(var14, "Center");
    2321            var13.validate();
    2322            var15.init();
    2323            var15.start();
    2324            Runtime.getRuntime().addShutdownHook(new ThreadShutdown());
    2325        }
    2326
    2327        public static boolean isGuiEnabled()
    2328        {
    2329            return theMinecraft == null || !theMinecraft.gameSettings.hideGUI;
    2330        }
    2331
    2332        public static boolean isFancyGraphicsEnabled()
    2333        {
    2334            return theMinecraft != null && theMinecraft.gameSettings.fancyGraphics;
    2335        }
    2336
    2337        /**
    2338         * Returns if ambient occlusion is enabled
    2339         */
    2340        public static boolean isAmbientOcclusionEnabled()
    2341        {
    2342            return theMinecraft != null && theMinecraft.gameSettings.ambientOcclusion;
    2343        }
    2344
    2345        public static boolean isDebugInfoEnabled()
    2346        {
    2347            return theMinecraft != null && theMinecraft.gameSettings.showDebugInfo;
    2348        }
    2349
    2350        /**
    2351         * Returns true if the message is a client command and should not be sent to the server. However there are no such
    2352         * commands at this point in time.
    2353         */
    2354        public boolean handleClientCommand(String par1Str)
    2355        {
    2356            return !par1Str.startsWith("/") ? false : false;
    2357        }
    2358
    2359        /**
    2360         * Called when the middle mouse button gets clicked
    2361         */
    2362        private void clickMiddleMouseButton()
    2363        {
    2364            if (this.objectMouseOver != null)
    2365            {
    2366                boolean var1 = this.thePlayer.capabilities.isCreativeMode;
    2367                int var5;
    2368
    2369                if (!ForgeHooks.onPickBlock(this.objectMouseOver, this.thePlayer, this.theWorld))
    2370                {
    2371                    return;
    2372                }
    2373
    2374                if (var1)
    2375                {
    2376                    var5 = this.thePlayer.inventoryContainer.inventorySlots.size() - 9 + this.thePlayer.inventory.currentItem;
    2377                    this.playerController.sendSlotPacket(this.thePlayer.inventory.getStackInSlot(this.thePlayer.inventory.currentItem), var5);
    2378                }
    2379            }
    2380        }
    2381
    2382        /**
    2383         * adds core server Info (GL version , Texture pack, isModded, type), and the worldInfo to the crash report
    2384         */
    2385        public CrashReport addGraphicsAndWorldToCrashReport(CrashReport par1CrashReport)
    2386        {
    2387            par1CrashReport.func_85056_g().addCrashSectionCallable("LWJGL", new CallableLWJGLVersion(this));
    2388            par1CrashReport.func_85056_g().addCrashSectionCallable("OpenGL", new CallableGLInfo(this));
    2389            par1CrashReport.func_85056_g().addCrashSectionCallable("Is Modded", new CallableModded(this));
    2390            par1CrashReport.func_85056_g().addCrashSectionCallable("Type", new CallableType2(this));
    2391            par1CrashReport.func_85056_g().addCrashSectionCallable("Texture Pack", new CallableTexturePack(this));
    2392            par1CrashReport.func_85056_g().addCrashSectionCallable("Profiler Position", new CallableClientProfiler(this));
    2393            par1CrashReport.func_85056_g().addCrashSectionCallable("Vec3 Pool Size", new CallableClientMemoryStats(this));
    2394
    2395            if (this.theWorld != null)
    2396            {
    2397                this.theWorld.addWorldInfoToCrashReport(par1CrashReport);
    2398            }
    2399
    2400            return par1CrashReport;
    2401        }
    2402
    2403        /**
    2404         * Return the singleton Minecraft instance for the game
    2405         */
    2406        public static Minecraft getMinecraft()
    2407        {
    2408            return theMinecraft;
    2409        }
    2410
    2411        /**
    2412         * Sets refreshTexturePacksScheduled to true, triggering a texture pack refresh next time the while(running) loop is
    2413         * run
    2414         */
    2415        public void scheduleTexturePackRefresh()
    2416        {
    2417            this.refreshTexturePacksScheduled = true;
    2418        }
    2419
    2420        public void addServerStatsToSnooper(PlayerUsageSnooper par1PlayerUsageSnooper)
    2421        {
    2422            par1PlayerUsageSnooper.addData("fps", Integer.valueOf(debugFPS));
    2423            par1PlayerUsageSnooper.addData("texpack_name", this.texturePackList.getSelectedTexturePack().getTexturePackFileName());
    2424            par1PlayerUsageSnooper.addData("texpack_resolution", Integer.valueOf(this.texturePackList.getSelectedTexturePack().getTexturePackResolution()));
    2425            par1PlayerUsageSnooper.addData("vsync_enabled", Boolean.valueOf(this.gameSettings.enableVsync));
    2426            par1PlayerUsageSnooper.addData("display_frequency", Integer.valueOf(Display.getDisplayMode().getFrequency()));
    2427            par1PlayerUsageSnooper.addData("display_type", this.fullscreen ? "fullscreen" : "windowed");
    2428
    2429            if (this.theIntegratedServer != null && this.theIntegratedServer.getPlayerUsageSnooper() != null)
    2430            {
    2431                par1PlayerUsageSnooper.addData("snooper_partner", this.theIntegratedServer.getPlayerUsageSnooper().getUniqueID());
    2432            }
    2433        }
    2434
    2435        public void addServerTypeToSnooper(PlayerUsageSnooper par1PlayerUsageSnooper)
    2436        {
    2437            par1PlayerUsageSnooper.addData("opengl_version", GL11.glGetString(GL11.GL_VERSION));
    2438            par1PlayerUsageSnooper.addData("opengl_vendor", GL11.glGetString(GL11.GL_VENDOR));
    2439            par1PlayerUsageSnooper.addData("client_brand", ClientBrandRetriever.getClientModName());
    2440            par1PlayerUsageSnooper.addData("applet", Boolean.valueOf(this.hideQuitButton));
    2441            ContextCapabilities var2 = GLContext.getCapabilities();
    2442            par1PlayerUsageSnooper.addData("gl_caps[ARB_multitexture]", Boolean.valueOf(var2.GL_ARB_multitexture));
    2443            par1PlayerUsageSnooper.addData("gl_caps[ARB_multisample]", Boolean.valueOf(var2.GL_ARB_multisample));
    2444            par1PlayerUsageSnooper.addData("gl_caps[ARB_texture_cube_map]", Boolean.valueOf(var2.GL_ARB_texture_cube_map));
    2445            par1PlayerUsageSnooper.addData("gl_caps[ARB_vertex_blend]", Boolean.valueOf(var2.GL_ARB_vertex_blend));
    2446            par1PlayerUsageSnooper.addData("gl_caps[ARB_matrix_palette]", Boolean.valueOf(var2.GL_ARB_matrix_palette));
    2447            par1PlayerUsageSnooper.addData("gl_caps[ARB_vertex_program]", Boolean.valueOf(var2.GL_ARB_vertex_program));
    2448            par1PlayerUsageSnooper.addData("gl_caps[ARB_vertex_shader]", Boolean.valueOf(var2.GL_ARB_vertex_shader));
    2449            par1PlayerUsageSnooper.addData("gl_caps[ARB_fragment_program]", Boolean.valueOf(var2.GL_ARB_fragment_program));
    2450            par1PlayerUsageSnooper.addData("gl_caps[ARB_fragment_shader]", Boolean.valueOf(var2.GL_ARB_fragment_shader));
    2451            par1PlayerUsageSnooper.addData("gl_caps[ARB_shader_objects]", Boolean.valueOf(var2.GL_ARB_shader_objects));
    2452            par1PlayerUsageSnooper.addData("gl_caps[ARB_vertex_buffer_object]", Boolean.valueOf(var2.GL_ARB_vertex_buffer_object));
    2453            par1PlayerUsageSnooper.addData("gl_caps[ARB_framebuffer_object]", Boolean.valueOf(var2.GL_ARB_framebuffer_object));
    2454            par1PlayerUsageSnooper.addData("gl_caps[ARB_pixel_buffer_object]", Boolean.valueOf(var2.GL_ARB_pixel_buffer_object));
    2455            par1PlayerUsageSnooper.addData("gl_caps[ARB_uniform_buffer_object]", Boolean.valueOf(var2.GL_ARB_uniform_buffer_object));
    2456            par1PlayerUsageSnooper.addData("gl_caps[ARB_texture_non_power_of_two]", Boolean.valueOf(var2.GL_ARB_texture_non_power_of_two));
    2457            par1PlayerUsageSnooper.addData("gl_caps[gl_max_vertex_uniforms]", Integer.valueOf(GL11.glGetInteger(GL20.GL_MAX_VERTEX_UNIFORM_COMPONENTS)));
    2458            par1PlayerUsageSnooper.addData("gl_caps[gl_max_fragment_uniforms]", Integer.valueOf(GL11.glGetInteger(GL20.GL_MAX_FRAGMENT_UNIFORM_COMPONENTS)));
    2459            par1PlayerUsageSnooper.addData("gl_max_texture_size", Integer.valueOf(getGLMaximumTextureSize()));
    2460        }
    2461
    2462        /**
    2463         * Used in the usage snooper.
    2464         */
    2465        private static int getGLMaximumTextureSize()
    2466        {
    2467            for (int var0 = 16384; var0 > 0; var0 >>= 1)
    2468            {
    2469                GL11.glTexImage2D(GL11.GL_PROXY_TEXTURE_2D, 0, GL11.GL_RGBA, var0, var0, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (ByteBuffer)null);
    2470                int var1 = GL11.glGetTexLevelParameteri(GL11.GL_PROXY_TEXTURE_2D, 0, GL11.GL_TEXTURE_WIDTH);
    2471
    2472                if (var1 != 0)
    2473                {
    2474                    return var0;
    2475                }
    2476            }
    2477
    2478            return -1;
    2479        }
    2480
    2481        /**
    2482         * Returns whether snooping is enabled or not.
    2483         */
    2484        public boolean isSnooperEnabled()
    2485        {
    2486            return this.gameSettings.snooperEnabled;
    2487        }
    2488
    2489        /**
    2490         * Set the current ServerData instance.
    2491         */
    2492        public void setServerData(ServerData par1ServerData)
    2493        {
    2494            this.currentServerData = par1ServerData;
    2495        }
    2496
    2497        /**
    2498         * Get the current ServerData instance.
    2499         */
    2500        public ServerData getServerData()
    2501        {
    2502            return this.currentServerData;
    2503        }
    2504
    2505        public boolean isIntegratedServerRunning()
    2506        {
    2507            return this.integratedServerIsRunning;
    2508        }
    2509
    2510        /**
    2511         * Returns true if there is only one player playing, and the current server is the integrated one.
    2512         */
    2513        public boolean isSingleplayer()
    2514        {
    2515            return this.integratedServerIsRunning && this.theIntegratedServer != null;
    2516        }
    2517
    2518        /**
    2519         * Returns the currently running integrated server
    2520         */
    2521        public IntegratedServer getIntegratedServer()
    2522        {
    2523            return this.theIntegratedServer;
    2524        }
    2525
    2526        public static void stopIntegratedServer()
    2527        {
    2528            if (theMinecraft != null)
    2529            {
    2530                IntegratedServer var0 = theMinecraft.getIntegratedServer();
    2531
    2532                if (var0 != null)
    2533                {
    2534                    var0.stopServer();
    2535                }
    2536            }
    2537        }
    2538
    2539        /**
    2540         * Returns the PlayerUsageSnooper instance.
    2541         */
    2542        public PlayerUsageSnooper getPlayerUsageSnooper()
    2543        {
    2544            return this.usageSnooper;
    2545        }
    2546
    2547        /**
    2548         * Gets the system time in milliseconds.
    2549         */
    2550        public static long getSystemTime()
    2551        {
    2552            return Sys.getTime() * 1000L / Sys.getTimerResolution();
    2553        }
    2554
    2555        /**
    2556         * Returns whether we're in full screen or not.
    2557         */
    2558        public boolean isFullScreen()
    2559        {
    2560            return this.fullscreen;
    2561        }
    2562    }