Search in sources :

Example 31 with Tessellator

use of net.minecraft.client.renderer.Tessellator in project Minechem by iopleke.

the class GuiElement method drawTexturedModalRect.

/**
     * Draws a textured rectangle at the current zLevel.
     *
     * @param x            x pos
     * @param y            y pos
     * @param u            u pos of texture
     * @param v            v pos of texture
     * @param actualWidth  width of texture
     * @param actualHeight height of texture
     * @param drawWidth    width to draw on
     * @param drawHeight   height to draw on
     */
protected void drawTexturedModalRect(int x, int y, int u, int v, int actualWidth, int actualHeight, int drawWidth, int drawHeight) {
    float f = 0.00390625F;
    float f1 = 0.00390625F;
    Tessellator tessellator = Tessellator.instance;
    tessellator.startDrawingQuads();
    tessellator.addVertexWithUV((double) x, (double) (y + drawHeight), (double) this.zLevel, (double) ((float) u * f), (double) ((float) (v + actualHeight) * f1));
    tessellator.addVertexWithUV((double) (x + drawWidth), (double) (y + drawHeight), (double) this.zLevel, (double) ((float) (u + actualWidth) * f), (double) ((float) (v + actualHeight) * f1));
    tessellator.addVertexWithUV((double) (x + drawWidth), (double) (y), (double) this.zLevel, (double) ((float) (u + actualWidth) * f), (double) ((float) (v) * f1));
    tessellator.addVertexWithUV((double) (x), (double) (y), (double) this.zLevel, (double) ((float) (u) * f), (double) ((float) (v) * f1));
    tessellator.draw();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator)

Example 32 with Tessellator

use of net.minecraft.client.renderer.Tessellator in project Minechem by iopleke.

the class EnhancedFontRenderer method renderStringAtPos.

/**
     * Render a single line string at the current (posX,posY) and update posX
     */
private void renderStringAtPos(String sting, boolean p_78255_2_) {
    for (int i = 0; i < sting.length(); ++i) {
        char c0 = sting.charAt(i);
        int j;
        int k;
        if (c0 == 167 && i + 1 < sting.length()) {
            j = "0123456789abcdefklmnor".indexOf(sting.toLowerCase().charAt(i + 1));
            if (j < 16) {
                this.resetStyles();
                if (j < 0 || j > 15) {
                    j = 15;
                }
                if (p_78255_2_) {
                    j += 16;
                }
                k = this.colorCode[j];
                this.textColor = k;
                GL11.glColor4f((float) (k >> 16) / 255.0F, (float) (k >> 8 & 255) / 255.0F, (float) (k & 255) / 255.0F, this.alpha);
            } else if (j == 16) {
                this.randomStyle = true;
            } else if (j == 17) {
                this.boldStyle = true;
            } else if (j == 18) {
                this.strikethroughStyle = true;
            } else if (j == 19) {
                this.underlineStyle = true;
            } else if (j == 20) {
                this.italicStyle = true;
            } else if (j == 21) {
                this.resetStyles();
                GL11.glColor4f(this.red, this.blue, this.green, this.alpha);
            }
            ++i;
        } else {
            j = UNICHARS.indexOf(c0);
            if (this.randomStyle && j != -1) {
                do {
                    k = this.fontRandom.nextInt(this.charWidth.length);
                } while (this.charWidth[j] != this.charWidth[k]);
                j = k;
            }
            float f1 = this.unicodeFlag ? 0.5F : 1.0F;
            boolean flag1 = (c0 == 0 || j == -1 || this.unicodeFlag) && p_78255_2_;
            if (flag1) {
                this.posX -= f1;
                this.posY -= f1;
            }
            float f = this.renderCharAtPos(j, c0, this.italicStyle);
            if (flag1) {
                this.posX += f1;
                this.posY += f1;
            }
            if (this.boldStyle) {
                this.posX += f1;
                if (flag1) {
                    this.posX -= f1;
                    this.posY -= f1;
                }
                this.renderCharAtPos(j, c0, this.italicStyle);
                this.posX -= f1;
                if (flag1) {
                    this.posX += f1;
                    this.posY += f1;
                }
                ++f;
            }
            Tessellator tessellator;
            if (this.strikethroughStyle) {
                tessellator = Tessellator.instance;
                GL11.glDisable(GL11.GL_TEXTURE_2D);
                tessellator.startDrawingQuads();
                tessellator.addVertex((double) this.posX, (double) (this.posY + (float) (this.FONT_HEIGHT / 2)), 0.0D);
                tessellator.addVertex((double) (this.posX + f), (double) (this.posY + (float) (this.FONT_HEIGHT / 2)), 0.0D);
                tessellator.addVertex((double) (this.posX + f), (double) (this.posY + (float) (this.FONT_HEIGHT / 2) - 1.0F), 0.0D);
                tessellator.addVertex((double) this.posX, (double) (this.posY + (float) (this.FONT_HEIGHT / 2) - 1.0F), 0.0D);
                tessellator.draw();
                GL11.glEnable(GL11.GL_TEXTURE_2D);
            }
            if (this.underlineStyle) {
                tessellator = Tessellator.instance;
                GL11.glDisable(GL11.GL_TEXTURE_2D);
                tessellator.startDrawingQuads();
                int l = this.underlineStyle ? -1 : 0;
                tessellator.addVertex((double) (this.posX + (float) l), (double) (this.posY + (float) this.FONT_HEIGHT), 0.0D);
                tessellator.addVertex((double) (this.posX + f), (double) (this.posY + (float) this.FONT_HEIGHT), 0.0D);
                tessellator.addVertex((double) (this.posX + f), (double) (this.posY + (float) this.FONT_HEIGHT - 1.0F), 0.0D);
                tessellator.addVertex((double) (this.posX + (float) l), (double) (this.posY + (float) this.FONT_HEIGHT - 1.0F), 0.0D);
                tessellator.draw();
                GL11.glEnable(GL11.GL_TEXTURE_2D);
            }
            this.posX += (float) ((int) f);
        }
    }
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator)

