Пример #1
0
  protected void renderRecordOverlay(int width, int height, float partialTicks) {
    if (recordPlayingUpFor > 0) {
      mc.mcProfiler.startSection("overlayMessage");
      float hue = (float) recordPlayingUpFor - partialTicks;
      int opacity = (int) (hue * 256.0F / 20.0F);
      if (opacity > 255) opacity = 255;

      if (opacity > 0) {
        GlStateManager.pushMatrix();
        GlStateManager.translate((float) (width / 2), (float) (height - 68), 0.0F);
        GlStateManager.enableBlend();
        GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
        int color = (recordIsPlaying ? Color.HSBtoRGB(hue / 50.0F, 0.7F, 0.6F) & WHITE : WHITE);
        fontrenderer.drawString(
            recordPlaying,
            -fontrenderer.getStringWidth(recordPlaying) / 2,
            -4,
            color | (opacity << 24));
        GlStateManager.disableBlend();
        GlStateManager.popMatrix();
      }

      mc.mcProfiler.endSection();
    }
  }
Пример #2
0
 public void updateAndRender(float renderTickTime) {
   if (scale == null) {
     return;
   }
   ScaledResolution resolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
   final int height = 64;
   int guiTop = resolution.getScaledHeight() - height;
   int guiLeft = resolution.getScaledWidth();
   GlStateManager.pushMatrix();
   GlStateManager.translate(guiLeft, guiTop, 0f);
   GlStateManager.scale(scale.get(), scale.get(), 1f);
   GlStateManager.enableBlend();
   for (int i = messages.size() - 1; i >= 0; i--) {
     JoinLeaveMessage message = messages.get(i);
     message.timeLeft -= renderTickTime;
     int alpha = 255;
     if (message.timeLeft < visibleTime.get() / 5f) {
       alpha = (int) Math.max(11, (255f * (message.timeLeft / (visibleTime.get() / 5f))));
     }
     if (message.timeLeft <= 0) {
       messages.remove(i);
     }
     String formattedText = message.chatComponent.getFormattedText();
     fontRenderer.drawString(
         formattedText,
         -fontRenderer.getStringWidth(formattedText) - 16,
         message.y,
         16777215 | (alpha << 24),
         true);
   }
   GlStateManager.disableBlend();
   GlStateManager.popMatrix();
 }
