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));
}
}
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;
}
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);
}
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;
}
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;
}
Aggregations