Fix screen api passing wrong MatrixStack to render events (#3061)

This commit is contained in:
Xander 2023-05-14 14:55:35 +01:00 committed by GitHub
parent a37e8e70b7
commit 3bd4ab0f82
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -42,17 +42,17 @@ abstract class GameRendererMixin {
private Screen renderingScreen;
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;renderWithTooltip(Lnet/minecraft/client/util/math/MatrixStack;IIF)V"), locals = LocalCapture.CAPTURE_FAILEXCEPTION)
private void onBeforeRenderScreen(float tickDelta, long startTime, boolean tick, CallbackInfo ci, int mouseX, int mouseY, MatrixStack matrices) {
private void onBeforeRenderScreen(float tickDelta, long startTime, boolean tick, CallbackInfo ci, int mouseX, int mouseY, MatrixStack worldStack, MatrixStack screenStack) {
// Store the screen in a variable in case someone tries to change the screen during this before render event.
// If someone changes the screen, the after render event will likely have class cast exceptions or an NPE.
this.renderingScreen = this.client.currentScreen;
ScreenEvents.beforeRender(this.renderingScreen).invoker().beforeRender(this.renderingScreen, matrices, mouseX, mouseY, tickDelta);
ScreenEvents.beforeRender(this.renderingScreen).invoker().beforeRender(this.renderingScreen, screenStack, mouseX, mouseY, tickDelta);
}
// This injection should end up in the try block so exceptions are caught
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;renderWithTooltip(Lnet/minecraft/client/util/math/MatrixStack;IIF)V", shift = At.Shift.AFTER), locals = LocalCapture.CAPTURE_FAILEXCEPTION)
private void onAfterRenderScreen(float tickDelta, long startTime, boolean tick, CallbackInfo ci, int mouseX, int mouseY, MatrixStack matrices) {
ScreenEvents.afterRender(this.renderingScreen).invoker().afterRender(this.renderingScreen, matrices, mouseX, mouseY, tickDelta);
private void onAfterRenderScreen(float tickDelta, long startTime, boolean tick, CallbackInfo ci, int mouseX, int mouseY, MatrixStack worldStack, MatrixStack screenStack) {
ScreenEvents.afterRender(this.renderingScreen).invoker().afterRender(this.renderingScreen, screenStack, mouseX, mouseY, tickDelta);
// Finally set the currently rendering screen to null
this.renderingScreen = null;
}