Пример #3
0
 /**
  * Utility method: splits the string in different lines so it will fit on the page.
  *
  * @param fontRendererObj the font renderer to check against.
  * @param input the line to split up.
  * @param maxWidth the maximum allowable width of the line before being wrapped.
  * @param scale the scale of the text to the width.
  * @return the string split up into lines by the '\n' character.
  */
 public static String splitInLines(
     FontRenderer fontRendererObj, String input, float maxWidth, float scale) {
   maxWidth = maxWidth / scale;
   String notProcessed = input;
   String output = "";
   while (fontRendererObj.getStringWidth(notProcessed) > maxWidth) {
     int index = 0;
     if (notProcessed != null && !notProcessed.equals("")) {
       // find the first index at which the string exceeds the size limit
       while (notProcessed.length() - 1 > index
           && fontRendererObj.getStringWidth(notProcessed.substring(0, index)) < maxWidth) {
         index = (index + 1) < notProcessed.length() ? index + 1 : index;
       }
       // go back to the first space to cut the string in two lines
       while (index > 0 && notProcessed.charAt(index) != ' ') {
         index--;
       }
       // update the data for the next iteration
       output = output.equals("") ? output : output + '\n';
       output = output + notProcessed.substring(0, index);
       notProcessed =
           notProcessed.length() > index + 1 ? notProcessed.substring(index + 1) : notProcessed;
     }
   }
   return output + '\n' + notProcessed;
 }
 protected void drawAuxGraphics(int posX, int posY) {
   ItemHashMap<Integer> items = this.getItemCounts();
   ArrayList<ItemStack> li = new ArrayList(items.keySet());
   Collections.sort(li, new AlphabeticItemComparator());
   for (int i = recipeTextOffset; i < li.size(); i++) {
     ItemStack is = li.get(i);
     int num = items.get(is);
     String s0 = is.getDisplayName();
     String s = String.format(": x%d", num);
     FontRenderer fr =
         s0.contains(FontType.OBFUSCATED.id) ? FontType.OBFUSCATED.renderer : fontRendererObj;
     s0 = DelegateFontRenderer.stripFlags(s0);
     fr.drawString(
         s0,
         posX + descX + 3,
         posY + descY + (fr.FONT_HEIGHT + 2) * (i - recipeTextOffset),
         0xffffff);
     fontRendererObj.drawString(
         s,
         posX + descX + 3 + fr.getStringWidth(s0),
         posY + descY + (fr.FONT_HEIGHT + 2) * (i - recipeTextOffset),
         0xffffff);
     if (i - recipeTextOffset > 9) break;
   }
 }
  private void drawCenteredString(
      FontRenderer fontRenderer, String string, int x, int y, int colour) {
    String fixedString = string.replaceAll("\\P{InBasic_Latin}", "");
    int fixedStringWidth = fontRenderer.getStringWidth(fixedString);
    int centeredX = x - fixedStringWidth / 2;

    fontRenderer.drawStringWithShadow(string, centeredX, y, colour);
  }
 public int getContentWidth() {
   FontRenderer font = getFontRenderer();
   int width = 0;
   for (int i = 0; i < textLength; ++i) {
     width += font.getCharWidth(text[i]);
   }
   return width;
 }
  @Override
  public void render(int xScreen, int yScreen, float partialTicks) {
    if (data == null) data = ExtendedPlayerData.get(player);
    if (data == null) return;
    if (data.player != player) {
      data = ExtendedPlayerData.get(player);
    }
    if (data == null) return;
    FontRenderer fr = TessUtil.getFontRenderer();
    if (UtilM.isNull(player, fr)) return;
    if (handAlpha > 0 && UtilM.isItemInStack(MItems.theHand, player.getCurrentEquippedItem())) {
      float HandAlpha = PartialTicksUtil.calculatePos(lastHandAlpha, handAlpha);
      int slot = player.inventory.currentItem;
      OpenGLM.pushMatrix();

      int posId = 0;
      for (int b = 0; b < HandPosition.values().length; b++) {
        if (HandPosition.values()[b].equals(TheHandHandler.getActivePosition(player))) {
          posId = b;
          continue;
        }
      }
      int a1 = -1, a2 = -1, a3 = -1;
      if (posId == 1) {
        a1 = posId - 1;
        a2 = posId;
        a3 = posId + 1;
      } else if (posId == 0) {
        a1 = 2;
        a2 = posId;
        a3 = posId + 1;
      } else {
        a1 = 1;
        a2 = posId;
        a3 = 0;
      }
      String up = "string " + a1, now = "string " + a2, down = "string " + a3;

      GL11U.setUpOpaqueRendering(1);
      OpenGLM.translate(slot * 20 + xScreen / 2 - 95, yScreen - 38, 0);

      OpenGLM.translate(0, -HandAlpha * 20 + 20, 0);
      OpenGLM.translate(13, 0, 0);
      OpenGLM.scale(HandAlpha, HandAlpha, HandAlpha);
      OpenGLM.rotate(HandAlpha * 90 - 90, 0, 0, 1);
      OpenGLM.translate(-13, 0, 0);

      OpenGLM.translate(-10 + HandAlpha * 10, 0, 0);
      fr.drawStringWithShadow(up, 0, -9, Color.WHITE.hashCode());
      OpenGLM.translate(10 - HandAlpha * 10, 0, 0);
      fr.drawStringWithShadow(now, 0, 0, Color.WHITE.hashCode());
      OpenGLM.translate(10 - HandAlpha * 10, 0, 0);
      fr.drawStringWithShadow(down, 0, 9, Color.WHITE.hashCode());

      GL11U.endOpaqueRendering();
      OpenGLM.popMatrix();
    }
  }
  @Override
  protected void drawGuiContainerForegroundLayer(int param1, int param2) {
    FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
    // draw text and stuff here
    // the parameters for drawString are: string, x, y, color
    fr.drawString(getLabel(), 8, 6, 4210752);

    initialized = true;
  }
Пример #9
0
  static String[] layoutText(String text, int width) {
    if (width < 64) {
      width = 64; // Arbitrary minimum width, to prevent excessive wrapping. Space for at least 4
      // characters.
    }

    FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
    List<String> lines = fr.listFormattedStringToWidth(text, width);

    return lines.toArray(new String[lines.size()]);
  }
