net.minecraft.client.renderer.GlStateManager Java Examples

The following examples show how to use net.minecraft.client.renderer.GlStateManager. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Utils.java    From SkyblockAddons with MIT License 6 votes vote down vote up
public void drawTextWithStyle(String text, float x, float y, int color) {
    GlStateManager.pushMatrix();
    GlStateManager.translate(x, y, 0);

    if (main.getConfigValues().getTextStyle() == EnumUtils.TextStyle.STYLE_TWO) {
        int colorAlpha = Math.max(getAlpha(color), 4);
        int colorBlack = new Color(0, 0, 0, colorAlpha/255F).getRGB();
        String strippedText = TextUtils.stripColor(text);
        Minecraft.getMinecraft().fontRendererObj.drawString(strippedText,1, 0, colorBlack, false);
        Minecraft.getMinecraft().fontRendererObj.drawString(strippedText, -1, 0, colorBlack, false);
        Minecraft.getMinecraft().fontRendererObj.drawString(strippedText, 0, 1, colorBlack, false);
        Minecraft.getMinecraft().fontRendererObj.drawString(strippedText, 0, -1, colorBlack, false);
        Minecraft.getMinecraft().fontRendererObj.drawString(text, 0, 0, color, false);
    } else {
        Minecraft.getMinecraft().fontRendererObj.drawString(text, 0, 0, color, true);
    }

    GlStateManager.popMatrix();
}
 
Example #2
Source File: SliderWidget.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void drawInBackground(int mouseX, int mouseY, IRenderContext context) {
    Position pos = getPosition();
    Size size = getSize();
    if (backgroundArea != null) {
        backgroundArea.draw(pos.x, pos.y, size.width, size.height);
    }
    if(displayString == null) {
        this.displayString = getDisplayString();
    }
    sliderIcon.draw(pos.x + (int) (this.sliderPosition * (float) (size.width - 8)), pos.y, sliderWidth, size.height);
    FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
    fontRenderer.drawString(displayString,
        pos.x + size.width / 2 - fontRenderer.getStringWidth(displayString) / 2,
        pos.y + size.height / 2 - fontRenderer.FONT_HEIGHT / 2, textColor);
    GlStateManager.color(1.0f, 1.0f, 1.0f);
}
 
Example #3
Source File: ModelBigCat.java    From TFC2 with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Sets the models various rotation angles then renders the model.
 */
@Override
public void render(Entity entityIn, float p_78088_2_, float p_78088_3_, float p_78088_4_, float p_78088_5_, float p_78088_6_, float scale)
{
	this.setRotationAngles(p_78088_2_, p_78088_3_, p_78088_4_, p_78088_5_, p_78088_6_, scale, entityIn);
	if(((EntityBigCat)entityIn).getGender() == Gender.Male)
	{
		GlStateManager.scale(1.5, 1.5, 1.5);
		GlStateManager.translate(0.0, -0.5, -0.5);
	}
	else
	{
		GlStateManager.scale(1.4, 1.4, 1.4);
		GlStateManager.translate(0.0, -0.44, -0.5);
	}
	Neck.render(scale);
	HEAD.render(scale);
	BODY.render(scale);
	LegLEFTREAR.render(scale);
	LegLEFTFRONT.render(scale);
	LegRIGHTFRONT.render(scale);
	LegRIGHTREAR.render(scale);
}
 
Example #4
Source File: CraftingPatternSelection.java    From SkyblockAddons with MIT License 6 votes vote down vote up
public void draw() {
    GlStateManager.disableDepth();
    GlStateManager.enableBlend();
    Minecraft.getMinecraft().getTextureManager().bindTexture(CraftingPattern.ICONS);
    GlStateManager.color(1,1,1, 1F);
    for(CraftingPattern craftingPattern : CraftingPattern.values()) {
        int offset = getYOffsetByIndex(craftingPattern.index);
        GlStateManager.color(1,1,1, 1F);
        mc.ingameGUI.drawTexturedModalRect(x, y+ offset, 0, offset, ICON_SIZE, ICON_SIZE);
        if(craftingPattern != SkyblockAddons.getInstance().getPersistentValues().getSelectedCraftingPattern()) {
            GlStateManager.color(1,1,1, .5F);
            mc.ingameGUI.drawTexturedModalRect(x, y+ offset, 33, 0, ICON_SIZE, ICON_SIZE);
        }
    }
    GlStateManager.disableBlend();
    GlStateManager.enableDepth();

    blockIncompleteCheckBox.draw();
}
 
