Пример #1
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();
  }
Пример #2
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;
 }