Пример #10
0
  protected void renderHUDText(int width, int height) {
    mc.mcProfiler.startSection("forgeHudText");
    OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
    ArrayList<String> listL = new ArrayList<String>();
    ArrayList<String> listR = new ArrayList<String>();

    if (mc.isDemo()) {
      long time = mc.theWorld.getTotalWorldTime();
      if (time >= 120500L) {
        listR.add(I18n.format("demo.demoExpired"));
      } else {
        listR.add(
            I18n.format(
                "demo.remainingTime", StringUtils.ticksToElapsedTime((int) (120500L - time))));
      }
    }

    if (this.mc.gameSettings.showDebugInfo && !pre(DEBUG)) {
      listL.addAll(debugOverlay.getLeft());
      listR.addAll(debugOverlay.getRight());
      post(DEBUG);
    }

    RenderGameOverlayEvent.Text event = new RenderGameOverlayEvent.Text(eventParent, listL, listR);
    if (!MinecraftForge.EVENT_BUS.post(event)) {
      int top = 2;
      for (String msg : listL) {
        if (msg == null) continue;
        drawRect(
            1,
            top - 1,
            2 + fontrenderer.getStringWidth(msg) + 1,
            top + fontrenderer.FONT_HEIGHT - 1,
            -1873784752);
        fontrenderer.drawString(msg, 2, top, 14737632);
        top += fontrenderer.FONT_HEIGHT;
      }

      top = 2;
      for (String msg : listR) {
        if (msg == null) continue;
        int w = fontrenderer.getStringWidth(msg);
        int left = width - 2 - w;
        drawRect(left - 1, top - 1, left + w + 1, top + fontrenderer.FONT_HEIGHT - 1, -1873784752);
        fontrenderer.drawString(msg, left, top, 14737632);
        top += fontrenderer.FONT_HEIGHT;
      }
    }

    mc.mcProfiler.endSection();
    post(TEXT);
  }
Пример #11
0
  @SubscribeEvent
  public void onRenderGameOverlayPost(Post event) {
    if (event.type == ElementType.ALL) {

      Minecraft mc = Minecraft.getMinecraft();
      FontRenderer fr = mc.fontRenderer;
      Profiler p = mc.mcProfiler;
      p.startSection("gimmetime-hud");

      switch (ConfigHandler.analog_digital) {
        case 0: // None
          break;
        case 1: // Analog
          p.startSection("clock");
          RenderUtil.drawClock(32, 34, 24);
          p.endSection();
          break;
        case 2: // Digital
          p.startSection("clock");
          drawString(TimeUtil.getTime(), 1, 1);
          p.endSection();
          break;
        case 3: // Both
          p.startSection("clock");
          RenderUtil.drawClock(32, 34, 24);
          drawString(TimeUtil.getTime(), 64, 1);
          p.endSection();
          break;
      }

      if (currentAlarm != null) {
        p.startSection("alarm");
        String title = currentAlarm.getTitle() + " - " + TimeUtil.getAlarmTimeString();
        drawString(
            title,
            (event.resolution.getScaledWidth() / 2) - (fr.getStringWidth(title) / 2),
            (event.resolution.getScaledHeight() / 2) - (fr.FONT_HEIGHT + 4));
        String closeHint =
            StatCollector.translateToLocalFormatted(
                "hud.alarmAlert.close",
                GameSettings.getKeyDisplayString(KeyHandler.INSTANCE.clock.getKeyCode()));
        drawString(
            closeHint,
            (event.resolution.getScaledWidth() / 2) - (fr.getStringWidth(closeHint) / 2),
            (event.resolution.getScaledHeight() / 2) + (fr.FONT_HEIGHT - 2));
        p.endSection();
      }

      p.endSection();
    }
  }
Пример #12
0
 public static void renderLocalizedGuiName(
     FontRenderer fontRenderer, int xSize, String name, String append, int colour) {
   String unlocalizedName = "inventory." + LibModInfo.ID.toLowerCase() + ":" + name + ".name";
   String localizedName = StatCollector.translateToLocal(unlocalizedName);
   String renderText = unlocalizedName;
   if (!unlocalizedName.equals(localizedName)) {
     renderText = localizedName;
   }
   if (append != null) {
     renderText = renderText + " - " + append;
   }
   int xPos = xSize / 2 - fontRenderer.getStringWidth(renderText) / 2;
   fontRenderer.drawString(renderText, xPos, 6, colour);
 }
Пример #13
0
  public void renderItemStack(
      FontRenderer par1FontRenderer,
      RenderEngine par2RenderEngine,
      ItemStack par3ItemStack,
      int par4,
      int par5,
      String par6Str) {
    if (par3ItemStack != null) {
      if (par3ItemStack.stackSize > 1 || par6Str != null) {
        String s1 = par6Str == null ? String.valueOf(par3ItemStack.stackSize) : par6Str;
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glDisable(GL11.GL_DEPTH_TEST);
        par1FontRenderer.drawStringWithShadow(
            s1, par4 + 19 - 2 - par1FontRenderer.getStringWidth(s1), par5 + 6 + 3, 16777215);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glEnable(GL11.GL_DEPTH_TEST);
      }

      if (par3ItemStack.isItemDamaged()) {
        int k =
            (int)
                Math.round(
                    13.0D
                        - (double) par3ItemStack.getItemDamageForDisplay()
                            * 13.0D
                            / (double) par3ItemStack.getMaxDamage());
        int l =
            (int)
                Math.round(
                    255.0D
                        - (double) par3ItemStack.getItemDamageForDisplay()
                            * 255.0D
                            / (double) par3ItemStack.getMaxDamage());
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glDisable(GL11.GL_DEPTH_TEST);
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        Tessellator tessellator = Tessellator.instance;
        int i1 = 255 - l << 16 | l << 8;
        int j1 = (255 - l) / 4 << 16 | 16128;
        this.renderQuad(tessellator, par4 + 2, par5 + 13, 13, 2, 0);
        this.renderQuad(tessellator, par4 + 2, par5 + 13, 12, 1, j1);
        this.renderQuad(tessellator, par4 + 2, par5 + 13, k, 1, i1);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glEnable(GL11.GL_DEPTH_TEST);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
      }
    }
  }
