Search in sources :

Example 31 with BufferBuilder

use of net.minecraft.client.renderer.BufferBuilder in project Tropicraft by Tropicraft.

the class RenderPoisonBlot method doRender.

@Override
public void doRender(EntityPoisonBlot entity, double x, double y, double z, float entityYaw, float partialTicks) {
    GlStateManager.pushMatrix();
    GlStateManager.enableRescaleNormal();
    this.bindEntityTexture(entity);
    Tessellator tessellator = Tessellator.getInstance();
    GlStateManager.translate(x, y, z);
    GlStateManager.rotate(180f - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
    // GlStateManager.scale(0.25f, 0.25f, 0.25f);
    BufferBuilder buffer = tessellator.getBuffer();
    buffer.begin(7, DefaultVertexFormats.POSITION_TEX);
    GlStateManager.glNormal3f(0.0F, 1.0F, 0.0F);
    buffer.pos(-.5, -.5, 0).tex(0, 1).endVertex();
    buffer.pos(.5, -.5, 0).tex(1, 1).endVertex();
    buffer.pos(.5, .5, 0).tex(1, 0).endVertex();
    buffer.pos(-.5, .5, 0).tex(0, 0).endVertex();
    tessellator.draw();
    GlStateManager.disableRescaleNormal();
    GlStateManager.popMatrix();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) BufferBuilder(net.minecraft.client.renderer.BufferBuilder)

Example 32 with BufferBuilder

use of net.minecraft.client.renderer.BufferBuilder in project Tropicraft by Tropicraft.

the class RenderStarfish method popper.

private void popper(Tessellator tessellator, float f, float f1, float f2, float f3, float f1shifted, float f3shifted, float layerHeight) {
    float f4 = 1.0F;
    float f5 = layerHeight;
    BufferBuilder vertexbuffer = tessellator.getBuffer();
    vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX);
    GlStateManager.glNormal3f(0.0F, 0.0F, 1.0F);
    // vertexbuffer.pos(0D, 0D, 0D).tex((double)f, (double)f3shifted).endVertex();
    buf(vertexbuffer, 0.0D, 0.0D, 0.0D, f, f3shifted);
    buf(vertexbuffer, f4, 0.0D, 0.0D, f2, f3shifted);
    buf(vertexbuffer, f4, 1.0D, 0.0D, f2, f1shifted);
    buf(vertexbuffer, 0.0D, 1.0D, 0.0D, f, f1shifted);
    tessellator.draw();
    vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX);
    GlStateManager.glNormal3f(0.0F, 0.0F, -1F);
    buf(vertexbuffer, 0.0D, 1.0D, 0.0F - f5, f, f1);
    buf(vertexbuffer, f4, 1.0D, 0.0F - f5, f2, f1);
    buf(vertexbuffer, f4, 0.0D, 0.0F - f5, f2, f3);
    buf(vertexbuffer, 0.0D, 0.0D, 0.0F - f5, f, f3);
    tessellator.draw();
    vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX);
    GlStateManager.glNormal3f(-1F, 0.0F, 0.0F);
    for (int i = 0; i < 32; i++) {
        float f6 = (float) i / 32F;
        float f10 = (f + (f2 - f) * f6) - 0.001953125F;
        float f14 = f4 * f6;
        buf(vertexbuffer, f14, 0.0D, 0.0F - f5, f10, f3);
        buf(vertexbuffer, f14, 0.0D, 0.0D, f10, f3);
        buf(vertexbuffer, f14, 1.0D, 0.0D, f10, f1);
        buf(vertexbuffer, f14, 1.0D, 0.0F - f5, f10, f1);
    }
    tessellator.draw();
    vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX);
    GlStateManager.glNormal3f(1.0F, 0.0F, 0.0F);
    for (int j = 0; j < 32; j++) {
        float f7 = (float) j / 32F;
        float f11 = (f + (f2 - f) * f7) - 0.001953125F;
        float f15 = f4 * f7 + 0.03125F;
        buf(vertexbuffer, f15, 1.0D, 0.0F - f5, f11, f1);
        buf(vertexbuffer, f15, 1.0D, 0.0D, f11, f1);
        buf(vertexbuffer, f15, 0.0D, 0.0D, f11, f3);
        buf(vertexbuffer, f15, 0.0D, 0.0F - f5, f11, f3);
    }
    tessellator.draw();
    vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX);
    GlStateManager.glNormal3f(0.0F, 1.0F, 0.0F);
    for (int k = 0; k < 32; k++) {
        float f8 = (float) k / 32F;
        float f12 = (f3 + (f1 - f3) * f8) - 0.001953125F;
        float f16 = f4 * f8 + 0.03125F;
        buf(vertexbuffer, 0.0D, f16, 0.0D, f, f12);
        buf(vertexbuffer, f4, f16, 0.0D, f2, f12);
        buf(vertexbuffer, f4, f16, 0.0F - f5, f2, f12);
        buf(vertexbuffer, 0.0D, f16, 0.0F - f5, f, f12);
    }
    tessellator.draw();
    vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX);
    GlStateManager.glNormal3f(0.0F, -1F, 0.0F);
    for (int l = 0; l < 32; l++) {
        float f9 = (float) l / 32F;
        float f13 = (f3 + (f1 - f3) * f9) - 0.001953125F;
        float f17 = f4 * f9;
        buf(vertexbuffer, f4, f17, 0.0D, f2, f13);
        buf(vertexbuffer, 0.0D, f17, 0.0D, f, f13);
        buf(vertexbuffer, 0.0D, f17, 0.0F - f5, f, f13);
        buf(vertexbuffer, f4, f17, 0.0F - f5, f2, f13);
    }
    tessellator.draw();
}
Also used : BufferBuilder(net.minecraft.client.renderer.BufferBuilder)

