net.minecraft.client.gui.Gui.drawRect()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(10.8k)|赞(0)|评价(0)|浏览(300)

本文整理了Java中net.minecraft.client.gui.Gui.drawRect()方法的一些代码示例,展示了Gui.drawRect()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Gui.drawRect()方法的具体详情如下:
包路径:net.minecraft.client.gui.Gui
类名称:Gui
方法名:drawRect

Gui.drawRect介绍

暂无

代码示例

代码示例来源:origin: Vazkii/Botania

private static void drawManaBar(ItemStack stack, IManaTooltipDisplay display, int mouseX, int mouseY, int width, int height) {
  float fraction = display.getManaFractionForDisplay(stack);
  int manaBarWidth = (int) Math.ceil(width * fraction);
  GlStateManager.disableDepth();
  Gui.drawRect(mouseX - 1, mouseY - height - 1, mouseX + width + 1, mouseY, 0xFF000000);
  Gui.drawRect(mouseX, mouseY - height, mouseX + manaBarWidth, mouseY, Color.HSBtoRGB(0.528F, ((float) Math.sin((ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks) * 0.2) + 1F) * 0.3F + 0.4F, 1F));
  Gui.drawRect(mouseX + manaBarWidth, mouseY - height, mouseX + width, mouseY, 0xFF555555);
}

代码示例来源:origin: Vazkii/Botania

@SideOnly(Side.CLIENT)
public static void renderHUD(ScaledResolution resolution, EntityPlayer player, ItemStack stack, float pticks) {
  int xo = resolution.getScaledWidth() / 2 - 20;
  int y = resolution.getScaledHeight() / 2 + 20;
  if(!player.capabilities.isFlying) {
    int cd = ItemNBTHelper.getInt(stack, TAG_DODGE_COOLDOWN, 0);
    int width = Math.min((int) ((cd - pticks) * 2), 40);
    GlStateManager.color(1F, 1F, 1F, 1F);
    if(width > 0) {
      Gui.drawRect(xo, y - 2, xo + 40, y - 1, 0x88000000);
      Gui.drawRect(xo, y - 2, xo + width, y - 1, 0xFFFFFFFF);
    }
  }
  GlStateManager.enableAlpha();
  GlStateManager.color(1F, 1F, 1F, 1F);
}

代码示例来源:origin: Vazkii/Botania

private static void drawTerraPick(ItemStack stack, int mouseX, int mouseY, int width, int height, FontRenderer font) {
  int level = ItemTerraPick.getLevel(stack);
  int max = ItemTerraPick.LEVELS[Math.min(ItemTerraPick.LEVELS.length - 1, level + 1)];
  boolean ss = level >= ItemTerraPick.LEVELS.length - 1;
  int curr = ItemTerraPick.getMana_(stack);
  float percent = level == 0 ? 0F : (float) curr / (float) max;
  int rainbowWidth = Math.min(width - (ss ? 0 : 1), (int) (width * percent));
  float huePer = width == 0 ? 0F : 1F / width;
  float hueOff = (ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks) * 0.01F;
  GlStateManager.disableDepth();
  Gui.drawRect(mouseX - 1, mouseY - height - 1, mouseX + width + 1, mouseY, 0xFF000000);
  for(int i = 0; i < rainbowWidth; i++)
    Gui.drawRect(mouseX + i, mouseY - height, mouseX + i + 1, mouseY, Color.HSBtoRGB(hueOff + huePer * i, 1F, 1F));
  Gui.drawRect(mouseX + rainbowWidth, mouseY - height, mouseX + width, mouseY, 0xFF555555);
  String rank = I18n.format("botania.rank" + level).replaceAll("&", "\u00a7");
  GL11.glPushAttrib(GL11.GL_LIGHTING_BIT);
  GlStateManager.disableLighting();
  font.drawStringWithShadow(rank, mouseX, mouseY - 12, 0xFFFFFF);
  if(!ss) {
    rank = I18n.format("botania.rank" + (level + 1)).replaceAll("&", "\u00a7");
    font.drawStringWithShadow(rank, mouseX + width - font.getStringWidth(rank), mouseY - 12, 0xFFFFFF);
  }
  GlStateManager.enableLighting();
  GlStateManager.enableDepth();
  GL11.glPopAttrib();
}

