Search in sources :

Example 11 with MatrixStack

use of net.minecraft.client.util.math.MatrixStack in project BleachHack by BleachDrinker420.

the class BlockHighlight method onWorldRender.

@BleachSubscribe
public void onWorldRender(EventWorldRender.Post event) {
    int mode = getSetting(0).asMode().getMode();
    if (!(mc.crosshairTarget instanceof BlockHitResult))
        return;
    BlockPos pos = ((BlockHitResult) mc.crosshairTarget).getBlockPos();
    BlockState state = mc.world.getBlockState(pos);
    if (state.getMaterial() == Material.AIR || !mc.world.getWorldBorder().contains(pos))
        return;
    int[] color = this.getSetting(4).asColor().getRGBArray();
    if (mode == 0) {
        shader.prepare();
        shader.clearFramebuffer("main");
        Vec3d offset = state.getModelOffset(mc.world, pos);
        MatrixStack matrices = Renderer.matrixFrom(pos.getX() + offset.x, pos.getY() + offset.y, pos.getZ() + offset.z);
        BlockEntity be = mc.world.getBlockEntity(pos);
        BlockEntityRenderer<BlockEntity> renderer = be != null ? mc.getBlockEntityRenderDispatcher().get(be) : null;
        if (renderer != null) {
            renderer.render(be, mc.getTickDelta(), matrices, colorVertexer.createSingleProvider(mc.getBufferBuilders().getEntityVertexConsumers(), color[0], color[1], color[2], getSetting(1).asSlider().getValueInt()), LightmapTextureManager.MAX_LIGHT_COORDINATE, OverlayTexture.DEFAULT_UV);
        } else {
            mc.getBlockRenderManager().getModelRenderer().renderFlat(mc.world, mc.getBlockRenderManager().getModel(state), state, pos, matrices, colorVertexer.createSingleProvider(mc.getBufferBuilders().getEntityVertexConsumers(), color[0], color[1], color[2], getSetting(1).asSlider().getValueInt()).getBuffer(RenderLayers.getMovingBlockLayer(state)), false, new Random(), 0L, OverlayTexture.DEFAULT_UV);
        }
        colorVertexer.draw();
        shader.render();
        shader.drawFramebufferToMain("main");
    } else {
        Box box = state.getOutlineShape(mc.world, pos).getBoundingBox().offset(pos);
        float width = getSetting(2).asSlider().getValueFloat();
        int fill = getSetting(3).asSlider().getValueInt();
        if (width != 0)
            Renderer.drawBoxOutline(box, QuadColor.single(color[0], color[1], color[2], 255), width);
        if (fill != 0)
            Renderer.drawBoxFill(box, QuadColor.single(color[0], color[1], color[2], fill));
    }
}
Also used : BlockState(net.minecraft.block.BlockState) Random(java.util.Random) MatrixStack(net.minecraft.client.util.math.MatrixStack) BlockPos(net.minecraft.util.math.BlockPos) Box(net.minecraft.util.math.Box) BlockHitResult(net.minecraft.util.hit.BlockHitResult) Vec3d(net.minecraft.util.math.Vec3d) BlockEntity(net.minecraft.block.entity.BlockEntity) BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe)

Example 12 with MatrixStack

use of net.minecraft.client.util.math.MatrixStack in project BleachHack by BleachDrinker420.

the class MixinChunkRebuildTask method newRender.