Example 33 with Tessellator

use of net.minecraft.client.renderer.Tessellator in project Minechem by iopleke.

the class RenderHelper method drawTextureIn3D.

/**
     * Draws a texture in 3D using {@link net.minecraft.client.renderer.ItemRenderer#renderItemIn2D(net.minecraft.client.renderer.Tessellator, float, float, float, float, int, int, float)}
     *
     * @param texture the {@link net.minecraft.util.IIcon}
     */
public static void drawTextureIn3D(IIcon texture) {
    Tessellator tessellator = Tessellator.instance;
    float scale = 0.7F;
    GL11.glPushMatrix();
    GL11.glScalef(scale, scale, scale);
    GL11.glTranslatef(-scale / 2, -scale / 2, 0.0F);
    ItemRenderer.renderItemIn2D(tessellator, texture.getMaxU(), texture.getMinV(), texture.getMinU(), texture.getMaxV(), texture.getIconWidth(), texture.getIconHeight(), .0625F);
    GL11.glPopMatrix();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator)

Example 34 with Tessellator

use of net.minecraft.client.renderer.Tessellator in project Minechem by iopleke.

the class RenderHelper method drawScaledTexturedRectUV.

/**
     * Draw a {@link net.minecraft.util.ResourceLocation} on given coords with given scaling
     *
     * @param x        xPos
     * @param y        yPos
     * @param z        zPos
     * @param u        uPos on the {@link net.minecraft.util.ResourceLocation}
     * @param v        vPos on the {@link net.minecraft.util.ResourceLocation}
     * @param w        width
     * @param h        height
     * @param scale    the scale to draw 1.0F is exact, less is smaller and bigger is larger
     * @param resource the {@link net.minecraft.util.ResourceLocation}
     */
public static void drawScaledTexturedRectUV(float x, float y, float z, float u, float v, float w, float h, float scale, ResourceLocation resource) {
    Minecraft.getMinecraft().getTextureManager().bindTexture(resource);
    float drawH = h * scale;
    float drawW = w * scale;
    float xScale = 1.0F / w;
    float yScale = 1.0F / h;
    Tessellator tessellator = Tessellator.instance;
    tessellator.startDrawingQuads();
    tessellator.addVertexWithUV(x, y + drawH, z, u * xScale, (v + h) * yScale);
    tessellator.addVertexWithUV(x + drawW, y + drawH, z, (u + w) * xScale, (v + h) * yScale);
    tessellator.addVertexWithUV(x + drawW, y, z, (u + w) * xScale, v * yScale);
    tessellator.addVertexWithUV(x, y, z, u * xScale, v * yScale);
    tessellator.draw();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator)