Пример #14
0
  @SubscribeEvent
  public void drawDislocationFocusHUD(RenderGameOverlayEvent.Post event) {
    if (event.type == ElementType.HOTBAR && ClientHelper.minecraft().currentScreen == null) {
      boolean up = !Config.dialBottom;
      int xpos = 4;
      int ypos = up ? 50 : event.resolution.getScaledHeight() - 70;

      ItemStack item = ClientHelper.clientPlayer().getCurrentEquippedItem();
      if (item != null && item.getItem() instanceof ItemWandCasting) {
        ItemWandCasting wand = (ItemWandCasting) item.getItem();
        wand.getFocusItem(item);
        ItemFocusBasic focus = wand.getFocus(item);

        if (focus != null && focus instanceof ItemFocusDislocation) {
          ItemStack pickedBlock = ((ItemFocusDislocation) focus).getPickedBlock(item);
          if (pickedBlock != null) {
            Gui.drawRect(xpos - 1, ypos - 1, xpos + 18, ypos + 18, 0x66000000);

            FontRenderer font = ClientHelper.fontRenderer();
            boolean unicode = font.getUnicodeFlag();
            font.setUnicodeFlag(true);
            String name = StatCollector.translateToLocal("ttmisc.focusDislocation.tooltip");
            int strLength = font.getStringWidth(name);

            Gui.drawRect(xpos + 18, ypos, xpos + 18 + strLength + 4, ypos + 9, 0x66000000);
            font.drawStringWithShadow(name, xpos + 20, ypos, 0xFFAA00);

            NBTTagCompound cmp = ((ItemFocusDislocation) focus).getStackTileEntity(item);
            if (cmp != null && !cmp.hasNoTags()) {
              String content =
                  StatCollector.translateToLocal("ttmisc.focusDislocation.tooltipExtra");
              font.getStringWidth(content);

              Gui.drawRect(xpos + 18, ypos + 9, xpos + 18 + strLength + 4, ypos + 18, 0x66000000);
              font.drawStringWithShadow(content, xpos + 20, ypos + 9, 0xFFAA00);
            }

            if (new ItemStack(((ItemBlock) pickedBlock.getItem()).field_150939_a).getItem() != null)
              renderItem.renderItemIntoGUI(
                  font,
                  ClientHelper.minecraft().renderEngine,
                  new ItemStack(((ItemBlock) pickedBlock.getItem()).field_150939_a),
                  xpos,
                  ypos);
            else {
              if (((ItemBlock) pickedBlock.getItem()).field_150939_a == Blocks.reeds)
                renderItem.renderItemIntoGUI(
                    font,
                    ClientHelper.minecraft().renderEngine,
                    new ItemStack(Items.reeds),
                    xpos,
                    ypos);
            }
            font.setUnicodeFlag(unicode);
          }
        }
      }
    }
  }
Пример #15
0
 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 );
 }
 public int getVisibleWidth() {
   FontRenderer font = getFontRenderer();
   int width = 0, endX = sizeX - 1;
   for (int i = renderStart; i < textLength; ++i) {
     int charW = font.getCharWidth(text[i]);
     if (!enableStencil && (width + charW) > endX) {
       break;
     }
     width += charW;
     if (width >= endX) {
       width = Math.min(width, endX);
       break;
     }
   }
   return width;
 }
    public void renderIcon(float p_178663_1_, int alpha) {
      int i = -1;
      String s = FontRenderer.getFormatFromString(this.team.getColorPrefix());

      if (s.length() >= 2) {
        i = Minecraft.getMinecraft().fontRendererObj.getColorCode(s.charAt(1));
      }

      if (i >= 0) {
        float f = (float) (i >> 16 & 255) / 255.0F;
        float f1 = (float) (i >> 8 & 255) / 255.0F;
        float f2 = (float) (i & 255) / 255.0F;
        Gui.drawRect(
            1,
            1,
            15,
            15,
            MathHelper.rgb(f * p_178663_1_, f1 * p_178663_1_, f2 * p_178663_1_) | alpha << 24);
      }

      Minecraft.getMinecraft().getTextureManager().bindTexture(this.location);
      GlStateManager.color(p_178663_1_, p_178663_1_, p_178663_1_, (float) alpha / 255.0F);
      Gui.drawScaledCustomSizeModalRect(2, 2, 8.0F, 8.0F, 8, 8, 12, 12, 64.0F, 64.0F);
      Gui.drawScaledCustomSizeModalRect(2, 2, 40.0F, 8.0F, 8, 8, 12, 12, 64.0F, 64.0F);
    }