Example #5
Source File: TextureUtils.java    From CodeChickenLib with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static void prepareTexture(int target, int texture, int min_mag_filter, int wrap) {
    GL11.glTexParameteri(target, GL11.GL_TEXTURE_MIN_FILTER, min_mag_filter);
    GL11.glTexParameteri(target, GL11.GL_TEXTURE_MAG_FILTER, min_mag_filter);
    if(target == GL11.GL_TEXTURE_2D)
        GlStateManager.bindTexture(target);
    else
        GL11.glBindTexture(target, texture);

    switch (target) {
        case GL12.GL_TEXTURE_3D:
            GL11.glTexParameteri(target, GL12.GL_TEXTURE_WRAP_R, wrap);
        case GL11.GL_TEXTURE_2D:
            GL11.glTexParameteri(target, GL11.GL_TEXTURE_WRAP_T, wrap);
        case GL11.GL_TEXTURE_1D:
            GL11.glTexParameteri(target, GL11.GL_TEXTURE_WRAP_S, wrap);
    }
}
 
Example #6
Source File: ModelElk.java    From TFC2 with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Sets the models various rotation angles then renders the model.
 */
@Override
public void render(Entity entityIn, float p_78088_2_, float p_78088_3_, float p_78088_4_, float p_78088_5_, float p_78088_6_, float scale)
{
	this.setRotationAngles(p_78088_2_, p_78088_3_, p_78088_4_, p_78088_5_, p_78088_6_, scale, entityIn);

	GlStateManager.pushMatrix();
	//GlStateManager.translate(0.0F, 0.0F, -0.5F);
	Body.render(scale);
	Tail.render(scale);
	LegFrontLUpper.render(scale);
	LegFrontRUpper.render(scale);
	LegRearLUpper.render(scale);
	LegRearRUpper.render(scale);
	Mane.render(scale);
	GlStateManager.popMatrix();
}
 
Example #7
Source File: GuiItemIconDumper.java    From NotEnoughItems with MIT License 6 votes vote down vote up
private void drawItems() {
    Dimension d = GuiDraw.getDisplayRes();

    GlStateManager.matrixMode(GL11.GL_PROJECTION);
    GlStateManager.loadIdentity();
    GlStateManager.ortho(0, d.width * 16D / iconSize, d.height * 16D / iconSize, 0, 1000, 3000);
    GlStateManager.matrixMode(GL11.GL_MODELVIEW);
    GlStateManager.clearColor(0, 0, 0, 0);
    GlStateManager.clear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);

    int rows = d.height / boxSize;
    int cols = d.width / boxSize;
    int fit = rows * cols;

    RenderHelper.enableGUIStandardItemLighting();
    GlStateManager.enableRescaleNormal();
    GlStateManager.color(1, 1, 1, 1);

    for (int i = 0; drawIndex < ItemPanel.items.size() && i < fit; drawIndex++, i++) {
        int x = i % cols * 18;
        int y = i / cols * 18;
        GuiHelper.drawItem(x + 1, y + 1, ItemPanel.items.get(drawIndex));
    }

    GL11.glFlush();
}
 
Example #8
Source File: ButtonSettings.java    From SkyblockAddons with MIT License 6 votes vote down vote up
@Override
public void drawButton(Minecraft mc, int mouseX, int mouseY) {
    if (visible) {
        float alphaMultiplier = 1F;
        if (main.getUtils().isFadingIn()) {
            long timeSinceOpen = System.currentTimeMillis() - timeOpened;
            int fadeMilis = 500;
            if (timeSinceOpen <= fadeMilis) {
                alphaMultiplier = (float) timeSinceOpen / fadeMilis;
            }
        }
        hovered = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
        // Alpha multiplier is from 0 to 1, multiplying it creates the fade effect.
        // Regular features are red if disabled, green if enabled or part of the gui feature is enabled.
        GlStateManager.enableBlend();
        GlStateManager.color(1,1,1,alphaMultiplier*0.7F);
        if (hovered) {
            GlStateManager.color(1,1,1,1);
        }
        mc.getTextureManager().bindTexture(GEAR);
        main.getUtils().drawModalRectWithCustomSizedTexture(xPosition, yPosition,0,0,width,height,width,height, true);
    }
}
 
