Skip to content

Commit 3ea0398

Browse files
committed
Shaders: update block vertex format before resource reload
1 parent 5dd8284 commit 3ea0398

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/main/java/mods/Hileb/optirefine/mixin/defaults/optifine/MixinShaders.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import com.google.common.util.concurrent.ListenableFuture;
55
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
66
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
7+
import mods.Hileb.optirefine.library.cursedmixinextensions.annotations.AccessibleOperation;
8+
import org.objectweb.asm.Opcodes;
79
import net.minecraft.client.Minecraft;
810
import net.minecraftforge.client.resource.SelectiveReloadStateHandler;
911
import net.minecraftforge.client.resource.VanillaResourceType;
@@ -18,7 +20,9 @@ public abstract class MixinShaders {
1820
@WrapOperation(method = "loadShaderPack", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;func_175603_A()Lcom/google/common/util/concurrent/ListenableFuture;"))
1921
private static ListenableFuture<Object> optiRefine$selectiveRefresh(Minecraft mc, Operation<ListenableFuture<Object>> original) {
2022
// SelectiveReloadStateHandler state is read at reload time, so run the reload
21-
// synchronously inside begin/end (async submission would lose the predicate).
23+
// OptiFine updates BLOCK/ITEM before scheduling the resource reload. The Cleanroom
24+
// reload path immediately rebuilds RenderChunk VBOs, so preserve that ordering here.
25+
DefaultVertexFormats_updateVertexFormats();
2226
SelectiveReloadStateHandler.INSTANCE.beginReload(type -> type == VanillaResourceType.TEXTURES || type == VanillaResourceType.MODELS);
2327
try {
2428
mc.refreshResources();
@@ -27,4 +31,8 @@ public abstract class MixinShaders {
2731
}
2832
return Futures.immediateFuture(null);
2933
}
34+
35+
@SuppressWarnings("MissingUnique")
36+
@AccessibleOperation(opcode = Opcodes.INVOKESTATIC, desc = "net.minecraft.client.renderer.vertex.DefaultVertexFormats updateVertexFormats ()V")
37+
private static native void DefaultVertexFormats_updateVertexFormats();
3038
}

0 commit comments

Comments
 (0)