Пример #18
0
  @Override
  public void render(FontRenderer fontRenderer, int currenty, Object[] screenData, float factor) {
    GL11.glDisable(GL11.GL_LIGHTING);
    int xoffset;
    if (!line.isEmpty()) {
      fontRenderer.drawString(line, 7, currenty, color);
      xoffset = 7 + 40;
    } else {
      xoffset = 7;
    }

    ClientScreenModuleHelper.renderLevel(
        fontRenderer,
        xoffset,
        currenty,
        screenData,
        "RF",
        hidebar,
        hidetext,
        showpct,
        showdiff,
        rfcolor,
        rfcolorNeg,
        0xffff0000,
        0xff333300,
        format);
  }
  @Override
  public void renderPage(
      int x,
      int y,
      FontRenderer fontRenderer,
      GuiSteamcraftBook book,
      RenderItem renderer,
      boolean isFirstPage,
      int mx,
      int my) {
    book.mc.getTextureManager().bindTexture(craftSquareTexture);
    book.drawTexturedModalRect(x + 45, y + 65, 0, 146, 97, 59);
    fontRenderer.setUnicodeFlag(false);
    int ticks =
        MathHelper.floor_double(
            (Minecraft.getMinecraft().thePlayer.ticksExisted % (item1.length * 20.0D)) / 20.0D);
    this.drawItemStack(
        item1[ticks],
        x + 40 + 19 + 28,
        y + 65 + 14,
        amount > 1 ? Integer.toString(amount) : "",
        renderer,
        fontRenderer,
        true);
    this.drawItemStack(
        inputItem,
        x + 43,
        y + 65 + 14,
        amount > 1 ? Integer.toString(amount) : "",
        renderer,
        fontRenderer,
        true);
    this.drawItemStack(
        resultItem,
        x + 40 + 90,
        y + 65 + 14,
        amount > 1 ? Integer.toString(amount) : "",
        renderer,
        fontRenderer,
        false);

    // this.drawItemStack(item1[ticks], x+40+19, y+65+2, amount > 1 ? Integer.toString(amount) : "",
    // renderer, fontRenderer);

    fontRenderer.setUnicodeFlag(true);
  }
Пример #20
0
  @Override
  public int getStringWidth(String s) {
    if (s.indexOf("SPECIAL:") < 0) {
      return realRenderer.getStringWidth(s);
    }

    return 21;
  }
Пример #21
0
 Text append(String text, TextFormat format, FontRenderer fontrenderer) {
   this.text += addFormat(text, format);
   float scale = format.size / (float) fontrenderer.FONT_HEIGHT;
   this.dimensions =
       new Vector2D(
           fontrenderer.getStringWidth(this.text) * scale, fontrenderer.FONT_HEIGHT * scale);
   return this;
 }
