Search in sources :

Example 46 with BufferBuilder

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

the class TravelEntitySpecialRenderer method renderBlock.

public void renderBlock(@Nonnull BlockPos pos, IBlockAccess blockAccess, double globalScale, boolean highlight) {
    BufferBuilder tes = Tessellator.getInstance().getBuffer();
    BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
    GlStateManager.pushMatrix();
    GlStateManager.translate(0.5f, 0.5f, 0.5f);
    GlStateManager.scale(globalScale, globalScale, globalScale);
    GlStateManager.translate(-0.5f, -0.5f, -0.5f);
    IBlockState state = blockAccess.getBlockState(pos).getActualState(blockAccess, pos);
    IBakedModel ibakedmodel = blockrendererdispatcher.getModelForState(state);
    state = state.getBlock().getExtendedState(state, blockAccess, pos);
    tes.setTranslation(-pos.getX(), -pos.getY(), -pos.getZ());
    Vector4f color = highlight ? selectedBlockBlend : blockBlend;
    GlStateManager.color(1, 1, 1, 1);
    GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_CONSTANT_COLOR, GlStateManager.SourceFactor.ONE.factor, GlStateManager.DestFactor.ZERO.factor);
    GL14.glBlendColor(color.x, color.y, color.z, color.w);
    tes.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
    for (BlockRenderLayer layer : BlockRenderLayer.values()) {
        if (state.getBlock().canRenderInLayer(state, NullHelper.notnullJ(layer, "BlockRenderLayer value was null!"))) {
            ForgeHooksClient.setRenderLayer(layer);
            blockrendererdispatcher.getBlockModelRenderer().renderModel(blockAccess, ibakedmodel, state, pos, tes, false);
        }
    }
    ForgeHooksClient.setRenderLayer(null);
    Tessellator.getInstance().draw();
    GL14.glBlendColor(1, 1, 1, 1);
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    tes.setTranslation(0, 0, 0);
    GlStateManager.popMatrix();
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) Vector4f(com.enderio.core.common.vecmath.Vector4f) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) BlockRenderLayer(net.minecraft.util.BlockRenderLayer) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) BlockRendererDispatcher(net.minecraft.client.renderer.BlockRendererDispatcher)

Example 47 with BufferBuilder

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

the class ReservoirRenderer method renderTankFluid.

private void renderTankFluid(SmartTank tank, Set<EnumFacing> mergers, World world, BlockPos pos) {
    final FluidStack fluid = tank.getFluid();
    if (fluid != null) {
        TextureAtlasSprite icon = RenderUtil.getStillTexture(fluid);
        int color = fluid.getFluid().getColor(fluid);
        float fullness = tank.getFilledRatio();
        boolean[][][] merge = getMergers9(world, pos);
        BufferBuilder tes = Tessellator.getInstance().getBuffer();
        float minU = icon.getMinU(), maxU = icon.getMaxU(), minV = icon.getMinV(), maxV = icon.getMaxV();
        for (int i = 0; i <= 1; i++) {
            if (i == 0) {
                GlStateManager.cullFace(CullFace.FRONT);
            } else {
                GlStateManager.cullFace(CullFace.BACK);
            }
            for (NNIterator<EnumFacing> facings = NNList.FACING.fastIterator(); facings.hasNext(); ) {
                EnumFacing dir = facings.next();
                float fullness2 = 0;
                if (mergers.contains(dir)) {
                    BlockPos pos2 = pos.offset(dir);
                    TileEntity tileEntity = world.getTileEntity(pos2);
                    if (tileEntity instanceof TileReservoir) {
                        TileReservoir res2 = (TileReservoir) tileEntity;
                        fullness2 = res2.tank.getFilledRatio();
                    }
                }
                BoundingBox bb = mkFace(merge, dir, fullness, fullness2);
                if (bb != null) {
                    float minVx = minV, maxVx = maxV;
                    if (dir.getAxis() != EnumFacing.Axis.Y) {
                        minVx = icon.getInterpolatedV((1 - fullness) * 16);
                        maxVx = icon.getInterpolatedV((1 - fullness2) * 16);
                    }
                    renderFace(tes, bb, dir, minU, maxU, minVx, maxVx, color);
                }
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) FluidStack(net.minecraftforge.fluids.FluidStack) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) EnumFacing(net.minecraft.util.EnumFacing) BoundingBox(com.enderio.core.client.render.BoundingBox) BlockPos(net.minecraft.util.math.BlockPos)

Example 48 with BufferBuilder

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

the class ObeliskSpecialRenderer method renderObelisk.

protected void renderObelisk() {
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    GlStateManager.enableRescaleNormal();
    RenderUtil.bindBlockTexture();
    BufferBuilder tes = Tessellator.getInstance().getBuffer();
    tes.begin(GL11.GL_QUADS, DefaultVertexFormats.ITEM);
    for (BakedQuad quad : bakedQuads) {
        tes.addVertexData(quad.getVertexData());
    }
    Tessellator.getInstance().draw();
    GlStateManager.disableRescaleNormal();
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) BufferBuilder(net.minecraft.client.renderer.BufferBuilder)

Example 49 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 50 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)

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