Example #9
Source File: ItemArmorCyberware.java    From Cyberware with MIT License 6 votes vote down vote up
@Override
public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale)
{
	super.render(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
	GlStateManager.pushMatrix();

	if (this.isChild)
	{
		float f = 2.0F;
		GlStateManager.scale(1.0F / f, 1.0F / f, 1.0F / f);
		GlStateManager.translate(0.0F, 24.0F * scale, 0.0F);
		this.bottomThing.render(scale);

	}
	else
	{
		if (entityIn.isSneaking())
		{
			GlStateManager.translate(0.0F, 0.2F, 0.0F);
		}

		this.bottomThing.render(scale);
	}

	GlStateManager.popMatrix();
}
 
Example #10
Source File: ModelPortableBarrel.java    From BetterChests with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void render(ItemStack stack, float patrtialTicks) {
	GlStateManager.pushMatrix();
	RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();
	renderItem.renderItem(stack, parent);
	InventoryBPortableBarrel barrel = BlocksItemsBetterChests.betterportablebarrel.getInventoryFor(stack, null);
	if (barrel != null && barrel.getChestPart().isItemSet()) {
		InventoryPartBarrel part = barrel.getChestPart();
		GlStateManager.pushMatrix();
		GlStateManager.translate(0, 0, -0.05);
		GlStateManager.scale(0.8, 0.8, 0.8);

		renderItem.renderItem(part.getDummy(), TransformType.FIXED);

		GlStateManager.enableBlend();
		GlStateManager.popMatrix();
	}
	GlStateManager.popMatrix();
}
 
Example #11
Source File: SurfaceHelper.java    From ForgeHax with MIT License 6 votes vote down vote up
public static void drawPotionEffect(PotionEffect potion, int x, int y) {
  int index = potion.getPotion().getStatusIconIndex();
  GlStateManager.pushMatrix();
  RenderHelper.enableGUIStandardItemLighting();
  GlStateManager.disableLighting();
  GlStateManager.enableRescaleNormal();
  GlStateManager.enableColorMaterial();
  GlStateManager.enableLighting();
  GlStateManager.enableTexture2D();
  GlStateManager.color(1.f, 1.f, 1.f, 1.f);
  MC.getTextureManager().bindTexture(GuiContainer.INVENTORY_BACKGROUND);
  drawTexturedRect(x, y, index % 8 * 18, 198 + index / 8 * 18, 18, 18, 100);
  potion.getPotion().renderHUDEffect(x, y, potion, MC, 255);
  GlStateManager.disableLighting();
  GlStateManager.enableDepth();
  GlStateManager.color(1.f, 1.f, 1.f, 1.f);
  GlStateManager.popMatrix();
}
 
Example #12
Source File: RenderUtils.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void drawCircle(int xx, int yy, int radius, int col) {
    float f = (col >> 24 & 0xFF) / 255.0F;
    float f2 = (col >> 16 & 0xFF) / 255.0F;
    float f3 = (col >> 8 & 0xFF) / 255.0F;
    float f4 = (col & 0xFF) / 255.0F;
    GL11.glPushMatrix();
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glEnable(GL11.GL_LINE_SMOOTH);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    GL11.glBegin(2);

    for (int i = 0; i < 70; i++) {
        float x = radius * MathHelper.cos((float) (i * 0.08975979010256552D));
        float y = radius * MathHelper.sin((float) (i * 0.08975979010256552D));
        GlStateManager.color(f2, f3, f4, f);
        GL11.glVertex2f(xx + x, yy + y);
    }

    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glEnd();
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_LINE_SMOOTH);
    GL11.glPopMatrix();
}
 