Пример #22
0
  private void renderText(TileEntityDisplay tile, double par2, double par4, double par6) {
    if (tile == null) return;
    if (!tile.hasList()) return;
    FontRenderer f = this.getFontRenderer();
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glDepthMask(false);
    GL11.glPushMatrix();
    GL11.glScaled(1, -1, 1);
    double sc = 0.02;
    GL11.glScaled(sc, sc, sc);
    GL11.glTranslated(0, -50, 25);
    GL11.glTranslated(0, -tile.displayHeight * tile.lineHeight, 0);
    int dd = 100 - tile.charWidth / 4;
    int dx = -dd;
    int dz = 0;
    GL11.glTranslated(dx, 0, dz);

    List<String> cache = tile.getMessageForDisplay();

    long core = tile.getTick(); // System.currentTimeMillis();
    float scroll = cache.size() > tile.displayHeight ? (core * 4) % (180 * cache.size()) / 180F : 0;
    int linescroll =
        scroll - (int) scroll > 0.5F ? (int) scroll + 1 : (int) scroll; // tile.getRoundedScroll();
    // ReikaJavaLibrary.pConsole(tile.getMessageLine(0));
    int len =
        ReikaMathLibrary.extrema(cache.size() - 1, tile.displayHeight + linescroll - 1, "min");
    for (int i = linescroll; i < len + 1; i++) {
      String s2 = cache.get(i);
      // ReikaJavaLibrary.pConsole("Printing line "+i+" of "+tile.getMessageLength()+":
      // "+tile.getMessageLine(i));
      // f.drawString(tile.getMessageLine(i), 1, -1+(int)((i-scroll)*tile.lineHeight),
      // tile.getTextColor());
      // f.drawSplitString(s, 1, -1+(int)((i-scroll)*tile.lineHeight),
      // tile.displayWidth*f.FONT_HEIGHT, tile.getTextColor());
      f.drawString(s2, 1, -1 + (int) ((i - scroll) * tile.lineHeight), tile.getTextColor());
      GL11.glTranslated(0, 0, -0.2875);
      // f.drawString(tile.getMessageLine(i), 1, -1+(int)((i-scroll)*tile.lineHeight),
      // tile.getTextColor());
      f.drawString(s2, 1, -1 + (int) ((i - scroll) * tile.lineHeight), tile.getTextColor());
      GL11.glTranslated(0, 0, 0.2875);
    }
    GL11.glPopMatrix();
    GL11.glDepthMask(true);
    GL11.glEnable(GL11.GL_LIGHTING);
  }
Пример #23
0
  protected void renderExperience(int width, int height) {
    bind(icons);
    if (pre(EXPERIENCE)) return;
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    GlStateManager.disableBlend();

    if (mc.playerController.gameIsSurvivalOrAdventure()) {
      mc.mcProfiler.startSection("expBar");
      int cap = this.mc.thePlayer.xpBarCap();
      int left = width / 2 - 91;

      if (cap > 0) {
        short barWidth = 182;
        int filled = (int) (mc.thePlayer.experience * (float) (barWidth + 1));
        int top = height - 32 + 3;
        drawTexturedModalRect(left, top, 0, 64, barWidth, 5);

        if (filled > 0) {
          drawTexturedModalRect(left, top, 0, 69, filled, 5);
        }
      }

      this.mc.mcProfiler.endSection();

      if (mc.playerController.gameIsSurvivalOrAdventure() && mc.thePlayer.experienceLevel > 0) {
        mc.mcProfiler.startSection("expLevel");
        boolean flag1 = false;
        int color = flag1 ? 16777215 : 8453920;
        String text = "" + mc.thePlayer.experienceLevel;
        int x = (width - fontrenderer.getStringWidth(text)) / 2;
        int y = height - 31 - 4;
        fontrenderer.drawString(text, x + 1, y, 0);
        fontrenderer.drawString(text, x - 1, y, 0);
        fontrenderer.drawString(text, x, y + 1, 0);
        fontrenderer.drawString(text, x, y - 1, 0);
        fontrenderer.drawString(text, x, y, color);
        mc.mcProfiler.endSection();
      }
    }
    GlStateManager.enableBlend();
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);

    post(EXPERIENCE);
  }
Пример #24
0
 @Override
 public void drawInformation(
     int positionX, int positionY, int width, int height, int page, FontRenderer fontRenderer) {
   width = Math.max(width, 20);
   int currentY = drawHead(positionX, positionY, width, fontRenderer);
   switch (page) {
     case 0:
       currentY = drawBaseInformation(positionX, currentY, width, fontRenderer);
       String TAG_STATUS =
           StatCollector.translateToLocal(MHFCReference.unlocalized_tag_status_long);
       currentY +=
           MHFCGuiUtil.drawTextAndReturnHeight(
               fontRenderer, TAG_STATUS, positionX + 5, currentY, 0, COLOUR_HEADER);
       currentY += LINE_SEPERATION;
       String draw = getLongStatus();
       for (String line : draw.split("\n")) {
         currentY +=
             MHFCGuiUtil.drawTextAndReturnHeight(
                 fontRenderer,
                 line,
                 positionX + width / 8,
                 currentY,
                 7 * width / 8 - BORDER,
                 COLOUR_TEXT);
         currentY += LINE_SEPERATION;
       }
       break;
     case 1:
       drawAimsFails(positionX, positionY, width, height, currentY, fontRenderer);
       break;
     case 2:
       drawClientDescription(positionX, currentY, width, fontRenderer);
       break;
   }
   String draw = (page + 1) + "/3";
   fontRenderer.drawString(
       draw,
       positionX + width - fontRenderer.getStringWidth(draw) - BORDER,
       positionY + height - fontRenderer.FONT_HEIGHT - BORDER,
       COLOUR_TEXT);
 }
  protected void findRenderStart() {

    caret = MathHelper.clampI(caret, 0, textLength);
    if (caret < renderStart) {
      renderStart = caret;
      return;
    }

    FontRenderer font = getFontRenderer();
    int endX = sizeX - 2;

    for (int i = renderStart, width = 0; i < caret; ++i) {
      width += font.getCharWidth(text[i]);
      while (width >= endX) {
        width -= font.getCharWidth(text[renderStart++]);
        if (renderStart >= textLength) {
          return;
        }
      }
    }
  }