Example 33 with BufferBuilder

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

the class YetaWrenchOverlayRenderer method doRenderOverlay.

private void doRenderOverlay(@Nonnull RenderGameOverlayEvent event, @Nonnull ItemStack equippedWrench) {
    ConduitDisplayMode mode = ConduitDisplayMode.getDisplayMode(equippedWrench);
    if (mode != cachedMode) {
        cachedMode = mode;
        displayTickCount = 20;
        lastTick = ClientHandler.getTicksElapsed();
    }
    ScaledResolution res = event.getResolution();
    int modeCount = ConduitDisplayMode.registrySize();
    Iterable<ConduitDisplayMode> renderable = ConduitDisplayMode.getRenderableModes();
    switch(PersonalConfig.yetaOverlayMode.get()) {
        case 0:
            if (displayTickCount > 0) {
                if (lastTick < ClientHandler.getTicksElapsed()) {
                    lastTick++;
                    displayTickCount--;
                }
                int x = res.getScaledWidth() / 2 - 8;
                int y = res.getScaledHeight() / 2 - 24;
                IWidgetIcon widget = mode.getWidgetSelected();
                RenderUtil.bindTexture(widget.getMap().getTexture());
                widget.getMap().render(widget, x, y, true);
                int size = 12;
                widget = mode.previous().getWidgetSelected();
                RenderUtil.bindTexture(widget.getMap().getTexture());
                widget.getMap().render(widget, x - 18 + (16 - size), y + (16 - size), size, size, 0, true);
                widget = mode.next().getWidgetSelected();
                RenderUtil.bindTexture(widget.getMap().getTexture());
                widget.getMap().render(widget, x + 18, y + (16 - size), size, size, 0, true);
            } else {
                int x = res.getScaledWidth() - 20;
                int y = res.getScaledHeight() - 20;
                IWidgetIcon widget = mode.getWidgetSelected();
                RenderUtil.bindTexture(widget.getMap().getTexture());
                widget.getMap().render(widget, x, y, true);
            }
            break;
        case 1:
            int size = 16;
            int padding = 2;
            int inset = (int) (size / 1.5);
            int offsetX = res.getScaledWidth() - inset - 1;
            int offsetY = res.getScaledHeight() - modeCount * (size + padding) - padding;
            inset = size - inset;
            int x = offsetX + 2;
            int y = offsetY - (padding * 2);
            int height = (modeCount * (size + padding)) + (padding * 3);
            // FIXME
            GL11.glDisable(GL11.GL_TEXTURE_2D);
            GL11.glShadeModel(GL11.GL_SMOOTH);
            VertexFormat vf = DefaultVertexFormats.POSITION_COLOR;
            Tessellator tess = Tessellator.getInstance();
            BufferBuilder wr = tess.getBuffer();
            wr.begin(GL11.GL_QUADS, vf);
            wr.pos(x, y, -5).color(0, 0, 0, 0.2f).endVertex();
            ;
            wr.pos(x, y + height, -5).color(0, 0, 0, 0.2f).endVertex();
            ;
            Vector4f color = new Vector4f(0, 0, 0, 1);
            wr.pos(x + size, y + height, -5).color(color.x, color.y, color.z, color.w).endVertex();
            wr.pos(x + size, y, -5).color(color.x, color.y, color.z, color.w).endVertex();
            tess.draw();
            GlStateManager.color(1, 1, 1);
            GL11.glShadeModel(GL11.GL_FLAT);
            y += padding * 2;
            x -= 2;
            if (mode == ConduitDisplayMode.ALL) {
                x -= inset;
            }
            GL11.glEnable(GL11.GL_TEXTURE_2D);
            for (ConduitDisplayMode toRender : renderable) {
                IWidgetIcon widget = mode == ConduitDisplayMode.ALL ? toRender.getWidgetSelected() : toRender.getWidgetUnselected();
                RenderUtil.bindTexture(widget.getMap().getTexture());
                if (toRender == mode) {
                    widget = toRender.getWidgetSelected();
                    widget.getMap().render(widget, x - inset, y, true);
                } else {
                    widget.getMap().render(widget, x, y, true);
                }
                y += size + padding;
            }
            break;
        case 2:
            offsetX = res.getScaledWidth() - (modeCount * 8) - 16;
            y = res.getScaledHeight() - 40;
            x = offsetX;
            if (modeCount % 2 == 1) {
                x += 8;
            }
            int count = 0;
            for (ConduitDisplayMode toRender : renderable) {
                IWidgetIcon widget = mode == ConduitDisplayMode.ALL || toRender == mode ? toRender.getWidgetSelected() : toRender.getWidgetUnselected();
                RenderUtil.bindTexture(widget.getMap().getTexture());
                widget.getMap().render(widget, x, y, true);
                x += 16;
                if (count == modeCount / 2 - 1) {
                    x = offsetX;
                    y += 16;
                }
                count++;
            }
    }
}
Also used : ConduitDisplayMode(crazypants.enderio.base.conduit.ConduitDisplayMode) ScaledResolution(net.minecraft.client.gui.ScaledResolution) IWidgetIcon(com.enderio.core.api.client.render.IWidgetIcon) Tessellator(net.minecraft.client.renderer.Tessellator) Vector4f(com.enderio.core.common.vecmath.Vector4f) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) VertexFormat(net.minecraft.client.renderer.vertex.VertexFormat)

