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