Search in sources :

Example 1 with WorldRendererAccessor

use of mathax.client.mixin.WorldRendererAccessor in project Client by MatHax.

the class EntityShaders method renderOutlines.

public static void renderOutlines(Runnable draw, boolean entities, int width, float fillOpacity, ShapeMode shapeMode) {
    WorldRenderer worldRenderer = mc.worldRenderer;
    WorldRendererAccessor wra = (WorldRendererAccessor) worldRenderer;
    Framebuffer fbo = worldRenderer.getEntityOutlinesFramebuffer();
    if (entities)
        wra.setEntityOutlinesFramebuffer(outlinesFramebuffer);
    else {
        outlinesFramebuffer.clear(false);
        outlinesFramebuffer.beginWrite(false);
    }
    draw.run();
    if (entities)
        wra.setEntityOutlinesFramebuffer(fbo);
    mc.getFramebuffer().beginWrite(false);
    GL.bindTexture(outlinesFramebuffer.getColorAttachment());
    outlinesShader.bind();
    outlinesShader.set("u_Size", mc.getWindow().getFramebufferWidth(), mc.getWindow().getFramebufferHeight());
    outlinesShader.set("u_Texture", 0);
    outlinesShader.set("u_Width", width);
    outlinesShader.set("u_FillOpacity", fillOpacity / 255.0);
    outlinesShader.set("u_ShapeMode", shapeMode.ordinal());
    PostProcessRenderer.render();
}
Also used : WorldRendererAccessor(mathax.client.mixin.WorldRendererAccessor) SimpleFramebuffer(net.minecraft.client.gl.SimpleFramebuffer) Framebuffer(net.minecraft.client.gl.Framebuffer) WorldRenderer(net.minecraft.client.render.WorldRenderer)

Example 2 with WorldRendererAccessor

use of mathax.client.mixin.WorldRendererAccessor in project Client by MatHax.

the class HoleHud method drawBlock.

private void drawBlock(Direction dir, double x, double y) {
    Block block = dir == Direction.DOWN ? Blocks.OBSIDIAN : mc.world.getBlockState(mc.player.getBlockPos().offset(dir)).getBlock();
    if (!safe.get().contains(block))
        return;
    RenderUtils.drawItem(block.asItem().getDefaultStack(), (int) x, (int) y, scale.get(), false);
    if (dir == Direction.DOWN)
        return;
    ((WorldRendererAccessor) mc.worldRenderer).getBlockBreakingInfos().values().forEach(info -> {
        if (info.getPos().equals(mc.player.getBlockPos().offset(dir)))
            renderBreaking(x, y, info.getStage() / 9f);
    });
}
Also used : WorldRendererAccessor(mathax.client.mixin.WorldRendererAccessor) Block(net.minecraft.block.Block)

Example 3 with WorldRendererAccessor

use of mathax.client.mixin.WorldRendererAccessor in project Client by MatHax.

the class BreakIndicators method renderNormal.

private void renderNormal(Render3DEvent event) {
    Map<Integer, BlockBreakingInfo> blocks = ((WorldRendererAccessor) mc.worldRenderer).getBlockBreakingInfos();
    float ownBreakingStage = ((ClientPlayerInteractionManagerAccessor) mc.interactionManager).getBreakingProgress();
    BlockPos ownBreakingPos = ((ClientPlayerInteractionManagerAccessor) mc.interactionManager).getCurrentBreakingBlockPos();
    if (ownBreakingPos != null && mc.interactionManager.isBreakingBlock()) {
        BlockState state = mc.world.getBlockState(ownBreakingPos);
        VoxelShape shape = state.getOutlineShape(mc.world, ownBreakingPos);
        if (shape.isEmpty() || shape == null)
            return;
        Box orig = shape.getBoundingBox();
        Box box = orig;
        double shrinkFactor = 1d - ownBreakingStage;
        double progress = 1d - shrinkFactor;
        renderBlock(event, box, orig, ownBreakingPos, shrinkFactor, progress);
    }
    blocks.values().forEach(info -> {
        BlockPos pos = info.getPos();
        int stage = info.getStage();
        if (pos.equals(ownBreakingPos))
            return;
        BlockState state = mc.world.getBlockState(pos);
        VoxelShape shape = state.getOutlineShape(mc.world, pos);
        if (shape.isEmpty())
            return;
        Box orig = shape.getBoundingBox();
        Box box = orig;
        double shrinkFactor = (9 - (stage + 1)) / 9d;
        double progress = 1d - shrinkFactor;
        renderBlock(event, box, orig, pos, shrinkFactor, progress);
    });
}
Also used : WorldRendererAccessor(mathax.client.mixin.WorldRendererAccessor) ClientPlayerInteractionManagerAccessor(mathax.client.mixin.ClientPlayerInteractionManagerAccessor) BlockState(net.minecraft.block.BlockState) VoxelShape(net.minecraft.util.shape.VoxelShape) BlockBreakingInfo(net.minecraft.client.render.BlockBreakingInfo) BlockPos(net.minecraft.util.math.BlockPos) Box(net.minecraft.util.math.Box)

Example 4 with WorldRendererAccessor

use of mathax.client.mixin.WorldRendererAccessor in project Client by MatHax.

the class EntityShaders method endRender.

public static void endRender() {
    WorldRenderer worldRenderer = mc.worldRenderer;
    WorldRendererAccessor wra = (WorldRendererAccessor) worldRenderer;
    Framebuffer fbo = worldRenderer.getEntityOutlinesFramebuffer();
    // Overlay
    if (chams != null && chams.isShader()) {
        wra.setEntityOutlinesFramebuffer(overlayFramebuffer);
        overlayVertexConsumerProvider.draw();
        wra.setEntityOutlinesFramebuffer(fbo);
        mc.getFramebuffer().beginWrite(false);
        GL.bindTexture(overlayFramebuffer.getColorAttachment());
        overlayShader.bind();
        overlayShader.set("u_Size", mc.getWindow().getFramebufferWidth(), mc.getWindow().getFramebufferHeight());
        overlayShader.set("u_Texture", 0);
        overlayShader.set("u_Time", timer++ / 20.0);
        PostProcessRenderer.render();
    }
    // Outline
    if (esp != null && esp.isShader())
        renderOutlines(outlinesVertexConsumerProvider::draw, true, esp.outlineWidth.get(), esp.fillOpacity.get().floatValue(), esp.shapeMode.get());
}
Also used : WorldRendererAccessor(mathax.client.mixin.WorldRendererAccessor) SimpleFramebuffer(net.minecraft.client.gl.SimpleFramebuffer) Framebuffer(net.minecraft.client.gl.Framebuffer) WorldRenderer(net.minecraft.client.render.WorldRenderer)

Aggregations

WorldRendererAccessor (mathax.client.mixin.WorldRendererAccessor)4 Framebuffer (net.minecraft.client.gl.Framebuffer)2 SimpleFramebuffer (net.minecraft.client.gl.SimpleFramebuffer)2 WorldRenderer (net.minecraft.client.render.WorldRenderer)2 ClientPlayerInteractionManagerAccessor (mathax.client.mixin.ClientPlayerInteractionManagerAccessor)1 Block (net.minecraft.block.Block)1 BlockState (net.minecraft.block.BlockState)1 BlockBreakingInfo (net.minecraft.client.render.BlockBreakingInfo)1 BlockPos (net.minecraft.util.math.BlockPos)1 Box (net.minecraft.util.math.Box)1 VoxelShape (net.minecraft.util.shape.VoxelShape)1