Search in sources :

Example 41 with BufferBuilder

use of net.minecraft.client.renderer.BufferBuilder in project EnderIO by SleepyTrousers.

the class IoConfigRenderer method renderSelection.

private void renderSelection() {
    if (selection == null) {
        return;
    }
    BoundingBox bb = new BoundingBox(selection.config.getLocation());
    TextureAtlasSprite icon = selectedFaceIcon.get(TextureAtlasSprite.class);
    List<Vertex> corners = bb.getCornersWithUvForFace(selection.face, icon.getMinU(), icon.getMaxU(), icon.getMinV(), icon.getMaxV());
    GlStateManager.disableDepth();
    GlStateManager.disableLighting();
    RenderUtil.bindBlockTexture();
    BufferBuilder tes = Tessellator.getInstance().getBuffer();
    GlStateManager.color(1, 1, 1);
    Vector3d trans = new Vector3d((-origin.x) + eye.x, (-origin.y) + eye.y, (-origin.z) + eye.z);
    tes.setTranslation(trans.x, trans.y, trans.z);
    RenderUtil.addVerticesToTessellator(corners, DefaultVertexFormats.POSITION_TEX, true);
    Tessellator.getInstance().draw();
    tes.setTranslation(0, 0, 0);
}
Also used : Vertex(com.enderio.core.common.vecmath.Vertex) Vector3d(com.enderio.core.common.vecmath.Vector3d) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) BoundingBox(com.enderio.core.client.render.BoundingBox) BufferBuilder(net.minecraft.client.renderer.BufferBuilder)

Example 42 with BufferBuilder

use of net.minecraft.client.renderer.BufferBuilder in project EnderIO by SleepyTrousers.

the class EnchanterModelRenderer method renderBase.

private void renderBase() {
    BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
    BlockModelShapes modelShapes = blockrendererdispatcher.getBlockModelShapes();
    IBakedModel bakedModel = modelShapes.getModelForState(MachineObject.block_enchanter.getBlockNN().getDefaultState().withProperty(EnumRenderMode.RENDER, EnumRenderMode.FRONT));
    RenderUtil.bindBlockTexture();
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    GlStateManager.enableRescaleNormal();
    GlStateManager.pushMatrix();
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder vertexbuffer = tessellator.getBuffer();
    vertexbuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.ITEM);
    for (EnumFacing enumfacing : EnumFacing.values()) {
        this.renderQuads(vertexbuffer, bakedModel.getQuads((IBlockState) null, enumfacing, 0L));
    }
    this.renderQuads(vertexbuffer, bakedModel.getQuads((IBlockState) null, (EnumFacing) null, 0L));
    tessellator.draw();
    GlStateManager.popMatrix();
    GlStateManager.disableRescaleNormal();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) IBlockState(net.minecraft.block.state.IBlockState) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) EnumFacing(net.minecraft.util.EnumFacing) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) BlockModelShapes(net.minecraft.client.renderer.BlockModelShapes) BlockRendererDispatcher(net.minecraft.client.renderer.BlockRendererDispatcher)

Example 43 with BufferBuilder

use of net.minecraft.client.renderer.BufferBuilder in project minecolonies by Minecolonies.

the class Structure method renderQuads.

private void renderQuads(final World world, final IBlockState actualState, final BlockPos pos, final List<BakedQuad> quads, final int alpha) {
    final Tessellator tessellator = Tessellator.getInstance();
    final BufferBuilder buffer = tessellator.getBuffer();
    for (final BakedQuad quad : quads) {
        buffer.begin(GL11.GL_QUADS, quad.getFormat());
        final int color = quad.hasTintIndex() ? this.getTint(world, actualState, pos, alpha, quad.getTintIndex()) : (alpha | 0xffffff);
        LightUtil.renderQuadColor(buffer, quad, color);
        tessellator.draw();
    }
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) Tessellator(net.minecraft.client.renderer.Tessellator) BufferBuilder(net.minecraft.client.renderer.BufferBuilder)

Example 44 with BufferBuilder

use of net.minecraft.client.renderer.BufferBuilder in project minecolonies by Minecolonies.

the class TextField method drawSelf.

/**
 * Draw itself at positions mx and my.
 */