private Set<BlockEntity> newRender(float cameraX, float cameraY, float cameraZ, ChunkData data, BlockBufferBuilderStorage buffers) {
    BlockPos blockPos = field_20839.getOrigin().toImmutable();
    BlockPos blockPos2 = blockPos.add(15, 15, 15);
    ChunkOcclusionDataBuilder chunkOcclusionDataBuilder = new ChunkOcclusionDataBuilder();
    Set<BlockEntity> set = new HashSet<>();
    ChunkRendererRegion chunkRendererRegion = this.region;
    this.region = null;
    MatrixStack matrixStack = new MatrixStack();
    if (chunkRendererRegion != null) {
        BlockModelRenderer.enableBrightnessCache();
        Random random = new Random();
        BlockRenderManager blockRenderManager = MinecraftClient.getInstance().getBlockRenderManager();
        for (BlockPos blockPos3 : BlockPos.iterate(blockPos, blockPos2)) {
            BlockState blockState = chunkRendererRegion.getBlockState(blockPos3);
            if (blockState.isOpaqueFullCube(chunkRendererRegion, blockPos3)) {
                chunkOcclusionDataBuilder.markClosed(blockPos3);
            }
            if (blockState.hasBlockEntity()) {
                BlockEntity blockEntityx = chunkRendererRegion.getBlockEntity(blockPos3, WorldChunk.CreationType.CHECK);
                if (blockEntityx != null) {
                    this.addBlockEntity(data, set, blockEntityx);
                }
            }
            FluidState fluid = chunkRendererRegion.getFluidState(blockPos3);
            if (!fluid.isEmpty()) {
                RenderLayer renderLayer = RenderLayers.getFluidLayer(fluid);
                BufferBuilder bufferBuilder = buffers.get(renderLayer);
                if (data.initializedLayers.add(renderLayer)) {
                    bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR_TEXTURE_LIGHT_NORMAL);
                }
                EventRenderFluid event = new EventRenderFluid(fluid, blockPos3, bufferBuilder);
                BleachHack.eventBus.post(event);
                if (event.isCancelled())
                    continue;
                if (blockRenderManager.renderFluid(blockPos3, chunkRendererRegion, bufferBuilder, fluid)) {
                    data.empty = false;
                    data.nonEmptyLayers.add(renderLayer);
                }
            }
            if (blockState.getRenderType() != BlockRenderType.INVISIBLE) {
                RenderLayer renderLayer = RenderLayers.getBlockLayer(blockState);
                BufferBuilder bufferBuilder = buffers.get(renderLayer);
                if (data.initializedLayers.add(renderLayer)) {
                    bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR_TEXTURE_LIGHT_NORMAL);
                }
                EventRenderBlock.Tesselate event = new EventRenderBlock.Tesselate(blockState, blockPos3, matrixStack, bufferBuilder);
                BleachHack.eventBus.post(event);
                if (event.isCancelled())
                    continue;
                matrixStack.push();
                matrixStack.translate(blockPos3.getX() & 15, blockPos3.getY() & 15, blockPos3.getZ() & 15);
                if (blockRenderManager.renderBlock(blockState, blockPos3, chunkRendererRegion, matrixStack, bufferBuilder, true, random)) {
                    data.empty = false;
                    data.nonEmptyLayers.add(renderLayer);
                }
                bufferBuilder.unfixColor();
                matrixStack.pop();
            }
        }
        if (data.nonEmptyLayers.contains(RenderLayer.getTranslucent())) {
            BufferBuilder bufferBuilder2 = buffers.get(RenderLayer.getTranslucent());
            bufferBuilder2.setCameraPosition(cameraX - (float) blockPos.getX(), cameraY - (float) blockPos.getY(), cameraZ - (float) blockPos.getZ());
            data.bufferState = bufferBuilder2.popState();
        }
        Stream<RenderLayer> var10000 = data.initializedLayers.stream();
        Objects.requireNonNull(buffers);
        var10000.map(buffers::get).forEach(BufferBuilder::end);
        BlockModelRenderer.disableBrightnessCache();
    }
    data.occlusionGraph = chunkOcclusionDataBuilder.build();
    return set;
}
Also used : ChunkRendererRegion(net.minecraft.client.render.chunk.ChunkRendererRegion) MatrixStack(net.minecraft.client.util.math.MatrixStack) BufferBuilder(net.minecraft.client.render.BufferBuilder) RenderLayer(net.minecraft.client.render.RenderLayer) ChunkOcclusionDataBuilder(net.minecraft.client.render.chunk.ChunkOcclusionDataBuilder) BlockState(net.minecraft.block.BlockState) Random(java.util.Random) BlockRenderManager(net.minecraft.client.render.block.BlockRenderManager) EventRenderBlock(org.bleachhack.event.events.EventRenderBlock) EventRenderFluid(org.bleachhack.event.events.EventRenderFluid) BlockPos(net.minecraft.util.math.BlockPos) BlockEntity(net.minecraft.block.entity.BlockEntity) HashSet(java.util.HashSet) FluidState(net.minecraft.fluid.FluidState)

Example 13 with MatrixStack

use of net.minecraft.client.util.math.MatrixStack in project EdenClient by HahaOO7.

the class TracerRenderer method render.