Example 34 with BufferBuilder

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

the class PowerBarOverlayRenderHelper method overpaintVanillaRenderBug.

protected void overpaintVanillaRenderBug(int xPosition, int yPosition) {
    GlStateManager.disableLighting();
    GlStateManager.disableDepth();
    GlStateManager.disableTexture2D();
    GlStateManager.disableAlpha();
    GlStateManager.disableBlend();
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder worldrenderer = tessellator.getBuffer();
    worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
    overpaintVanillaRenderBug(worldrenderer, xPosition, yPosition);
    tessellator.draw();
    GlStateManager.enableAlpha();
    GlStateManager.enableTexture2D();
    GlStateManager.enableLighting();
    GlStateManager.enableDepth();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) BufferBuilder(net.minecraft.client.renderer.BufferBuilder)

Example 35 with BufferBuilder

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

the class TeleportEntityRenderHandler method onEntityRender.

/*
   * gl flags when this is called: GL_ALPHA_TEST GL_COLOR_MATERIAL GL_CULL_FACE GL_DEPTH_TEST GL_DITHER GL_FOG GL_LIGHTING GL_TEXTURE_2D
   */
@SubscribeEvent
public static void onEntityRender(RenderLivingEvent.Post<EntityLivingBase> event) {
    EntityLivingBase e = event.getEntity();
    if (e.getEntityData().getBoolean("eio_needs_pop")) {
        GlStateManager.popMatrix();
        e.getEntityData().removeTag("eio_needs_pop");
    }
    if (e.getEntityData().getBoolean(TileTelePad.TELEPORTING_KEY)) {
        final float progress = e.getEntityData().getFloat(TileTelePad.PROGRESS_KEY);
        final float speed = progress * 1.2f;
        final float rot = (e.getEntityData().getFloat("eio_teleportrotation")) + speed;
        e.getEntityData().setFloat("eio_teleportrotation", rot);
        AxisAlignedBB bb = e.getRenderBoundingBox();
        if (NullHelper.untrust(bb) == null || bb.getAverageEdgeLength() < .2) {
            float radius = e.width / 2.0F;
            bb = new AxisAlignedBB(-radius, 0, -radius, radius, e.height, radius).offset(e.posX, e.posY, e.posZ);
        }
        bb = bb.setMaxY(bb.maxY + 1.25 - progress / 2).expand(0.5 - progress / 5, 0, 0.5 - progress / 5);
        GlStateManager.pushMatrix();
        GlStateManager.disableTexture2D();
        GlStateManager.shadeModel(GL11.GL_SMOOTH);
        GlStateManager.enableBlend();
        GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE, GL_ZERO, GL_ONE);
        GlStateManager.disableAlpha();
        GlStateManager.disableCull();
        GlStateManager.disableLighting();
        GlStateManager.depthMask(false);
        GlStateManager.translate(event.getX(), event.getY(), event.getZ());
        GlStateManager.rotate(rot + Minecraft.getMinecraft().getRenderPartialTicks() + e.ticksExisted, 0, 1, 0);
        Tessellator tes = Tessellator.getInstance();
        BufferBuilder vertexBuffer = tes.getBuffer();
        vertexBuffer.setTranslation(-e.posX, -e.posY, -e.posZ);
        vertexBuffer.begin(GL11.GL_QUAD_STRIP, DefaultVertexFormats.POSITION_COLOR);
        vertexBuffer.pos(bb.maxX, bb.maxY, bb.maxZ).color(COL_TOP.x, COL_TOP.y, COL_TOP.z, COL_TOP.w).endVertex();
        vertexBuffer.pos(bb.maxX, bb.minY, bb.maxZ).color(COL_BOT.x, COL_BOT.y, COL_BOT.z, COL_BOT.w).endVertex();
        vertexBuffer.pos(bb.minX, bb.maxY, bb.maxZ).color(COL_TOP.x, COL_TOP.y, COL_TOP.z, COL_TOP.w).endVertex();
        vertexBuffer.pos(bb.minX, bb.minY, bb.maxZ).color(COL_BOT.x, COL_BOT.y, COL_BOT.z, COL_BOT.w).endVertex();
        vertexBuffer.pos(bb.minX, bb.maxY, bb.minZ).color(COL_TOP.x, COL_TOP.y, COL_TOP.z, COL_TOP.w).endVertex();
        vertexBuffer.pos(bb.minX, bb.minY, bb.minZ).color(COL_BOT.x, COL_BOT.y, COL_BOT.z, COL_BOT.w).endVertex();
        vertexBuffer.pos(bb.maxX, bb.maxY, bb.minZ).color(COL_TOP.x, COL_TOP.y, COL_TOP.z, COL_TOP.w).endVertex();
        vertexBuffer.pos(bb.maxX, bb.minY, bb.minZ).color(COL_BOT.x, COL_BOT.y, COL_BOT.z, COL_BOT.w).endVertex();
        vertexBuffer.pos(bb.maxX, bb.maxY, bb.maxZ).color(COL_TOP.x, COL_TOP.y, COL_TOP.z, COL_TOP.w).endVertex();
        vertexBuffer.pos(bb.maxX, bb.minY, bb.maxZ).color(COL_BOT.x, COL_BOT.y, COL_BOT.z, COL_BOT.w).endVertex();
        tes.draw();
        GlStateManager.enableTexture2D();
        GlStateManager.disableBlend();
        GlStateManager.enableAlpha();
        GlStateManager.enableCull();
        GlStateManager.enableLighting();
        GlStateManager.depthMask(true);
        GlStateManager.popMatrix();
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Tessellator(net.minecraft.client.renderer.Tessellator) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) EntityLivingBase(net.minecraft.entity.EntityLivingBase) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

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