Search in sources :

Example 36 with VertexBuffer

use of net.minecraft.client.renderer.VertexBuffer in project MinecraftForge by MinecraftForge.

the class GuiUtils method drawTexturedModalRect.

public static void drawTexturedModalRect(int x, int y, int u, int v, int width, int height, float zLevel) {
    float uScale = 1f / 0x100;
    float vScale = 1f / 0x100;
    Tessellator tessellator = Tessellator.getInstance();
    VertexBuffer wr = tessellator.getBuffer();
    wr.begin(7, DefaultVertexFormats.POSITION_TEX);
    wr.pos(x, y + height, zLevel).tex(u * uScale, ((v + height) * vScale)).endVertex();
    wr.pos(x + width, y + height, zLevel).tex((u + width) * uScale, ((v + height) * vScale)).endVertex();
    wr.pos(x + width, y, zLevel).tex((u + width) * uScale, (v * vScale)).endVertex();
    wr.pos(x, y, zLevel).tex(u * uScale, (v * vScale)).endVertex();
    tessellator.draw();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) VertexBuffer(net.minecraft.client.renderer.VertexBuffer)

Example 37 with VertexBuffer

use of net.minecraft.client.renderer.VertexBuffer in project Overloaded by CJ-MC-Mods.

the class ModelUtils method renderQuadsARGB.

public static void renderQuadsARGB(List<BakedQuad> listQuads, int ARGB_Hex) {
    Tessellator tessellator = Tessellator.getInstance();
    VertexBuffer vertexbuffer = tessellator.getBuffer();
    int i = 0;
    for (int j = listQuads.size(); i < j; ++i) {
        BakedQuad bakedquad = (BakedQuad) listQuads.get(i);
        vertexbuffer.begin(7, DefaultVertexFormats.ITEM);
        vertexbuffer.addVertexData(bakedquad.getVertexData());
        vertexbuffer.putColor4(ARGB_Hex);
        Vec3i vec3i = bakedquad.getFace().getDirectionVec();
        vertexbuffer.putNormal((float) vec3i.getX(), (float) vec3i.getY(), (float) vec3i.getZ());
        tessellator.draw();
    }
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) Vec3i(net.minecraft.util.math.Vec3i) Tessellator(net.minecraft.client.renderer.Tessellator) VertexBuffer(net.minecraft.client.renderer.VertexBuffer)

Example 38 with VertexBuffer

use of net.minecraft.client.renderer.VertexBuffer in project Overloaded by CJ-MC-Mods.

the class ModelUtils method renderQuads.

public static void renderQuads(List<BakedQuad> listQuads) {
    Tessellator tessellator = Tessellator.getInstance();
    VertexBuffer vertexbuffer = tessellator.getBuffer();
    int i = 0;
    vertexbuffer.begin(7, DefaultVertexFormats.ITEM);
    for (int j = listQuads.size(); i < j; ++i) {
        BakedQuad bakedquad = listQuads.get(i);
        vertexbuffer.addVertexData(bakedquad.getVertexData());
        vertexbuffer.putColorRGB_F4(1, 1, 1);
        Vec3i vec3i = bakedquad.getFace().getDirectionVec();
        vertexbuffer.putNormal((float) vec3i.getX(), (float) vec3i.getY(), (float) vec3i.getZ());
    }
    tessellator.draw();
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) Vec3i(net.minecraft.util.math.Vec3i) Tessellator(net.minecraft.client.renderer.Tessellator) VertexBuffer(net.minecraft.client.renderer.VertexBuffer)

Example 39 with VertexBuffer

use of net.minecraft.client.renderer.VertexBuffer in project Bookshelf by Darkhax-Minecraft.

the class RenderUtils method renderFluid.

/**
     * Renders a fluid at the given position.
     *
     * @param fluid The fluid to render.
     * @param pos The position in the world to render the fluid.
     * @param x The base X position.
     * @param y The base Y position.
     * @param z The base Z position.
     * @param x1 The middle X position.
     * @param y1 The middle Y position.
     * @param z1 The middle Z position.
     * @param x2 The max X position.
     * @param y2 The max Y position.
     * @param z2 The max Z position.
     * @param color The color offset used by the fluid. Default is white.
     */
public static void renderFluid(FluidStack fluid, BlockPos pos, double x, double y, double z, double x1, double y1, double z1, double x2, double y2, double z2, int color) {
    final Minecraft mc = Minecraft.getMinecraft();
    final Tessellator tessellator = Tessellator.getInstance();
    final VertexBuffer buffer = tessellator.getBuffer();
    final int brightness = mc.world.getCombinedLight(pos, fluid.getFluid().getLuminosity());
    buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
    mc.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    setupRenderState(x, y, z);
    GlStateManager.translate(x, y, z);
    final TextureAtlasSprite still = mc.getTextureMapBlocks().getTextureExtry(fluid.getFluid().getStill(fluid).toString());
    final TextureAtlasSprite flowing = mc.getTextureMapBlocks().getTextureExtry(fluid.getFluid().getFlowing(fluid).toString());
    addTexturedQuad(buffer, still, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.DOWN, color, brightness);
    addTexturedQuad(buffer, flowing, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.NORTH, color, brightness);
    addTexturedQuad(buffer, flowing, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.EAST, color, brightness);
    addTexturedQuad(buffer, flowing, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.SOUTH, color, brightness);
    addTexturedQuad(buffer, flowing, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.WEST, color, brightness);
    addTexturedQuad(buffer, still, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.UP, color, brightness);
    tessellator.draw();
    cleanupRenderState();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) VertexBuffer(net.minecraft.client.renderer.VertexBuffer) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) Minecraft(net.minecraft.client.Minecraft)

