Skip to content

Commit

Permalink
Handle changes in FREX events
Browse files Browse the repository at this point in the history
  • Loading branch information
grondag committed Nov 25, 2020
1 parent 6b57da6 commit 6d697cc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/main/java/grondag/canvas/compat/BborHolder.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class BborHolder {
}

@SuppressWarnings("resource")
static void render(WorldRenderContext ctx) {
static void render(WorldRenderContext.FrustumContext ctx) {
bborHandler.render(ctx.matrixStack(), ctx.tickDelta(), MinecraftClient.getInstance().player);
}

Expand Down
31 changes: 21 additions & 10 deletions src/main/java/grondag/canvas/render/CanvasWorldRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -658,18 +658,29 @@ public void renderWorld(MatrixStack matrixStack, float tickDelta, long limitTime
assert matrixStack.isEmpty() : "Matrix stack not empty in world render when expected";

profiler.pop();

profiler.swap("outline");
final HitResult hitResult = mc.crosshairTarget;
eventContext.setHitResult(hitResult);
WorldRenderEvents.BEFORE_BLOCK_OUTLINE.invoker().beforeBlockOutline(eventContext);

if (eventContext.didCancelDefaultBlockOutline()) {
eventContext.resetDefaultBlockOutline();
} else {
if (blockOutlines && hitResult != null && hitResult.getType() == HitResult.Type.BLOCK) {
final BlockPos blockOutlinePos = ((BlockHitResult) hitResult).getBlockPos();
final BlockState blockOutlineState = world.getBlockState(blockOutlinePos);

if (blockOutlines && hitResult != null && hitResult.getType() == HitResult.Type.BLOCK) {
profiler.swap("outline");
final BlockPos blockPos4 = ((BlockHitResult) hitResult).getBlockPos();
final BlockState blockState = world.getBlockState(blockPos4);
if (!blockOutlineState.isAir() && world.getWorldBorder().contains(blockOutlinePos)) {
// THIS IS WHEN LIGHTENING RENDERS IN VANILLA
final VertexConsumer blockOutlineConumer = immediate.getBuffer(RenderLayer.getLines());

if (!blockState.isAir() && world.getWorldBorder().contains(blockPos4)) {
// THIS IS WHEN LIGHTENING RENDERS IN VANILLA
final VertexConsumer vertexConsumer3 = immediate.getBuffer(RenderLayer.getLines());
wr.canvas_drawBlockOutline(matrixStack, vertexConsumer3, camera.getFocusedEntity(), cameraX, cameraY, cameraZ, blockPos4, blockState);
eventContext.prepareBlockOutline(blockOutlineConumer, camera.getFocusedEntity(), cameraX, cameraY, cameraZ, blockOutlinePos, blockOutlineState);
WorldRenderEvents.BLOCK_OUTLINE.invoker().onBlockOutline(eventContext);

if (!eventContext.didCancelDefaultBlockOutline()) {
wr.canvas_drawBlockOutline(matrixStack, blockOutlineConumer, camera.getFocusedEntity(), cameraX, cameraY, cameraZ, blockOutlinePos, blockOutlineState);
}
}
}
}

Expand Down Expand Up @@ -1126,7 +1137,7 @@ public void scheduleRegionRender(int x, int y, int z, boolean urgent) {
@Override
public void render(MatrixStack matrices, float tickDelta, long limitTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f matrix4f) {
wr.canvas_mc().getProfiler().swap("dynamic_lighting");
eventContext.prepare(this, matrices, tickDelta, limitTime, renderBlockOutline, camera, gameRenderer, lightmapTextureManager, matrix4f, worldRenderImmediate, wr.canvas_mc().getProfiler(), wr.canvas_transparencyShader() != null);
eventContext.prepare(this, matrices, tickDelta, limitTime, renderBlockOutline, camera, gameRenderer, lightmapTextureManager, matrix4f, worldRenderImmediate, wr.canvas_mc().getProfiler(), wr.canvas_transparencyShader() != null, world);
WorldRenderEvents.START.invoker().onStart(eventContext);
renderWorld(matrices, tickDelta, limitTime, renderBlockOutline, camera, gameRenderer, lightmapTextureManager, matrix4f);
WorldRenderEvents.END.invoker().onEnd(eventContext);
Expand Down

0 comments on commit 6d697cc

Please sign in to comment.