private static FancyDial getInstance(TextureAtlasSprite icon) {
   if (instances.containsKey(icon)) {
     return instances.get(icon);
   }
   ResourceLocation resource = setupInfo.remove(icon);
   instances.put(icon, null);
   if (resource == null) {
     return null;
   }
   PropertiesFile properties = PropertiesFile.get(logger, resource);
   if (properties == null) {
     return null;
   }
   try {
     FancyDial instance = new FancyDial(icon, properties);
     if (instance.ok) {
       instances.put(icon, instance);
       return instance;
     }
     instance.finish();
   } catch (Throwable e) {
     e.printStackTrace();
   }
   return null;
 }
  private void writeCustomImage() {
    try {
      BufferedImage image =
          new BufferedImage(width, outputFrames * height, BufferedImage.TYPE_INT_ARGB);
      IntBuffer intBuffer = scratchBuffer.asIntBuffer();
      int[] argb = new int[width * height];
      File path = MCPatcherUtils.getGamePath("custom_" + name + ".png");
      logger.info("generating %d %s frames", outputFrames, name);
      for (int i = 0; i < outputFrames; i++) {
        renderToItems(i * (360.0 / outputFrames));
        itemsFBO.read(scratchBuffer);
        intBuffer.position(0);
        for (int j = 0; j < argb.length; j++) {
          switch (MipmapHelper.TEX_FORMAT) {
            case GL12.GL_BGRA:
              int bgra = intBuffer.get(j);
              argb[j] =
                  (bgra << 24) | ((bgra & 0xff00) << 8) | ((bgra & 0xff0000) >> 8) | (bgra >>> 24);
              break;

            default:
              if (i == 0 && j == 0) {
                logger.warning(
                    "unhandled texture format %d, color channels may be incorrect",
                    MipmapHelper.TEX_FORMAT);
              }
              // fall through

            case GL11.GL_RGBA:
              argb[j] = Integer.rotateRight(intBuffer.get(j), 8);
              break;
          }
        }
        image.setRGB(0, i * height, width, height, argb, 0, width);
      }
      ImageIO.write(image, "png", path);
      logger.info("wrote %dx%d %s", image.getWidth(), image.getHeight(), path.getPath());
    } catch (Throwable e) {
      e.printStackTrace();
    }
  }
Пример #3
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();
    }
  }