Search in sources :

Example 6 with VertexBuffer

use of net.minecraft.client.gl.VertexBuffer in project EdenClient by HahaOO7.

the class ItemEsp method build.

private void build() {
    wireframeBox = new VertexBuffer();
    Box bb = new Box(-0.25, -0.0, -0.25, 0.25, 0.5, 0.25);
    RenderUtils.drawOutlinedBox(bb, wireframeBox);
    solidBox = new VertexBuffer();
    RenderUtils.drawSolidBox(bb, solidBox);
}
Also used : VertexBuffer(net.minecraft.client.gl.VertexBuffer) Box(net.minecraft.util.math.Box)

Example 7 with VertexBuffer

use of net.minecraft.client.gl.VertexBuffer in project Paradise-Lost by devs-immortal.

the class CloudRendererMixin method internalCloudRender.

private void internalCloudRender(MatrixStack matrices, float tickDelta, double cameraX, double cameraY, double cameraZ, float cloudOffset, float cloudScale, float speedMod) {
    SkyProperties properties = this.world.getSkyProperties();
    float cloudHeight = properties.getCloudsHeight();
    if (!Float.isNaN(cloudHeight)) {
        RenderSystem.disableCull();
        RenderSystem.enableBlend();
        RenderSystem.enableAlphaTest();
        RenderSystem.enableDepthTest();
        RenderSystem.defaultAlphaFunc();
        RenderSystem.blendFuncSeparate(SrcFactor.SRC_ALPHA, DstFactor.ONE_MINUS_SRC_ALPHA, SrcFactor.ONE, DstFactor.ONE_MINUS_SRC_ALPHA);
        RenderSystem.enableFog();
        RenderSystem.depthMask(true);
        double e = ((this.ticks + tickDelta) * (0.03F * speedMod));
        double posX = (cameraX + e) / 12.0D;
        // --- THIS RIGHT HERE IS THE JACKPOT ---
        double renderHeight = cloudHeight - (float) cameraY + cloudOffset;
        double posZ = cameraZ / 12.0D + 0.33000001311302185D;
        posX -= MathHelper.floor(posX / 2048.0D) * 2048;
        posZ -= MathHelper.floor(posZ / 2048.0D) * 2048;
        float adjustedX = (float) (posX - (double) MathHelper.floor(posX));
        float adjustedY = (float) (renderHeight / 4.0D - (double) MathHelper.floor(renderHeight / 4.0D)) * 4.0F;
        float adjustedZ = (float) (posZ - (double) MathHelper.floor(posZ));
        Vec3d cloudColor = this.world.getCloudsColor(tickDelta);
        int floorX = (int) Math.floor(posX);
        int floorY = (int) Math.floor(renderHeight / 4.0D);
        int floorZ = (int) Math.floor(posZ);
        if (floorX != this.lastCloudsBlockX || floorY != this.lastCloudsBlockY || floorZ != this.lastCloudsBlockZ || this.client.options.getCloudRenderMode() != this.lastCloudsRenderMode || this.lastCloudsColor.squaredDistanceTo(cloudColor) > 2.0E-4D) {
            this.lastCloudsBlockX = floorX;
            this.lastCloudsBlockY = floorY;
            this.lastCloudsBlockZ = floorZ;
            this.lastCloudsColor = cloudColor;
            this.lastCloudsRenderMode = this.client.options.getCloudRenderMode();
            this.cloudsDirty = true;
        }
        if (this.cloudsDirty) {
            this.cloudsDirty = false;
            Tessellator tessellator = Tessellator.getInstance();
            BufferBuilder bufferBuilder = tessellator.getBuffer();
            if (this.cloudsBuffer != null)
                this.cloudsBuffer.close();
            this.cloudsBuffer = new VertexBuffer(VertexFormats.POSITION_TEXTURE_COLOR_NORMAL);
            this.renderClouds(bufferBuilder, posX, renderHeight, posZ, cloudColor);
            bufferBuilder.end();
            this.cloudsBuffer.upload(bufferBuilder);
        }
        this.textureManager.bindTexture(CLOUDS);
        matrices.push();
        matrices.scale(12.0F, 1.0F, 12.0F);
        matrices.scale(cloudScale, cloudScale, cloudScale);
        matrices.translate(-adjustedX, adjustedY, -adjustedZ);
        if (this.cloudsBuffer != null) {
            this.cloudsBuffer.bind();
            VertexFormats.POSITION_TEXTURE_COLOR_NORMAL.startDrawing(0L);
            int cloudMainIndex = this.lastCloudsRenderMode == CloudRenderMode.FANCY ? 0 : 1;
            for (byte cloudIndex = 1; cloudMainIndex <= cloudIndex; ++cloudMainIndex) {
                if (cloudMainIndex == 0) {
                    RenderSystem.colorMask(false, false, false, false);
                } else {
                    RenderSystem.colorMask(true, true, true, true);
                }
                VertexBuffer cloudBuffer = this.cloudsBuffer;
                Entry entry = matrices.peek();
                cloudBuffer.draw(entry.getModel(), 7);
            }
            VertexBuffer.unbind();
            VertexFormats.POSITION_TEXTURE_COLOR_NORMAL.endDrawing();
        }
        matrices.pop();
        RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
        RenderSystem.disableAlphaTest();
        RenderSystem.enableCull();
        RenderSystem.disableBlend();
        RenderSystem.disableFog();
    }
}
Also used : Entry(net.minecraft.client.util.math.MatrixStack.Entry) VertexBuffer(net.minecraft.client.gl.VertexBuffer) Vec3d(net.minecraft.util.math.Vec3d)

Example 8 with VertexBuffer

use of net.minecraft.client.gl.VertexBuffer in project custom-stars by b3spectacled.

the class MixinWorldRenderer method reloadStars.

@Inject(method = "renderSky(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/util/math/Matrix4f;FLnet/minecraft/client/render/Camera;ZLjava/lang/Runnable;)V", at = @At("HEAD"))
private void reloadStars(CallbackInfo info) {
    if (CustomStars.STARS_RERENDER_OBSERVER.update()) {
        CustomStars.log(Level.INFO, "Star settings modified, reloading buffer...");
        Tessellator tess = Tessellator.getInstance();
        BufferBuilder builder = tess.getBuffer();
        RenderSystem.setShader(GameRenderer::getPositionShader);
        this.starsBuffer = new VertexBuffer();
        ((MixinWorldRendererInvoker) this).rerenderStars(builder);
        builder.end();
        this.starsBuffer.upload(builder);
    }
}
Also used : Tessellator(net.minecraft.client.render.Tessellator) VertexBuffer(net.minecraft.client.gl.VertexBuffer) BufferBuilder(net.minecraft.client.render.BufferBuilder) GameRenderer(net.minecraft.client.render.GameRenderer) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

VertexBuffer (net.minecraft.client.gl.VertexBuffer)8 Box (net.minecraft.util.math.Box)3 BufferBuilder (net.minecraft.client.render.BufferBuilder)1 GameRenderer (net.minecraft.client.render.GameRenderer)1 Tessellator (net.minecraft.client.render.Tessellator)1 Entry (net.minecraft.client.util.math.MatrixStack.Entry)1 Vec3d (net.minecraft.util.math.Vec3d)1 Inject (org.spongepowered.asm.mixin.injection.Inject)1