Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AFTER_SETUP event not being able to render #4219

Merged
merged 8 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
* <p>The order of events each frame is as follows:
* <ul><li>START
* <li>AFTER_SETUP
* <li>BEFORE_TERRAIN
* <li>BEFORE_ENTITIES
* <li>AFTER_ENTITIES
* <li>BEFORE_BLOCK_OUTLINE
Expand Down Expand Up @@ -68,13 +69,26 @@ private WorldRenderEvents() { }
* identified and rebuilt but before chunks are uploaded to GPU.
*
* <p>Use for setup of state that depends on view frustum.
*
* <b>Can NOT be used to render anything after MC 1.21.2 due to a glClear call, use {@link WorldRenderEvents#BEFORE_TERRAIN} instead.
JustRed23 marked this conversation as resolved.
Show resolved Hide resolved
*/
public static final Event<AfterSetup> AFTER_SETUP = EventFactory.createArrayBacked(AfterSetup.class, context -> { }, callbacks -> context -> {
for (final AfterSetup callback : callbacks) {
callback.afterSetup(context);
}
});

/**
* Called before the terrain layers are output to the framebuffer, but after the terrain shader fog has been set up.
*
* <p>Use to render before the terrain is drawn.
*/
public static final Event<BeforeTerrain> BEFORE_TERRAIN = EventFactory.createArrayBacked(BeforeTerrain.class, context -> { }, callbacks -> context -> {
for (final BeforeTerrain callback : callbacks) {
callback.beforeTerrain(context);
}
});

/**
* Called after the Solid, Cutout and Cutout Mipped terrain layers have been output to the framebuffer.
*
Expand Down Expand Up @@ -263,6 +277,11 @@ public interface AfterSetup {
void afterSetup(WorldRenderContext context);
}

@FunctionalInterface
public interface BeforeTerrain {
void beforeTerrain(WorldRenderContext context);
}

@FunctionalInterface
public interface BeforeEntities {
void beforeEntities(WorldRenderContext context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,19 @@ private void afterTerrainSetup(Camera camera, Frustum frustum, boolean hasForced
WorldRenderEvents.AFTER_SETUP.invoker().afterSetup(context);
}

@Inject(
method = "method_62214",
at = @At(
value = "INVOKE",
JustRed23 marked this conversation as resolved.
Show resolved Hide resolved
target = "Lnet/minecraft/util/profiler/Profiler;push(Ljava/lang/String;)V",
ordinal = 0,
shift = Shift.AFTER
)
)
JustRed23 marked this conversation as resolved.
Show resolved Hide resolved
private void beforeTerrainSolid(CallbackInfo ci) {
WorldRenderEvents.BEFORE_TERRAIN.invoker().beforeTerrain(context);
}

@Inject(
method = "method_62214",
at = @At(
Expand Down