Example 40 with VertexBuffer

use of net.minecraft.client.renderer.VertexBuffer in project OpenModularTurrets by OpenModularTurretsTeam.

the class EventHandler method drawBlockOutline.

@SubscribeEvent
@SideOnly(Side.CLIENT)
public void drawBlockOutline(DrawBlockHighlightEvent event) {
    if (event.getTarget() != null && event.getTarget().getBlockPos() != null && event.getTarget().sideHit != null && event.getPlayer().getHeldItemMainhand() != null && event.getPlayer().getHeldItemMainhand().getItem() instanceof ItemBlockBaseAddon) {
        BlockPos blockpos = event.getTarget().getBlockPos().offset(event.getTarget().sideHit);
        if (getTurretBase(event.getPlayer().getEntityWorld(), blockpos) != null) {
            ItemBlockBaseAddon addon = (ItemBlockBaseAddon) event.getPlayer().getHeldItemMainhand().getItem();
            GlStateManager.enableBlend();
            GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
            GlStateManager.glLineWidth(2.0F);
            GlStateManager.disableTexture2D();
            GlStateManager.depthMask(false);
            AxisAlignedBB alignedBB;
            EnumFacing facing = getTurretBaseFacing(event.getPlayer().getEntityWorld(), blockpos);
            if (addon.getBlock().getDefaultState().getProperties().containsKey(FACING)) {
                alignedBB = addon.getRenderOutline(addon.getBlock().getDefaultState().withProperty(FACING, facing), event.getPlayer().getEntityWorld(), blockpos);
            } else {
                alignedBB = addon.getRenderOutline(addon.getBlock().getDefaultState(), event.getPlayer().getEntityWorld(), blockpos);
            }
            EntityPlayer player = event.getPlayer();
            double partialTicks = event.getPartialTicks();
            double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialTicks;
            double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTicks;
            double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTicks;
            float[] color = new float[3];
            if (event.getPlayer().getEntityWorld().isAirBlock(blockpos)) {
                color[0] = 0F;
                color[1] = 1F;
                color[2] = 1F;
            } else {
                color[0] = 1F;
                color[1] = 0F;
                color[2] = 0F;
            }
            alignedBB = alignedBB.offset(-d0, -d1, -d2);
            Tessellator tessellator = Tessellator.getInstance();
            VertexBuffer vertexbuffer = tessellator.getBuffer();
            vertexbuffer.begin(3, DefaultVertexFormats.POSITION_COLOR);
            drawHighlightBox(vertexbuffer, alignedBB.minX, alignedBB.minY, alignedBB.minZ, alignedBB.maxX, alignedBB.maxY, alignedBB.maxZ, color[0], color[1], color[2], 0.5F);
            tessellator.draw();
            GlStateManager.depthMask(true);
            GlStateManager.enableTexture2D();
            GlStateManager.disableBlend();
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Tessellator(net.minecraft.client.renderer.Tessellator) VertexBuffer(net.minecraft.client.renderer.VertexBuffer) EnumFacing(net.minecraft.util.EnumFacing) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos) ItemBlockBaseAddon(omtteam.openmodularturrets.items.blocks.ItemBlockBaseAddon) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

VertexBuffer (net.minecraft.client.renderer.VertexBuffer)52 Tessellator (net.minecraft.client.renderer.Tessellator)50 BlockPos (net.minecraft.util.math.BlockPos)8 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)6 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)5 EnumFacing (net.minecraft.util.EnumFacing)5 PhysicsWrapperEntity (ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity)3 Minecraft (net.minecraft.client.Minecraft)3 BlockRendererDispatcher (net.minecraft.client.renderer.BlockRendererDispatcher)3 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)3 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)3 Entity (net.minecraft.entity.Entity)3 Vec3i (net.minecraft.util.math.Vec3i)3 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)3 FontRenderer (net.minecraft.client.gui.FontRenderer)2 RenderManager (net.minecraft.client.renderer.entity.RenderManager)2 Vec3d (net.minecraft.util.math.Vec3d)2 FluidStack (net.minecraftforge.fluids.FluidStack)2 NotNull (org.jetbrains.annotations.NotNull)2 IImmersiveConnectable (blusunrize.immersiveengineering.api.energy.wires.IImmersiveConnectable)1