Beispiel #1
0
 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();
 }
Beispiel #2
0
 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();
 }
Beispiel #3
0
 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");
     }
   }
 }
Beispiel #4
0
  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();
    }
  }
Beispiel #5
0
 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;
 }