代码示例来源:origin: Vazkii/Botania

@SideOnly(Side.CLIENT)
@Override
public void renderHUD(Minecraft mc, ScaledResolution res, World world, BlockPos pos) {
  TileEntity tile = world.getTileEntity(pos);
  if(tile instanceof TileCraftCrate) {
    TileCraftCrate craft = (TileCraftCrate) tile;
    int width = 52;
    int height = 52;
    int xc = res.getScaledWidth() / 2 + 20;
    int yc = res.getScaledHeight() / 2 - height / 2;
    Gui.drawRect(xc - 6, yc - 6, xc + width + 6, yc + height + 6, 0x22000000);
    Gui.drawRect(xc - 4, yc - 4, xc + width + 4, yc + height + 4, 0x22000000);
    for(int i = 0; i < 3; i++)
      for(int j = 0; j < 3; j++) {
        int index = i * 3 + j;
        int xp = xc + j * 18;
        int yp = yc + i * 18;
        boolean enabled = true;
        if(craft.pattern > -1)
          enabled = TileCraftCrate.PATTERNS[craft.pattern][index];
        Gui.drawRect(xp, yp, xp + 16, yp + 16, enabled ? 0x22FFFFFF : 0x22FF0000);
        ItemStack item = craft.getItemHandler().getStackInSlot(index);
        net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting();
        GlStateManager.enableRescaleNormal();
        mc.getRenderItem().renderItemAndEffectIntoGUI(item, xp, yp);
        net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting();
      }
  }
}

代码示例来源:origin: Vazkii/Botania

private static void renderNearIndexDisplay(ScaledResolution res) {
  Minecraft mc = Minecraft.getMinecraft();
  String txt0 = I18n.format("botaniamisc.nearIndex0");
  String txt1 = TextFormatting.GRAY + I18n.format("botaniamisc.nearIndex1");
  String txt2 = TextFormatting.GRAY + I18n.format("botaniamisc.nearIndex2");
  int l = Math.max(mc.fontRenderer.getStringWidth(txt0), Math.max(mc.fontRenderer.getStringWidth(txt1), mc.fontRenderer.getStringWidth(txt2))) + 20;
  int x = res.getScaledWidth() - l - 20;
  int y = res.getScaledHeight() - 60;
  Gui.drawRect(x - 6, y - 6, x + l + 6, y + 37, 0x44000000);
  Gui.drawRect(x - 4, y - 4, x + l + 4, y + 35, 0x44000000);
  net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting();
  GlStateManager.enableRescaleNormal();
  mc.getRenderItem().renderItemAndEffectIntoGUI(new ItemStack(ModBlocks.corporeaIndex), x, y + 10);
  net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting();
  mc.fontRenderer.drawStringWithShadow(txt0, x + 20, y, 0xFFFFFF);
  mc.fontRenderer.drawStringWithShadow(txt1, x + 20, y + 14, 0xFFFFFF);
  mc.fontRenderer.drawStringWithShadow(txt2, x + 20, y + 24, 0xFFFFFF);
}

代码示例来源:origin: Vazkii/Botania

int y = resolution.getScaledHeight() / 2 - 90;
Gui.drawRect(x - 6, y - 6, x + 90 + 6, y + 60, 0x22000000);
Gui.drawRect(x - 4, y - 4, x + 90 + 4, y + 58, 0x22000000);
Gui.drawRect(x + 66, y + 14, x + 92, y + 40, 0x22000000);
Gui.drawRect(x - 2, y - 2, x + 56, y + 56, 0x22000000);
    int xpos = x + i % 3 * 18;
    int ypos = y + i / 3 * 18;
    Gui.drawRect(xpos, ypos, xpos + 16, ypos + 16, 0x22000000);

代码示例来源:origin: RS485/LogisticsPipes

protected void drawProgressPoint(int x, int y, int color) {
    int line = zoom.line + 1;
    Gui.drawRect(x - line + 1, y - line + 1, x + line, y + line, color);
  }
}

