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 static void startMainThread(String s, String s1, String s2) { boolean flag = false; String s3 = s; Frame frame = new Frame("Minecraft"); Canvas canvas = new Canvas(); frame.setLayout(new BorderLayout()); frame.add(canvas, "Center"); canvas.setPreferredSize(new Dimension(854, 480)); frame.pack(); frame.setLocationRelativeTo(null); MinecraftImpl minecraftimpl = new MinecraftImpl(frame, canvas, null, 854, 480, flag, frame); Thread thread = new Thread(minecraftimpl, "Minecraft main thread"); thread.setPriority(10); minecraftimpl.minecraftUri = "www.minecraft.net"; if (s3 != null && s1 != null) { minecraftimpl.session = new Session(s3, s1); } else { minecraftimpl.session = new Session( (new StringBuilder()) .append("Player") .append(System.currentTimeMillis() % 1000L) .toString(), ""); } if (s2 != null) { String as[] = s2.split(":"); minecraftimpl.setServer(as[0], Integer.parseInt(as[1])); } frame.setVisible(true); frame.addWindowListener(new GameWindowListener(minecraftimpl, thread)); thread.start(); }
private void initLoader() { if (loaderStartupDone) return; loaderStartupDone = true; // Set up base class overrides prepareClassOverrides(); // Set up loader, initialises any reflection methods needed if (prepareLoader()) { logger.info("LiteLoader " + LOADER_VERSION + " starting up..."); logger.info( String.format("Java reports OS=\"%s\"", System.getProperty("os.name").toLowerCase())); // Examines the class path and mods folder and locates loadable mods prepareMods(); // Initialises enumerated mods initMods(); // Initialises the required hooks for loaded mods initHooks(); loaderStartupComplete = true; } }
public void func_28002_e() { try { field_28006_b = new byte[0]; renderGlobal.func_28137_f(); } catch (Throwable throwable) { } try { System.gc(); AxisAlignedBB.func_28196_a(); Vec3D.func_28215_a(); } catch (Throwable throwable1) { } try { System.gc(); changeWorld1(null); } catch (Throwable throwable2) { } System.gc(); }
public static File getAppDir(String s) { String s1 = System.getProperty("user.home", "."); File file; switch (EnumOSMappingHelper.enumOSMappingArray[getOs().ordinal()]) { case 1: // '\001' case 2: // '\002' file = new File(s1, (new StringBuilder()).append('.').append(s).append('/').toString()); break; case 3: // '\003' String s2 = System.getenv("APPDATA"); if (s2 != null) { file = new File(s2, (new StringBuilder()).append(".").append(s).append('/').toString()); } else { file = new File(s1, (new StringBuilder()).append('.').append(s).append('/').toString()); } break; case 4: // '\004' file = new File( s1, (new StringBuilder()).append("Library/Application Support/").append(s).toString()); break; default: file = new File(s1, (new StringBuilder()).append(s).append('/').toString()); break; } if (!file.exists() && !file.mkdirs()) { throw new RuntimeException( (new StringBuilder()) .append("The working directory could not be created: ") .append(file) .toString()); } else { return file; } }
/** Enumerate the java class path and "mods" folder to find mod classes, then load the classes */ private void prepareMods() { // List of mod files in the "mods" folder LinkedList<File> modFiles = new LinkedList<File>(); // Find and enumerate the "mods" folder File modFolder = getModsFolder(); if (modFolder.exists() && modFolder.isDirectory()) { logger.info("Mods folder found, searching " + modFolder.getPath()); findModFiles(modFolder, modFiles); logger.info("Found " + modFiles.size() + " mod file(s)"); } // Find and enumerate classes on the class path HashMap<String, Class> modsToLoad = null; try { logger.info("Enumerating class path..."); String classPath = System.getProperty("java.class.path"); String classPathSeparator = System.getProperty("path.separator"); String[] classPathEntries = classPath.split(classPathSeparator); logger.info(String.format("Class path separator=\"%s\"", classPathSeparator)); logger.info( String.format( "Class path entries=(\n classpathEntry=%s\n)", classPath.replace(classPathSeparator, "\n classpathEntry="))); logger.info("Loading mods from class path..."); modsToLoad = findModClasses(classPathEntries, modFiles); logger.info("Mod class discovery completed"); } catch (Throwable th) { logger.log(Level.WARNING, "Mod class discovery failed", th); return; } loadMods(modsToLoad); }
public Minecraft( Component component, Canvas canvas, MinecraftApplet minecraftapplet, int i, int j, boolean flag) { fullscreen = false; hasCrashed = false; timer = new Timer(20F); session = null; hideQuitButton = true; isGamePaused = false; currentScreen = null; loadingScreen = new LoadingScreenRenderer(this); ticksRan = 0; leftClickCounter = 0; guiAchievement = new GuiAchievement(this); skipRenderWorld = false; field_9242_w = new ModelBiped(0.0F); objectMouseOver = null; sndManager = new SoundManager(); textureWaterFX = new TextureWaterFX(); textureLavaFX = new TextureLavaFX(); running = true; debug = ""; isTakingScreenshot = false; prevFrameTime = -1L; inGameHasFocus = false; mouseTicksRan = 0; isRaining = false; systemTime = System.currentTimeMillis(); joinPlayerCounter = 0; StatList.func_27360_a(); tempDisplayHeight = j; fullscreen = flag; mcApplet = minecraftapplet; new ThreadSleepForever(this, "Timer hack thread"); mcCanvas = canvas; displayWidth = i; displayHeight = j; fullscreen = flag; if (minecraftapplet == null || "true".equals(minecraftapplet.getParameter("stand-alone"))) { hideQuitButton = false; } theMinecraft = this; }
public static void main(String args[]) { String s = null; String s1 = null; s = (new StringBuilder()) .append("Player") .append(System.currentTimeMillis() % 1000L) .toString(); if (args.length > 0) { s = args[0]; } s1 = "-"; if (args.length > 1) { s1 = args[1]; } func_6269_a(s, s1); }
public void startWorld(String s, String s1, long l) { changeWorld1(null); System.gc(); if (saveLoader.isOldMapFormat(s)) { convertMapFormat(s, s1); } else { net.minecraft.src.ISaveHandler isavehandler = saveLoader.getSaveLoader(s, false); World world = null; world = new World(isavehandler, s1, l); if (world.isNewWorld) { statFileWriter.readStat(StatList.createWorldStat, 1); statFileWriter.readStat(StatList.startGameStat, 1); changeWorld2(world, "Generating level"); } else { statFileWriter.readStat(StatList.loadWorldStat, 1); statFileWriter.readStat(StatList.startGameStat, 1); changeWorld2(world, "Loading level"); } } }
private static EnumOS2 getOs() { String s = System.getProperty("os.name").toLowerCase(); if (s.contains("win")) { return EnumOS2.windows; } if (s.contains("mac")) { return EnumOS2.macos; } if (s.contains("solaris")) { return EnumOS2.solaris; } if (s.contains("sunos")) { return EnumOS2.solaris; } if (s.contains("linux")) { return EnumOS2.linux; } if (s.contains("unix")) { return EnumOS2.linux; } else { return EnumOS2.unknown; } }
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(); }
private void displayDebugInfo(long l) { long l1 = 0xfe502aL; if (prevFrameTime == -1L) { prevFrameTime = System.nanoTime(); } long l2 = System.nanoTime(); tickTimes[numRecordedFrameTimes & frameTimes.length - 1] = l; frameTimes[numRecordedFrameTimes++ & frameTimes.length - 1] = l2 - prevFrameTime; prevFrameTime = l2; GL11.glClear(256); GL11.glMatrixMode(5889 /*GL_PROJECTION*/); GL11.glLoadIdentity(); GL11.glOrtho(0.0D, displayWidth, displayHeight, 0.0D, 1000D, 3000D); GL11.glMatrixMode(5888 /*GL_MODELVIEW0_ARB*/); GL11.glLoadIdentity(); GL11.glTranslatef(0.0F, 0.0F, -2000F); GL11.glLineWidth(1.0F); GL11.glDisable(3553 /*GL_TEXTURE_2D*/); Tessellator tessellator = Tessellator.instance; tessellator.startDrawing(7); int i = (int) (l1 / 0x30d40L); tessellator.setColorOpaque_I(0x20000000); tessellator.addVertex(0.0D, displayHeight - i, 0.0D); tessellator.addVertex(0.0D, displayHeight, 0.0D); tessellator.addVertex(frameTimes.length, displayHeight, 0.0D); tessellator.addVertex(frameTimes.length, displayHeight - i, 0.0D); tessellator.setColorOpaque_I(0x20200000); tessellator.addVertex(0.0D, displayHeight - i * 2, 0.0D); tessellator.addVertex(0.0D, displayHeight - i, 0.0D); tessellator.addVertex(frameTimes.length, displayHeight - i, 0.0D); tessellator.addVertex(frameTimes.length, displayHeight - i * 2, 0.0D); tessellator.draw(); long l3 = 0L; for (int j = 0; j < frameTimes.length; j++) { l3 += frameTimes[j]; } int k = (int) (l3 / 0x30d40L / (long) frameTimes.length); tessellator.startDrawing(7); tessellator.setColorOpaque_I(0x20400000); tessellator.addVertex(0.0D, displayHeight - k, 0.0D); tessellator.addVertex(0.0D, displayHeight, 0.0D); tessellator.addVertex(frameTimes.length, displayHeight, 0.0D); tessellator.addVertex(frameTimes.length, displayHeight - k, 0.0D); tessellator.draw(); tessellator.startDrawing(1); for (int i1 = 0; i1 < frameTimes.length; i1++) { int j1 = ((i1 - numRecordedFrameTimes & frameTimes.length - 1) * 255) / frameTimes.length; int k1 = (j1 * j1) / 255; k1 = (k1 * k1) / 255; int i2 = (k1 * k1) / 255; i2 = (i2 * i2) / 255; if (frameTimes[i1] > l1) { tessellator.setColorOpaque_I(0xff000000 + k1 * 0x10000); } else { tessellator.setColorOpaque_I(0xff000000 + k1 * 256); } long l4 = frameTimes[i1] / 0x30d40L; long l5 = tickTimes[i1] / 0x30d40L; tessellator.addVertex((float) i1 + 0.5F, (float) ((long) displayHeight - l4) + 0.5F, 0.0D); tessellator.addVertex((float) i1 + 0.5F, (float) displayHeight + 0.5F, 0.0D); tessellator.setColorOpaque_I(0xff000000 + k1 * 0x10000 + k1 * 256 + k1 * 1); tessellator.addVertex((float) i1 + 0.5F, (float) ((long) displayHeight - l4) + 0.5F, 0.0D); tessellator.addVertex( (float) i1 + 0.5F, (float) ((long) displayHeight - (l4 - l5)) + 0.5F, 0.0D); } tessellator.draw(); GL11.glEnable(3553 /*GL_TEXTURE_2D*/); }
public void run() { running = true; try { startGame(); } catch (Exception exception) { exception.printStackTrace(); onMinecraftCrash(new UnexpectedThrowable("Failed to start game", exception)); return; } try { long l = System.currentTimeMillis(); int i = 0; do { if (!running) { break; } try { if (mcApplet != null && !mcApplet.isActive()) { break; } AxisAlignedBB.clearBoundingBoxPool(); Vec3D.initialize(); if (mcCanvas == null && Display.isCloseRequested()) { shutdown(); } if (isGamePaused && theWorld != null) { float f = timer.renderPartialTicks; timer.updateTimer(); timer.renderPartialTicks = f; } else { timer.updateTimer(); } long l1 = System.nanoTime(); for (int j = 0; j < timer.elapsedTicks; j++) { ticksRan++; try { runTick(); continue; } catch (MinecraftException minecraftexception1) { theWorld = null; } changeWorld1(null); displayGuiScreen(new GuiConflictWarning()); } long l2 = System.nanoTime() - l1; checkGLError("Pre render"); RenderBlocks.fancyGrass = gameSettings.fancyGraphics; sndManager.func_338_a(thePlayer, timer.renderPartialTicks); GL11.glEnable(3553 /*GL_TEXTURE_2D*/); if (theWorld != null) { theWorld.updatingLighting(); } if (!Keyboard.isKeyDown(65)) { Display.update(); } if (thePlayer != null && thePlayer.isEntityInsideOpaqueBlock()) { gameSettings.thirdPersonView = false; } if (!skipRenderWorld) { if (playerController != null) { playerController.setPartialTime(timer.renderPartialTicks); } entityRenderer.updateCameraAndRender(timer.renderPartialTicks); } if (!Display.isActive()) { if (fullscreen) { toggleFullscreen(); } Thread.sleep(10L); } if (gameSettings.showDebugInfo) { displayDebugInfo(l2); } else { prevFrameTime = System.nanoTime(); } guiAchievement.updateAchievementWindow(); Thread.yield(); if (Keyboard.isKeyDown(65)) { Display.update(); } screenshotListener(); if (mcCanvas != null && !fullscreen && (mcCanvas.getWidth() != displayWidth || mcCanvas.getHeight() != displayHeight)) { displayWidth = mcCanvas.getWidth(); displayHeight = mcCanvas.getHeight(); if (displayWidth <= 0) { displayWidth = 1; } if (displayHeight <= 0) { displayHeight = 1; } resize(displayWidth, displayHeight); } checkGLError("Post render"); i++; isGamePaused = !isMultiplayerWorld() && currentScreen != null && currentScreen.doesGuiPauseGame(); while (System.currentTimeMillis() >= l + 1000L) { debug = (new StringBuilder()) .append(i) .append(" fps, ") .append(WorldRenderer.chunksUpdated) .append(" chunk updates") .toString(); WorldRenderer.chunksUpdated = 0; l += 1000L; i = 0; } } catch (MinecraftException minecraftexception) { theWorld = null; changeWorld1(null); displayGuiScreen(new GuiConflictWarning()); } catch (OutOfMemoryError outofmemoryerror) { func_28002_e(); displayGuiScreen(new GuiErrorScreen()); System.gc(); } } while (true); } catch (MinecraftError minecrafterror) { } catch (Throwable throwable) { func_28002_e(); throwable.printStackTrace(); onMinecraftCrash(new UnexpectedThrowable("Unexpected error", throwable)); } finally { shutdownMinecraftApplet(); } }
public void changeWorld(World world, String s, EntityPlayer entityplayer) { statFileWriter.func_27175_b(); statFileWriter.syncStats(); renderViewEntity = null; loadingScreen.printText(s); loadingScreen.displayLoadingString(""); sndManager.playStreaming(null, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F); if (theWorld != null) { theWorld.saveWorldIndirectly(loadingScreen); } theWorld = world; if (world != null) { playerController.func_717_a(world); if (!isMultiplayerWorld()) { if (entityplayer == null) { thePlayer = (EntityPlayerSP) world.func_4085_a(net.minecraft.src.EntityPlayerSP.class); } } else if (thePlayer != null) { thePlayer.preparePlayerToSpawn(); if (world != null) { world.entityJoinedWorld(thePlayer); } } if (!world.multiplayerWorld) { func_6255_d(s); } if (thePlayer == null) { thePlayer = (EntityPlayerSP) playerController.createPlayer(world); thePlayer.preparePlayerToSpawn(); playerController.flipPlayer(thePlayer); } thePlayer.movementInput = new MovementInputFromOptions(gameSettings); if (renderGlobal != null) { renderGlobal.changeWorld(world); } if (effectRenderer != null) { effectRenderer.clearEffects(world); } playerController.func_6473_b(thePlayer); if (entityplayer != null) { world.emptyMethod1(); } net.minecraft.src.IChunkProvider ichunkprovider = world.getIChunkProvider(); if (ichunkprovider instanceof ChunkProviderLoadOrGenerate) { ChunkProviderLoadOrGenerate chunkproviderloadorgenerate = (ChunkProviderLoadOrGenerate) ichunkprovider; int i = MathHelper.floor_float((int) thePlayer.posX) >> 4; int j = MathHelper.floor_float((int) thePlayer.posZ) >> 4; chunkproviderloadorgenerate.setCurrentChunkOver(i, j); } world.spawnPlayerWithLoadedChunks(thePlayer); if (world.isNewWorld) { world.saveWorldIndirectly(loadingScreen); } renderViewEntity = thePlayer; } else { thePlayer = null; } System.gc(); systemTime = 0L; }