Example #13
Source File: CollectorGui.java    From EmergingTechnology with MIT License 5 votes vote down vote up
@Override
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
	GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f);
	this.mc.getTextureManager().bindTexture(TEXTURES);
	this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize);

}
 
Example #14
Source File: RenderFallTofu.java    From TofuCraftReload with MIT License 5 votes vote down vote up
/**
 * Renders the desired {@code T} type Entity.
 */
public void doRender(EntityFallTofu entity, double x, double y, double z, float entityYaw, float partialTicks) {

    IBlockState iblockstate = BlockLoader.tofuTerrain.getDefaultState();

    if (iblockstate.getRenderType() == EnumBlockRenderType.MODEL) {
        World world = entity.getWorldObj();

        if (iblockstate != world.getBlockState(new BlockPos(entity)) && iblockstate.getRenderType() != EnumBlockRenderType.INVISIBLE) {
            this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
            GlStateManager.pushMatrix();
            GlStateManager.disableLighting();
            Tessellator tessellator = Tessellator.getInstance();
            BufferBuilder bufferbuilder = tessellator.getBuffer();

            if (this.renderOutlines) {
                GlStateManager.enableColorMaterial();
                GlStateManager.enableOutlineMode(this.getTeamColor(entity));
            }

            bufferbuilder.begin(7, DefaultVertexFormats.BLOCK);
            BlockPos blockpos = new BlockPos(entity.posX, entity.getEntityBoundingBox().maxY, entity.posZ);
            GlStateManager.translate((float) (x - (double) blockpos.getX() - 0.5D), (float) (y - (double) blockpos.getY()), (float) (z - (double) blockpos.getZ() - 0.5D));
            BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
            blockrendererdispatcher.getBlockModelRenderer().renderModel(world, blockrendererdispatcher.getModelForState(iblockstate), iblockstate, blockpos, bufferbuilder, false);
            tessellator.draw();

            if (this.renderOutlines) {
                GlStateManager.disableOutlineMode();
                GlStateManager.disableColorMaterial();
            }

            GlStateManager.enableLighting();
            GlStateManager.popMatrix();
            super.doRender(entity, x, y, z, entityYaw, partialTicks);
        }
    }

}
 
Example #15
Source File: GuiEnchantmentModifier.java    From NotEnoughItems with MIT License 5 votes vote down vote up
protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
    GlStateManager.color(1, 1, 1, 1);
    TextureUtils.changeTexture("textures/gui/container/enchanting_table.png");
    GlStateManager.translate(guiLeft, guiTop, 0);
    drawTexturedModalRect(0, 0, 0, 0, xSize, ySize);

    container.onUpdate(i, j);
    container.drawSlots(this);
    container.drawScrollBar(this);

    String levelstring = "" + container.level;
    fontRenderer.drawString(levelstring, 33 - fontRenderer.getStringWidth(levelstring) / 2, 34, 0xFF606060);

    GlStateManager.translate(-guiLeft, -guiTop, 0);
}
 
Example #16
Source File: RenderUtils.java    From OpenModsLib with MIT License 5 votes vote down vote up
public static void setColor(int rgb, float alpha) {
	final float r = (float)((rgb >> 16) & 0xFF) / 255;
	final float g = (float)((rgb >> 8) & 0xFF) / 255;
	final float b = (float)((rgb >> 0) & 0xFF) / 255;

	GlStateManager.color(r, g, b, alpha);
}
 
Example #17
Source File: ModelTofuTurret.java    From TofuCraftReload with MIT License 5 votes vote down vote up
@Override
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {
    GlStateManager.pushMatrix();
    GlStateManager.scale(1.1F, 1.1F, 1.1F);
    this.core.render(f5);
    GlStateManager.popMatrix();
}
 
Example #18
Source File: GuiMinecoprocessor.java    From Minecoprocessors with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Draws the background layer of this container (behind the items).
 */
