public void shutdownMinecraftApplet() { try { statFileWriter.func_27175_b(); statFileWriter.syncStats(); if (mcApplet != null) { mcApplet.clearApplet(); } try { if (downloadResourcesThread != null) { downloadResourcesThread.closeMinecraft(); } } catch (Exception exception) { } System.out.println("Stopping!"); try { changeWorld1(null); } catch (Throwable throwable) { } try { GLAllocation.deleteTexturesAndDisplayLists(); } catch (Throwable throwable1) { } sndManager.closeMinecraft(); Mouse.destroy(); Keyboard.destroy(); } finally { Display.destroy(); if (!hasCrashed) { System.exit(0); } } System.gc(); }
public void runTick() { if (ticksRan == 6000) { func_28001_B(); } statFileWriter.func_27178_d(); ingameGUI.updateTick(); entityRenderer.getMouseOver(1.0F); if (thePlayer != null) { net.minecraft.src.IChunkProvider ichunkprovider = theWorld.getIChunkProvider(); if (ichunkprovider instanceof ChunkProviderLoadOrGenerate) { ChunkProviderLoadOrGenerate chunkproviderloadorgenerate = (ChunkProviderLoadOrGenerate) ichunkprovider; int j = MathHelper.floor_float((int) thePlayer.posX) >> 4; int i1 = MathHelper.floor_float((int) thePlayer.posZ) >> 4; chunkproviderloadorgenerate.setCurrentChunkOver(j, i1); } } if (!isGamePaused && theWorld != null) { playerController.updateController(); } GL11.glBindTexture(3553 /*GL_TEXTURE_2D*/, renderEngine.getTexture("/terrain.png")); if (!isGamePaused) { renderEngine.updateDynamicTextures(); } if (currentScreen == null && thePlayer != null) { if (thePlayer.health <= 0) { displayGuiScreen(null); } else if (thePlayer.isPlayerSleeping() && theWorld != null && theWorld.multiplayerWorld) { displayGuiScreen(new GuiSleepMP()); } } else if (currentScreen != null && (currentScreen instanceof GuiSleepMP) && !thePlayer.isPlayerSleeping()) { displayGuiScreen(null); } if (currentScreen != null) { leftClickCounter = 10000; mouseTicksRan = ticksRan + 10000; } if (currentScreen != null) { currentScreen.handleInput(); if (currentScreen != null) { currentScreen.field_25091_h.func_25088_a(); currentScreen.updateScreen(); } } if (currentScreen == null || currentScreen.field_948_f) { do { if (!Mouse.next()) { break; } long l = System.currentTimeMillis() - systemTime; if (l <= 200L) { int k = Mouse.getEventDWheel(); if (k != 0) { thePlayer.inventory.changeCurrentItem(k); if (gameSettings.field_22275_C) { if (k > 0) { k = 1; } if (k < 0) { k = -1; } gameSettings.field_22272_F += (float) k * 0.25F; } } if (currentScreen == null) { if (!inGameHasFocus && Mouse.getEventButtonState()) { setIngameFocus(); } else { if (Mouse.getEventButton() == 0 && Mouse.getEventButtonState()) { clickMouse(0); mouseTicksRan = ticksRan; } if (Mouse.getEventButton() == 1 && Mouse.getEventButtonState()) { clickMouse(1); mouseTicksRan = ticksRan; } if (Mouse.getEventButton() == 2 && Mouse.getEventButtonState()) { clickMiddleMouseButton(); } } } else if (currentScreen != null) { currentScreen.handleMouseInput(); } } } while (true); if (leftClickCounter > 0) { leftClickCounter--; } do { if (!Keyboard.next()) { break; } thePlayer.handleKeyPress(Keyboard.getEventKey(), Keyboard.getEventKeyState()); if (Keyboard.getEventKeyState()) { if (Keyboard.getEventKey() == 87) { toggleFullscreen(); } else { if (currentScreen != null) { currentScreen.handleKeyboardInput(); } else { if (Keyboard.getEventKey() == 1) { displayInGameMenu(); } if (Keyboard.getEventKey() == 31 && Keyboard.isKeyDown(61)) { forceReload(); } if (Keyboard.getEventKey() == 59) { gameSettings.hideGUI = !gameSettings.hideGUI; } if (Keyboard.getEventKey() == 61) { gameSettings.showDebugInfo = !gameSettings.showDebugInfo; } if (Keyboard.getEventKey() == 63) { gameSettings.thirdPersonView = !gameSettings.thirdPersonView; } if (Keyboard.getEventKey() == 66) { gameSettings.smoothCamera = !gameSettings.smoothCamera; } if (Keyboard.getEventKey() == gameSettings.keyBindInventory.keyCode) { displayGuiScreen(new GuiInventory(thePlayer)); } if (Keyboard.getEventKey() == gameSettings.keyBindDrop.keyCode) { thePlayer.dropCurrentItem(); } if (isMultiplayerWorld() && Keyboard.getEventKey() == gameSettings.keyBindChat.keyCode) { displayGuiScreen(new GuiChat()); } } for (int i = 0; i < 9; i++) { if (Keyboard.getEventKey() == 2 + i) { thePlayer.inventory.currentItem = i; } } if (Keyboard.getEventKey() == gameSettings.keyBindToggleFog.keyCode) { gameSettings.setOptionValue( EnumOptions.RENDER_DISTANCE, !Keyboard.isKeyDown(42) && !Keyboard.isKeyDown(54) ? 1 : -1); } } } } while (true); if (currentScreen == null) { if (Mouse.isButtonDown(0) && (float) (ticksRan - mouseTicksRan) >= timer.ticksPerSecond / 4F && inGameHasFocus) { clickMouse(0); mouseTicksRan = ticksRan; } if (Mouse.isButtonDown(1) && (float) (ticksRan - mouseTicksRan) >= timer.ticksPerSecond / 4F && inGameHasFocus) { clickMouse(1); mouseTicksRan = ticksRan; } } func_6254_a(0, currentScreen == null && Mouse.isButtonDown(0) && inGameHasFocus); } if (theWorld != null) { if (thePlayer != null) { joinPlayerCounter++; if (joinPlayerCounter == 30) { joinPlayerCounter = 0; theWorld.joinEntityInSurroundings(thePlayer); } } theWorld.difficultySetting = gameSettings.difficulty; if (theWorld.multiplayerWorld) { theWorld.difficultySetting = 3; } if (!isGamePaused) { entityRenderer.updateRenderer(); } if (!isGamePaused) { renderGlobal.updateClouds(); } if (!isGamePaused) { if (theWorld.field_27172_i > 0) { theWorld.field_27172_i--; } theWorld.updateEntities(); } if (!isGamePaused || isMultiplayerWorld()) { theWorld.setAllowedMobSpawns(gameSettings.difficulty > 0, true); theWorld.tick(); } if (!isGamePaused && theWorld != null) { theWorld.randomDisplayUpdates( MathHelper.floor_double(thePlayer.posX), MathHelper.floor_double(thePlayer.posY), MathHelper.floor_double(thePlayer.posZ)); } if (!isGamePaused) { effectRenderer.updateEffects(); } } systemTime = System.currentTimeMillis(); }
public void startGame() throws LWJGLException { if (mcCanvas != null) { Graphics g = mcCanvas.getGraphics(); if (g != null) { g.setColor(Color.BLACK); g.fillRect(0, 0, displayWidth, displayHeight); g.dispose(); } Display.setParent(mcCanvas); } else if (fullscreen) { Display.setFullscreen(true); displayWidth = Display.getDisplayMode().getWidth(); displayHeight = Display.getDisplayMode().getHeight(); if (displayWidth <= 0) { displayWidth = 1; } if (displayHeight <= 0) { displayHeight = 1; } } else { Display.setDisplayMode(new DisplayMode(displayWidth, displayHeight)); } Display.setTitle("Minecraft Minecraft Beta 1.7.3"); try { Display.create(); } catch (LWJGLException lwjglexception) { lwjglexception.printStackTrace(); try { Thread.sleep(1000L); } catch (InterruptedException interruptedexception) { } Display.create(); } mcDataDir = getMinecraftDir(); saveLoader = new SaveConverterMcRegion(new File(mcDataDir, "saves")); gameSettings = new GameSettings(this, mcDataDir); texturePackList = new TexturePackList(this, mcDataDir); renderEngine = new RenderEngine(texturePackList, gameSettings); fontRenderer = new FontRenderer(gameSettings, "/font/default.png", renderEngine); ColorizerWater.func_28182_a(renderEngine.func_28149_a("/misc/watercolor.png")); ColorizerGrass.func_28181_a(renderEngine.func_28149_a("/misc/grasscolor.png")); ColorizerFoliage.func_28152_a(renderEngine.func_28149_a("/misc/foliagecolor.png")); entityRenderer = new EntityRenderer(this); RenderManager.instance.itemRenderer = new ItemRenderer(this); statFileWriter = new StatFileWriter(session, mcDataDir); AchievementList.openInventory.setStatStringFormatter(new StatStringFormatKeyInv(this)); loadScreen(); Keyboard.create(); Mouse.create(); mouseHelper = new MouseHelper(mcCanvas); try { Controllers.create(); } catch (Exception exception) { exception.printStackTrace(); } checkGLError("Pre startup"); GL11.glEnable(3553 /*GL_TEXTURE_2D*/); GL11.glShadeModel(7425 /*GL_SMOOTH*/); GL11.glClearDepth(1.0D); GL11.glEnable(2929 /*GL_DEPTH_TEST*/); GL11.glDepthFunc(515); GL11.glEnable(3008 /*GL_ALPHA_TEST*/); GL11.glAlphaFunc(516, 0.1F); GL11.glCullFace(1029 /*GL_BACK*/); GL11.glMatrixMode(5889 /*GL_PROJECTION*/); GL11.glLoadIdentity(); GL11.glMatrixMode(5888 /*GL_MODELVIEW0_ARB*/); checkGLError("Startup"); glCapabilities = new OpenGlCapsChecker(); sndManager.loadSoundSettings(gameSettings); renderEngine.registerTextureFX(textureLavaFX); renderEngine.registerTextureFX(textureWaterFX); renderEngine.registerTextureFX(new TexturePortalFX()); renderEngine.registerTextureFX(new TextureCompassFX(this)); renderEngine.registerTextureFX(new TextureWatchFX(this)); renderEngine.registerTextureFX(new TextureWaterFlowFX()); renderEngine.registerTextureFX(new TextureLavaFlowFX()); renderEngine.registerTextureFX(new TextureFlamesFX(0)); renderEngine.registerTextureFX(new TextureFlamesFX(1)); renderGlobal = new RenderGlobal(this, renderEngine); GL11.glViewport(0, 0, displayWidth, displayHeight); effectRenderer = new EffectRenderer(theWorld, renderEngine); try { downloadResourcesThread = new ThreadDownloadResources(mcDataDir, this); downloadResourcesThread.start(); } catch (Exception exception1) { } checkGLError("Post startup"); ingameGUI = new GuiIngame(this); if (serverName != null) { displayGuiScreen(new GuiConnecting(this, serverName, serverPort)); } else { displayGuiScreen(new GuiMainMenu()); } }