Пример #26
0
  protected void renderToolHightlight(ScaledResolution res) {
    if (this.mc.gameSettings.heldItemTooltips && !this.mc.playerController.isSpectator()) {
      mc.mcProfiler.startSection("toolHighlight");

      if (this.remainingHighlightTicks > 0 && this.highlightingItemStack != null) {
        String name = this.highlightingItemStack.getDisplayName();
        if (this.highlightingItemStack.hasDisplayName()) name = EnumChatFormatting.ITALIC + name;

        name =
            this.highlightingItemStack.getItem().getHighlightTip(this.highlightingItemStack, name);

        int opacity = (int) ((float) this.remainingHighlightTicks * 256.0F / 10.0F);
        if (opacity > 255) opacity = 255;

        if (opacity > 0) {
          int y = res.getScaledHeight() - 59;
          if (!mc.playerController.shouldDrawHUD()) y += 14;

          GlStateManager.pushMatrix();
          GlStateManager.enableBlend();
          GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
          FontRenderer font =
              highlightingItemStack.getItem().getFontRenderer(highlightingItemStack);
          if (font != null) {
            int x = (res.getScaledWidth() - font.getStringWidth(name)) / 2;
            font.drawStringWithShadow(name, x, y, WHITE | (opacity << 24));
          } else {
            int x = (res.getScaledWidth() - fontrenderer.getStringWidth(name)) / 2;
            fontrenderer.drawStringWithShadow(name, x, y, WHITE | (opacity << 24));
          }
          GlStateManager.disableBlend();
          GlStateManager.popMatrix();
        }
      }

      mc.mcProfiler.endSection();
    } else if (this.mc.thePlayer.isSpectator()) {
      this.spectatorGui.func_175263_a(res);
    }
  }
Пример #27
0
 private void drawFluids(int recipe) {
   CentrifugeRecipe r = (CentrifugeRecipe) arecipes.get(recipe);
   ItemStack in = r.input;
   FluidStack fs = RecipesCentrifuge.getRecipes().getFluidResult(in);
   if (fs != null) {
     Fluid f = fs.getFluid();
     IIcon ico = f.getIcon();
     float u = ico.getMinU();
     float v = ico.getMinV();
     float du = ico.getMaxU();
     float dv = ico.getMaxV();
     ReikaTextureHelper.bindTerrainTexture();
     Tessellator v5 = Tessellator.instance;
     v5.startDrawingQuads();
     int x = 147;
     for (int i = 0; i < 4; i++) {
       int y = 1 + i * 16;
       v5.addVertexWithUV(x, y, 0, u, v);
       v5.addVertexWithUV(x, y + 16, 0, u, dv);
       v5.addVertexWithUV(x + 16, y + 16, 0, du, dv);
       v5.addVertexWithUV(x + 16, y, 0, du, v);
     }
     v5.addVertexWithUV(x, 65, 0, u, v);
     v5.addVertexWithUV(x, 68, 0, u, dv);
     v5.addVertexWithUV(x + 16, 68, 0, du, dv);
     v5.addVertexWithUV(x + 16, 65, 0, du, v);
     v5.draw();
     FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
     String s =
         f.getLocalizedName()
             + " ("
             + fs.amount
             + " mB) ("
             + RecipesCentrifuge.getRecipes().getFluidChance(in)
             + "%)";
     int l = fr.getStringWidth(s);
     fr.drawString(s, 166 - l, 70, 0);
   }
 }