@Override
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
  GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
  this.mc.getTextureManager().bindTexture(TEXTURES);
  int i = (this.width - this.xSize) / 2;
  int j = (this.height - this.ySize) / 2;
  this.drawTexturedModalRect(i, j, 0, 0, this.xSize, this.ySize);
  int k = this.minecoprocessor.getField(1);
  int l = MathHelper.clamp((18 * k + 20 - 1) / 20, 0, 18);

  if (l > 0) {
    this.drawTexturedModalRect(i + 60, j + 44, 176, 29, l, 4);
  }

  int i1 = this.minecoprocessor.getField(0);

  if (i1 > 0) {
    int j1 = (int) (28.0F * (1.0F - i1 / 400.0F));

    if (j1 > 0) {
      this.drawTexturedModalRect(i + 97, j + 16, 176, 0, 9, j1);
    }

    j1 = 0;

    if (j1 > 0) {
      this.drawTexturedModalRect(i + 63, j + 14 + 29 - j1, 185, 29 - j1, 12, j1);
    }
  }
}
 
Example #19
Source File: CookerGui.java    From EmergingTechnology with MIT License 5 votes vote down vote up
@Override
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
	GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f);
	this.mc.getTextureManager().bindTexture(TEXTURES);
	this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize);

}
 
Example #20
Source File: PortalFinderModule.java    From seppuku with GNU General Public License v3.0 5 votes vote down vote up
@Listener
public void render3D(EventRender3D event) {
    if (this.mode.getValue() == Mode.THREE_DIMENSIONAL) {
        final Minecraft mc = Minecraft.getMinecraft();

        for (Vec3d portal : this.portals) {
            GlStateManager.pushMatrix();
            final boolean bobbing = mc.gameSettings.viewBobbing;
            mc.gameSettings.viewBobbing = false;
            mc.entityRenderer.setupCameraTransform(event.getPartialTicks(), 0);

            final Vec3d forward = new Vec3d(0, 0, 1).rotatePitch(-(float) Math.toRadians(Minecraft.getMinecraft().player.rotationPitch)).rotateYaw(-(float) Math.toRadians(Minecraft.getMinecraft().player.rotationYaw));

            // Line
            RenderUtil.drawLine3D((float) forward.x, (float) forward.y + mc.player.getEyeHeight(), (float) forward.z, (float) (portal.x - mc.getRenderManager().renderPosX), (float) (portal.y - mc.getRenderManager().renderPosY), (float) (portal.z - mc.getRenderManager().renderPosZ), this.width.getValue(), new Color(red.getValue() / 255.0f, green.getValue() / 255.0f, blue.getValue() / 255.0f).getRGB());

            // Info
            if (this.showInfo.getValue()) {
                RenderUtil.glBillboardDistanceScaled((float) portal.x, (float) portal.y, (float) portal.z, mc.player, this.infoScale.getValue());
                GlStateManager.disableDepth();
                this.drawPortalInfoText(portal, 0, 0);
                GlStateManager.enableDepth();
            }

            mc.gameSettings.viewBobbing = bobbing;
            mc.entityRenderer.setupCameraTransform(event.getPartialTicks(), 0);
            GlStateManager.popMatrix();
        }
    }
}
 
Example #21
Source File: GuiContainerWidget.java    From CodeChickenCore with MIT License 5 votes vote down vote up
@Override
protected void drawGuiContainerBackgroundLayer(float f, int mousex, int mousey) {
    GlStateManager.translate(guiLeft, guiTop, 0);
    drawBackground();
    for (GuiWidget widget : widgets)
        widget.draw(mousex - guiLeft, mousey - guiTop, f);

    GlStateManager.translate(-guiLeft, -guiTop, 0);
}
 
Example #22
Source File: LuminanceProducerImplementation.java    From malmo with MIT License 5 votes vote down vote up
@Override
public void getFrame(MissionInit missionInit, ByteBuffer buffer)
{
    final int width = getWidth();
    final int height = getHeight();

    // Render the Minecraft frame into our own FBO, at the desired size:
    OpenGlHelper.glUseProgram(shaderID);
    this.fbo.bindFramebuffer(true);
    Minecraft.getMinecraft().getFramebuffer().framebufferRenderExt(width, height, true);
    GlStateManager.bindTexture(this.fbo.framebufferTexture);
    GL11.glGetTexImage(GL11.GL_TEXTURE_2D, 0, GL_RED, GL_UNSIGNED_BYTE, buffer);
    this.fbo.unbindFramebuffer();
    OpenGlHelper.glUseProgram(0);
}
 
Example #23
Source File: ModularUIGui.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void drawSlotContents(Slot slot) {
    GlStateManager.enableDepth();
    RenderHelper.enableGUIStandardItemLighting();
    OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0F, 240.0F);
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    drawSlot(slot);
    GlStateManager.enableDepth();
    GlStateManager.enableBlend();
    GlStateManager.disableLighting();
}
 
Example #24
Source File: GuiContainer.java    From NotEnoughItems with MIT License 5 votes vote down vote up
private void drawItemStack(ItemStack stack, int x, int y, String altText)
{
    GlStateManager.translate(0.0F, 0.0F, 32.0F);
    this.zLevel = 500.0F;
    itemRender.zLevel = 500.0F;
    FontRenderer font = null;
    if (stack != null) font = stack.getItem().getFontRenderer(stack);
    if (font == null) font = fontRendererObj;
    this.itemRender.renderItemAndEffectIntoGUI(stack, x, y);
    this.itemRender.renderItemOverlayIntoGUI(font, stack, x, y - (this.draggedStack == null ? 0 : 8), altText);
    this.zLevel = 0.0F;
    this.itemRender.zLevel = 0.0F;
}
 
Example #25
Source File: RenderListener.java    From SkyblockAddons with MIT License 5 votes vote down vote up
public void drawItemPickupLog(float scale, ButtonLocation buttonLocation) {
    float x = main.getConfigValues().getActualX(Feature.ITEM_PICKUP_LOG);
    float y = main.getConfigValues().getActualY(Feature.ITEM_PICKUP_LOG);

    EnumUtils.AnchorPoint anchorPoint = main.getConfigValues().getAnchorPoint(Feature.ITEM_PICKUP_LOG);
    boolean downwards = anchorPoint == EnumUtils.AnchorPoint.TOP_RIGHT || anchorPoint == EnumUtils.AnchorPoint.TOP_LEFT;

    int lineHeight = 8 + 1; // 1 pixel spacer
    int height = lineHeight * 3 - 1;
    int width = MinecraftReflection.FontRenderer.getStringWidth("+ 1x Forceful Ember Chestplate");
    x -= width * scale / 2F;
    y -= height * scale / 2F;
    x /= scale;
    y /= scale;
    if (buttonLocation != null) {
        buttonLocation.checkHoveredAndDrawBox(x, x+width, y, y+height, scale);
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    }

    main.getUtils().enableStandardGLOptions();

    int i = 0;
    Collection<ItemDiff> log = main.getInventoryUtils().getItemPickupLog();
    if (buttonLocation != null) {
        log = DUMMY_PICKUP_LOG;
    }
    for (ItemDiff itemDiff : log) {
        String text = String.format("%s %sx §r%s", itemDiff.getAmount() > 0 ? "§a+" : "§c-",
                Math.abs(itemDiff.getAmount()), itemDiff.getDisplayName());
        float stringY = y + (i * lineHeight);
        if (!downwards) {
            stringY = y + height - (i * lineHeight) - 8;
        }

        main.getUtils().drawTextWithStyle(text, x, stringY, 0xFFFFFFFF);
        i++;
    }

    main.getUtils().restoreGLOptions();
}
 
Example #26
Source File: TESRBarrel.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void renderText(String text, double x, double y, double z, EnumFacing side, EnumFacing barrelFront)
{
    FontRenderer fontRenderer = this.mc.fontRenderer;
    int strLenHalved = fontRenderer.getStringWidth(text) / 2;

    GlStateManager.pushMatrix();
    GlStateManager.translate(x, y, z);

    if (side == EnumFacing.UP || side == EnumFacing.DOWN)
    {
        GlStateManager.rotate(LABEL_ROT_SIDE_Y[barrelFront.getIndex()], 0, 1, 0);
        GlStateManager.rotate(90f * side.getYOffset(), 1, 0, 0);
    }
    else
    {
        GlStateManager.rotate(LABEL_ROT_SIDE_Y[side.getIndex()], 0, 1, 0);
    }

    GlStateManager.translate(0, 0.48, 0);
    GlStateManager.scale(-0.01F, -0.01F, 0.01F);
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);

    GlStateManager.disableLighting();
    GlStateManager.enablePolygonOffset();
    GlStateManager.depthMask(false);
    GlStateManager.enableBlend();
    GlStateManager.doPolygonOffset(-1, -20);

    this.getFontRenderer().drawString(text, -strLenHalved, 0, 0xFFFFFFFF);

    GlStateManager.disableBlend();
    GlStateManager.depthMask(true);
    GlStateManager.disablePolygonOffset();
    GlStateManager.enableLighting();

    GlStateManager.popMatrix();
}
 
