net.minecraft.client.gui.Gui类的使用及代码示例

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

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

Gui介绍

暂无

代码示例

代码示例来源: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: OpenMods/OpenModsLib

protected void renderTopLeftCorner(Gui gui) {
  gui.drawTexturedModalRect(0, 0, u, v, 4, 4);
}

代码示例来源:origin: PrinceOfAmber/Cyclic

@Override
 protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
  super.drawGuiContainerBackgroundLayer(partialTicks, mouseX, mouseY);
  int u = 0, v = 0;
  this.mc.getTextureManager().bindTexture(Const.Res.SLOT);
  Gui.drawModalRectWithCustomSizedTexture(
    this.guiLeft + 50 - 1,
    this.guiTop + ContainerAnvilAuto.SLOTY - 1,
    u, v, Const.SQ, Const.SQ, Const.SQ, Const.SQ);
  Gui.drawModalRectWithCustomSizedTexture(
    this.guiLeft + 110 - 1,
    this.guiTop + ContainerAnvilAuto.SLOTY - 1,
    u, v, Const.SQ, Const.SQ, Const.SQ, Const.SQ);
 }
}

代码示例来源:origin: gegy1000/Terrarium

@Override
public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected, float partialTicks) {
  this.mc.fontRenderer.drawString(this.preset.getLocalizedName(), x + 32 + 3, y + 1, 0xFFFFFF);
  String description = TextFormatting.DARK_GRAY + this.preset.getLocalizedDescription();
  this.mc.fontRenderer.drawString(description, x + 32 + 3, y + this.mc.fontRenderer.FONT_HEIGHT + 3, 0xFFFFFF);
  GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
  TextureManager textureManager = this.mc.getTextureManager();
  textureManager.bindTexture(this.icon);
  if (textureManager.getTexture(this.icon) == TextureUtil.MISSING_TEXTURE) {
    textureManager.bindTexture(FALLBACK_ICON);
  }
  Gui.drawModalRectWithCustomSizedTexture(x, y, 0.0F, 0.0F, 32, 32, 32.0F, 32.0F);
  if (this.mc.gameSettings.touchscreen || isSelected) {
    Gui.drawRect(x, y, x + 32, y + 32, 0xA0909090);
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    textureManager.bindTexture(ICON_OVERLAY);
    Gui.drawModalRectWithCustomSizedTexture(x, y, 0.0F, mouseX - x < 32 ? 32.0F : 0.0F, 32, 32, 256.0F, 256.0F);
  }
}

代码示例来源:origin: ForestryMC/ForestryMC

public void draw(int xOffset, int yOffset, int width, int height) {
    TextureManager textureManager = Minecraft.getMinecraft().getTextureManager();
    textureManager.bindTexture(textureLocation);

    // Enable correct lighting.
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);

    Gui.drawScaledCustomSizeModalRect(xOffset, yOffset, u, v, uWidth, vHeight, width, height, textureWidth, textureHeight);
  }
}

代码示例来源:origin: PrinceOfAmber/Cyclic

@Override
 protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
  super.drawGuiContainerBackgroundLayer(partialTicks, mouseX, mouseY);
  int u = 0, v = 0;
  this.mc.getTextureManager().bindTexture(Const.Res.SLOT);
  Gui.drawModalRectWithCustomSizedTexture(
    this.guiLeft + 50 - 1,
    this.guiTop + ContainerAnvilAuto.SLOTY - 1,
    u, v, Const.SQ, Const.SQ, Const.SQ, Const.SQ);
  Gui.drawModalRectWithCustomSizedTexture(
    this.guiLeft + 110 - 1,
    this.guiTop + ContainerAnvilAuto.SLOTY - 1,
    u, v, Const.SQ, Const.SQ, Const.SQ, Const.SQ);
 }
}

代码示例来源:origin: P3pp3rF1y/AncientWarfare2

@Override
public void render(int mouseX, int mouseY, float partialTick) {
  super.render(mouseX, mouseY, partialTick);
  Minecraft.getMinecraft().renderEngine.bindTexture(texture);
  int textureWidth = getElement().getWidth();
  int textureHeight = getElement().getHeight();
  float scale = getScale(width, textureWidth);
  int scaledWidth = (int) (scale * textureWidth);
  int padding = Math.min(0, (width - scaledWidth) / 2);
  Gui.drawScaledCustomSizeModalRect(renderX + padding, renderY, 0, 0, textureWidth, textureHeight, scaledWidth, (int) (textureHeight * scale),
      textureWidth, textureHeight);
}

代码示例来源: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: mezz/JustEnoughItems