private void render(MatrixStack matrixStack, VertexConsumerProvider.Immediate vertexConsumerProvider, float delta) {
    RenderSystem.setShader(GameRenderer::getPositionShader);
    RenderSystem.disableDepthTest();
    Matrix4f matrix = matrixStack.peek().getPositionMatrix();
    Vec3d start = RenderUtils.getCameraPos().add(PlayerUtils.getClientLookVec());
    BufferBuilder bb = Tessellator.getInstance().getBuffer();
    bb.begin(VertexFormat.DrawMode.DEBUG_LINES, VertexFormats.POSITION);
    tracers.values().forEach(s -> s.forEach(target -> {
        bb.vertex(matrix, (float) target.x, (float) target.y, (float) target.z).next();
        bb.vertex(matrix, (float) start.x, (float) start.y, (float) start.z).next();
    }));
    bb.end();
    RenderSystem.setShaderColor(1, 1, 1, 1);
    BufferRenderer.draw(bb);
}
Also used : Matrix4f(net.minecraft.util.math.Matrix4f) net.minecraft.client.render(net.minecraft.client.render) MatrixStack(net.minecraft.client.util.math.MatrixStack) Set(java.util.Set) GameRenderCallback(at.haha007.edenclient.callbacks.GameRenderCallback) RenderUtils(at.haha007.edenclient.utils.RenderUtils) HashSet(java.util.HashSet) Vec3d(net.minecraft.util.math.Vec3d) TreeMap(java.util.TreeMap) PlayerTickCallback(at.haha007.edenclient.callbacks.PlayerTickCallback) RenderSystem(com.mojang.blaze3d.systems.RenderSystem) LeaveWorldCallback(at.haha007.edenclient.callbacks.LeaveWorldCallback) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity) PlayerUtils(at.haha007.edenclient.utils.PlayerUtils) Matrix4f(net.minecraft.util.math.Matrix4f) Vec3d(net.minecraft.util.math.Vec3d)

Example 14 with MatrixStack

use of net.minecraft.client.util.math.MatrixStack in project meteor-client by MeteorDevelopment.

the class VanillaTextRenderer method end.

@Override
public void end(MatrixStack matrices) {
    if (!building)
        throw new RuntimeException("VanillaTextRenderer.end() called without calling begin()");
    MatrixStack matrixStack = RenderSystem.getModelViewStack();
    RenderSystem.disableDepthTest();
    matrixStack.push();
    if (matrices != null)
        matrixStack.multiplyPositionMatrix(matrices.peek().getPositionMatrix());
    matrixStack.scale((float) scale, (float) scale, 1);
    RenderSystem.applyModelViewMatrix();
    immediate.draw();
    matrixStack.pop();
    RenderSystem.enableDepthTest();
    RenderSystem.applyModelViewMatrix();
    // Vanilla font is twice as small as our custom font (vanilla = 9, custom = 18)
    this.scale = 1.74;
    this.building = false;
}
Also used : MatrixStack(net.minecraft.client.util.math.MatrixStack)

Example 15 with MatrixStack

use of net.minecraft.client.util.math.MatrixStack in project meteor-client by MeteorDevelopment.

the class Mesh method beginRender.

public void beginRender(MatrixStack matrices) {
    GL.saveState();
    if (depthTest)
        GL.enableDepth();
    else
        GL.disableDepth();
    GL.enableBlend();
    GL.disableCull();
    GL.enableLineSmooth();
    if (rendering3D) {
        MatrixStack matrixStack = RenderSystem.getModelViewStack();
        matrixStack.push();
        if (matrices != null)
            matrixStack.multiplyPositionMatrix(matrices.peek().getPositionMatrix());
        Vec3d cameraPos = mc.gameRenderer.getCamera().getPos();
        matrixStack.translate(0, -cameraPos.y, 0);
    }
    beganRendering = true;
}
Also used : MatrixStack(net.minecraft.client.util.math.MatrixStack) Vec3d(net.minecraft.util.math.Vec3d)

Aggregations

MatrixStack (net.minecraft.client.util.math.MatrixStack)83 BufferBuilder (net.minecraft.client.render.BufferBuilder)14 GameRenderer (net.minecraft.client.render.GameRenderer)12 Tessellator (net.minecraft.client.render.Tessellator)12 Camera (net.minecraft.client.render.Camera)11 VertexConsumerProvider (net.minecraft.client.render.VertexConsumerProvider)10 MinecraftClient (net.minecraft.client.MinecraftClient)8 BlockPos (net.minecraft.util.math.BlockPos)8 ItemStack (net.minecraft.item.ItemStack)7 Vec3d (net.minecraft.util.math.Vec3d)7 Color (java.awt.Color)6 Random (java.util.Random)6 BlockState (net.minecraft.block.BlockState)6 Identifier (net.minecraft.util.Identifier)6 Matrix4f (net.minecraft.util.math.Matrix4f)6 BlockEntity (net.minecraft.block.entity.BlockEntity)5 LiteralText (net.minecraft.text.LiteralText)5 Box (net.minecraft.util.math.Box)5 Inject (org.spongepowered.asm.mixin.injection.Inject)5 PlayerEntity (net.minecraft.entity.player.PlayerEntity)4