Пример #28
0
  /** Renders an entity's name above its head */
  protected void renderLivingLabel(
      T entityIn, String str, double x, double y, double z, int maxDistance) {
    double d0 = entityIn.getDistanceSqToEntity(this.renderManager.livingPlayer);

    if (d0 <= (double) (maxDistance * maxDistance)) {
      FontRenderer fontrenderer = this.getFontRendererFromRenderManager();
      float f = 1.6F;
      float f1 = 0.016666668F * f;
      GlStateManager.pushMatrix();
      GlStateManager.translate((float) x + 0.0F, (float) y + entityIn.height + 0.5F, (float) z);
      GL11.glNormal3f(0.0F, 1.0F, 0.0F);
      GlStateManager.rotate(-this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
      GlStateManager.rotate(this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
      GlStateManager.scale(-f1, -f1, f1);
      GlStateManager.disableLighting();
      GlStateManager.depthMask(false);
      GlStateManager.disableDepth();
      GlStateManager.enableBlend();
      GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
      Tessellator tessellator = Tessellator.getInstance();
      WorldRenderer worldrenderer = tessellator.getWorldRenderer();
      int i = 0;

      if (str.equals("deadmau5")) {
        i = -10;
      }

      int j = fontrenderer.getStringWidth(str) / 2;
      GlStateManager.disableTexture2D();
      worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR);
      worldrenderer
          .pos((double) (-j - 1), (double) (-1 + i), 0.0D)
          .color(0.0F, 0.0F, 0.0F, 0.25F)
          .endVertex();
      worldrenderer
          .pos((double) (-j - 1), (double) (8 + i), 0.0D)
          .color(0.0F, 0.0F, 0.0F, 0.25F)
          .endVertex();
      worldrenderer
          .pos((double) (j + 1), (double) (8 + i), 0.0D)
          .color(0.0F, 0.0F, 0.0F, 0.25F)
          .endVertex();
      worldrenderer
          .pos((double) (j + 1), (double) (-1 + i), 0.0D)
          .color(0.0F, 0.0F, 0.0F, 0.25F)
          .endVertex();
      tessellator.draw();
      GlStateManager.enableTexture2D();
      fontrenderer.drawString(str, -fontrenderer.getStringWidth(str) / 2, i, 553648127);
      GlStateManager.enableDepth();
      GlStateManager.depthMask(true);
      fontrenderer.drawString(str, -fontrenderer.getStringWidth(str) / 2, i, -1);
      GlStateManager.enableLighting();
      GlStateManager.disableBlend();
      GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
      GlStateManager.popMatrix();
    }
  }
Пример #29
0
  @Override
  public void render(float paramFloat) {
    Minecraft mc = Minecraft.getMinecraft();

    if (mc.currentScreen instanceof GuiAdvancedHUDConfiguration
        || mc.currentScreen instanceof GuiScreenReposition) {
      itemName = "TOOLTIP";
    }

    if (itemName != null && !itemName.isEmpty()) {
      FontRenderer fontrenderer = mc.fontRenderer;
      int posX = 0;
      if (Alignment.isLeft(alignment)) {
        posX = this.posX;
      } else if (Alignment.isHorizontalCenter(alignment)) {
        posX = this.posX + (getWidth() - fontrenderer.getStringWidth(itemName)) / 2;
      } else {
        posX = this.posX + getWidth() - fontrenderer.getStringWidth(itemName);
      }

      fontrenderer.drawStringWithShadow(itemRarityColorCode + itemName, posX, posY, stringColor);
    }
  }
  @SideOnly(Side.CLIENT)
  private KnowledgeObject<?> getHoveredObject(
      FontRenderer fontRenderer, int mouseX, int mouseY, int x, int y) {
    if (!(mouseX >= x
        && mouseX <= x + CompendiumPageHandler.innerWidth
        && mouseY >= y
        && parsed.contains(linkColor))) return null;

    boolean origFont = fontRenderer.getUnicodeFlag();
    fontRenderer.setUnicodeFlag(true);

    List<String> list =
        fontRenderer.listFormattedStringToWidth(parsed, CompendiumPageHandler.innerWidth);

    if (mouseY <= y + list.size() * fontRenderer.FONT_HEIGHT) {
      boolean multiLine = false;
      int count = -1, index, prevIndex;
      String lineStr;

      for (int line = 0; line < list.size(); line++) {
        lineStr = list.get(line);
        prevIndex = -1;

        while ((index = lineStr.indexOf(linkColor, ++prevIndex)) != -1) {
          prevIndex = index;

          if (multiLine) multiLine = false;
          else ++count;

          int startX = x + fontRenderer.getStringWidth(lineStr.substring(0, prevIndex = index));

          if ((index = lineStr.indexOf(EnumChatFormatting.BLACK.toString(), index)) == -1) {
            index = lineStr.length();
            multiLine = true;
          }

          if (mouseY >= y + line * fontRenderer.FONT_HEIGHT
              && mouseY <= y + (line + 1) * fontRenderer.FONT_HEIGHT
              && mouseX >= startX
              && mouseX
                  <= startX + fontRenderer.getStringWidth(lineStr.substring(prevIndex, index))) {
            fontRenderer.setUnicodeFlag(origFont);
            return count < parsedObjects.size() ? parsedObjects.get(count) : null;
          }
        }
      }
    }

    fontRenderer.setUnicodeFlag(origFont);
    return null;
  }