Exemple #1
0
 private void loadScreen() throws LWJGLException {
   ScaledResolution scaledresolution =
       new ScaledResolution(gameSettings, displayWidth, displayHeight);
   GL11.glClear(16640);
   GL11.glMatrixMode(5889 /*GL_PROJECTION*/);
   GL11.glLoadIdentity();
   GL11.glOrtho(
       0.0D, scaledresolution.field_25121_a, scaledresolution.field_25120_b, 0.0D, 1000D, 3000D);
   GL11.glMatrixMode(5888 /*GL_MODELVIEW0_ARB*/);
   GL11.glLoadIdentity();
   GL11.glTranslatef(0.0F, 0.0F, -2000F);
   GL11.glViewport(0, 0, displayWidth, displayHeight);
   GL11.glClearColor(0.0F, 0.0F, 0.0F, 0.0F);
   Tessellator tessellator = Tessellator.instance;
   GL11.glDisable(2896 /*GL_LIGHTING*/);
   GL11.glEnable(3553 /*GL_TEXTURE_2D*/);
   GL11.glDisable(2912 /*GL_FOG*/);
   GL11.glBindTexture(3553 /*GL_TEXTURE_2D*/, renderEngine.getTexture("/title/mojang.png"));
   tessellator.startDrawingQuads();
   tessellator.setColorOpaque_I(0xffffff);
   tessellator.addVertexWithUV(0.0D, displayHeight, 0.0D, 0.0D, 0.0D);
   tessellator.addVertexWithUV(displayWidth, displayHeight, 0.0D, 0.0D, 0.0D);
   tessellator.addVertexWithUV(displayWidth, 0.0D, 0.0D, 0.0D, 0.0D);
   tessellator.addVertexWithUV(0.0D, 0.0D, 0.0D, 0.0D, 0.0D);
   tessellator.draw();
   char c = '\u0100';
   char c1 = '\u0100';
   GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
   tessellator.setColorOpaque_I(0xffffff);
   func_6274_a(
       (scaledresolution.getScaledWidth() - c) / 2,
       (scaledresolution.getScaledHeight() - c1) / 2,
       0,
       0,
       c,
       c1);
   GL11.glDisable(2896 /*GL_LIGHTING*/);
   GL11.glDisable(2912 /*GL_FOG*/);
   GL11.glEnable(3008 /*GL_ALPHA_TEST*/);
   GL11.glAlphaFunc(516, 0.1F);
   Display.swapBuffers();
 }
  protected void drawGuiContainerForegroundLayer(int par1, int par2) {
    GL11.glDisable(GL11.GL_LIGHTING);
    int xSize = this.xSize;
    int ySize = this.ySize;
    if (!inverted) {
      fontRendererObj.drawString(
          blockName, xSize / 2 - fontRendererObj.getStringWidth(blockName) / 2 + 1, 5, 4210752);
      fontRendererObj.drawString(I18n.format("container.inventory"), 6, ySize - 96 + 2, 4210752);

      Color darkGreen = new Color(75, 245, 75);
      String string1 = I18n.format("uncrafting.compute") + ":";
      fontRendererObj.drawString(
          EnumChatFormatting.DARK_GRAY + string1 + EnumChatFormatting.RESET,
          24 - fontRendererObj.getStringWidth(string1) / 2 + 1,
          22,
          0);
      fontRendererObj.drawString(
          EnumChatFormatting.GRAY + string1 + EnumChatFormatting.RESET,
          24 - fontRendererObj.getStringWidth(string1) / 2,
          21,
          0);

      fontRendererObj.drawString(
          EnumChatFormatting.DARK_GRAY
              + ""
              + EnumChatFormatting.UNDERLINE
              + ""
              + (ModUncrafting.standardLevel + container.xp)
              + " levels"
              + EnumChatFormatting.RESET,
          xSize / 2
              - fontRendererObj.getStringWidth(
                      (ModUncrafting.standardLevel + container.xp) + " levels")
                  / 2
              + 1,
          ySize - 126 - 10,
          0);
      fontRendererObj.drawString(
          EnumChatFormatting.UNDERLINE
              + ""
              + (ModUncrafting.standardLevel + container.xp)
              + " levels"
              + EnumChatFormatting.RESET,
          xSize / 2
              - fontRendererObj.getStringWidth(
                      (ModUncrafting.standardLevel + container.xp) + " levels")
                  / 2,
          ySize - 127 - 10,
          darkGreen.getRGB());

      String string = container.result;
      if (string != null) {
        State msgType = container.type;
        EnumChatFormatting format = EnumChatFormatting.GREEN;
        EnumChatFormatting shadowFormat = EnumChatFormatting.DARK_GRAY;
        if (msgType == ContainerUncraftingTable.State.ERROR) {
          format = EnumChatFormatting.WHITE;
          shadowFormat = EnumChatFormatting.DARK_RED;
        }

        fontRendererObj.drawString(
            shadowFormat + string + EnumChatFormatting.RESET,
            6 + 1,
            ySize - 95 + 2 - fontRendererObj.FONT_HEIGHT,
            0);

        fontRendererObj.drawString(
            format + string + EnumChatFormatting.RESET,
            6,
            ySize - 96 + 2 - fontRendererObj.FONT_HEIGHT,
            0);
      }
    } else {
      int height = 166 - 8;
      fontRendererObj.drawString(
          blockName,
          xSize / 2 - fontRendererObj.getStringWidth(blockName) / 2 + 1,
          height - 5,
          4210752);

      fontRendererObj.drawString(
          I18n.format("container.inventory"), 6, height - ySize - 96 + 2, 4210752);

      Color darkGreen = new Color(75, 245, 75);
      String string1 = "Calculs:";
      fontRendererObj.drawString(
          EnumChatFormatting.DARK_GRAY + string1 + EnumChatFormatting.RESET,
          24 - fontRendererObj.getStringWidth(string1) / 2 + 1,
          height - 22,
          0);
      fontRendererObj.drawString(
          EnumChatFormatting.GRAY + string1 + EnumChatFormatting.RESET,
          24 - fontRendererObj.getStringWidth(string1) / 2,
          height - 21,
          0);

      fontRendererObj.drawString(
          EnumChatFormatting.DARK_GRAY
              + ""
              + EnumChatFormatting.UNDERLINE
              + ""
              + (ModUncrafting.standardLevel + container.xp)
              + " levels"
              + EnumChatFormatting.RESET,
          xSize / 2
              - fontRendererObj.getStringWidth(
                      (ModUncrafting.standardLevel + container.xp) + " levels")
                  / 2
              + 1,
          height - (ySize - 126 - 10),
          0);
      fontRendererObj.drawString(
          EnumChatFormatting.UNDERLINE
              + ""
              + (ModUncrafting.standardLevel + container.xp)
              + " levels"
              + EnumChatFormatting.RESET,
          xSize / 2
              - fontRendererObj.getStringWidth(
                      (ModUncrafting.standardLevel + container.xp) + " levels")
                  / 2,
          height - (ySize - 127 - 10),
          darkGreen.getRGB());

      String string = container.result;
      if (string != null) {
        State msgType = container.type;
        EnumChatFormatting format = EnumChatFormatting.GREEN;
        EnumChatFormatting shadowFormat = EnumChatFormatting.DARK_GRAY;
        if (msgType == ContainerUncraftingTable.State.ERROR) {
          format = EnumChatFormatting.WHITE;
          shadowFormat = EnumChatFormatting.DARK_RED;
        }

        fontRendererObj.drawString(
            shadowFormat + string + EnumChatFormatting.RESET,
            6 + 1,
            height - (ySize - 95 + 2 - fontRendererObj.FONT_HEIGHT),
            0);

        fontRendererObj.drawString(
            format + string + EnumChatFormatting.RESET,
            6,
            height - (ySize - 96 + 2 - fontRendererObj.FONT_HEIGHT),
            0);
      }
    }
    boolean op = false; // TODO: Check if user is OP
    String optionsText = I18n.format("uncrafting.options.hit");
    if (op)
      fontRendererObj.drawString(
          EnumChatFormatting.UNDERLINE + optionsText,
          xSize - fontRendererObj.getStringWidth(optionsText) - 4,
          ySize - 96 + 2,
          0);

    GL11.glEnable(GL11.GL_LIGHTING);
  }
Exemple #3
0
 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());
   }
 }
Exemple #4
0
  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*/);
  }
Exemple #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();
    }
  }