@Override
public void drawSelf(final int mx, final int my) {
    final int color = enabled ? textColor : textColorDisabled;
    final int drawWidth = getInternalWidth();
    final int drawX = x;
    final int drawY = y;
    // Determine the portion of the string that is visible on screen
    final String visibleString = mc.fontRenderer.trimStringToWidth(text.substring(scrollOffset), drawWidth);
    final int relativeCursorPosition = cursorPosition - scrollOffset;
    int relativeSelectionEnd = selectionEnd - scrollOffset;
    final boolean cursorVisible = relativeCursorPosition >= 0 && relativeCursorPosition <= visibleString.length();
    final boolean cursorBeforeEnd = cursorPosition < text.length() || text.length() >= maxTextLength;
    // Enforce selection to the length limit of the visible string
    if (relativeSelectionEnd > visibleString.length()) {
        relativeSelectionEnd = visibleString.length();
    }
    // Draw string up through cursor
    int textX = drawX;
    if (visibleString.length() > 0) {
        @NotNull final String s1 = cursorVisible ? visibleString.substring(0, relativeCursorPosition) : visibleString;
        mc.renderEngine.bindTexture(TEXTURE);
        textX = mc.fontRenderer.drawString(s1, textX, drawY, color, shadow);
    }
    int cursorX = textX;
    if (!cursorVisible) {
        cursorX = relativeCursorPosition > 0 ? (drawX + width) : drawX;
    } else if (cursorBeforeEnd && shadow) {
        textX -= 1;
        cursorX -= 1;
    }
    // Draw string after cursor
    if (visibleString.length() > 0 && cursorVisible && relativeCursorPosition < visibleString.length()) {
        mc.renderEngine.bindTexture(TEXTURE);
        mc.fontRenderer.drawString(visibleString.substring(relativeCursorPosition), textX, drawY, color, shadow);
    }
    // Should we draw the cursor this frame?
    if (isFocus() && cursorVisible && (cursorBlinkCounter / 6 % 2 == 0)) {
        if (cursorBeforeEnd) {
            drawRect(cursorX, drawY - 1, cursorX + 1, drawY + 1 + mc.fontRenderer.FONT_HEIGHT, RECT_COLOR);
        } else {
            mc.renderEngine.bindTexture(TEXTURE);
            mc.fontRenderer.drawString("_", cursorX, drawY, color, shadow);
        }
    }
    // Draw selection
    if (relativeSelectionEnd != relativeCursorPosition) {
        final int selectedDrawX = drawX + mc.fontRenderer.getStringWidth(visibleString.substring(0, relativeSelectionEnd));
        int selectionStartX = Math.min(cursorX, selectedDrawX - 1);
        int selectionEndX = Math.max(cursorX, selectedDrawX - 1);
        if (selectionStartX > (x + width)) {
            selectionStartX = x + width;
        }
        if (selectionEndX > (x + width)) {
            selectionEndX = x + width;
        }
        final Tessellator tessellator = Tessellator.getInstance();
        GlStateManager.color(0.0F, 0.0F, 255.0F, 255.0F);
        GlStateManager.disableTexture2D();
        GlStateManager.enableColorLogic();
        GlStateManager.colorLogicOp(GL11.GL_OR_REVERSE);
        final BufferBuilder vertexBuffer = tessellator.getBuffer();
        // There are several to choose from, look at DefaultVertexFormats for more info
        vertexBuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
        // Since our points do not have any u,v this seems to be the correct code
        vertexBuffer.pos((double) selectionStartX, (double) drawY + 1 + mc.fontRenderer.FONT_HEIGHT, 0.0D).endVertex();
        vertexBuffer.pos((double) selectionEndX, (double) drawY + 1 + mc.fontRenderer.FONT_HEIGHT, 0.0D).endVertex();
        vertexBuffer.pos((double) selectionEndX, (double) drawY - 1, 0.0D).endVertex();
        vertexBuffer.pos((double) selectionStartX, (double) drawY - 1, 0.0D).endVertex();
        tessellator.draw();
        GlStateManager.disableColorLogic();
        GlStateManager.enableTexture2D();
    }
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) NotNull(org.jetbrains.annotations.NotNull)

Example 45 with BufferBuilder

use of net.minecraft.client.renderer.BufferBuilder in project Minestuck by mraof.

the class RenderGrist method doRender.

@Override
public void doRender(EntityGrist grist, double d0, double d1, double d2, float f, float f1) {
    GlStateManager.pushMatrix();
    GlStateManager.translate((float) d0, (float) d1 + grist.getSizeByValue() / 2, (float) d2);
    this.bindEntityTexture(grist);
    BufferBuilder vertexbuffer = Tessellator.getInstance().getBuffer();
    int j = grist.getBrightnessForRender();
    int k = j % 65536;
    int l = j / 65536;
    OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) k / 1.0F, (float) l / 1.0F);
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    GlStateManager.rotate(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
    GlStateManager.rotate(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
    float f11 = grist.getSizeByValue();
    GlStateManager.scale(f11, f11, f11);
    vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX_NORMAL);
    vertexbuffer.pos(-0.5D, -0.25D, 0.0D).tex(0.0D, 1.0D).normal(0.0F, 1.0F, 0.0F).endVertex();
    vertexbuffer.pos(0.5D, -0.25D, 0.0D).tex(1.0D, 1.0D).normal(0.0F, 1.0F, 0.0F).endVertex();
    vertexbuffer.pos(0.5D, 0.75D, 0.0D).tex(1.0D, 0.0D).normal(0.0F, 1.0F, 0.0F).endVertex();
    vertexbuffer.pos(-0.5D, 0.75D, 0.0D).tex(0.0D, 0.0D).normal(0.0F, 1.0F, 0.0F).endVertex();
    Tessellator.getInstance().draw();
    GlStateManager.disableBlend();
    GlStateManager.disableRescaleNormal();
    GlStateManager.popMatrix();
}
Also used : BufferBuilder(net.minecraft.client.renderer.BufferBuilder)

Aggregations

BufferBuilder (net.minecraft.client.renderer.BufferBuilder)358 Tessellator (net.minecraft.client.renderer.Tessellator)292 BlockPos (net.minecraft.util.math.BlockPos)37 Vec3d (net.minecraft.util.math.Vec3d)33 ResourceLocation (net.minecraft.util.ResourceLocation)25 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)23 IBlockState (net.minecraft.block.state.IBlockState)21 EnumFacing (net.minecraft.util.EnumFacing)21 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)17 Random (java.util.Random)14 Minecraft (net.minecraft.client.Minecraft)13 EntityPlayer (net.minecraft.entity.player.EntityPlayer)13 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)12 BlockRendererDispatcher (net.minecraft.client.renderer.BlockRendererDispatcher)11 EntityLivingBase (net.minecraft.entity.EntityLivingBase)11 World (net.minecraft.world.World)11 ArrayList (java.util.ArrayList)10 ItemStack (net.minecraft.item.ItemStack)10 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)10 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)9