Ejemplo n.º 1
0
 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();
 }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 3
0
 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);
 }
Ejemplo n.º 4
0
  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();
  }
Ejemplo n.º 5
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();
    }
  }