Exemple #1
1
  @Override
  public void drawScreen(int mouseX, int mouseY, float partialTicks) {
    this.drawDefaultBackground();

    mc.getTextureManager().bindTexture(skrivemaskinegui);

    this.drawTexturedModalRect(this.width / 2 - 128, this.height / 2 - 128, 0, 0, 256, 256);

    /* this is where the editor reads keys and writes to the screen */
    if (org.lwjgl.input.Keyboard.getEventKeyState()) {
      //
      if (isAllowedDeletion()) {
        text.deleteCharAt(cursorLocation);
        cursorLocation--;
        text.deleteCharAt(cursorLocation);
        text.insert(cursorLocation, cursor); // moving cursor
      } else if (isAllowedNewLine()) {
        text.deleteCharAt(cursorLocation);
        text.insert(cursorLocation, '\n');
        cursorLocation++;
        text.insert(cursorLocation, cursor); // moving cursor
      } else if (isAllowedLeftArrowNavigation()) {
        text.deleteCharAt(cursorLocation);
        cursorLocation--;
        text.insert(cursorLocation, cursor); // moving cursor

      } else if (isAllowedRightArrowNavigation()) {
        text.deleteCharAt(cursorLocation);
        cursorLocation++;
        text.insert(cursorLocation, cursor); // moving cursor

      } else if (Keyboard.getEventKey() == Keyboard.KEY_TAB) {
        text.deleteCharAt(cursorLocation);
        for (int i = 0; i < 3; i++) {
          text.insert(cursorLocation, " ");
          cursorLocation++;
        }
        text.insert(cursorLocation, cursor); // moving cursor

      } else {
        if (isAllowedCharacters()) {
          // System.out.println(org.lwjgl.input.Keyboard.getEventKey());
          text.deleteCharAt(cursorLocation);
          text.insert(cursorLocation, org.lwjgl.input.Keyboard.getEventCharacter());
          cursorLocation++;
          text.insert(cursorLocation, cursor); // moving cursor
        }
      }

      org.lwjgl.input.Keyboard.destroy();
    } else if (!org.lwjgl.input.Keyboard.isCreated()) {
      try {
        org.lwjgl.input.Keyboard.create();
      } catch (Exception e) {
      }
    }

    /* writes the text string to the screen */
    renderer.drawSplitString(
        text.toString(), this.width / 2 - 118, this.height / 2 - 119, 238, 0xFFFFF0);

    super.drawScreen(mouseX, mouseY, partialTicks);
  }
 protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) {
   FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
   fr.drawSplitString(
       ChatFormatting.DARK_GRAY
           + StatCollector.translateToLocal(
               "tile." + tilePymParticleProducer.getInventoryName() + ".name"),
       75,
       5,
       70,
       0);
   //        fr.drawSplitString(ChatFormatting.DARK_GRAY + "Client: " +
   // this.tilePymParticleProducer.pymParticles.getFluidAmount(), 105, 25, 70, 0 );
   //        fr.drawSplitString(ChatFormatting.DARK_GRAY + "Server: " +
   // this.tilePymParticleProducerServer.pymParticles.getFluidAmount(), 105, 35, 70, 0 );
 }
  @Override
  public void renderPage(
      int x,
      int y,
      FontRenderer fontRenderer,
      GuiSteamcraftBook book,
      RenderItem renderer,
      boolean isFirstPage,
      int mx,
      int my) {
    if (!lastViewing.equals(book.viewing)) {
      abdoName = Minecraft.getMinecraft().thePlayer.worldObj.rand.nextInt(7);
      lastViewing = book.viewing;
    }
    String s;
    int l;
    int yOffset = y + 55;
    if (isFirstPage) {
      yOffset = y + 65;
      s = I18n.format(name);
      l = fontRenderer.getStringWidth(s);
      fontRenderer.drawString(
          "\u00A7l" + "\u00A7n" + s,
          (int) (x + book.bookImageWidth / 2 - (l / 1.6) - 3),
          y + 30,
          0x3F3F3F);
    }

    s = I18n.format(text);
    String stringLeft = s;
    while (stringLeft.indexOf("<br>") != -1) {
      String output = stringLeft.substring(0, stringLeft.indexOf("<br>"));
      if ((Minecraft.getMinecraft().gameSettings.thirdPersonView != 0
              || Minecraft.getMinecraft()
                  .thePlayer
                  .getCommandSenderName()
                  .equals("MasterAbdoTGM50"))
          && Config.easterEggs) {
        output = doLizbeth(output);
      }
      l = fontRenderer.splitStringWidth(output, 110);
      fontRenderer.drawSplitString(output, x + 40, yOffset, 110, 0);
      yOffset += this.getSplitStringHeight(fontRenderer, output, x + 40, yOffset, 110);
      yOffset += 10;
      stringLeft = stringLeft.substring(stringLeft.indexOf("<br>") + 4, stringLeft.length());
    }
    String output = stringLeft;
    if ((Minecraft.getMinecraft().gameSettings.thirdPersonView != 0
            || Minecraft.getMinecraft().thePlayer.getCommandSenderName().equals("MasterAbdoTGM50"))
        && Config.easterEggs) {
      output = doLizbeth(output);
    }
    l = fontRenderer.splitStringWidth(output, 110);
    fontRenderer.drawSplitString(output, x + 40, yOffset, 110, 0);

    int size = item.length;
    int i = 0;
    for (ItemStack stack : item) {
      this.drawItemStack(
          stack,
          (int) (x + book.bookImageWidth / 2 - 12 - (size - 1) * 9 + i * 18),
          isFirstPage ? y + 45 : y + 35,
          "",
          renderer,
          fontRenderer);
      i++;
    }
    for (Tuple3 item : items) {
      int ix = (Integer) item.first;
      int iy = (Integer) item.second;
      if (mx >= ix && mx <= ix + 16 && my >= iy && my <= iy + 16) {
        fontRenderer.setUnicodeFlag(false);
        book.renderToolTip((ItemStack) item.third, mx, my);
        fontRenderer.setUnicodeFlag(true);
      }
    }
    items.clear();
  }
  /** Args : renderPartialTicks, mouseX, mouseY */
  @Override
  protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
    OpenGLHelper.colour(1, 1, 1);
    mc.getTextureManager().bindTexture(field_147078_C);
    int k = (width - xSize) / 2;
    int l = (height - ySize) / 2;
    drawTexturedModalRect(k, l, 0, 0, xSize, ySize);
    OpenGLHelper.pushMatrix();
    OpenGLHelper.matrixMode(5889);
    OpenGLHelper.pushMatrix();
    OpenGLHelper.loadIdentity();
    ScaledResolution var6 = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
    OpenGLHelper.viewport(
        (var6.getScaledWidth() - 320) / 2 * var6.getScaleFactor(),
        (var6.getScaledHeight() - 240) / 2 * var6.getScaleFactor(),
        320 * var6.getScaleFactor(),
        240 * var6.getScaleFactor());
    OpenGLHelper.translate(-0.34F, 0.23F, 0.0F);
    Project.gluPerspective(90.0F, 1.3333334F, 9.0F, 80.0F);
    float var7 = 1.0F;
    OpenGLHelper.matrixMode(5888);
    OpenGLHelper.loadIdentity();
    RenderHelper.enableStandardItemLighting();
    OpenGLHelper.translate(0.0F, 3.3F, -16.0F);
    OpenGLHelper.scale(var7, var7, var7);
    float var8 = 5.0F;
    OpenGLHelper.scale(var8, var8, var8);
    OpenGLHelper.rotate(180.0F, 0.0F, 0.0F, 1.0F);
    mc.getTextureManager().bindTexture(field_147070_D);
    OpenGLHelper.rotate(20.0F, 1.0F, 0.0F, 0.0F);
    float var9 = field_147076_A + (field_147080_z - field_147076_A) * partialTicks;
    OpenGLHelper.translate((1.0F - var9) * 0.2F, (1.0F - var9) * 0.1F, (1.0F - var9) * 0.25F);
    OpenGLHelper.rotate(-(1.0F - var9) * 90.0F - 90.0F, 0.0F, 1.0F, 0.0F);
    OpenGLHelper.rotate(180.0F, 1.0F, 0.0F, 0.0F);
    float var10 = field_147069_w + (field_147071_v - field_147069_w) * partialTicks + 0.25F;
    float var11 = field_147069_w + (field_147071_v - field_147069_w) * partialTicks + 0.75F;
    var10 = (var10 - MathHelper.truncateDoubleToInt(var10)) * 1.6F - 0.3F;
    var11 = (var11 - MathHelper.truncateDoubleToInt(var11)) * 1.6F - 0.3F;

    if (var10 < 0.0F) var10 = 0.0F;

    if (var11 < 0.0F) var11 = 0.0F;

    if (var10 > 1.0F) var10 = 1.0F;

    if (var11 > 1.0F) var11 = 1.0F;

    OpenGLHelper.enableRescaleNormal();
    field_147072_E.render((Entity) null, 0.0F, var10, var11, var9, 0.0F, 0.0625F);
    OpenGLHelper.disableRescaleNormal();
    RenderHelper.disableStandardItemLighting();
    OpenGLHelper.matrixMode(5889);
    OpenGLHelper.viewport(0, 0, mc.displayWidth, mc.displayHeight);
    OpenGLHelper.popMatrix();
    OpenGLHelper.matrixMode(5888);
    OpenGLHelper.popMatrix();
    RenderHelper.disableStandardItemLighting();
    OpenGLHelper.colour(1.0F, 1.0F, 1.0F);
    EnchantmentNameParts.instance.reseedRandomGenerator(field_147075_G.enchantmentSeed);
    int var12 = field_147075_G.func_178147_e();

    for (int i1 = 0; i1 < 3; i1++) {
      int var14 = k + 60;
      int var15 = var14 + 20;
      byte var16 = 86;
      String s = EnchantmentNameParts.instance.generateNewRandomName();
      zLevel = 0.0F;
      mc.getTextureManager().bindTexture(field_147078_C);
      int j1 = field_147075_G.enchantLevels[i1];
      OpenGLHelper.colour(1.0F, 1.0F, 1.0F);

      if (j1 == 0) drawTexturedModalRect(var14, l + 14 + 19 * i1, 0, 185, 108, 19);
      else {
        String s1 = "" + j1;
        FontRenderer fontrenderer = mc.standardGalacticFontRenderer;
        int k1 = 6839882;

        if ((var12 < i1 + 1 || mc.thePlayer.experienceLevel < j1)
            && !mc.thePlayer.capabilities.isCreativeMode) {
          drawTexturedModalRect(var14, l + 14 + 19 * i1, 0, 185, 108, 19);
          drawTexturedModalRect(var14 + 1, l + 15 + 19 * i1, 16 * i1, 239, 16, 16);
          fontrenderer.drawSplitString(s, var15, l + 16 + 19 * i1, var16, (k1 & 16711422) >> 1);
          k1 = 4226832;
        } else {
          int l1 = mouseX - (k + 60);
          int i2 = mouseY - (l + 14 + 19 * i1);

          if (l1 >= 0 && i2 >= 0 && l1 < 108 && i2 < 19) {
            drawTexturedModalRect(var14, l + 14 + 19 * i1, 0, 204, 108, 19);
            k1 = 16777088;
          } else drawTexturedModalRect(var14, l + 14 + 19 * i1, 0, 166, 108, 19);

          drawTexturedModalRect(var14 + 1, l + 15 + 19 * i1, 16 * i1, 223, 16, 16);
          fontrenderer.drawSplitString(s, var15, l + 16 + 19 * i1, var16, k1);
          k1 = 8453920;
        }

        fontrenderer = mc.fontRenderer;
        fontrenderer.drawStringWithShadow(
            s1, var15 + 86 - fontrenderer.getStringWidth(s1), l + 16 + 19 * i1 + 7, k1);
        OpenGLHelper.colour(1, 1, 1);
      }
    }
  }