代码示例来源:origin: McJtyMods/TheOneProbe

/**
 * Draw a thick beveled box. x2 and y2 are not included.
 */
public static void drawThickBeveledBox(int x1, int y1, int x2, int y2, int thickness, int topleftcolor, int botrightcolor, int fillcolor) {
  if (fillcolor != -1) {
    Gui.drawRect(x1 + 1, y1 + 1, x2 - 1, y2 - 1, fillcolor);
  }
  Gui.drawRect(x1, y1, x2 - 1, y1 + thickness, topleftcolor);
  Gui.drawRect(x1, y1, x1 + thickness, y2 - 1, topleftcolor);
  Gui.drawRect(x2 - thickness, y1, x2, y2 - 1, botrightcolor);
  Gui.drawRect(x1, y2 - thickness, x2, y2, botrightcolor);
}

代码示例来源:origin: Mine-and-blade-admin/Battlegear2

/**
 * Draws a solid color rectangle with the specified coordinates and color. Args: x1, y1, x2, y2, color
 */
public static void drawRect(int x1, int y1, int x2, int y2, int col)
{
  Gui.drawRect(x1, y1, x2, y2, col);
}

代码示例来源:origin: Vazkii/Botania

private static void renderCrystalCubeHUD(ScaledResolution res, TileCorporeaCrystalCube tile) {
  Minecraft mc = Minecraft.getMinecraft();
  Profiler profiler = mc.profiler;
  profiler.startSection("crystalCube");
  ItemStack target = tile.getRequestTarget();
  if(!target.isEmpty()) {
    String s1 = target.getDisplayName();
    String s2 = tile.getItemCount() + "x";
    int strlen = Math.max(mc.fontRenderer.getStringWidth(s1), mc.fontRenderer.getStringWidth(s2));
    int w = res.getScaledWidth();
    int h = res.getScaledHeight();
    Gui.drawRect(w / 2 + 8, h / 2 - 12, w / 2 + strlen + 32, h / 2 + 10, 0x44000000);
    Gui.drawRect(w / 2 + 6, h / 2 - 14, w / 2 + strlen + 34, h / 2 + 12, 0x44000000);
    mc.fontRenderer.drawStringWithShadow(target.getDisplayName(), w / 2 + 30, h / 2 - 10, 0x6666FF);
    mc.fontRenderer.drawStringWithShadow(tile.getItemCount() + "x", w / 2 + 30, h / 2, 0xFFFFFF);
    net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting();
    GlStateManager.enableRescaleNormal();
    mc.getRenderItem().renderItemAndEffectIntoGUI(target, w / 2 + 10, h / 2 - 10);
    net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting();
  }
  profiler.endSection();
}

代码示例来源:origin: Vazkii/Botania

GlStateManager.color(1F, 1F, 1F, 1F);
if(width > 0)
  Gui.drawRect(xo, y - 2, xo + 80, y - 1, 0x88000000);
Gui.drawRect(xo, y - 2, xo + width, y - 1, 0xFFFFFFFF);

代码示例来源:origin: Vazkii/Botania

GlStateManager.translate(x, y, 0);
GlStateManager.scale(fract, 1F, 1F);
Gui.drawRect(12, -30, width + 20, -2, 0x44000000);
Gui.drawRect(10, -32, width + 22, -2, 0x44000000);

代码示例来源:origin: MrCrayfish/MrCrayfishDeviceMod

@Override
  public void render(Gui gui, Minecraft mc, int x, int y, int width, int height, int mouseX, int mouseY, boolean windowActive)
  {
    Gui.drawRect(x, y, x + width, y + 22, Color.LIGHT_GRAY.getRGB());
    Gui.drawRect(x, y + 22, x + width, y + 23, Color.DARK_GRAY.getRGB());
    mc.fontRenderer.drawString("Select an Item...", x + 5, y + 7, Color.WHITE.getRGB(), true);
  }
});

代码示例来源:origin: MrCrayfish/MrCrayfishDeviceMod

