Search in sources :

Example 76 with BufferBuilder

use of net.minecraft.client.render.BufferBuilder in project RPG-Hud by KurodaAkira.

the class HudElement method drawTetragon.

/**
 * Draws a tetragon on the screen
 *
 * @param posX1
 *            x position of the upper left corner
 * @param posX2
 *            x position of the lower left corner
 * @param posY1
 *            y position of the upper left corner
 * @param posY2
 *            y position of the lower left corner
 * @param width1
 *            width of the top edge
 * @param width2
 *            width of the bottom edge
 * @param height1
 *            height of the left edge
 * @param height2
 *            height of the right edge
 * @param color
 *            color of the tetragon (hexa format 0xAARRGGBB)
 */
public void drawTetragon(int posX1, int posX2, int posY1, int posY2, int width1, int width2, int height1, int height2, int color) {
    if (color == -1)
        return;
    if (width1 < 0)
        width1 = 0;
    if (width2 < 0)
        width2 = 0;
    float f3;
    if (color <= 0xFFFFFF && color >= 0)
        f3 = 1.0F;
    else
        f3 = (color >> 24 & 255) / 255.0F;
    float f = (color >> 16 & 255) / 255.0F;
    float f1 = (color >> 8 & 255) / 255.0F;
    float f2 = (color & 255) / 255.0F;
    RenderSystem.enableBlend();
    RenderSystem.disableTexture();
    RenderSystem.defaultBlendFunc();
    RenderSystem.setShader(GameRenderer::getPositionColorShader);
    RenderSystem.disableDepthTest();
    BufferBuilder vertexbuffer = Tessellator.getInstance().getBuffer();
    vertexbuffer.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
    vertexbuffer.vertex(posX1, (double) posY1 + height1, 0.0D).color(f, f1, f2, f3).next();
    vertexbuffer.vertex((double) posX2 + width2, (double) posY2 + height2, 0.0D).color(f, f1, f2, f3).next();
    vertexbuffer.vertex((double) posX1 + width1, posY2, 0.0D).color(f, f1, f2, f3).next();
    vertexbuffer.vertex(posX2, posY1, 0.0D).color(f, f1, f2, f3).next();
    vertexbuffer.end();
    BufferRenderer.draw(vertexbuffer);
    RenderSystem.enableTexture();
    RenderSystem.disableBlend();
    RenderSystem.enableDepthTest();
}
Also used : BufferBuilder(net.minecraft.client.render.BufferBuilder) GameRenderer(net.minecraft.client.render.GameRenderer)

Aggregations

BufferBuilder (net.minecraft.client.render.BufferBuilder)76 GameRenderer (net.minecraft.client.render.GameRenderer)46 Tessellator (net.minecraft.client.render.Tessellator)44 Matrix4f (net.minecraft.util.math.Matrix4f)18 MatrixStack (net.minecraft.client.util.math.MatrixStack)14 IMatrix4f (dev.hypnotic.utils.mixin.IMatrix4f)9 Color (java.awt.Color)9 RenderLayer (net.minecraft.client.render.RenderLayer)5 Vec3d (net.minecraft.util.math.Vec3d)5 BlockState (net.minecraft.block.BlockState)4 BlockEntity (net.minecraft.block.entity.BlockEntity)4 ChunkOcclusionDataBuilder (net.minecraft.client.render.chunk.ChunkOcclusionDataBuilder)4 FluidState (net.minecraft.fluid.FluidState)4 BlockPos (net.minecraft.util.math.BlockPos)4 Random (java.util.Random)3 BlockRenderManager (net.minecraft.client.render.block.BlockRenderManager)3 ChunkRendererRegion (net.minecraft.client.render.chunk.ChunkRendererRegion)3 Inject (org.spongepowered.asm.mixin.injection.Inject)3 Mirror (com.qouteall.immersive_portals.portal.Mirror)2 HashSet (java.util.HashSet)2