Search in sources :

Example 71 with BufferBuilder

use of net.minecraft.client.renderer.BufferBuilder in project SomeModjam5Mod by HellFirePvP.

the class RenderingUtils method renderTexturedCubeCentral.

public static void renderTexturedCubeCentral(Vector3 offset, double size, double u, double v, double uLength, double vLength) {
    Tessellator tes = Tessellator.getInstance();
    BufferBuilder vb = tes.getBuffer();
    double half = size / 2D;
    vb.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
    vb.pos(offset.getX() - half, offset.getY() - half, offset.getZ() - half).tex(u, v).endVertex();
    vb.pos(offset.getX() + half, offset.getY() - half, offset.getZ() - half).tex(u + uLength, v).endVertex();
    vb.pos(offset.getX() + half, offset.getY() - half, offset.getZ() + half).tex(u + uLength, v + vLength).endVertex();
    vb.pos(offset.getX() - half, offset.getY() - half, offset.getZ() + half).tex(u, v + vLength).endVertex();
    vb.pos(offset.getX() - half, offset.getY() + half, offset.getZ() + half).tex(u, v).endVertex();
    vb.pos(offset.getX() + half, offset.getY() + half, offset.getZ() + half).tex(u + uLength, v).endVertex();
    vb.pos(offset.getX() + half, offset.getY() + half, offset.getZ() - half).tex(u + uLength, v + vLength).endVertex();
    vb.pos(offset.getX() - half, offset.getY() + half, offset.getZ() - half).tex(u, v + vLength).endVertex();
    vb.pos(offset.getX() - half, offset.getY() - half, offset.getZ() + half).tex(u + uLength, v).endVertex();
    vb.pos(offset.getX() - half, offset.getY() + half, offset.getZ() + half).tex(u + uLength, v + vLength).endVertex();
    vb.pos(offset.getX() - half, offset.getY() + half, offset.getZ() - half).tex(u, v + vLength).endVertex();
    vb.pos(offset.getX() - half, offset.getY() - half, offset.getZ() - half).tex(u, v).endVertex();
    vb.pos(offset.getX() + half, offset.getY() - half, offset.getZ() - half).tex(u + uLength, v).endVertex();
    vb.pos(offset.getX() + half, offset.getY() + half, offset.getZ() - half).tex(u + uLength, v + vLength).endVertex();
    vb.pos(offset.getX() + half, offset.getY() + half, offset.getZ() + half).tex(u, v + vLength).endVertex();
    vb.pos(offset.getX() + half, offset.getY() - half, offset.getZ() + half).tex(u, v).endVertex();
    vb.pos(offset.getX() + half, offset.getY() - half, offset.getZ() - half).tex(u, v).endVertex();
    vb.pos(offset.getX() + half, offset.getY() + half, offset.getZ() - half).tex(u, v + vLength).endVertex();
    vb.pos(offset.getX() - half, offset.getY() + half, offset.getZ() - half).tex(u + uLength, v + vLength).endVertex();
    vb.pos(offset.getX() - half, offset.getY() - half, offset.getZ() - half).tex(u + uLength, v).endVertex();
    vb.pos(offset.getX() - half, offset.getY() - half, offset.getZ() + half).tex(u, v).endVertex();
    vb.pos(offset.getX() - half, offset.getY() + half, offset.getZ() + half).tex(u, v + vLength).endVertex();
    vb.pos(offset.getX() + half, offset.getY() + half, offset.getZ() + half).tex(u + uLength, v + vLength).endVertex();
    vb.pos(offset.getX() + half, offset.getY() - half, offset.getZ() + half).tex(u + uLength, v).endVertex();
    tes.draw();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) BufferBuilder(net.minecraft.client.renderer.BufferBuilder)

Example 72 with BufferBuilder

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

the class ConduitBundleRenderer method render.

