Skip to content

Commit d64378b

Browse files
committed
Fixed experimental screen batching on NeoForge and (Lex)Forge
1 parent 43d8c6a commit d64378b

File tree

7 files changed

+98
-5
lines changed

7 files changed

+98
-5
lines changed

common/src/main/resources/immediatelyfast-common.mixins.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
"map_atlas_generation.MixinMapRenderState",
3232
"map_atlas_generation.MixinMapTextureManager",
3333
"map_atlas_generation.MixinMapTextureManager_MapTexture",
34-
"screen_batching.MixinGameRenderer",
3534
"screen_batching.MixinHandledScreen",
3635
"screen_batching.compat.MixinChatScreen",
3736
"sign_text_buffering.MixinAbstractSignBlockEntityRenderer",

common/src/main/java/net/raphimc/immediatelyfast/injection/mixins/screen_batching/MixinGameRenderer.java renamed to fabric/src/main/java/net/raphimc/immediatelyfast/fabric/injection/mixins/screen_batching/MixinGameRenderer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* You should have received a copy of the GNU General Public License
1616
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
*/
18-
package net.raphimc.immediatelyfast.injection.mixins.screen_batching;
18+
package net.raphimc.immediatelyfast.fabric.injection.mixins.screen_batching;
1919

2020
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
2121
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;

fabric/src/main/resources/immediatelyfast-fabric.mixins.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"compatibilityLevel": "JAVA_21",
66
"plugin": "net.raphimc.immediatelyfast.injection.ImmediatelyFastMixinPlugin",
77
"client": [
8-
"hud_batching.compat.appleskin.MixinAppleSkin_HUDOverlayHandler"
8+
"hud_batching.compat.appleskin.MixinAppleSkin_HUDOverlayHandler",
9+
"screen_batching.MixinGameRenderer"
910
],
1011
"injectors": {
1112
"defaultRequire": 1
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* This file is part of ImmediatelyFast - https://github.com/RaphiMC/ImmediatelyFast
3+
* Copyright (C) 2023-2025 RK_01/RaphiMC and contributors
4+
*
5+
* This program is free software; you can redistribute it and/or
6+
* modify it under the terms of the GNU Lesser General Public
7+
* License as published by the Free Software Foundation; either
8+
* version 3 of the License, or (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
package net.raphimc.immediatelyfast.forge.injection.mixins.screen_batching;
19+
20+
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
21+
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
22+
import net.minecraft.client.gui.DrawContext;
23+
import net.minecraft.client.gui.screen.ChatScreen;
24+
import net.minecraft.client.gui.screen.Screen;
25+
import net.minecraftforge.client.ForgeHooksClient;
26+
import net.raphimc.immediatelyfast.ImmediatelyFast;
27+
import net.raphimc.immediatelyfast.feature.batching.BatchingBuffers;
28+
import org.spongepowered.asm.mixin.Mixin;
29+
import org.spongepowered.asm.mixin.injection.At;
30+
31+
@SuppressWarnings("UnstableApiUsage")
32+
@Mixin(ForgeHooksClient.class)
33+
public abstract class MixinForgeHooksClient {
34+
35+
@WrapOperation(method = "drawScreen", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/client/ForgeHooksClient;drawScreenInternal(Lnet/minecraft/client/gui/screen/Screen;Lnet/minecraft/client/gui/DrawContext;IIF)V"))
36+
private static void screenBatching(Screen screen, DrawContext guiGraphics, int mouseX, int mouseY, float partialTick, Operation<Void> original) {
37+
final boolean batchScreen = screen instanceof ChatScreen;
38+
39+
if (ImmediatelyFast.runtimeConfig.experimental_screen_batching && batchScreen) {
40+
BatchingBuffers.runBatched(guiGraphics, () -> original.call(screen, guiGraphics, mouseX, mouseY, partialTick));
41+
} else {
42+
original.call(screen, guiGraphics, mouseX, mouseY, partialTick);
43+
}
44+
}
45+
46+
}

forge/src/main/resources/immediatelyfast-forge.mixins.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"compatibilityLevel": "JAVA_17",
66
"plugin": "net.raphimc.immediatelyfast.injection.ImmediatelyFastMixinPlugin",
77
"client": [
8-
"core.MixinForgeRenderTypes"
8+
"core.MixinForgeRenderTypes",
9+
"screen_batching.MixinForgeHooksClient"
910
],
1011
"injectors": {
1112
"defaultRequire": 1
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* This file is part of ImmediatelyFast - https://github.com/RaphiMC/ImmediatelyFast
3+
* Copyright (C) 2023-2025 RK_01/RaphiMC and contributors
4+
*
5+
* This program is free software; you can redistribute it and/or
6+
* modify it under the terms of the GNU Lesser General Public
7+
* License as published by the Free Software Foundation; either
8+
* version 3 of the License, or (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
package net.raphimc.immediatelyfast.neoforge.injection.mixins.screen_batching;
19+
20+
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
21+
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
22+
import net.minecraft.client.gui.DrawContext;
23+
import net.minecraft.client.gui.screen.ChatScreen;
24+
import net.minecraft.client.gui.screen.Screen;
25+
import net.neoforged.neoforge.client.ClientHooks;
26+
import net.raphimc.immediatelyfast.ImmediatelyFast;
27+
import net.raphimc.immediatelyfast.feature.batching.BatchingBuffers;
28+
import org.spongepowered.asm.mixin.Mixin;
29+
import org.spongepowered.asm.mixin.injection.At;
30+
31+
@Mixin(ClientHooks.class)
32+
public abstract class MixinClientHooks {
33+
34+
@WrapOperation(method = {"drawScreen", "lambda$drawScreen$1"}, at = @At(value = "INVOKE", target = "Lnet/neoforged/neoforge/client/ClientHooks;drawScreenInternal(Lnet/minecraft/client/gui/screen/Screen;Lnet/minecraft/client/gui/DrawContext;IIF)V"))
35+
private static void screenBatching(Screen screen, DrawContext guiGraphics, int mouseX, int mouseY, float partialTick, Operation<Void> original) {
36+
final boolean batchScreen = screen instanceof ChatScreen;
37+
38+
if (ImmediatelyFast.runtimeConfig.experimental_screen_batching && batchScreen) {
39+
BatchingBuffers.runBatched(guiGraphics, () -> original.call(screen, guiGraphics, mouseX, mouseY, partialTick));
40+
} else {
41+
original.call(screen, guiGraphics, mouseX, mouseY, partialTick);
42+
}
43+
}
44+
45+
}

neoforge/src/main/resources/immediatelyfast-neoforge.mixins.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"client": [
88
"core.MixinNeoForgeRenderTypes",
99
"hud_batching.MixinGuiLayerManager",
10-
"hud_batching.compat.appleskin.MixinAppleSkin_HUDOverlayHandler"
10+
"hud_batching.compat.appleskin.MixinAppleSkin_HUDOverlayHandler",
11+
"screen_batching.MixinClientHooks"
1112
],
1213
"injectors": {
1314
"defaultRequire": 1

0 commit comments

Comments
 (0)