Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 58.82 KB | None | 0 0
  1. // Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
  2. // Jad home page: http://www.kpdus.com/jad.html
  3. // Decompiler options: packimports(3) braces deadcode
  4.  
  5. package net.minecraft.client;
  6.  
  7. import java.awt.*;
  8. import java.io.File;
  9. import java.io.PrintStream;
  10. import net.minecraft.src.*;
  11. import org.lwjgl.LWJGLException;
  12. import org.lwjgl.input.*;
  13. import org.lwjgl.opengl.*;
  14. import org.lwjgl.opengl.DisplayMode;
  15. import org.lwjgl.util.glu.GLU;
  16.  
  17. // Referenced classes of package net.minecraft.client:
  18. //            MinecraftApplet
  19.  
  20. public abstract class Minecraft
  21.     implements Runnable
  22. {
  23.  
  24.     public Minecraft(Component component, Canvas canvas, MinecraftApplet minecraftapplet, int i, int j, boolean flag)
  25.     {
  26.         fullscreen = false;
  27.         hasCrashed = false;
  28.         timer = new Timer(20F);
  29.         session = null;
  30.         hideQuitButton = true;
  31.         isGamePaused = false;
  32.         currentScreen = null;
  33.         loadingScreen = new LoadingScreenRenderer(this);
  34.         ticksRan = 0;
  35.         leftClickCounter = 0;
  36.         guiAchievement = new GuiAchievement(this);
  37.         skipRenderWorld = false;
  38.         field_9242_w = new ModelBiped(0.0F);
  39.         objectMouseOver = null;
  40.         sndManager = new SoundManager();
  41.         textureWaterFX = new TextureWaterFX();
  42.         textureLavaFX = new TextureLavaFX();
  43.         running = true;
  44.         debug = "";
  45.         isTakingScreenshot = false;
  46.         prevFrameTime = -1L;
  47.         inGameHasFocus = false;
  48.         mouseTicksRan = 0;
  49.         isRaining = false;
  50.         systemTime = System.currentTimeMillis();
  51.         joinPlayerCounter = 0;
  52.         StatList.func_27360_a();
  53.         tempDisplayHeight = j;
  54.         fullscreen = flag;
  55.         mcApplet = minecraftapplet;
  56.         new ThreadSleepForever(this, "Timer hack thread");
  57.         mcCanvas = canvas;
  58.         displayWidth = i;
  59.         displayHeight = j;
  60.         fullscreen = flag;
  61.         if(minecraftapplet == null || "true".equals(minecraftapplet.getParameter("stand-alone")))
  62.         {
  63.             hideQuitButton = false;
  64.         }
  65.         theMinecraft = this;
  66.     }
  67.  
  68.     public void onMinecraftCrash(UnexpectedThrowable unexpectedthrowable)
  69.     {
  70.         hasCrashed = true;
  71.         displayUnexpectedThrowable(unexpectedthrowable);
  72.     }
  73.  
  74.     public abstract void displayUnexpectedThrowable(UnexpectedThrowable unexpectedthrowable);
  75.  
  76.     public void setServer(String s, int i)
  77.     {
  78.         serverName = s;
  79.         serverPort = i;
  80.     }
  81.  
  82.     public void startGame()
  83.         throws LWJGLException
  84.     {
  85.         if(mcCanvas != null)
  86.         {
  87.             Graphics g = mcCanvas.getGraphics();
  88.             if(g != null)
  89.             {
  90.                 g.setColor(Color.BLACK);
  91.                 g.fillRect(0, 0, displayWidth, displayHeight);
  92.                 g.dispose();
  93.             }
  94.             Display.setParent(mcCanvas);
  95.         } else
  96.         if(fullscreen)
  97.         {
  98.             Display.setFullscreen(true);
  99.             displayWidth = Display.getDisplayMode().getWidth();
  100.             displayHeight = Display.getDisplayMode().getHeight();
  101.             if(displayWidth <= 0)
  102.             {
  103.                 displayWidth = 1;
  104.             }
  105.             if(displayHeight <= 0)
  106.             {
  107.                 displayHeight = 1;
  108.             }
  109.         } else
  110.         {
  111.             Display.setDisplayMode(new DisplayMode(displayWidth, displayHeight));
  112.         }
  113.         Display.setTitle("Minecraft Minecraft Beta 1.7.3");
  114.         try
  115.         {
  116.             Display.create();
  117.         }
  118.         catch(LWJGLException lwjglexception)
  119.         {
  120.             lwjglexception.printStackTrace();
  121.             try
  122.             {
  123.                 Thread.sleep(1000L);
  124.             }
  125.             catch(InterruptedException interruptedexception) { }
  126.             Display.create();
  127.         }
  128.         mcDataDir = getMinecraftDir();
  129.         saveLoader = new SaveConverterMcRegion(new File(mcDataDir, "saves"));
  130.         gameSettings = new GameSettings(this, mcDataDir);
  131.         texturePackList = new TexturePackList(this, mcDataDir);
  132.         renderEngine = new RenderEngine(texturePackList, gameSettings);
  133.         fontRenderer = new FontRenderer(gameSettings, "/font/default.png", renderEngine);
  134.         ColorizerWater.func_28182_a(renderEngine.func_28149_a("/misc/watercolor.png"));
  135.         ColorizerGrass.func_28181_a(renderEngine.func_28149_a("/misc/grasscolor.png"));
  136.         ColorizerFoliage.func_28152_a(renderEngine.func_28149_a("/misc/foliagecolor.png"));
  137.         entityRenderer = new EntityRenderer(this);
  138.         RenderManager.instance.itemRenderer = new ItemRenderer(this);
  139.         statFileWriter = new StatFileWriter(session, mcDataDir);
  140.         AchievementList.openInventory.setStatStringFormatter(new StatStringFormatKeyInv(this));
  141.         loadScreen();
  142.         Keyboard.create();
  143.         Mouse.create();
  144.         mouseHelper = new MouseHelper(mcCanvas);
  145.         try
  146.         {
  147.             Controllers.create();
  148.         }
  149.         catch(Exception exception)
  150.         {
  151.             exception.printStackTrace();
  152.         }
  153.         checkGLError("Pre startup");
  154.         GL11.glEnable(3553 /*GL_TEXTURE_2D*/);
  155.         GL11.glShadeModel(7425 /*GL_SMOOTH*/);
  156.         GL11.glClearDepth(1.0D);
  157.         GL11.glEnable(2929 /*GL_DEPTH_TEST*/);
  158.         GL11.glDepthFunc(515);
  159.         GL11.glEnable(3008 /*GL_ALPHA_TEST*/);
  160.         GL11.glAlphaFunc(516, 0.1F);
  161.         GL11.glCullFace(1029 /*GL_BACK*/);
  162.         GL11.glMatrixMode(5889 /*GL_PROJECTION*/);
  163.         GL11.glLoadIdentity();
  164.         GL11.glMatrixMode(5888 /*GL_MODELVIEW0_ARB*/);
  165.         checkGLError("Startup");
  166.         glCapabilities = new OpenGlCapsChecker();
  167.         sndManager.loadSoundSettings(gameSettings);
  168.         renderEngine.registerTextureFX(textureLavaFX);
  169.         renderEngine.registerTextureFX(textureWaterFX);
  170.         renderEngine.registerTextureFX(new TexturePortalFX());
  171.         renderEngine.registerTextureFX(new TextureCompassFX(this));
  172.         renderEngine.registerTextureFX(new TextureWatchFX(this));
  173.         renderEngine.registerTextureFX(new TextureWaterFlowFX());
  174.         renderEngine.registerTextureFX(new TextureLavaFlowFX());
  175.         renderEngine.registerTextureFX(new TextureFlamesFX(0));
  176.         renderEngine.registerTextureFX(new TextureFlamesFX(1));
  177.         renderGlobal = new RenderGlobal(this, renderEngine);
  178.         GL11.glViewport(0, 0, displayWidth, displayHeight);
  179.         effectRenderer = new EffectRenderer(theWorld, renderEngine);
  180.         try
  181.         {
  182.             downloadResourcesThread = new ThreadDownloadResources(mcDataDir, this);
  183.             downloadResourcesThread.start();
  184.         }
  185.         catch(Exception exception1) { }
  186.         checkGLError("Post startup");
  187.         ingameGUI = new GuiIngame(this);
  188.         if(serverName != null)
  189.         {
  190.             displayGuiScreen(new GuiConnecting(this, serverName, serverPort));
  191.         } else
  192.         {
  193.             displayGuiScreen(new GuiMainMenu());
  194.         }
  195.     }
  196.  
  197.     private void loadScreen()
  198.         throws LWJGLException
  199.     {
  200.         ScaledResolution scaledresolution = new ScaledResolution(gameSettings, displayWidth, displayHeight);
  201.         GL11.glClear(16640);
  202.         GL11.glMatrixMode(5889 /*GL_PROJECTION*/);
  203.         GL11.glLoadIdentity();
  204.         GL11.glOrtho(0.0D, scaledresolution.field_25121_a, scaledresolution.field_25120_b, 0.0D, 1000D, 3000D);
  205.         GL11.glMatrixMode(5888 /*GL_MODELVIEW0_ARB*/);
  206.         GL11.glLoadIdentity();
  207.         GL11.glTranslatef(0.0F, 0.0F, -2000F);
  208.         GL11.glViewport(0, 0, displayWidth, displayHeight);
  209.         GL11.glClearColor(0.0F, 0.0F, 0.0F, 0.0F);
  210.         Tessellator tessellator = Tessellator.instance;
  211.         GL11.glDisable(2896 /*GL_LIGHTING*/);
  212.         GL11.glEnable(3553 /*GL_TEXTURE_2D*/);
  213.         GL11.glDisable(2912 /*GL_FOG*/);
  214.         GL11.glBindTexture(3553 /*GL_TEXTURE_2D*/, renderEngine.getTexture("/title/mojang.png"));
  215.         tessellator.startDrawingQuads();
  216.         tessellator.setColorOpaque_I(0xffffff);
  217.         tessellator.addVertexWithUV(0.0D, displayHeight, 0.0D, 0.0D, 0.0D);
  218.         tessellator.addVertexWithUV(displayWidth, displayHeight, 0.0D, 0.0D, 0.0D);
  219.         tessellator.addVertexWithUV(displayWidth, 0.0D, 0.0D, 0.0D, 0.0D);
  220.         tessellator.addVertexWithUV(0.0D, 0.0D, 0.0D, 0.0D, 0.0D);
  221.         tessellator.draw();
  222.         char c = '\u0100';
  223.         char c1 = '\u0100';
  224.         GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
  225.         tessellator.setColorOpaque_I(0xffffff);
  226.         func_6274_a((scaledresolution.getScaledWidth() - c) / 2, (scaledresolution.getScaledHeight() - c1) / 2, 0, 0, c, c1);
  227.         GL11.glDisable(2896 /*GL_LIGHTING*/);
  228.         GL11.glDisable(2912 /*GL_FOG*/);
  229.         GL11.glEnable(3008 /*GL_ALPHA_TEST*/);
  230.         GL11.glAlphaFunc(516, 0.1F);
  231.         Display.swapBuffers();
  232.     }
  233.  
  234.     public void func_6274_a(int i, int j, int k, int l, int i1, int j1)
  235.     {
  236.         float f = 0.00390625F;
  237.         float f1 = 0.00390625F;
  238.         Tessellator tessellator = Tessellator.instance;
  239.         tessellator.startDrawingQuads();
  240.         tessellator.addVertexWithUV(i + 0, j + j1, 0.0D, (float)(k + 0) * f, (float)(l + j1) * f1);
  241.         tessellator.addVertexWithUV(i + i1, j + j1, 0.0D, (float)(k + i1) * f, (float)(l + j1) * f1);
  242.         tessellator.addVertexWithUV(i + i1, j + 0, 0.0D, (float)(k + i1) * f, (float)(l + 0) * f1);
  243.         tessellator.addVertexWithUV(i + 0, j + 0, 0.0D, (float)(k + 0) * f, (float)(l + 0) * f1);
  244.         tessellator.draw();
  245.     }
  246.  
  247.     public static File getMinecraftDir()
  248.     {
  249.         if(minecraftDir == null)
  250.         {
  251.             minecraftDir = getAppDir("minecraft");
  252.         }
  253.         return minecraftDir;
  254.     }
  255.  
  256.     public static File getAppDir(String s)
  257.     {
  258.         String s1 = System.getProperty("user.home", ".");
  259.         File file;
  260.         switch(EnumOSMappingHelper.enumOSMappingArray[getOs().ordinal()])
  261.         {
  262.         case 1: // '\001'
  263.         case 2: // '\002'
  264.             file = new File(s1, (new StringBuilder()).append('.').append(s).append('/').toString());
  265.             break;
  266.  
  267.         case 3: // '\003'
  268.             String s2 = System.getenv("APPDATA");
  269.             if(s2 != null)
  270.             {
  271.                 file = new File(s2, (new StringBuilder()).append(".").append(s).append('/').toString());
  272.             } else
  273.             {
  274.                 file = new File(s1, (new StringBuilder()).append('.').append(s).append('/').toString());
  275.             }
  276.             break;
  277.  
  278.         case 4: // '\004'
  279.             file = new File(s1, (new StringBuilder()).append("Library/Application Support/").append(s).toString());
  280.             break;
  281.  
  282.         default:
  283.             file = new File(s1, (new StringBuilder()).append(s).append('/').toString());
  284.             break;
  285.         }
  286.         if(!file.exists() && !file.mkdirs())
  287.         {
  288.             throw new RuntimeException((new StringBuilder()).append("The working directory could not be created: ").append(file).toString());
  289.         } else
  290.         {
  291.             return file;
  292.         }
  293.     }
  294.  
  295.     private static EnumOS2 getOs()
  296.     {
  297.         String s = System.getProperty("os.name").toLowerCase();
  298.         if(s.contains("win"))
  299.         {
  300.             return EnumOS2.windows;
  301.         }
  302.         if(s.contains("mac"))
  303.         {
  304.             return EnumOS2.macos;
  305.         }
  306.         if(s.contains("solaris"))
  307.         {
  308.             return EnumOS2.solaris;
  309.         }
  310.         if(s.contains("sunos"))
  311.         {
  312.             return EnumOS2.solaris;
  313.         }
  314.         if(s.contains("linux"))
  315.         {
  316.             return EnumOS2.linux;
  317.         }
  318.         if(s.contains("unix"))
  319.         {
  320.             return EnumOS2.linux;
  321.         } else
  322.         {
  323.             return EnumOS2.unknown;
  324.         }
  325.     }
  326.  
  327.     public ISaveFormat getSaveLoader()
  328.     {
  329.         return saveLoader;
  330.     }
  331.  
  332.     public void displayGuiScreen(GuiScreen guiscreen)
  333.     {
  334.         if(currentScreen instanceof GuiUnused)
  335.         {
  336.             return;
  337.         }
  338.         if(currentScreen != null)
  339.         {
  340.             currentScreen.onGuiClosed();
  341.         }
  342.         if(guiscreen instanceof GuiMainMenu)
  343.         {
  344.             statFileWriter.func_27175_b();
  345.         }
  346.         statFileWriter.syncStats();
  347.         if(guiscreen == null && theWorld == null)
  348.         {
  349.             guiscreen = new GuiMainMenu();
  350.         } else
  351.         if(guiscreen == null && thePlayer.health <= 0)
  352.         {
  353.             guiscreen = new GuiGameOver();
  354.         }
  355.         if(guiscreen instanceof GuiMainMenu)
  356.         {
  357.             ingameGUI.clearChatMessages();
  358.         }
  359.         currentScreen = guiscreen;
  360.         if(guiscreen != null)
  361.         {
  362.             setIngameNotInFocus();
  363.             ScaledResolution scaledresolution = new ScaledResolution(gameSettings, displayWidth, displayHeight);
  364.             int i = scaledresolution.getScaledWidth();
  365.             int j = scaledresolution.getScaledHeight();
  366.             guiscreen.setWorldAndResolution(this, i, j);
  367.             skipRenderWorld = false;
  368.         } else
  369.         {
  370.             setIngameFocus();
  371.         }
  372.     }
  373.  
  374.     private void checkGLError(String s)
  375.     {
  376.         int i = GL11.glGetError();
  377.         if(i != 0)
  378.         {
  379.             String s1 = GLU.gluErrorString(i);
  380.             System.out.println("########## GL ERROR ##########");
  381.             System.out.println((new StringBuilder()).append("@ ").append(s).toString());
  382.             System.out.println((new StringBuilder()).append(i).append(": ").append(s1).toString());
  383.         }
  384.     }
  385.  
  386.     public void shutdownMinecraftApplet()
  387.     {
  388.         try
  389.         {
  390.             statFileWriter.func_27175_b();
  391.             statFileWriter.syncStats();
  392.             if(mcApplet != null)
  393.             {
  394.                 mcApplet.clearApplet();
  395.             }
  396.             try
  397.             {
  398.                 if(downloadResourcesThread != null)
  399.                 {
  400.                     downloadResourcesThread.closeMinecraft();
  401.                 }
  402.             }
  403.             catch(Exception exception) { }
  404.             System.out.println("Stopping!");
  405.             try
  406.             {
  407.                 changeWorld1(null);
  408.             }
  409.             catch(Throwable throwable) { }
  410.             try
  411.             {
  412.                 GLAllocation.deleteTexturesAndDisplayLists();
  413.             }
  414.             catch(Throwable throwable1) { }
  415.             sndManager.closeMinecraft();
  416.             Mouse.destroy();
  417.             Keyboard.destroy();
  418.         }
  419.         finally
  420.         {
  421.             Display.destroy();
  422.             if(!hasCrashed)
  423.             {
  424.                 System.exit(0);
  425.             }
  426.         }
  427.         System.gc();
  428.     }
  429.  
  430.     public void run()
  431.     {
  432.         running = true;
  433.         try
  434.         {
  435.             startGame();
  436.         }
  437.         catch(Exception exception)
  438.         {
  439.             exception.printStackTrace();
  440.             onMinecraftCrash(new UnexpectedThrowable("Failed to start game", exception));
  441.             return;
  442.         }
  443.         try
  444.         {
  445.             long l = System.currentTimeMillis();
  446.             int i = 0;
  447.             do
  448.             {
  449.                 if(!running)
  450.                 {
  451.                     break;
  452.                 }
  453.                 try
  454.                 {
  455.                     if(mcApplet != null && !mcApplet.isActive())
  456.                     {
  457.                         break;
  458.                     }
  459.                     AxisAlignedBB.clearBoundingBoxPool();
  460.                     Vec3D.initialize();
  461.                     if(mcCanvas == null && Display.isCloseRequested())
  462.                     {
  463.                         shutdown();
  464.                     }
  465.                     if(isGamePaused && theWorld != null)
  466.                     {
  467.                         float f = timer.renderPartialTicks;
  468.                         timer.updateTimer();
  469.                         timer.renderPartialTicks = f;
  470.                     } else
  471.                     {
  472.                         timer.updateTimer();
  473.                     }
  474.                     long l1 = System.nanoTime();
  475.                     for(int j = 0; j < timer.elapsedTicks; j++)
  476.                     {
  477.                         ticksRan++;
  478.                         try
  479.                         {
  480.                             runTick();
  481.                             continue;
  482.                         }
  483.                         catch(MinecraftException minecraftexception1)
  484.                         {
  485.                             theWorld = null;
  486.                         }
  487.                         changeWorld1(null);
  488.                         displayGuiScreen(new GuiConflictWarning());
  489.                     }
  490.  
  491.                     long l2 = System.nanoTime() - l1;
  492.                     checkGLError("Pre render");
  493.                     RenderBlocks.fancyGrass = gameSettings.fancyGraphics;
  494.                     sndManager.func_338_a(thePlayer, timer.renderPartialTicks);
  495.                     GL11.glEnable(3553 /*GL_TEXTURE_2D*/);
  496.                     if(theWorld != null)
  497.                     {
  498.                         theWorld.updatingLighting();
  499.                     }
  500.                     if(!Keyboard.isKeyDown(65))
  501.                     {
  502.                         Display.update();
  503.                     }
  504.                     if(thePlayer != null && thePlayer.isEntityInsideOpaqueBlock())
  505.                     {
  506.                         gameSettings.thirdPersonView = 0;
  507.                     }
  508.                     if(!skipRenderWorld)
  509.                     {
  510.                         if(playerController != null)
  511.                         {
  512.                             playerController.setPartialTime(timer.renderPartialTicks);
  513.                         }
  514.                         entityRenderer.updateCameraAndRender(timer.renderPartialTicks);
  515.                     }
  516.                     if(!Display.isActive())
  517.                     {
  518.                         if(fullscreen)
  519.                         {
  520.                             toggleFullscreen();
  521.                         }
  522.                         Thread.sleep(10L);
  523.                     }
  524.                     if(gameSettings.showDebugInfo)
  525.                     {
  526.                         displayDebugInfo(l2);
  527.                     } else
  528.                     {
  529.                         prevFrameTime = System.nanoTime();
  530.                     }
  531.                     guiAchievement.updateAchievementWindow();
  532.                     Thread.yield();
  533.                     if(Keyboard.isKeyDown(65))
  534.                     {
  535.                         Display.update();
  536.                     }
  537.                     screenshotListener();
  538.                     if(mcCanvas != null && !fullscreen && (mcCanvas.getWidth() != displayWidth || mcCanvas.getHeight() != displayHeight))
  539.                     {
  540.                         displayWidth = mcCanvas.getWidth();
  541.                         displayHeight = mcCanvas.getHeight();
  542.                         if(displayWidth <= 0)
  543.                         {
  544.                             displayWidth = 1;
  545.                         }
  546.                         if(displayHeight <= 0)
  547.                         {
  548.                             displayHeight = 1;
  549.                         }
  550.                         resize(displayWidth, displayHeight);
  551.                     }
  552.                     checkGLError("Post render");
  553.                     i++;
  554.                     isGamePaused = !isMultiplayerWorld() && currentScreen != null && currentScreen.doesGuiPauseGame();
  555.                     while(System.currentTimeMillis() >= l + 1000L)
  556.                     {
  557.                         debug = (new StringBuilder()).append(i).append(" fps, ").append(WorldRenderer.chunksUpdated).append(" chunk updates").toString();
  558.                         WorldRenderer.chunksUpdated = 0;
  559.                         l += 1000L;
  560.                         i = 0;
  561.                     }
  562.                 }
  563.                 catch(MinecraftException minecraftexception)
  564.                 {
  565.                     theWorld = null;
  566.                     changeWorld1(null);
  567.                     displayGuiScreen(new GuiConflictWarning());
  568.                 }
  569.                 catch(OutOfMemoryError outofmemoryerror)
  570.                 {
  571.                     func_28002_e();
  572.                     displayGuiScreen(new GuiErrorScreen());
  573.                     System.gc();
  574.                 }
  575.             } while(true);
  576.         }
  577.         catch(MinecraftError minecrafterror) { }
  578.         catch(Throwable throwable)
  579.         {
  580.             func_28002_e();
  581.             throwable.printStackTrace();
  582.             onMinecraftCrash(new UnexpectedThrowable("Unexpected error", throwable));
  583.         }
  584.         finally
  585.         {
  586.             shutdownMinecraftApplet();
  587.         }
  588.     }
  589.  
  590.     public void func_28002_e()
  591.     {
  592.         try
  593.         {
  594.             field_28006_b = new byte[0];
  595.             renderGlobal.func_28137_f();
  596.         }
  597.         catch(Throwable throwable) { }
  598.         try
  599.         {
  600.             System.gc();
  601.             AxisAlignedBB.func_28196_a();
  602.             Vec3D.func_28215_a();
  603.         }
  604.         catch(Throwable throwable1) { }
  605.         try
  606.         {
  607.             System.gc();
  608.             changeWorld1(null);
  609.         }
  610.         catch(Throwable throwable2) { }
  611.         System.gc();
  612.     }
  613.  
  614.     private void screenshotListener()
  615.     {
  616.         if(Keyboard.isKeyDown(60))
  617.         {
  618.             if(!isTakingScreenshot)
  619.             {
  620.                 isTakingScreenshot = true;
  621.                 ingameGUI.addChatMessage(ScreenShotHelper.saveScreenshot(minecraftDir, displayWidth, displayHeight));
  622.             }
  623.         } else
  624.         {
  625.             isTakingScreenshot = false;
  626.         }
  627.     }
  628.  
  629.     private void displayDebugInfo(long l)
  630.     {
  631.         long l1 = 0xfe502aL;
  632.         if(prevFrameTime == -1L)
  633.         {
  634.             prevFrameTime = System.nanoTime();
  635.         }
  636.         long l2 = System.nanoTime();
  637.         tickTimes[numRecordedFrameTimes & frameTimes.length - 1] = l;
  638.         frameTimes[numRecordedFrameTimes++ & frameTimes.length - 1] = l2 - prevFrameTime;
  639.         prevFrameTime = l2;
  640.         GL11.glClear(256);
  641.         GL11.glMatrixMode(5889 /*GL_PROJECTION*/);
  642.         GL11.glLoadIdentity();
  643.         GL11.glOrtho(0.0D, displayWidth, displayHeight, 0.0D, 1000D, 3000D);
  644.         GL11.glMatrixMode(5888 /*GL_MODELVIEW0_ARB*/);
  645.         GL11.glLoadIdentity();
  646.         GL11.glTranslatef(0.0F, 0.0F, -2000F);
  647.         GL11.glLineWidth(1.0F);
  648.         GL11.glDisable(3553 /*GL_TEXTURE_2D*/);
  649.         Tessellator tessellator = Tessellator.instance;
  650.         tessellator.startDrawing(7);
  651.         int i = (int)(l1 / 0x30d40L);
  652.         tessellator.setColorOpaque_I(0x20000000);
  653.         tessellator.addVertex(0.0D, displayHeight - i, 0.0D);
  654.         tessellator.addVertex(0.0D, displayHeight, 0.0D);
  655.         tessellator.addVertex(frameTimes.length, displayHeight, 0.0D);
  656.         tessellator.addVertex(frameTimes.length, displayHeight - i, 0.0D);
  657.         tessellator.setColorOpaque_I(0x20200000);
  658.         tessellator.addVertex(0.0D, displayHeight - i * 2, 0.0D);
  659.         tessellator.addVertex(0.0D, displayHeight - i, 0.0D);
  660.         tessellator.addVertex(frameTimes.length, displayHeight - i, 0.0D);
  661.         tessellator.addVertex(frameTimes.length, displayHeight - i * 2, 0.0D);
  662.         tessellator.draw();
  663.         long l3 = 0L;
  664.         for(int j = 0; j < frameTimes.length; j++)
  665.         {
  666.             l3 += frameTimes[j];
  667.         }
  668.  
  669.         int k = (int)(l3 / 0x30d40L / (long)frameTimes.length);
  670.         tessellator.startDrawing(7);
  671.         tessellator.setColorOpaque_I(0x20400000);
  672.         tessellator.addVertex(0.0D, displayHeight - k, 0.0D);
  673.         tessellator.addVertex(0.0D, displayHeight, 0.0D);
  674.         tessellator.addVertex(frameTimes.length, displayHeight, 0.0D);
  675.         tessellator.addVertex(frameTimes.length, displayHeight - k, 0.0D);
  676.         tessellator.draw();
  677.         tessellator.startDrawing(1);
  678.         for(int i1 = 0; i1 < frameTimes.length; i1++)
  679.         {
  680.             int j1 = ((i1 - numRecordedFrameTimes & frameTimes.length - 1) * 255) / frameTimes.length;
  681.             int k1 = (j1 * j1) / 255;
  682.             k1 = (k1 * k1) / 255;
  683.             int i2 = (k1 * k1) / 255;
  684.             i2 = (i2 * i2) / 255;
  685.             if(frameTimes[i1] > l1)
  686.             {
  687.                 tessellator.setColorOpaque_I(0xff000000 + k1 * 0x10000);
  688.             } else
  689.             {
  690.                 tessellator.setColorOpaque_I(0xff000000 + k1 * 256);
  691.             }
  692.             long l4 = frameTimes[i1] / 0x30d40L;
  693.             long l5 = tickTimes[i1] / 0x30d40L;
  694.             tessellator.addVertex((float)i1 + 0.5F, (float)((long)displayHeight - l4) + 0.5F, 0.0D);
  695.             tessellator.addVertex((float)i1 + 0.5F, (float)displayHeight + 0.5F, 0.0D);
  696.             tessellator.setColorOpaque_I(0xff000000 + k1 * 0x10000 + k1 * 256 + k1 * 1);
  697.             tessellator.addVertex((float)i1 + 0.5F, (float)((long)displayHeight - l4) + 0.5F, 0.0D);
  698.             tessellator.addVertex((float)i1 + 0.5F, (float)((long)displayHeight - (l4 - l5)) + 0.5F, 0.0D);
  699.         }
  700.  
  701.         tessellator.draw();
  702.         GL11.glEnable(3553 /*GL_TEXTURE_2D*/);
  703.     }
  704.  
  705.     public void shutdown()
  706.     {
  707.         running = false;
  708.     }
  709.  
  710.     public void setIngameFocus()
  711.     {
  712.         if(!Display.isActive())
  713.         {
  714.             return;
  715.         }
  716.         if(inGameHasFocus)
  717.         {
  718.             return;
  719.         } else
  720.         {
  721.             inGameHasFocus = true;
  722.             mouseHelper.grabMouseCursor();
  723.             displayGuiScreen(null);
  724.             leftClickCounter = 10000;
  725.             mouseTicksRan = ticksRan + 10000;
  726.             return;
  727.         }
  728.     }
  729.  
  730.     public void setIngameNotInFocus()
  731.     {
  732.         if(!inGameHasFocus)
  733.         {
  734.             return;
  735.         }
  736.         if(thePlayer != null)
  737.         {
  738.             thePlayer.resetPlayerKeyState();
  739.         }
  740.         inGameHasFocus = false;
  741.         mouseHelper.ungrabMouseCursor();
  742.     }
  743.  
  744.     public void displayInGameMenu()
  745.     {
  746.         if(currentScreen != null)
  747.         {
  748.             return;
  749.         } else
  750.         {
  751.             displayGuiScreen(new GuiIngameMenu());
  752.             return;
  753.         }
  754.     }
  755.  
  756.     private void func_6254_a(int i, boolean flag)
  757.     {
  758.         if(playerController.field_1064_b)
  759.         {
  760.             return;
  761.         }
  762.         if(!flag)
  763.         {
  764.             leftClickCounter = 0;
  765.         }
  766.         if(i == 0 && leftClickCounter > 0)
  767.         {
  768.             return;
  769.         }
  770.         if(flag && objectMouseOver != null && objectMouseOver.typeOfHit == EnumMovingObjectType.TILE && i == 0)
  771.         {
  772.             int j = objectMouseOver.blockX;
  773.             int k = objectMouseOver.blockY;
  774.             int l = objectMouseOver.blockZ;
  775.             playerController.sendBlockRemoving(j, k, l, objectMouseOver.sideHit);
  776.             effectRenderer.addBlockHitEffects(j, k, l, objectMouseOver.sideHit);
  777.         } else
  778.         {
  779.             playerController.resetBlockRemoving();
  780.         }
  781.     }
  782.  
  783.     private void clickMouse(int i)
  784.     {
  785.         if(i == 0 && leftClickCounter > 0)
  786.         {
  787.             return;
  788.         }
  789.         if(i == 0)
  790.         {
  791.             thePlayer.swingItem();
  792.         }
  793.         boolean flag = true;
  794.         if(objectMouseOver == null)
  795.         {
  796.             if(i == 0 && !(playerController instanceof PlayerControllerTest))
  797.             {
  798.                 leftClickCounter = 10;
  799.             }
  800.         } else
  801.         if(objectMouseOver.typeOfHit == EnumMovingObjectType.ENTITY)
  802.         {
  803.             if(i == 0)
  804.             {
  805.                 playerController.attackEntity(thePlayer, objectMouseOver.entityHit);
  806.             }
  807.             if(i == 1)
  808.             {
  809.                 playerController.interactWithEntity(thePlayer, objectMouseOver.entityHit);
  810.             }
  811.         } else
  812.         if(objectMouseOver.typeOfHit == EnumMovingObjectType.TILE)
  813.         {
  814.             int j = objectMouseOver.blockX;
  815.             int k = objectMouseOver.blockY;
  816.             int l = objectMouseOver.blockZ;
  817.             int i1 = objectMouseOver.sideHit;
  818.             if(i == 0)
  819.             {
  820.                 playerController.clickBlock(j, k, l, objectMouseOver.sideHit);
  821.             } else
  822.             {
  823.                 ItemStack itemstack1 = thePlayer.inventory.getCurrentItem();
  824.                 int j1 = itemstack1 == null ? 0 : itemstack1.stackSize;
  825.                 if(playerController.sendPlaceBlock(thePlayer, theWorld, itemstack1, j, k, l, i1))
  826.                 {
  827.                     flag = false;
  828.                     thePlayer.swingItem();
  829.                 }
  830.                 if(itemstack1 == null)
  831.                 {
  832.                     return;
  833.                 }
  834.                 if(itemstack1.stackSize == 0)
  835.                 {
  836.                     thePlayer.inventory.mainInventory[thePlayer.inventory.currentItem] = null;
  837.                 } else
  838.                 if(itemstack1.stackSize != j1)
  839.                 {
  840.                     entityRenderer.itemRenderer.func_9449_b();
  841.                 }
  842.             }
  843.         }
  844.         if(flag && i == 1)
  845.         {
  846.             ItemStack itemstack = thePlayer.inventory.getCurrentItem();
  847.             if(itemstack != null && playerController.sendUseItem(thePlayer, theWorld, itemstack))
  848.             {
  849.                 entityRenderer.itemRenderer.func_9450_c();
  850.             }
  851.         }
  852.     }
  853.  
  854.     public void toggleFullscreen()
  855.     {
  856.         try
  857.         {
  858.             fullscreen = !fullscreen;
  859.             if(fullscreen)
  860.             {
  861.                 Display.setDisplayMode(Display.getDesktopDisplayMode());
  862.                 displayWidth = Display.getDisplayMode().getWidth();
  863.                 displayHeight = Display.getDisplayMode().getHeight();
  864.                 if(displayWidth <= 0)
  865.                 {
  866.                     displayWidth = 1;
  867.                 }
  868.                 if(displayHeight <= 0)
  869.                 {
  870.                     displayHeight = 1;
  871.                 }
  872.             } else
  873.             {
  874.                 if(mcCanvas != null)
  875.                 {
  876.                     displayWidth = mcCanvas.getWidth();
  877.                     displayHeight = mcCanvas.getHeight();
  878.                 } else
  879.                 {
  880.                     displayWidth = tempDisplayWidth;
  881.                     displayHeight = tempDisplayHeight;
  882.                 }
  883.                 if(displayWidth <= 0)
  884.                 {
  885.                     displayWidth = 1;
  886.                 }
  887.                 if(displayHeight <= 0)
  888.                 {
  889.                     displayHeight = 1;
  890.                 }
  891.             }
  892.             if(currentScreen != null)
  893.             {
  894.                 resize(displayWidth, displayHeight);
  895.             }
  896.             Display.setFullscreen(fullscreen);
  897.             Display.update();
  898.         }
  899.         catch(Exception exception)
  900.         {
  901.             exception.printStackTrace();
  902.         }
  903.     }
  904.  
  905.     private void resize(int i, int j)
  906.     {
  907.         if(i <= 0)
  908.         {
  909.             i = 1;
  910.         }
  911.         if(j <= 0)
  912.         {
  913.             j = 1;
  914.         }
  915.         displayWidth = i;
  916.         displayHeight = j;
  917.         if(currentScreen != null)
  918.         {
  919.             ScaledResolution scaledresolution = new ScaledResolution(gameSettings, i, j);
  920.             int k = scaledresolution.getScaledWidth();
  921.             int l = scaledresolution.getScaledHeight();
  922.             currentScreen.setWorldAndResolution(this, k, l);
  923.         }
  924.     }
  925.  
  926.     private void clickMiddleMouseButton()
  927.     {
  928.         if(objectMouseOver != null)
  929.         {
  930.             int i = theWorld.getBlockId(objectMouseOver.blockX, objectMouseOver.blockY, objectMouseOver.blockZ);
  931.             if(i == Block.grass.blockID)
  932.             {
  933.                 i = Block.dirt.blockID;
  934.             }
  935.             if(i == Block.stairDouble.blockID)
  936.             {
  937.                 i = Block.stairSingle.blockID;
  938.             }
  939.             if(i == Block.bedrock.blockID)
  940.             {
  941.                 i = Block.stone.blockID;
  942.             }
  943.             thePlayer.inventory.setCurrentItem(i, playerController instanceof PlayerControllerTest);
  944.         }
  945.     }
  946.  
  947.     private void func_28001_B()
  948.     {
  949.         (new ThreadCheckHasPaid(this)).start();
  950.     }
  951.  
  952.     public void runTick()
  953.     {
  954.         if(ticksRan == 6000)
  955.         {
  956.             func_28001_B();
  957.         }
  958.         statFileWriter.func_27178_d();
  959.         ingameGUI.updateTick();
  960.         entityRenderer.getMouseOver(1.0F);
  961.         if(thePlayer != null)
  962.         {
  963.             net.minecraft.src.IChunkProvider ichunkprovider = theWorld.getIChunkProvider();
  964.             if(ichunkprovider instanceof ChunkProviderLoadOrGenerate)
  965.             {
  966.                 ChunkProviderLoadOrGenerate chunkproviderloadorgenerate = (ChunkProviderLoadOrGenerate)ichunkprovider;
  967.                 int j = MathHelper.floor_float((int)thePlayer.posX) >> 4;
  968.                 int i1 = MathHelper.floor_float((int)thePlayer.posZ) >> 4;
  969.                 chunkproviderloadorgenerate.setCurrentChunkOver(j, i1);
  970.             }
  971.         }
  972.         if(!isGamePaused && theWorld != null)
  973.         {
  974.             playerController.updateController();
  975.         }
  976.         GL11.glBindTexture(3553 /*GL_TEXTURE_2D*/, renderEngine.getTexture("/terrain.png"));
  977.         if(!isGamePaused)
  978.         {
  979.             renderEngine.updateDynamicTextures();
  980.         }
  981.         if(currentScreen == null && thePlayer != null)
  982.         {
  983.             if(thePlayer.health <= 0)
  984.             {
  985.                 displayGuiScreen(null);
  986.             } else
  987.             if(thePlayer.isPlayerSleeping() && theWorld != null && theWorld.multiplayerWorld)
  988.             {
  989.                 displayGuiScreen(new GuiSleepMP());
  990.             }
  991.         } else
  992.         if(currentScreen != null && (currentScreen instanceof GuiSleepMP) && !thePlayer.isPlayerSleeping())
  993.         {
  994.             displayGuiScreen(null);
  995.         }
  996.         if(currentScreen != null)
  997.         {
  998.             leftClickCounter = 10000;
  999.             mouseTicksRan = ticksRan + 10000;
  1000.         }
  1001.         if(currentScreen != null)
  1002.         {
  1003.             currentScreen.handleInput();
  1004.             if(currentScreen != null)
  1005.             {
  1006.                 currentScreen.field_25091_h.func_25088_a();
  1007.                 currentScreen.updateScreen();
  1008.             }
  1009.         }
  1010.         if(currentScreen == null || currentScreen.field_948_f)
  1011.         {
  1012.             do
  1013.             {
  1014.                 if(!Mouse.next())
  1015.                 {
  1016.                     break;
  1017.                 }
  1018.                 long l = System.currentTimeMillis() - systemTime;
  1019.                 if(l <= 200L)
  1020.                 {
  1021.                     int k = Mouse.getEventDWheel();
  1022.                     if(k != 0)
  1023.                     {
  1024.                         thePlayer.inventory.changeCurrentItem(k);
  1025.                         if(gameSettings.field_22275_C)
  1026.                         {
  1027.                             if(k > 0)
  1028.                             {
  1029.                                 k = 1;
  1030.                             }
  1031.                             if(k < 0)
  1032.                             {
  1033.                                 k = -1;
  1034.                             }
  1035.                             gameSettings.field_22272_F += (float)k * 0.25F;
  1036.                         }
  1037.                     }
  1038.                     if(currentScreen == null)
  1039.                     {
  1040.                         if(!inGameHasFocus && Mouse.getEventButtonState())
  1041.                         {
  1042.                             setIngameFocus();
  1043.                         } else
  1044.                         {
  1045.                             if(Mouse.getEventButton() == 0 && Mouse.getEventButtonState())
  1046.                             {
  1047.                                 clickMouse(0);
  1048.                                 mouseTicksRan = ticksRan;
  1049.                             }
  1050.                             if(Mouse.getEventButton() == 1 && Mouse.getEventButtonState())
  1051.                             {
  1052.                                 clickMouse(1);
  1053.                                 mouseTicksRan = ticksRan;
  1054.                             }
  1055.                             if(Mouse.getEventButton() == 2 && Mouse.getEventButtonState())
  1056.                             {
  1057.                                 clickMiddleMouseButton();
  1058.                                
  1059.                             }
  1060.                         }
  1061.                     } else
  1062.                     if(currentScreen != null)
  1063.                     {
  1064.                         currentScreen.handleMouseInput();
  1065.                     }
  1066.                 }
  1067.             } while(true);
  1068.             if(leftClickCounter > 0)
  1069.             {
  1070.                 leftClickCounter--;
  1071.             }
  1072.             do
  1073.             {
  1074.                 if(!Keyboard.next())
  1075.                 {
  1076.                     break;
  1077.                 }
  1078.                 thePlayer.handleKeyPress(Keyboard.getEventKey(), Keyboard.getEventKeyState());
  1079.                 if(Keyboard.getEventKeyState())
  1080.                 {
  1081.                     if(Keyboard.getEventKey() == 87)
  1082.                     {
  1083.                         toggleFullscreen();
  1084.                     } else
  1085.                     {
  1086.                         if(currentScreen != null)
  1087.                         {
  1088.                             currentScreen.handleKeyboardInput();
  1089.                         } else
  1090.                         {
  1091.                             if(Keyboard.getEventKey() == 1)
  1092.                             {
  1093.                                 displayInGameMenu();
  1094.                             }
  1095.                             if(Keyboard.getEventKey() == 31 && Keyboard.isKeyDown(61))
  1096.                             {
  1097.                                 forceReload();
  1098.                             }
  1099.                             if(Keyboard.getEventKey() == 59)
  1100.                             {
  1101.                                 gameSettings.hideGUI = !gameSettings.hideGUI;
  1102.                             }
  1103.                             if(Keyboard.getEventKey() == 61)
  1104.                             {
  1105.                                 gameSettings.showDebugInfo = !gameSettings.showDebugInfo;
  1106.                             }
  1107.                             if(Keyboard.getEventKey() == gameSettings.keyBindThird.keyCode)
  1108.                             {
  1109.                                 if(gameSettings.thirdPersonView != 2) {
  1110.                                     gameSettings.thirdPersonView++;
  1111.                                 } else {
  1112.                                     gameSettings.thirdPersonView = 0;
  1113.                                 }
  1114.                             }
  1115.                             if(Keyboard.getEventKey() == 66)
  1116.                             {
  1117.                                 gameSettings.smoothCamera = !gameSettings.smoothCamera;
  1118.                             }
  1119.                             if(Keyboard.getEventKey() == gameSettings.keyBindInventory.keyCode)
  1120.                             {
  1121.                                 displayGuiScreen(new GuiInventory(thePlayer));
  1122.                             }
  1123.                             if(Keyboard.getEventKey() == gameSettings.keyBindDrop.keyCode)
  1124.                             {
  1125.                                 thePlayer.dropCurrentItem();
  1126.                             }
  1127.                             if(isMultiplayerWorld() && Keyboard.getEventKey() == gameSettings.keyBindChat.keyCode)
  1128.                             {
  1129.                                 displayGuiScreen(new GuiChat());
  1130.                             }
  1131.                         }
  1132.                         for(int i = 0; i < 9; i++)
  1133.                         {
  1134.                             if(Keyboard.getEventKey() == 2 + i)
  1135.                             {
  1136.                                 thePlayer.inventory.currentItem = i;
  1137.                             }
  1138.                         }
  1139.  
  1140.                         if(Keyboard.getEventKey() == gameSettings.keyBindToggleFog.keyCode)
  1141.                         {
  1142.                             gameSettings.setOptionValue(EnumOptions.RENDER_DISTANCE, !Keyboard.isKeyDown(42) && !Keyboard.isKeyDown(54) ? 1 : -1);
  1143.                         }
  1144.                     }
  1145.                 }
  1146.             } while(true);
  1147.             if(currentScreen == null)
  1148.             {
  1149.                 if(Mouse.isButtonDown(0) && (float)(ticksRan - mouseTicksRan) >= timer.ticksPerSecond / 4F && inGameHasFocus)
  1150.                 {
  1151.                     clickMouse(0);
  1152.                     mouseTicksRan = ticksRan;
  1153.                 }
  1154.                 if(Mouse.isButtonDown(1) && (float)(ticksRan - mouseTicksRan) >= timer.ticksPerSecond / 4F && inGameHasFocus)
  1155.                 {
  1156.                     clickMouse(1);
  1157.                     mouseTicksRan = ticksRan;
  1158.                 }
  1159.                
  1160.                 if(Mouse.isButtonDown(2)) {
  1161.                     if(!gameSettings.smoothCamera) gameSettings.smoothCamera = true;
  1162.                     gameSettings.zooming = true;
  1163.                 } else if(gameSettings.zooming) {
  1164.                    
  1165.                     gameSettings.smoothCamera = false;
  1166.                     gameSettings.zooming = false;
  1167.                    
  1168.                 }
  1169.             }
  1170.             func_6254_a(0, currentScreen == null && Mouse.isButtonDown(0) && inGameHasFocus);
  1171.         }
  1172.         if(theWorld != null)
  1173.         {
  1174.             if(thePlayer != null)
  1175.             {
  1176.                 joinPlayerCounter++;
  1177.                 if(joinPlayerCounter == 30)
  1178.                 {
  1179.                     joinPlayerCounter = 0;
  1180.                     theWorld.joinEntityInSurroundings(thePlayer);
  1181.                 }
  1182.             }
  1183.             theWorld.difficultySetting = gameSettings.difficulty;
  1184.             if(theWorld.multiplayerWorld)
  1185.             {
  1186.                 theWorld.difficultySetting = 3;
  1187.             }
  1188.             if(!isGamePaused)
  1189.             {
  1190.                 entityRenderer.updateRenderer();
  1191.             }
  1192.             if(!isGamePaused)
  1193.             {
  1194.                 renderGlobal.updateClouds();
  1195.             }
  1196.             if(!isGamePaused)
  1197.             {
  1198.                 if(theWorld.field_27172_i > 0)
  1199.                 {
  1200.                     theWorld.field_27172_i--;
  1201.                 }
  1202.                 theWorld.updateEntities();
  1203.             }
  1204.             if(!isGamePaused || isMultiplayerWorld())
  1205.             {
  1206.                 theWorld.setAllowedMobSpawns(gameSettings.difficulty > 0, true);
  1207.                 theWorld.tick();
  1208.             }
  1209.             if(!isGamePaused && theWorld != null)
  1210.             {
  1211.                 theWorld.randomDisplayUpdates(MathHelper.floor_double(thePlayer.posX), MathHelper.floor_double(thePlayer.posY), MathHelper.floor_double(thePlayer.posZ));
  1212.             }
  1213.             if(!isGamePaused)
  1214.             {
  1215.                 effectRenderer.updateEffects();
  1216.             }
  1217.         }
  1218.         systemTime = System.currentTimeMillis();
  1219.     }
  1220.  
  1221.     private void forceReload()
  1222.     {
  1223.         System.out.println("FORCING RELOAD!");
  1224.         sndManager = new SoundManager();
  1225.         sndManager.loadSoundSettings(gameSettings);
  1226.         downloadResourcesThread.reloadResources();
  1227.     }
  1228.  
  1229.     public boolean isMultiplayerWorld()
  1230.     {
  1231.         return theWorld != null && theWorld.multiplayerWorld;
  1232.     }
  1233.  
  1234.     public void startWorld(String s, String s1, long l)
  1235.     {
  1236.         changeWorld1(null);
  1237.         System.gc();
  1238.         if(saveLoader.isOldMapFormat(s))
  1239.         {
  1240.             convertMapFormat(s, s1);
  1241.         } else
  1242.         {
  1243.             net.minecraft.src.ISaveHandler isavehandler = saveLoader.getSaveLoader(s, false);
  1244.             World world = null;
  1245.             world = new World(isavehandler, s1, l);
  1246.             if(world.isNewWorld)
  1247.             {
  1248.                 statFileWriter.readStat(StatList.createWorldStat, 1);
  1249.                 statFileWriter.readStat(StatList.startGameStat, 1);
  1250.                 changeWorld2(world, "Generating level");
  1251.             } else
  1252.             {
  1253.                 statFileWriter.readStat(StatList.loadWorldStat, 1);
  1254.                 statFileWriter.readStat(StatList.startGameStat, 1);
  1255.                 changeWorld2(world, "Loading level");
  1256.             }
  1257.         }
  1258.     }
  1259.  
  1260.     public void usePortal()
  1261.     {
  1262.         System.out.println("Toggling dimension!!");
  1263.         if(thePlayer.dimension == -1)
  1264.         {
  1265.             thePlayer.dimension = 0;
  1266.         } else
  1267.         {
  1268.             thePlayer.dimension = -1;
  1269.         }
  1270.         theWorld.setEntityDead(thePlayer);
  1271.         thePlayer.isDead = false;
  1272.         double d = thePlayer.posX;
  1273.         double d1 = thePlayer.posZ;
  1274.         double d2 = 8D;
  1275.         if(thePlayer.dimension == -1)
  1276.         {
  1277.             d /= d2;
  1278.             d1 /= d2;
  1279.             thePlayer.setLocationAndAngles(d, thePlayer.posY, d1, thePlayer.rotationYaw, thePlayer.rotationPitch);
  1280.             if(thePlayer.isEntityAlive())
  1281.             {
  1282.                 theWorld.updateEntityWithOptionalForce(thePlayer, false);
  1283.             }
  1284.             World world = null;
  1285.             world = new World(theWorld, WorldProvider.getProviderForDimension(-1));
  1286.             changeWorld(world, "Entering the Nether", thePlayer);
  1287.         } else
  1288.         {
  1289.             d *= d2;
  1290.             d1 *= d2;
  1291.             thePlayer.setLocationAndAngles(d, thePlayer.posY, d1, thePlayer.rotationYaw, thePlayer.rotationPitch);
  1292.             if(thePlayer.isEntityAlive())
  1293.             {
  1294.                 theWorld.updateEntityWithOptionalForce(thePlayer, false);
  1295.             }
  1296.             World world1 = null;
  1297.             world1 = new World(theWorld, WorldProvider.getProviderForDimension(0));
  1298.             changeWorld(world1, "Leaving the Nether", thePlayer);
  1299.         }
  1300.         thePlayer.worldObj = theWorld;
  1301.         if(thePlayer.isEntityAlive())
  1302.         {
  1303.             thePlayer.setLocationAndAngles(d, thePlayer.posY, d1, thePlayer.rotationYaw, thePlayer.rotationPitch);
  1304.             theWorld.updateEntityWithOptionalForce(thePlayer, false);
  1305.             (new Teleporter()).func_4107_a(theWorld, thePlayer);
  1306.         }
  1307.     }
  1308.  
  1309.     public void changeWorld1(World world)
  1310.     {
  1311.         changeWorld2(world, "");
  1312.     }
  1313.  
  1314.     public void changeWorld2(World world, String s)
  1315.     {
  1316.         changeWorld(world, s, null);
  1317.     }
  1318.  
  1319.     public void changeWorld(World world, String s, EntityPlayer entityplayer)
  1320.     {
  1321.         statFileWriter.func_27175_b();
  1322.         statFileWriter.syncStats();
  1323.         renderViewEntity = null;
  1324.         loadingScreen.printText(s);
  1325.         loadingScreen.displayLoadingString("");
  1326.         sndManager.playStreaming(null, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F);
  1327.         if(theWorld != null)
  1328.         {
  1329.             theWorld.saveWorldIndirectly(loadingScreen);
  1330.         }
  1331.         theWorld = world;
  1332.         if(world != null)
  1333.         {
  1334.             playerController.func_717_a(world);
  1335.             if(!isMultiplayerWorld())
  1336.             {
  1337.                 if(entityplayer == null)
  1338.                 {
  1339.                     thePlayer = (EntityPlayerSP)world.func_4085_a(net.minecraft.src.EntityPlayerSP.class);
  1340.                 }
  1341.             } else
  1342.             if(thePlayer != null)
  1343.             {
  1344.                 thePlayer.preparePlayerToSpawn();
  1345.                 if(world != null)
  1346.                 {
  1347.                     world.entityJoinedWorld(thePlayer);
  1348.                 }
  1349.             }
  1350.             if(!world.multiplayerWorld)
  1351.             {
  1352.                 func_6255_d(s);
  1353.             }
  1354.             if(thePlayer == null)
  1355.             {
  1356.                 thePlayer = (EntityPlayerSP)playerController.createPlayer(world);
  1357.                 thePlayer.preparePlayerToSpawn();
  1358.                 playerController.flipPlayer(thePlayer);
  1359.             }
  1360.             thePlayer.movementInput = new MovementInputFromOptions(gameSettings);
  1361.             if(renderGlobal != null)
  1362.             {
  1363.                 renderGlobal.changeWorld(world);
  1364.             }
  1365.             if(effectRenderer != null)
  1366.             {
  1367.                 effectRenderer.clearEffects(world);
  1368.             }
  1369.             playerController.func_6473_b(thePlayer);
  1370.             if(entityplayer != null)
  1371.             {
  1372.                 world.emptyMethod1();
  1373.             }
  1374.             net.minecraft.src.IChunkProvider ichunkprovider = world.getIChunkProvider();
  1375.             if(ichunkprovider instanceof ChunkProviderLoadOrGenerate)
  1376.             {
  1377.                 ChunkProviderLoadOrGenerate chunkproviderloadorgenerate = (ChunkProviderLoadOrGenerate)ichunkprovider;
  1378.                 int i = MathHelper.floor_float((int)thePlayer.posX) >> 4;
  1379.                 int j = MathHelper.floor_float((int)thePlayer.posZ) >> 4;
  1380.                 chunkproviderloadorgenerate.setCurrentChunkOver(i, j);
  1381.             }
  1382.             world.spawnPlayerWithLoadedChunks(thePlayer);
  1383.             if(world.isNewWorld)
  1384.             {
  1385.                 world.saveWorldIndirectly(loadingScreen);
  1386.             }
  1387.             renderViewEntity = thePlayer;
  1388.         } else
  1389.         {
  1390.             thePlayer = null;
  1391.         }
  1392.         System.gc();
  1393.         systemTime = 0L;
  1394.     }
  1395.  
  1396.     private void convertMapFormat(String s, String s1)
  1397.     {
  1398.         loadingScreen.printText((new StringBuilder()).append("Converting World to ").append(saveLoader.func_22178_a()).toString());
  1399.         loadingScreen.displayLoadingString("This may take a while :)");
  1400.         saveLoader.convertMapFormat(s, loadingScreen);
  1401.         startWorld(s, s1, 0L);
  1402.     }
  1403.  
  1404.     private void func_6255_d(String s)
  1405.     {
  1406.         loadingScreen.printText(s);
  1407.         loadingScreen.displayLoadingString("Building terrain");
  1408.         char c = '\200';
  1409.         int i = 0;
  1410.         int j = (c * 2) / 16 + 1;
  1411.         j *= j;
  1412.         net.minecraft.src.IChunkProvider ichunkprovider = theWorld.getIChunkProvider();
  1413.         ChunkCoordinates chunkcoordinates = theWorld.getSpawnPoint();
  1414.         if(thePlayer != null)
  1415.         {
  1416.             chunkcoordinates.x = (int)thePlayer.posX;
  1417.             chunkcoordinates.z = (int)thePlayer.posZ;
  1418.         }
  1419.         if(ichunkprovider instanceof ChunkProviderLoadOrGenerate)
  1420.         {
  1421.             ChunkProviderLoadOrGenerate chunkproviderloadorgenerate = (ChunkProviderLoadOrGenerate)ichunkprovider;
  1422.             chunkproviderloadorgenerate.setCurrentChunkOver(chunkcoordinates.x >> 4, chunkcoordinates.z >> 4);
  1423.         }
  1424.         for(int k = -c; k <= c; k += 16)
  1425.         {
  1426.             for(int l = -c; l <= c; l += 16)
  1427.             {
  1428.                 loadingScreen.setLoadingProgress((i++ * 100) / j);
  1429.                 theWorld.getBlockId(chunkcoordinates.x + k, 64, chunkcoordinates.z + l);
  1430.                 while(theWorld.updatingLighting()) ;
  1431.             }
  1432.  
  1433.         }
  1434.  
  1435.         loadingScreen.displayLoadingString("Simulating world for a bit");
  1436.         j = 2000;
  1437.         theWorld.func_656_j();
  1438.     }
  1439.  
  1440.     public void installResource(String s, File file)
  1441.     {
  1442.         int i = s.indexOf("/");
  1443.         String s1 = s.substring(0, i);
  1444.         s = s.substring(i + 1);
  1445.         if(s1.equalsIgnoreCase("sound"))
  1446.         {
  1447.             sndManager.addSound(s, file);
  1448.         } else
  1449.         if(s1.equalsIgnoreCase("newsound"))
  1450.         {
  1451.             sndManager.addSound(s, file);
  1452.         } else
  1453.         if(s1.equalsIgnoreCase("streaming"))
  1454.         {
  1455.             sndManager.addStreaming(s, file);
  1456.         } else
  1457.         if(s1.equalsIgnoreCase("music"))
  1458.         {
  1459.             sndManager.addMusic(s, file);
  1460.         } else
  1461.         if(s1.equalsIgnoreCase("newmusic"))
  1462.         {
  1463.             sndManager.addMusic(s, file);
  1464.         }
  1465.     }
  1466.  
  1467.     public OpenGlCapsChecker getOpenGlCapsChecker()
  1468.     {
  1469.         return glCapabilities;
  1470.     }
  1471.  
  1472.     public String func_6241_m()
  1473.     {
  1474.         return renderGlobal.getDebugInfoRenders();
  1475.     }
  1476.  
  1477.     public String func_6262_n()
  1478.     {
  1479.         return renderGlobal.getDebugInfoEntities();
  1480.     }
  1481.  
  1482.     public String func_21002_o()
  1483.     {
  1484.         return theWorld.func_21119_g();
  1485.     }
  1486.  
  1487.     public String func_6245_o()
  1488.     {
  1489.         return (new StringBuilder()).append("P: ").append(effectRenderer.getStatistics()).append(". T: ").append(theWorld.func_687_d()).toString();
  1490.     }
  1491.  
  1492.     public void respawn(boolean flag, int i)
  1493.     {
  1494.         if(!theWorld.multiplayerWorld && !theWorld.worldProvider.canRespawnHere())
  1495.         {
  1496.             usePortal();
  1497.         }
  1498.         ChunkCoordinates chunkcoordinates = null;
  1499.         ChunkCoordinates chunkcoordinates1 = null;
  1500.         boolean flag1 = true;
  1501.         if(thePlayer != null && !flag)
  1502.         {
  1503.             chunkcoordinates = thePlayer.getPlayerSpawnCoordinate();
  1504.             if(chunkcoordinates != null)
  1505.             {
  1506.                 chunkcoordinates1 = EntityPlayer.func_25060_a(theWorld, chunkcoordinates);
  1507.                 if(chunkcoordinates1 == null)
  1508.                 {
  1509.                     thePlayer.addChatMessage("tile.bed.notValid");
  1510.                 }
  1511.             }
  1512.         }
  1513.         if(chunkcoordinates1 == null)
  1514.         {
  1515.             chunkcoordinates1 = theWorld.getSpawnPoint();
  1516.             flag1 = false;
  1517.         }
  1518.         net.minecraft.src.IChunkProvider ichunkprovider = theWorld.getIChunkProvider();
  1519.         if(ichunkprovider instanceof ChunkProviderLoadOrGenerate)
  1520.         {
  1521.             ChunkProviderLoadOrGenerate chunkproviderloadorgenerate = (ChunkProviderLoadOrGenerate)ichunkprovider;
  1522.             chunkproviderloadorgenerate.setCurrentChunkOver(chunkcoordinates1.x >> 4, chunkcoordinates1.z >> 4);
  1523.         }
  1524.         theWorld.setSpawnLocation();
  1525.         theWorld.updateEntityList();
  1526.         int j = 0;
  1527.         if(thePlayer != null)
  1528.         {
  1529.             j = thePlayer.entityId;
  1530.             theWorld.setEntityDead(thePlayer);
  1531.         }
  1532.         renderViewEntity = null;
  1533.         thePlayer = (EntityPlayerSP)playerController.createPlayer(theWorld);
  1534.         thePlayer.dimension = i;
  1535.         renderViewEntity = thePlayer;
  1536.         thePlayer.preparePlayerToSpawn();
  1537.         if(flag1)
  1538.         {
  1539.             thePlayer.setPlayerSpawnCoordinate(chunkcoordinates);
  1540.             thePlayer.setLocationAndAngles((float)chunkcoordinates1.x + 0.5F, (float)chunkcoordinates1.y + 0.1F, (float)chunkcoordinates1.z + 0.5F, 0.0F, 0.0F);
  1541.         }
  1542.         playerController.flipPlayer(thePlayer);
  1543.         theWorld.spawnPlayerWithLoadedChunks(thePlayer);
  1544.         thePlayer.movementInput = new MovementInputFromOptions(gameSettings);
  1545.         thePlayer.entityId = j;
  1546.         thePlayer.func_6420_o();
  1547.         playerController.func_6473_b(thePlayer);
  1548.         func_6255_d("Respawning");
  1549.         if(currentScreen instanceof GuiGameOver)
  1550.         {
  1551.             displayGuiScreen(null);
  1552.         }
  1553.     }
  1554.  
  1555.     public static void func_6269_a(String s, String s1)
  1556.     {
  1557.         startMainThread(s, s1, null);
  1558.     }
  1559.  
  1560.     public static void startMainThread(String s, String s1, String s2)
  1561.     {
  1562.         boolean flag = false;
  1563.         String s3 = s;
  1564.         Frame frame = new Frame("Minecraft");
  1565.         Canvas canvas = new Canvas();
  1566.         frame.setLayout(new BorderLayout());
  1567.         frame.add(canvas, "Center");
  1568.         canvas.setPreferredSize(new Dimension(854, 480));
  1569.         frame.pack();
  1570.         frame.setLocationRelativeTo(null);
  1571.         MinecraftImpl minecraftimpl = new MinecraftImpl(frame, canvas, null, 854, 480, flag, frame);
  1572.         Thread thread = new Thread(minecraftimpl, "Minecraft main thread");
  1573.         thread.setPriority(10);
  1574.         minecraftimpl.minecraftUri = "www.minecraft.net";
  1575.         if(s3 != null && s1 != null)
  1576.         {
  1577.             minecraftimpl.session = new Session(s3, s1);
  1578.         } else
  1579.         {
  1580.             minecraftimpl.session = new Session((new StringBuilder()).append("Player").append(System.currentTimeMillis() % 1000L).toString(), "");
  1581.         }
  1582.         if(s2 != null)
  1583.         {
  1584.             String as[] = s2.split(":");
  1585.             minecraftimpl.setServer(as[0], Integer.parseInt(as[1]));
  1586.         }
  1587.         frame.setVisible(true);
  1588.         frame.addWindowListener(new GameWindowListener(minecraftimpl, thread));
  1589.         thread.start();
  1590.     }
  1591.  
  1592.     public NetClientHandler getSendQueue()
  1593.     {
  1594.         if(thePlayer instanceof EntityClientPlayerMP)
  1595.         {
  1596.             return ((EntityClientPlayerMP)thePlayer).sendQueue;
  1597.         } else
  1598.         {
  1599.             return null;
  1600.         }
  1601.     }
  1602.  
  1603.     public static void main(String args[])
  1604.     {
  1605.         String s = null;
  1606.         String s1 = null;
  1607.         s = (new StringBuilder()).append("Player").append(System.currentTimeMillis() % 1000L).toString();
  1608.         if(args.length > 0)
  1609.         {
  1610.             s = args[0];
  1611.         }
  1612.         s1 = "-";
  1613.         if(args.length > 1)
  1614.         {
  1615.             s1 = args[1];
  1616.         }
  1617.         func_6269_a(s, s1);
  1618.     }
  1619.  
  1620.     public static boolean isGuiEnabled()
  1621.     {
  1622.         return theMinecraft == null || !theMinecraft.gameSettings.hideGUI;
  1623.     }
  1624.  
  1625.     public static boolean isFancyGraphicsEnabled()
  1626.     {
  1627.         return theMinecraft != null && theMinecraft.gameSettings.fancyGraphics;
  1628.     }
  1629.  
  1630.     public static boolean isAmbientOcclusionEnabled()
  1631.     {
  1632.         return theMinecraft != null && theMinecraft.gameSettings.ambientOcclusion;
  1633.     }
  1634.  
  1635.     public static boolean isDebugInfoEnabled()
  1636.     {
  1637.         return theMinecraft != null && theMinecraft.gameSettings.showDebugInfo;
  1638.     }
  1639.  
  1640.     public boolean lineIsCommand(String s)
  1641.     {
  1642.         if(!s.startsWith("/"));
  1643.         return false;
  1644.     }
  1645.  
  1646.     public static byte field_28006_b[] = new byte[0xa00000];
  1647.     private static Minecraft theMinecraft;
  1648.     public PlayerController playerController;
  1649.     private boolean fullscreen;
  1650.     private boolean hasCrashed;
  1651.     public int displayWidth;
  1652.     public int displayHeight;
  1653.     private OpenGlCapsChecker glCapabilities;
  1654.     private Timer timer;
  1655.     public World theWorld;
  1656.     public RenderGlobal renderGlobal;
  1657.     public EntityPlayerSP thePlayer;
  1658.     public EntityLiving renderViewEntity;
  1659.     public EffectRenderer effectRenderer;
  1660.     public Session session;
  1661.     public String minecraftUri;
  1662.     public Canvas mcCanvas;
  1663.     public boolean hideQuitButton;
  1664.     public volatile boolean isGamePaused;
  1665.     public RenderEngine renderEngine;
  1666.     public FontRenderer fontRenderer;
  1667.     public GuiScreen currentScreen;
  1668.     public LoadingScreenRenderer loadingScreen;
  1669.     public EntityRenderer entityRenderer;
  1670.     private ThreadDownloadResources downloadResourcesThread;
  1671.     private int ticksRan;
  1672.     private int leftClickCounter;
  1673.     private int tempDisplayWidth;
  1674.     private int tempDisplayHeight;
  1675.     public GuiAchievement guiAchievement;
  1676.     public GuiIngame ingameGUI;
  1677.     public boolean skipRenderWorld;
  1678.     public ModelBiped field_9242_w;
  1679.     public MovingObjectPosition objectMouseOver;
  1680.     public GameSettings gameSettings;
  1681.     protected MinecraftApplet mcApplet;
  1682.     public SoundManager sndManager;
  1683.     public MouseHelper mouseHelper;
  1684.     public TexturePackList texturePackList;
  1685.     private File mcDataDir;
  1686.     private ISaveFormat saveLoader;
  1687.     public static long frameTimes[] = new long[512];
  1688.     public static long tickTimes[] = new long[512];
  1689.     public static int numRecordedFrameTimes = 0;
  1690.     public static long hasPaidCheckTime = 0L;
  1691.     public StatFileWriter statFileWriter;
  1692.     private String serverName;
  1693.     private int serverPort;
  1694.     private TextureWaterFX textureWaterFX;
  1695.     private TextureLavaFX textureLavaFX;
  1696.     private static File minecraftDir = null;
  1697.     public volatile boolean running;
  1698.     public String debug;
  1699.     boolean isTakingScreenshot;
  1700.     long prevFrameTime;
  1701.     public boolean inGameHasFocus;
  1702.     private int mouseTicksRan;
  1703.     public boolean isRaining;
  1704.     long systemTime;
  1705.     private int joinPlayerCounter;
  1706.  
  1707. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement