Java Code Examples for net.minecraft.client.renderer.GlStateManager#enableDepth()

The following examples show how to use net.minecraft.client.renderer.GlStateManager#enableDepth() . 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: ScreenEntityEntry.java    From WearableBackpacks with MIT License 6 votes vote down vote up
@Override
public void draw(int mouseX, int mouseY, float partialTicks) {
	int w = getWidth();
	int h = getHeight();
	
	enableBlendAlphaStuffs();
	setRenderColorARGB(_colorBackground); drawRect(1, 1, w - 2, h - 2);
	setRenderColorARGB(_colorBorder);     drawOutline(0, 0, w, h);
	disableBlendAlphaStuffs();
	
	ItemStack stack = getStack();
	if (stack.isEmpty()) return;
	
	GlStateManager.enableDepth();
	GlStateManager.enableRescaleNormal();
	RenderHelper.enableGUIStandardItemLighting();
	getMC().getRenderItem().renderItemIntoGUI(stack, w / 2 - 8, h / 2 - 8);
	RenderHelper.disableStandardItemLighting();
	GlStateManager.disableRescaleNormal();
	GlStateManager.disableDepth();
}
 
Example 2
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 3
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 4
Source File: RenderListener.java    From SkyblockAddons with MIT License 5 votes vote down vote up
private void renderItem(ItemStack item, float x, float y) {
    GlStateManager.enableRescaleNormal();
    RenderHelper.enableGUIStandardItemLighting();
    GlStateManager.enableDepth();

    GlStateManager.pushMatrix();
    GlStateManager.translate(x, y, 0);
    Minecraft.getMinecraft().getRenderItem().renderItemIntoGUI(item, 0, 0);
    GlStateManager.popMatrix();

    GlStateManager.disableDepth();
    RenderHelper.disableStandardItemLighting();
    GlStateManager.disableRescaleNormal();
}
 
Example 5
Source File: PhasedBlockRenderer.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void finishRender(BufferBuilder buffer) {
	Tessellator.getInstance().draw();
	buffer.setTranslation(0, 0, 0);

	GlStateManager.glBlendEquation(GL14.GL_FUNC_ADD);
	GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
	GlStateManager.depthMask(true);

	GlStateManager.disablePolygonOffset();
	GlStateManager.enableDepth();
	GlStateManager.enableTexture2D();
}
 
Example 6
Source File: LitematicaRenderer.java    From litematica with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void renderSchematicOverlay()
{
    boolean invert = Hotkeys.INVERT_OVERLAY_RENDER_STATE.getKeybind().isKeybindHeld();

    if (Configs.Visuals.ENABLE_SCHEMATIC_OVERLAY.getBooleanValue() != invert)
    {
        boolean renderThrough = Configs.Visuals.SCHEMATIC_OVERLAY_RENDER_THROUGH.getBooleanValue() || Hotkeys.RENDER_OVERLAY_THROUGH_BLOCKS.getKeybind().isKeybindHeld();
        float lineWidth = (float) (renderThrough ? Configs.Visuals.SCHEMATIC_OVERLAY_OUTLINE_WIDTH_THROUGH.getDoubleValue() : Configs.Visuals.SCHEMATIC_OVERLAY_OUTLINE_WIDTH.getDoubleValue());

        GlStateManager.pushMatrix();
        GlStateManager.disableTexture2D();
        GlStateManager.disableCull();
        GlStateManager.alphaFunc(GL11.GL_GREATER, 0.001F);
        GlStateManager.enablePolygonOffset();
        GlStateManager.doPolygonOffset(-0.4f, -0.8f);
        fi.dy.masa.malilib.render.RenderUtils.setupBlend();
        GlStateManager.glLineWidth(lineWidth);
        fi.dy.masa.malilib.render.RenderUtils.color(1f, 1f, 1f, 1f);
        OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240);

        if (renderThrough)
        {
            GlStateManager.disableDepth();
        }

        this.getWorldRenderer().renderBlockOverlays();

        GlStateManager.enableDepth();
        GlStateManager.doPolygonOffset(0f, 0f);
        GlStateManager.disablePolygonOffset();
        GlStateManager.enableTexture2D();
        GlStateManager.popMatrix();
    }
}
 
Example 7
Source File: GuiComponentItemStackSpinner.java    From OpenModsLib with MIT License 5 votes vote down vote up
@Override
public void renderOverlay(int offsetX, int offsetY, int mouseX, int mouseY) {
	GL11.glPushMatrix();
	GlStateManager.enableDepth();
	float scale = 30.0f;
	GL11.glTranslated(offsetX + x + (scale / 2), offsetY + y + (scale / 2), scale);
	GL11.glScaled(scale, -scale, scale);
	rotationY += 0.6f;
	GL11.glRotatef(20, 1, 0, 0);
	GL11.glRotatef(rotationY, 0, 1, 0);
	GlStateManager.color(1, 1, 1);
	renderItem(stack);
	GlStateManager.disableDepth();
	GL11.glPopMatrix();
}
 
Example 8
Source File: PuzzleTESR.java    From YouTubeModdingTutorial with MIT License 5 votes vote down vote up
@Override
public void render(TilePuzzle te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {

    IBlockState state = te.getWorld().getBlockState(te.getPos());
    Block block = state.getBlock();
    if (!(block instanceof GenericBlock)) {
        return;
    }

    Minecraft.getMinecraft().entityRenderer.disableLightmap();

    GlStateManager.pushMatrix();
    GlStateManager.translate((float) x + 0.5F, (float) y + 0.75F, (float) z + 0.5F);
    setupRotation(state);
    GlStateManager.translate(0F, 0F, 0.9F);

    GlStateManager.depthMask(true);
    GlStateManager.enableDepth();

    if (te.isSolved()) {
        renderSlotHilight();
    }
    renderSlot(te);

    GlStateManager.popMatrix();
    Minecraft.getMinecraft().entityRenderer.enableLightmap();
}
 
Example 9
Source File: RenderEventService.java    From ForgeHax with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onRenderWorld(RenderWorldLastEvent event) {
  GlStateManager.pushMatrix();
  GlStateManager.disableTexture2D();
  GlStateManager.enableBlend();
  GlStateManager.disableAlpha();
  GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
  GlStateManager.shadeModel(GL11.GL_SMOOTH);
  GlStateManager.disableDepth();
  
  GlStateManager.glLineWidth(1.f);
  
  Vec3d renderPos = EntityUtils.getInterpolatedPos(getRenderEntity(), event.getPartialTicks());
  
  RenderEvent e = new RenderEvent(TESSELLATOR, renderPos, event.getPartialTicks());
  e.resetTranslation();
  MinecraftForge.EVENT_BUS.post(e);
  
  GlStateManager.glLineWidth(1.f);
  
  GlStateManager.shadeModel(GL11.GL_FLAT);
  GlStateManager.disableBlend();
  GlStateManager.enableAlpha();
  GlStateManager.enableTexture2D();
  GlStateManager.enableDepth();
  GlStateManager.enableCull();
  GlStateManager.popMatrix();
}
 
Example 10
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 11
Source File: ItemESP.java    From ForgeHax with MIT License 4 votes vote down vote up
@SubscribeEvent
public void onRender2D(final Render2DEvent event) {
  GlStateManager.enableBlend();
  GlStateManager.tryBlendFuncSeparate(
      GlStateManager.SourceFactor.SRC_ALPHA,
      GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA,
      GlStateManager.SourceFactor.ONE,
      GlStateManager.DestFactor.ZERO);
  GlStateManager.enableTexture2D();
  GlStateManager.disableDepth();
  
  final double scale = this.scale.get() == 0 ? 1.D : this.scale.get();
  
  getWorld()
      .loadedEntityList
      .stream()
      .filter(EntityItem.class::isInstance)
      .map(EntityItem.class::cast)
      .filter(entity -> entity.ticksExisted > 1)
      .forEach(
          entity -> {
            Vec3d bottomPos = EntityUtils.getInterpolatedPos(entity, event.getPartialTicks());
            Vec3d topPos =
                bottomPos.addVector(0.D, entity.getRenderBoundingBox().maxY - entity.posY, 0.D);
            
            Plane top = VectorUtils.toScreen(topPos);
            Plane bot = VectorUtils.toScreen(bottomPos);
            
            if (!top.isVisible() && !bot.isVisible()) {
              return;
            }
            
            double offX = bot.getX() - top.getX();
            double offY = bot.getY() - top.getY();
            
            GlStateManager.pushMatrix();
            GlStateManager.translate(top.getX() - (offX / 2.D), bot.getY(), 0);
            
            ItemStack stack = entity.getItem();
            String text =
                stack.getDisplayName() + (stack.isStackable() ? (" x" + stack.getCount()) : "");
            
            SurfaceHelper.drawTextShadow(
                text,
                (int) (offX / 2.D - SurfaceHelper.getTextWidth(text, scale) / 2.D),
                -(int) (offY - SurfaceHelper.getTextHeight(scale) / 2.D) - 1,
                Colors.WHITE.toBuffer(),
                scale);
            
            GlStateManager.popMatrix();
          });
  
  GlStateManager.enableDepth();
  GlStateManager.disableBlend();
}
 
Example 12
Source File: ShulkerViewer.java    From ForgeHax with MIT License 4 votes vote down vote up
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
  final int DEPTH = 500;
  
  int x = posX;
  int y = posY;
  
  GlStateManager.enableTexture2D();
  GlStateManager.disableLighting();
  GlStateManager.color(
      1.f,
      1.f,
      1.f,
      !isLocked()
          ? (tooltip_opacity.getAsFloat() / 255.f)
          : (locked_opacity.getAsFloat() / 255.f));
  
  GlStateManager.enableBlend();
  GlStateManager.tryBlendFuncSeparate(
      GlStateManager.SourceFactor.SRC_ALPHA,
      GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA,
      GlStateManager.SourceFactor.ONE,
      GlStateManager.DestFactor.ZERO);
  
  MC.getTextureManager().bindTexture(SHULKER_GUI_TEXTURE);
  
  // width 176        = width of container
  // height 16        = top of the gui
  // height 54        = gui item boxes
  // height 6         = bottom of the gui
  SurfaceHelper.drawTexturedRect(x, y, 0, 0, 176, 16, DEPTH);
  SurfaceHelper.drawTexturedRect(x, y + 16, 0, 16, 176, 54, DEPTH);
  SurfaceHelper.drawTexturedRect(x, y + 16 + 54, 0, 160, 176, 6, DEPTH);
  
  GlStateManager.disableDepth();
  SurfaceHelper.drawText(parentShulker.getDisplayName(), x + 8, y + 6, Colors.BLACK.toBuffer());
  GlStateManager.enableDepth();
  
  RenderHelper.enableGUIStandardItemLighting();
  GlStateManager.enableRescaleNormal();
  GlStateManager.enableColorMaterial();
  GlStateManager.enableLighting();
  
  Slot hoveringOver = null;
  
  int rx = x + 8;
  int ry = y - 1;
  
  for (Slot slot : inventorySlots.inventorySlots) {
    if (slot.getHasStack()) {
      int px = rx + slot.xPos;
      int py = ry + slot.yPos;
      MC.getRenderItem().zLevel = DEPTH + 1;
      SurfaceHelper.drawItem(slot.getStack(), px, py);
      SurfaceHelper.drawItemOverlay(slot.getStack(), px, py);
      MC.getRenderItem().zLevel = 0.f;
      if (isPointInRegion(px, py, 16, 16, mouseX, mouseY)) {
        hoveringOver = slot;
      }
    }
  }
  
  GlStateManager.disableLighting();
  
  if (hoveringOver != null) {
    // background of the gui
    GlStateManager.disableLighting();
    GlStateManager.disableDepth();
    GlStateManager.colorMask(true, true, true, false);
    this.drawGradientRect(
        rx + hoveringOver.xPos,
        ry + hoveringOver.yPos,
        rx + hoveringOver.xPos + 16,
        ry + hoveringOver.yPos + 16,
        -2130706433,
        -2130706433);
    GlStateManager.colorMask(true, true, true, true);
    
    // tool tip
    GlStateManager.color(1.f, 1.f, 1.f, 1.0f);
    GlStateManager.pushMatrix();
    isModGeneratedToolTip = true;
    renderToolTip(hoveringOver.getStack(), mouseX + 8, mouseY + 8);
    isModGeneratedToolTip = false;
    GlStateManager.popMatrix();
    GlStateManager.enableDepth();
  }
  
  if (isPointInRegion(this.posX, this.posY, getWidth(), getHeight(), mouseX, mouseY)) {
    isMouseInShulkerGui = true;
  }
  
  GlStateManager.disableBlend();
  GlStateManager.color(1.f, 1.f, 1.f, 1.0f);
}
 
Example 13
Source File: SurfaceBuilder.java    From ForgeHax with MIT License 4 votes vote down vote up
public static void disableFontRendering() {
  GlStateManager.enableDepth();
}
 
Example 14
Source File: YeetHandler.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
@InvokeEvent
public void render(RenderEntitiesEvent event) {
    for (Yeet yeet : yeets) {
        RenderManager renderManager = Minecraft.getMinecraft().getRenderManager();
        FontRenderer fontrenderer = renderManager.getFontRenderer();
        float f = 1.6F;
        float f1 = 0.016666668F * f;
        GlStateManager.pushMatrix();
        EntityPlayerSP entity = Minecraft.getMinecraft().thePlayer;
        float partialTicks = event.getPartialTicks();

        double d0 = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * (double) partialTicks;
        double d1 = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * (double) partialTicks;
        double d2 = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * (double) partialTicks;

        EntityPlayer sender = yeet.sender;
        if (sender == null) continue;
        double e0 = yeet.sender.lastTickPosX + (yeet.sender.posX - yeet.sender.lastTickPosX) * (double) partialTicks;
        double e1 = yeet.sender.lastTickPosY + (yeet.sender.posY - yeet.sender.lastTickPosY) * (double) partialTicks;
        double e2 = yeet.sender.lastTickPosZ + (yeet.sender.posZ - yeet.sender.lastTickPosZ) * (double) partialTicks;


        GlStateManager.translate(e0 - d0, e1 - d1, e2 - d2);
        GlStateManager.translate(0, 3, 0);

        GL11.glNormal3f(0.0F, 1.0F, 0.0F);
        GlStateManager.rotate(-renderManager.playerViewY, 0.0F, 1.0F, 0.0F);

        int xMultiplier = 1; // Nametag x rotations should flip in front-facing 3rd person

        if (Minecraft.getMinecraft() != null && Minecraft.getMinecraft().gameSettings != null && Minecraft.getMinecraft().gameSettings.thirdPersonView == 2) {
            xMultiplier = -1;
        }

        GlStateManager.rotate(renderManager.playerViewX * xMultiplier, 1.0F, 0.0F, 0.0F);
        GlStateManager.scale(-f1, -f1, f1);
        GlStateManager.disableLighting();
        GlStateManager.depthMask(false);
        GlStateManager.disableDepth();
        GlStateManager.enableBlend();
        GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
        Tessellator tessellator = Tessellator.getInstance();
        WorldRenderer worldrenderer = tessellator.getWorldRenderer();
        int i = 0;

        String string = "YEET";
        int j = fontrenderer.getStringWidth(string) / 2;
        GlStateManager.disableTexture2D();
        GlStateManager.scale(4, 4, 4);
        worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
        worldrenderer.pos(-j - 1, -1 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
        worldrenderer.pos(-j - 1, 8 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
        worldrenderer.pos(j + 1, 8 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
        worldrenderer.pos(j + 1, -1 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
        tessellator.draw();
        GlStateManager.enableTexture2D();

        fontrenderer.drawString(string, -j, 0, 16777215, true);
        GlStateManager.enableLighting();
        GlStateManager.disableBlend();
        GlStateManager.depthMask(true);
        GlStateManager.enableDepth();
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        GlStateManager.popMatrix();
    }
}
 
Example 15
Source File: WrapperGlStateManager.java    From ClientBase with MIT License 4 votes vote down vote up
public static void enableDepth() {
    GlStateManager.enableDepth();
}
 
Example 16
Source File: RenderUtil.java    From seppuku with GNU General Public License v3.0 4 votes vote down vote up
public static void drawFilledBox(AxisAlignedBB bb, int color) {
    GlStateManager.pushMatrix();
    GlStateManager.enableBlend();
    GlStateManager.disableDepth();
    GlStateManager.tryBlendFuncSeparate(770, 771, 0, 1);
    GlStateManager.disableTexture2D();
    GlStateManager.depthMask(false);

    final float alpha = (color >> 24 & 0xFF) / 255.0F;
    final float red = (color >> 16 & 0xFF) / 255.0F;
    final float green = (color >> 8 & 0xFF) / 255.0F;
    final float blue = (color & 0xFF) / 255.0F;

    final Tessellator tessellator = Tessellator.getInstance();
    final BufferBuilder bufferbuilder = tessellator.getBuffer();

    bufferbuilder.begin(GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
    bufferbuilder.pos(bb.minX, bb.minY, bb.minZ).color(red, green, blue, alpha).endVertex();
    bufferbuilder.pos(bb.maxX, bb.minY, bb.minZ).color(red, green, blue, alpha).endVertex();
    bufferbuilder.pos(bb.maxX, bb.minY, bb.maxZ).color(red, green, blue, alpha).endVertex();
    bufferbuilder.pos(bb.minX, bb.minY, bb.maxZ).color(red, green, blue, alpha).endVertex();

    bufferbuilder.pos(bb.minX, bb.maxY, bb.minZ).color(red, green, blue, alpha).endVertex();
    bufferbuilder.pos(bb.minX, bb.maxY, bb.maxZ).color(red, green, blue, alpha).endVertex();
    bufferbuilder.pos(bb.maxX, bb.maxY, bb.maxZ).color(red, green, blue, alpha).endVertex();
    bufferbuilder.pos(bb.maxX, bb.maxY, bb.minZ).color(red, green, blue, alpha).endVertex();

    bufferbuilder.pos(bb.minX, bb.minY, bb.minZ).color(red, green, blue, alpha).endVertex();
    bufferbuilder.pos(bb.minX, bb.maxY, bb.minZ).color(red, green, blue, alpha).endVertex();
    bufferbuilder.pos(bb.maxX, bb.maxY, bb.minZ).color(red, green, blue, alpha).endVertex();
    bufferbuilder.pos(bb.maxX, bb.minY, bb.minZ).color(red, green, blue, alpha).endVertex();

    bufferbuilder.pos(bb.maxX, bb.minY, bb.minZ).color(red, green, blue, alpha).endVertex();
    bufferbuilder.pos(bb.maxX, bb.maxY, bb.minZ).color(red, green, blue, alpha).endVertex();
    bufferbuilder.pos(bb.maxX, bb.maxY, bb.maxZ).color(red, green, blue, alpha).endVertex();
    bufferbuilder.pos(bb.maxX, bb.minY, bb.maxZ).color(red, green, blue, alpha).endVertex();

    bufferbuilder.pos(bb.minX, bb.minY, bb.maxZ).color(red, green, blue, alpha).endVertex();
    bufferbuilder.pos(bb.maxX, bb.minY, bb.maxZ).color(red, green, blue, alpha).endVertex();
    bufferbuilder.pos(bb.maxX, bb.maxY, bb.maxZ).color(red, green, blue, alpha).endVertex();
    bufferbuilder.pos(bb.minX, bb.maxY, bb.maxZ).color(red, green, blue, alpha).endVertex();

    bufferbuilder.pos(bb.minX, bb.minY, bb.minZ).color(red, green, blue, alpha).endVertex();
    bufferbuilder.pos(bb.minX, bb.minY, bb.maxZ).color(red, green, blue, alpha).endVertex();
    bufferbuilder.pos(bb.minX, bb.maxY, bb.maxZ).color(red, green, blue, alpha).endVertex();
    bufferbuilder.pos(bb.minX, bb.maxY, bb.minZ).color(red, green, blue, alpha).endVertex();
    tessellator.draw();
    GlStateManager.depthMask(true);
    GlStateManager.enableDepth();
    GlStateManager.enableTexture2D();
    GlStateManager.disableBlend();
    GlStateManager.popMatrix();
}
 
Example 17
Source File: GuiContainerLargeStacks.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void drawSlot(Slot slotIn)
{
    int slotPosX = slotIn.xPos;
    int slotPosY = slotIn.yPos;
    ItemStack stack = slotIn.getStack();
    boolean flag = false;
    boolean flag1 = slotIn == this.clickedSlot && this.draggedStack.isEmpty() == false && this.isRightMouseClick == false;
    ItemStack stackCursor = this.mc.player.inventory.getItemStack();
    String str = null;

    if (slotIn == this.clickedSlot && this.draggedStack.isEmpty() == false && this.isRightMouseClick && stack.isEmpty() == false)
    {
        stack = stack.copy();
        stack.setCount(stack.getCount() / 2);
    }
    else if (this.dragSplitting && this.dragSplittingSlots.contains(slotIn) && stackCursor.isEmpty() == false)
    {
        if (this.dragSplittingSlots.size() == 1)
        {
            return;
        }

        if (Container.canAddItemToSlot(slotIn, stackCursor, true) && this.inventorySlots.canDragIntoSlot(slotIn))
        {
            stack = stackCursor.copy();
            flag = true;
            Container.computeStackSize(this.dragSplittingSlots, this.dragSplittingLimit, stack, slotIn.getStack().getCount());

            if (stack.getCount() > stack.getMaxStackSize())
            {
                str = TextFormatting.YELLOW + "" + stack.getMaxStackSize();
                stack.setCount(stack.getMaxStackSize());
            }

            if (stack.getCount() > slotIn.getItemStackLimit(stack))
            {
                str = TextFormatting.YELLOW + "" + slotIn.getItemStackLimit(stack);
                stack.setCount(slotIn.getItemStackLimit(stack));
            }
        }
        else
        {
            this.dragSplittingSlots.remove(slotIn);
            this.updateDragSplitting();
        }
    }

    this.zLevel = 100.0F;
    this.itemRender.zLevel = 100.0F;

    if (stack.isEmpty())
    {
        TextureAtlasSprite textureatlassprite = slotIn.getBackgroundSprite();

        if (textureatlassprite != null)
        {
            GlStateManager.disableLighting();
            this.mc.getTextureManager().bindTexture(slotIn.getBackgroundLocation());
            this.drawTexturedModalRect(slotPosX, slotPosY, textureatlassprite, 16, 16);
            GlStateManager.enableLighting();
            flag1 = true;
        }
    }

    if (flag1 == false)
    {
        if (flag)
        {
            drawRect(slotPosX, slotPosY, slotPosX + 16, slotPosY + 16, -2130706433);
        }

        GlStateManager.enableDepth();
        this.itemRender.renderItemAndEffectIntoGUI(stack, slotPosX, slotPosY);

        // This slot belongs to a "large stacks" type inventory, render the stack size text scaled to 0.5x
        if (slotIn instanceof SlotItemHandler && this.scaledStackSizeTextInventories.contains(((SlotItemHandler) slotIn).getItemHandler()))
        {
            this.renderLargeStackItemOverlayIntoGUI(this.fontRenderer, stack, slotPosX, slotPosY);
        }
        else
        {
            this.itemRender.renderItemOverlayIntoGUI(this.fontRenderer, stack, slotPosX, slotPosY, str);
        }
    }

    this.itemRender.zLevel = 0.0F;
    this.zLevel = 0.0F;
}
 
Example 18
Source File: RenderCodex.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void renderItemStack(ItemStack stack) {
	GlStateManager.enableAlpha();
	GlStateManager.enableBlend();
	GlStateManager.enableRescaleNormal();

	GlStateManager.pushMatrix();

	RenderItem itemRender = Minecraft.getMinecraft().getRenderItem();
	itemRender.renderItemAndEffectIntoGUI(stack, 0, 0);

	GlStateManager.translate(0, 0, 150);

	FontRenderer font = stack.getItem().getFontRenderer(stack);
	if (font == null) font = Minecraft.getMinecraft().fontRenderer;

	if (font != null && stack.getCount() != 1) {
		GlStateManager.translate(0, 0, 5);
		GlStateManager.disableLighting();
		GlStateManager.disableBlend();
		font.drawStringWithShadow(stack.getCount() + "",
				17F - font.getStringWidth(stack.getCount() + ""),
				9F,
				0xFFFFFF);
		GlStateManager.enableDepth();
		GlStateManager.enableBlend();
		GlStateManager.translate(0, 0, -5);
	}

	if (stack.getItem().showDurabilityBar(stack)) {
		GlStateManager.disableLighting();
		GlStateManager.disableTexture2D();
		GlStateManager.disableAlpha();
		GlStateManager.disableBlend();
		Tessellator tessellator = Tessellator.getInstance();
		BufferBuilder bufferbuilder = tessellator.getBuffer();
		double health = stack.getItem().getDurabilityForDisplay(stack);
		int rgbfordisplay = stack.getItem().getRGBDurabilityForDisplay(stack);
		int i = Math.round(13.0F - (float) health * 13.0F);
		draw(bufferbuilder, 2, 13, 13, 2, 0, 0, 0, 255);
		draw(bufferbuilder, 2, 13, i, 1, rgbfordisplay >> 16 & 255, rgbfordisplay >> 8 & 255, rgbfordisplay & 255, 255);
		GlStateManager.enableBlend();
		GlStateManager.enableAlpha();
		GlStateManager.enableTexture2D();
		GlStateManager.enableLighting();
	}


	EntityPlayerSP entityplayersp = Minecraft.getMinecraft().player;
	float f3 = entityplayersp == null ? 0.0F : entityplayersp.getCooldownTracker().getCooldown(stack.getItem(), Minecraft.getMinecraft().getRenderPartialTicks());

	if (f3 > 0.0F) {
		GlStateManager.disableLighting();
		GlStateManager.disableTexture2D();
		Tessellator tessellator1 = Tessellator.getInstance();
		BufferBuilder bufferbuilder1 = tessellator1.getBuffer();
		this.draw(bufferbuilder1, 0, MathHelper.floor(16.0F * (1.0F - f3)), 16, MathHelper.ceil(16.0F * f3), 255, 255, 255, 127);
		GlStateManager.enableTexture2D();
		GlStateManager.enableLighting();
	}

	GlStateManager.popMatrix();

	GlStateManager.enableLighting();
	GlStateManager.enableAlpha();
	GlStateManager.enableBlend();
	GlStateManager.disableRescaleNormal();
}
 
Example 19
Source File: ComponentGui.java    From OpenModsLib with MIT License 4 votes vote down vote up
protected void restoreRenderState() {
	GlStateManager.enableRescaleNormal();
	GlStateManager.enableLighting();
	GlStateManager.enableDepth();
	RenderHelper.enableStandardItemLighting();
}
 
Example 20
Source File: GuiContainerHook.java    From SkyblockAddons with MIT License 4 votes vote down vote up
public static void drawSlot(GuiContainer guiContainer, Slot slot) {
    SkyblockAddons main = SkyblockAddons.getInstance();
    Minecraft mc = Minecraft.getMinecraft();
    Container container = mc.thePlayer.openContainer;

    if (slot != null) {
        // Draw crafting pattern overlays inside the crafting grid.
        if (main.getConfigValues().isEnabled(Feature.CRAFTING_PATTERNS) && main.getUtils().isOnSkyblock()
                && slot.inventory.getDisplayName().getUnformattedText().equals(CraftingPattern.CRAFTING_TABLE_DISPLAYNAME)
                && main.getPersistentValues().getSelectedCraftingPattern() != CraftingPattern.FREE) {

            int craftingGridIndex = CraftingPattern.slotToCraftingGridIndex(slot.getSlotIndex());
            if (craftingGridIndex >= 0) {
                int slotLeft = slot.xDisplayPosition;
                int slotTop = slot.yDisplayPosition;
                int slotRight = slotLeft + 16;
                int slotBottom = slotTop + 16;
                if (main.getPersistentValues().getSelectedCraftingPattern().isSlotInPattern(craftingGridIndex)) {
                    if (!slot.getHasStack()) {
                        drawRightGradientRect(guiContainer, slotLeft, slotTop, slotRight, slotBottom, OVERLAY_GREEN, OVERLAY_GREEN);
                    }
                } else {
                    if (slot.getHasStack()) {
                        drawRightGradientRect(guiContainer, slotLeft, slotTop, slotRight, slotBottom, OVERLAY_RED, OVERLAY_RED);
                    }
                }
            }
        }

        if (main.getConfigValues().isEnabled(Feature.LOCK_SLOTS) &&
                main.getUtils().isOnSkyblock()) {
            int slotNum = slot.slotNumber + main.getInventoryUtils().getSlotDifference(container);
            if (main.getConfigValues().getLockedSlots().contains(slotNum)
                    && (slotNum >= 9 || container instanceof ContainerPlayer && slotNum >= 5)) {
                GlStateManager.disableLighting();
                GlStateManager.disableDepth();
                GlStateManager.color(1,1,1,0.4F);
                GlStateManager.enableBlend();
                mc.getTextureManager().bindTexture(LOCK);
                mc.ingameGUI.drawTexturedModalRect(slot.xDisplayPosition, slot.yDisplayPosition, 0, 0, 16, 16);
                GlStateManager.enableLighting();
                GlStateManager.enableDepth();
            }
        }
    }
}