Example #27
Source File: SurfaceBuilder.java    From ForgeHax with MIT License 5 votes vote down vote up
public static void enableBlend() {
  GlStateManager.enableBlend();
  GlStateManager.tryBlendFuncSeparate(
      GlStateManager.SourceFactor.SRC_ALPHA,
      GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA,
      GlStateManager.SourceFactor.ONE,
      GlStateManager.DestFactor.ZERO);
}
 
Example #28
Source File: RenderListener.java    From SkyblockAddons with MIT License 5 votes vote down vote up
/**
 * This renders a bar for the skeleton hat bones bar.
 */
public void drawSkeletonBar(Minecraft mc, float scale, ButtonLocation buttonLocation) {
    float x = main.getConfigValues().getActualX(Feature.SKELETON_BAR);
    float y = main.getConfigValues().getActualY(Feature.SKELETON_BAR);
    int bones = 0;
    if (!(mc.currentScreen instanceof LocationEditGui)) {
        for (Entity listEntity : mc.theWorld.loadedEntityList) {
            if (listEntity instanceof EntityItem &&
                    listEntity.ridingEntity instanceof EntityArmorStand && listEntity.ridingEntity.isInvisible() && listEntity.getDistanceToEntity(mc.thePlayer) <= 8) {
                bones++;
            }
        }
    } else {
        bones = 3;
    }
    if (bones > 3) bones = 3;

    int height = 16;
    int width = 3 * 16;
    x -= width * scale / 2F;
    y -= height * scale / 2F;
    x /= scale;
    y /= scale;
    if (buttonLocation != null) {
        buttonLocation.checkHoveredAndDrawBox(x, x+width, y, y+height, scale);
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    }

    main.getUtils().enableStandardGLOptions();

    for (int boneCounter = 0; boneCounter < bones; boneCounter++) {
        renderItem(BONE_ITEM, x + boneCounter * 16, y);
    }

    main.getUtils().restoreGLOptions();
}
 
Example #29
Source File: RenderListener.java    From SkyblockAddons with MIT License 5 votes vote down vote up
private void drawModularBar(Minecraft mc, Color color, boolean filled, float x, float y, ButtonLocation buttonLocation, Feature feature, int fillWidth, int maxWidth) {
    Gui gui = mc.ingameGUI;
    if (buttonLocation != null) {
        gui = buttonLocation;
    }
    if (color.getRGB() == ChatFormatting.BLACK.getRGB()) {
        GlStateManager.color(0.25F, 0.25F, 0.25F); // too dark normally
    } else { // a little darker for contrast
        GlStateManager.color(((float) color.getRed() / 255) * 0.9F, ((float) color.getGreen() / 255) * 0.9F, ((float) color.getBlue() / 255) * 0.9F);
    }
    IntPair sizes = main.getConfigValues().getSizes(feature);
    if (!filled) fillWidth = maxWidth;
    drawBarStart(gui, x, y, filled, sizes.getX(), sizes.getY(), fillWidth, color, maxWidth);
}
 
Example #30
Source File: WorldOverlayRenderer.java    From NotEnoughItems with MIT License 5 votes vote down vote up
public static void render(float frame) {
    GlStateManager.pushMatrix();
    Entity entity = Minecraft.getMinecraft().getRenderViewEntity();
    RenderUtils.translateToWorldCoords(entity, frame);

    renderChunkBounds(entity);
    renderMobSpawnOverlay(entity);
    GlStateManager.popMatrix();
}