Fix some ScreenEvents not being called after resizing the window.

1.19.4 specific issue, fixes 
This commit is contained in:
modmuss50 2023-03-07 16:07:37 +00:00
parent 4626a20621
commit 8c25edb404
2 changed files with 24 additions and 4 deletions
fabric-screen-api-v1/src/client/java/net/fabricmc/fabric/mixin/screen
gradle.properties

View file

@ -102,6 +102,26 @@ abstract class ScreenMixin implements ScreenExtensions {
@Inject(method = "init(Lnet/minecraft/client/MinecraftClient;II)V", at = @At("HEAD"))
private void beforeInitScreen(MinecraftClient client, int width, int height, CallbackInfo ci) {
beforeInit(client, width, height);
}
@Inject(method = "init(Lnet/minecraft/client/MinecraftClient;II)V", at = @At("TAIL"))
private void afterInitScreen(MinecraftClient client, int width, int height, CallbackInfo ci) {
afterInit(client, width, height);
}
@Inject(method = "resize", at = @At("HEAD"))
private void beforeResizeScreen(MinecraftClient client, int width, int height, CallbackInfo ci) {
beforeInit(client, width, height);
}
@Inject(method = "resize", at = @At("TAIL"))
private void afterResizeScreen(MinecraftClient client, int width, int height, CallbackInfo ci) {
afterInit(client, width, height);
}
@Unique
private void beforeInit(MinecraftClient client, int width, int height) {
// All elements are repopulated on the screen, so we need to reinitialize all events
this.fabricButtons = null;
this.removeEvent = ScreenEventFactory.createRemoveEvent();
@ -132,8 +152,8 @@ abstract class ScreenMixin implements ScreenExtensions {
ScreenEvents.BEFORE_INIT.invoker().beforeInit(client, (Screen) (Object) this, width, height);
}
@Inject(method = "init(Lnet/minecraft/client/MinecraftClient;II)V", at = @At("TAIL"))
private void afterInitScreen(MinecraftClient client, int width, int height, CallbackInfo ci) {
@Unique
private void afterInit(MinecraftClient client, int width, int height) {
ScreenEvents.AFTER_INIT.invoker().afterInit(client, (Screen) (Object) this, width, height);
}

View file

@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx2560M
org.gradle.parallel=true
fabric.loom.multiProjectOptimisation=true
version=0.75.2
version=0.75.3
minecraft_version=1.19.4-pre2
yarn_version=+build.1
loader_version=0.14.14
@ -54,7 +54,7 @@ fabric-rendering-v0-version=1.1.39
fabric-rendering-v1-version=2.0.2
fabric-resource-conditions-api-v1-version=2.3.0
fabric-resource-loader-v0-version=0.10.9
fabric-screen-api-v1-version=1.0.43
fabric-screen-api-v1-version=1.0.44
fabric-screen-handler-api-v1-version=1.3.17
fabric-sound-api-v1-version=1.0.8
fabric-transfer-api-v1-version=3.0.1