Example 35 with Tessellator

use of net.minecraft.client.renderer.Tessellator in project VoodooCraft by Mod-DevCafeTeam.

the class TileTotemRender method renderTileEntityAt.

public void renderTileEntityAt(TileTotem te, double x, double y, double z, float partialTicks, int destroyStage) {
    for (EnumFacing side : EnumFacing.HORIZONTALS) {
        //Get the glyph on the given side
        EnumGlyphType glyph = te.getSide(side);
        if (glyph == null)
            continue;
        GlStateManager.pushMatrix();
        GlStateManager.translate(x, y, z);
        GlStateManager.enableAlpha();
        GlStateManager.enableBlend();
        GlStateManager.color(0.25f, 0.1f, 0.1f, 0.4f);
        //Fix the lighting
        int i = te.getWorld().getCombinedLight(te.getPos().offset(side), 0);
        int j = i % 65536;
        int k = i / 65536;
        OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, j / 1.0F, k / 1.0F);
        //Bind the glyph texture to use to render
        bindTexture(glyph.getTextureLocation());
        Tessellator tes = Tessellator.getInstance();
        VertexBuffer buf = tes.getBuffer();
        buf.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
        float offset = (1f / 16f) * 0.9f;
        switch(side) {
            case //-Z
            NORTH:
                buf.pos(1, 0, offset).tex(0, 1).endVertex();
                buf.pos(0, 0, offset).tex(1, 1).endVertex();
                buf.pos(0, 1, offset).tex(1, 0).endVertex();
                buf.pos(1, 1, offset).tex(0, 0).endVertex();
                break;
            case //+Z
            SOUTH:
                buf.pos(0, 0, 1 - offset).tex(0, 1).endVertex();
                buf.pos(1, 0, 1 - offset).tex(1, 1).endVertex();
                buf.pos(1, 1, 1 - offset).tex(1, 0).endVertex();
                buf.pos(0, 1, 1 - offset).tex(0, 0).endVertex();
                break;
            case //-X
            WEST:
                buf.pos(offset, 0, 0).tex(0, 1).endVertex();
                buf.pos(offset, 0, 1).tex(1, 1).endVertex();
                buf.pos(offset, 1, 1).tex(1, 0).endVertex();
                buf.pos(offset, 1, 0).tex(0, 0).endVertex();
                break;
            case //+X
            EAST:
                buf.pos(1 - offset, 0, 0).tex(1, 1).endVertex();
                buf.pos(1 - offset, 1, 0).tex(1, 0).endVertex();
                buf.pos(1 - offset, 1, 1).tex(0, 0).endVertex();
                buf.pos(1 - offset, 0, 1).tex(0, 1).endVertex();
        }
        tes.draw();
        GlStateManager.popMatrix();
    }
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) VertexBuffer(net.minecraft.client.renderer.VertexBuffer) EnumFacing(net.minecraft.util.EnumFacing) EnumGlyphType(mdc.voodoocraft.util.EnumGlyphType)

Aggregations

Tessellator (net.minecraft.client.renderer.Tessellator)618 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)290 WorldRenderer (net.minecraft.client.renderer.WorldRenderer)54 VertexBuffer (net.minecraft.client.renderer.VertexBuffer)42 BlockPos (net.minecraft.util.math.BlockPos)37 ResourceLocation (net.minecraft.util.ResourceLocation)31 Vec3d (net.minecraft.util.math.Vec3d)30 EnumFacing (net.minecraft.util.EnumFacing)24 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)23 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)19 IIcon (net.minecraft.util.IIcon)19 Random (java.util.Random)18 IBlockState (net.minecraft.block.state.IBlockState)17 Minecraft (net.minecraft.client.Minecraft)15 EntityPlayer (net.minecraft.entity.player.EntityPlayer)14 World (net.minecraft.world.World)14 Block (net.minecraft.block.Block)13 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)13 ArrayList (java.util.ArrayList)12 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)12