@Override
  public void draw(Minecraft minecraft, int xOffset, int yOffset, int maskTop, int maskBottom, int maskLeft, int maskRight) {
    minecraft.getTextureManager().bindTexture(this.resourceLocation);

    int x = xOffset + this.paddingLeft + maskLeft;
    int y = yOffset + this.paddingTop + maskTop;
    int u = this.u + maskLeft;
    int v = this.v + maskTop;
    int width = this.width - maskRight - maskLeft;
    int height = this.height - maskBottom - maskTop;
    Gui.drawModalRectWithCustomSizedTexture(x, y, u, v, width, height, textureWidth, textureHeight);
  }
}

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

public void render(int x, int y) {
  Minecraft mc = Minecraft.getMinecraft();
  switch(type) {
  case STACK:
    RenderHelper.enableGUIStandardItemLighting();
    mc.getRenderItem().renderItemIntoGUI(stack, x, y);    
    break;
    
  case RESOURCE:
    GlStateManager.color(1F, 1F, 1F, 1F);
    mc.renderEngine.bindTexture(res);
    Gui.drawScaledCustomSizeModalRect(x, y, 0, 0, 16, 16, 16, 16, 16, 16);
    break;
  }
}

代码示例来源:origin: OpenMods/OpenModsLib

protected void renderBottomRightCorner(Gui gui, int width, int height) {
  gui.drawTexturedModalRect(width - 4, height - 4, u + 15, v, 4, 4);
}

代码示例来源: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: PrinceOfAmber/Cyclic

@Override
 protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
  super.drawGuiContainerBackgroundLayer(partialTicks, mouseX, mouseY);
  int u = 0, v = 0;
  this.mc.getTextureManager().bindTexture(Const.Res.SLOT);
  //first draw the zero slot
  Gui.drawModalRectWithCustomSizedTexture(this.guiLeft + ContainerUncrafting.SLOTX_INPUT - 1, this.guiTop + ContainerUncrafting.SLOTY_INPUT - 1, u, v, Const.SQ, Const.SQ, Const.SQ, Const.SQ);
  int xPrefix = 48;
  for (int i = 0; i < TileEntityUncrafter.SLOT_ROWS; i++) {
   for (int j = 0; j < TileEntityUncrafter.SLOT_COLS; j++) {
    Gui.drawModalRectWithCustomSizedTexture(
      this.guiLeft + xPrefix - 1 + j * Const.SQ,
      this.guiTop + ContainerUncrafting.SLOTY_INPUT + (i - 1) * Const.SQ - 1,
      u, v, Const.SQ, Const.SQ, Const.SQ, Const.SQ);
   }
  }
 }
}

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

Gui.drawScaledCustomSizeModalRect(-4, 26, 0, 0, 16, 16, 16, 16, 64, 64);

代码示例来源:origin: OpenMods/OpenModsLib

protected void renderTopRightCorner(Gui gui, int width) {
  gui.drawTexturedModalRect(width - 3, 0, u + 5, v, 3, 3);
}

代码示例来源: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: WesCook/Nutrition

@Override
@SideOnly(Side.CLIENT)
public void renderInventoryEffect(int x, int y, PotionEffect effect, Minecraft mc) {
  if (mc.currentScreen != null) {
    mc.getTextureManager().bindTexture(icon);
    Gui.drawModalRectWithCustomSizedTexture(x + 6, y + 7, 0, 0, 18, 18, 18, 18);
  }
}

代码示例来源:origin: gegy1000/Terrarium

private void renderTile(int cameraX, int cameraY, int cameraZoom, SlippyMapTilePos pos, SlippyMapTile image, float partialTicks) {
  image.update(partialTicks);
  if (image.getLocation() != null) {
    int deltaZoom = cameraZoom - pos.getZoom();
    double zoomScale = Math.pow(2.0, deltaZoom);
    int size = MathHelper.floor(SlippyMap.TILE_SIZE * zoomScale);
    int renderX = (pos.getX() << deltaZoom) * SlippyMap.TILE_SIZE - cameraX;
    int renderY = (pos.getY() << deltaZoom) * SlippyMap.TILE_SIZE - cameraY;
    MC.getTextureManager().bindTexture(image.getLocation());
    GlStateManager.color(1.0F, 1.0F, 1.0F, image.getTransition());
    Gui.drawScaledCustomSizeModalRect(renderX, renderY, 0, 0, SlippyMap.TILE_SIZE, SlippyMap.TILE_SIZE, size, size, SlippyMap.TILE_SIZE, SlippyMap.TILE_SIZE);
  }
}

代码示例来源:origin: OpenMods/OpenModsLib

protected void renderBottomLeftCorner(Gui gui, int height) {
  gui.drawTexturedModalRect(0, height - 3, u + 11, v, 3, 3);
}

代码示例来源: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);
}

相关文章