// TESR rendering
@Override
public void render(@Nonnull TileConduitBundle te, double x, double y, double z, float partialTick, int b, float alpha) {
    IConduitBundle bundle = te;
    EntityPlayerSP player = Minecraft.getMinecraft().player;
    if (bundle.hasFacade() && bundle.getPaintSource().isOpaqueCube() && !YetaUtil.isFacadeHidden(bundle, player)) {
        return;
    }
    float brightness = -1;
    boolean hasDynamic = false;
    for (IClientConduit c : bundle.getClientConduits()) {
        // TODO Temporary work around
        IClientConduit.WithDefaultRendering con = (IClientConduit.WithDefaultRendering) c;
        if (YetaUtil.renderConduit(player, con)) {
            IConduitRenderer renderer = getRendererForConduit(con);
            if (renderer.isDynamic()) {
                if (!hasDynamic) {
                    hasDynamic = true;
                    BlockPos loc = bundle.getLocation();
                    brightness = bundle.getEntity().getWorld().getLightFor(EnumSkyBlock.SKY, loc);
                    RenderUtil.setupLightmapCoords(te.getPos(), te.getWorld());
                    RenderUtil.bindBlockTexture();
                    GlStateManager.enableNormalize();
                    GlStateManager.enableBlend();
                    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
                    GlStateManager.shadeModel(GL11.GL_SMOOTH);
                    GlStateManager.pushMatrix();
                    GlStateManager.translate(x, y, z);
                    Tessellator tessellator = Tessellator.getInstance();
                    BufferBuilder tes = tessellator.getBuffer();
                    tes.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
                }
                renderer.renderDynamicEntity(this, bundle, con, x, y, z, partialTick, brightness);
            }
        }
    }
    if (hasDynamic) {
        Tessellator.getInstance().draw();
        GlStateManager.disableNormalize();
        GlStateManager.disableBlend();
        GlStateManager.shadeModel(GL11.GL_FLAT);
        GlStateManager.popMatrix();
    }
}
Also used : IClientConduit(crazypants.enderio.base.conduit.IClientConduit) Tessellator(net.minecraft.client.renderer.Tessellator) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) IConduitBundle(crazypants.enderio.base.conduit.IConduitBundle) BlockPos(net.minecraft.util.math.BlockPos) IConduitRenderer(crazypants.enderio.base.conduit.IConduitRenderer) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP)

Example 73 with BufferBuilder

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

the class TESRPowerMonitor method renderTileEntity.

@Override
protected void renderTileEntity(@Nonnull TilePowerMonitor te, @Nonnull IBlockState blockState, float partialTicks, int destroyStage) {
    boolean isPainted = te.getPaintSource() != null;
    VertexRotationFacing xform = new VertexRotationFacing(te.getFacing());
    xform.setCenter(new Vector3d(0.5, 0.5, 0.5));
    xform.setRotation(EnumFacing.SOUTH);
    te.bindTexture();
    Helper helper = threadLocalHelper.get();
    BufferBuilder tes = Tessellator.getInstance().getBuffer();
    tes.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR_NORMAL);
    if (isPainted) {
        helper.setupVertices(bb2, xform);
        helper.renderSingleFace(tes, EnumFacing.SOUTH, 0 * px, 14 * px, 0 * px, 14 * px, xform, Helper.stdBrightness, false);
    } else {
        helper.setupVertices(bb1, xform);
        helper.renderSingleFace(tes, EnumFacing.SOUTH, 1 * px, 15 * px, 1 * px, 15 * px, xform, Helper.stdBrightness, false);
    }
    Tessellator.getInstance().draw();
}
Also used : VertexRotationFacing(com.enderio.core.client.render.VertexRotationFacing) Vector3d(com.enderio.core.common.vecmath.Vector3d) BufferBuilder(net.minecraft.client.renderer.BufferBuilder)

Example 74 with BufferBuilder

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

the class FillGaugeBakery method render.