@Override
  public void render(Gui gui, Minecraft mc, int x, int y, int width, int height, int mouseX, int mouseY, boolean windowActive)
  {
    Gui.drawRect(x, y, x + width, y + 22, Color.LIGHT_GRAY.getRGB());
    Gui.drawRect(x, y + 22, x + width, y + 23, Color.DARK_GRAY.getRGB());
    mc.fontRenderer.drawString("Set duration...", x + 5, y + 7, Color.WHITE.getRGB(), true);
  }
});

代码示例来源:origin: Vazkii/Botania

int y = resolution.getScaledHeight() / 2 - 65;
Gui.drawRect(x - 6, y - 6, x + l + 6, y + 37, 0x22000000);
Gui.drawRect(x - 4, y - 4, x + l + 4, y + 35, 0x22000000);
net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting();
GlStateManager.enableRescaleNormal();

代码示例来源:origin: MrCrayfish/MrCrayfishDeviceMod

@Override
  public void render(Gui gui, Minecraft mc, int x, int y, int width, int height, int mouseX, int mouseY, boolean windowActive)
  {
    Gui.drawRect(x, y, x + width, y + 25, Color.GRAY.getRGB());
    Gui.drawRect(x, y + 24, x + width, y + 25, Color.DARK_GRAY.getRGB());
    Gui.drawRect(x, y + 25, x + 95, y + height, Color.LIGHT_GRAY.getRGB());
    Gui.drawRect(x + 94, y + 25, x + 95, y + height, Color.GRAY.getRGB());
    
    mc.getTextureManager().bindTexture(MINEBAY_ASSESTS);
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    RenderUtil.drawRectWithTexture(x + 5, y + 6, 0, 0, 61, 11, 61, 12);
  }
});

代码示例来源:origin: MrCrayfish/MrCrayfishDeviceMod

@Override
  public void render(Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks)
  {
    Color color = new Color(Laptop.getSystem().getSettings().getColorScheme().getHeaderColor());
    Gui.drawRect(x, y, x + width, y + 20, color.getRGB());
    Gui.drawRect(x, y + 20, x + width, y + 21, color.darker().getRGB());
    mc.fontRenderer.drawString(title, x + 22, y + 6, Color.WHITE.getRGB(), true);
    super.render(laptop, mc, x, y, mouseX, mouseY, windowActive, partialTicks);
  }
}

代码示例来源:origin: Vazkii/Botania

GlStateManager.disableDepth();
Gui.drawRect(x - 4, tooltipY - 4, x + 20, tooltipY + 26, 0x44000000);
Gui.drawRect(x - 6, tooltipY - 6, x + 22, tooltipY + 28, 0x44000000);

代码示例来源:origin: lorddusk/HQM

public void drawCursor(int x, int y, int z, float size, int color) {
  GlStateManager.pushMatrix();
  GlStateManager.translate(0, 0, z);
  x += left;
  y += top;
  GlStateManager.translate(x, y, 0);
  GlStateManager.scale(size, size, 0);
  GlStateManager.translate(-x, -y, 0);
  Gui.drawRect(x, y + 1, x + 1, y + 10, color);
  GlStateManager.popMatrix();
}

代码示例来源:origin: SleepyTrousers/EnderIO

@Override
public void drawInfo(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) {
 FontRenderer fr = minecraft.fontRenderer;
 fr.drawString(Lang.GRINDING_BALL_2.get("", LangPower.toPercent(ball.getGrindingMultiplier())), 48, 4, 0x404040);
 fr.drawString(Lang.GRINDING_BALL_3.get("", LangPower.toPercent(ball.getChanceMultiplier())), 48, 16, 0x404040);
 fr.drawString(Lang.GRINDING_BALL_4.get("", LangPower.toPercent(ball.getPowerMultiplier())), 48, 28, 0x404040);
 int dura = ball.getDurability();
 int usedDura = (timer.getValue() * 400) % dura;
 int barH = (16 * usedDura) / dura;
 int barColor = 0xFFCA2F21;
 Gui.drawRect(37, 12 + barH, 41, 28, barColor);
}

相关文章