Skip to content

Commit 19e6d05

Browse files
committed
Draw current batch when mods modify the model view matrix
Fixes FTBTeam/FTB-Modpack-Issues#7231
1 parent fe3897e commit 19e6d05

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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.injection.mixins.hud_batching.compat;
19+
20+
import com.mojang.blaze3d.systems.RenderSystem;
21+
import net.raphimc.immediatelyfast.feature.batching.BatchingBuffers;
22+
import org.spongepowered.asm.mixin.Mixin;
23+
import org.spongepowered.asm.mixin.injection.At;
24+
import org.spongepowered.asm.mixin.injection.Inject;
25+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
26+
27+
@Mixin(value = RenderSystem.class, remap = false)
28+
public abstract class MixinRenderSystem {
29+
30+
@Inject(method = "applyModelViewMatrix", at = @At("HEAD"))
31+
private static void checkForModificationWhileBatching(CallbackInfo ci) {
32+
if (BatchingBuffers.isHudBatching()) {
33+
// If some mod tries to modify the model view matrix while we are batching, we should end the current batch and start a new one, so that the result is correct.
34+
BatchingBuffers.tryForceDrawHudBuffers();
35+
}
36+
}
37+
38+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"hud_batching.compat.MixinBufferRenderer",
2626
"hud_batching.compat.MixinDebugHud",
2727
"hud_batching.compat.MixinDrawContext",
28+
"hud_batching.compat.MixinRenderSystem",
2829
"hud_batching.compat.journeymap.MixinJourneyMap_MiniMap",
2930
"hud_batching.consumer.MixinDrawContext",
3031
"map_atlas_generation.MixinMapRenderer",

0 commit comments

Comments
 (0)