public void render() {
    if (canRender()) {
        int i = world.getCombinedLight(pos.offset(face), 0);
        int j = i % 65536;
        int k = i / 65536;
        OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, j / 1.0F, k / 1.0F);
        BufferBuilder tes = Tessellator.getInstance().getBuffer();
        tes.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR_NORMAL);
        buffer.render(tes);
        if (litBuffer != null) {
            litBuffer.render(tes);
        }
        Tessellator.getInstance().draw();
    }
}
Also used : BufferBuilder(net.minecraft.client.renderer.BufferBuilder)

Example 75 with BufferBuilder

use of net.minecraft.client.renderer.BufferBuilder in project RFTools by McJty.

the class MatterBeamerRenderer method render.

@Override
public void render(MatterBeamerTileEntity tileEntity, double x, double y, double z, float time, int destroyStage, float alpha) {
    ResourceLocation txt;
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder buffer = tessellator.getBuffer();
    BlockPos destination = tileEntity.getDestination();
    if (destination != null) {
        if (tileEntity.isPowered()) {
            GlStateManager.pushMatrix();
            buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_LMAP_COLOR);
            GlStateManager.depthMask(false);
            GlStateManager.enableBlend();
            GlStateManager.blendFunc(GL11.GL_ONE, GL11.GL_ONE);
            Minecraft mc = Minecraft.getMinecraft();
            EntityPlayerSP p = mc.player;
            double doubleX = p.lastTickPosX + (p.posX - p.lastTickPosX) * time;
            double doubleY = p.lastTickPosY + (p.posY - p.lastTickPosY) * time;
            double doubleZ = p.lastTickPosZ + (p.posZ - p.lastTickPosZ) * time;
            RenderHelper.Vector start = new RenderHelper.Vector(tileEntity.getPos().getX() + .5f, tileEntity.getPos().getY() + .5f, tileEntity.getPos().getZ() + .5f);
            RenderHelper.Vector end = new RenderHelper.Vector(destination.getX() + .5f, destination.getY() + .5f, destination.getZ() + .5f);
            RenderHelper.Vector player = new RenderHelper.Vector((float) doubleX, (float) doubleY + p.getEyeHeight(), (float) doubleZ);
            GlStateManager.translate(-doubleX, -doubleY, -doubleZ);
            this.bindTexture(redglow);
            RenderHelper.drawBeam(start, end, player, tileEntity.isGlowing() ? .1f : .05f);
            tessellator.draw();
            GlStateManager.popMatrix();
        }
    }
    BlockPos coord = tileEntity.getPos();
    if (coord.equals(RFTools.instance.clientInfo.getSelectedTE())) {
        txt = redglow;
    } else if (coord.equals(RFTools.instance.clientInfo.getDestinationTE())) {
        txt = blueglow;
    } else {
        txt = null;
    }
    if (txt != null) {
        this.bindTexture(txt);
        RenderGlowEffect.renderGlow(tessellator, x, y, z);
    }
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) RenderHelper(mcjty.lib.gui.RenderHelper) ResourceLocation(net.minecraft.util.ResourceLocation) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) BlockPos(net.minecraft.util.math.BlockPos) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) Minecraft(net.minecraft.client.Minecraft)

Aggregations

BufferBuilder (net.minecraft.client.renderer.BufferBuilder)319 Tessellator (net.minecraft.client.renderer.Tessellator)251 BlockPos (net.minecraft.util.math.BlockPos)35 Vec3d (net.minecraft.util.math.Vec3d)27 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 Minecraft (net.minecraft.client.Minecraft)14 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)14 EntityPlayer (net.minecraft.entity.player.EntityPlayer)11 ItemStack (net.minecraft.item.ItemStack)11 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)11 ArrayList (java.util.ArrayList)10 BlockRendererDispatcher (net.minecraft.client.renderer.BlockRendererDispatcher)10 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)9 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)9 World (net.minecraft.world.World)8 Random (java.util.Random)7 FontRenderer (net.minecraft.client.gui.FontRenderer)7