Conversation
There was a problem hiding this comment.
Pull request overview
This pull request ports the Shader Reload mod from Minecraft 1.21 to 1.21.10. The changes adapt the mod to significant API changes in Minecraft's shader loading system by replacing multiple mixins with a simpler approach using a custom shader loader.
Changes:
- Updated Minecraft, Fabric Loader, Fabric API, and Gradle versions to support 1.21.10
- Replaced shader loading mixins (GameRendererMixin, WorldRendererMixin, GlProgramManagerMixin) with a new CustomShaderLoader class
- Updated KeyboardMixin to use new input parameter types (KeyInput and CharInput) introduced in Minecraft 1.21.10
- Simplified error handling by removing the custom StopException in favor of an expectError flag
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| gradle.properties | Updated version numbers for Minecraft (1.21.10), Yarn mappings, Fabric Loader (0.18.4), and Fabric API; added Loom version and parallel build flag |
| gradle/wrapper/gradle-wrapper.properties | Updated Gradle from 8.8 to 9.3.0 |
| build.gradle | Changed plugin to fabric-loom-remap, added full Fabric API dependency, added loom mod configuration, added duplicate JavaCompile block |
| settings.gradle | Removed deprecated jcenter repository, added mavenCentral |
| fabric.mod.json | Updated minimum Fabric Loader to 0.18.4 and Minecraft to 1.21.10 |
| shaderreload.mixins.json | Removed GameRendererMixin, KeyboardInvoker, GlProgramManagerMixin, and WorldRendererMixin; added MinecraftClientMixin |
| MinecraftClientMixin.java | New mixin that replaces the ShaderLoader in MinecraftClient constructor with CustomShaderLoader |
| CustomShaderLoader.java | New class extending ShaderLoader to handle shader loading with fallback to default resource pack |
| KeyboardMixin.java | Updated to use new KeyInput and CharInput parameter types; simplified F3+R key handling logic |
| ShaderReload.java | Refactored error handling to use expectError flag instead of StopException; removed shader loading logic now handled by CustomShaderLoader |
| GameRendererMixin.java | Deleted - functionality moved to CustomShaderLoader |
| WorldRendererMixin.java | Deleted - functionality moved to CustomShaderLoader |
| KeyboardInvoker.java | Deleted - no longer needed with new approach |
| GlProgramManagerMixin.java | Deleted - no longer needed with new approach |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| private PostEffectProcessor loadDefaultPostEffect(Identifier id, Set<Identifier> availableExternalTargets) { | ||
| return null; | ||
| } |
There was a problem hiding this comment.
The method loadDefaultPostEffect is declared but only returns null without any implementation. This appears to be called in the exception handler on line 25, which means it will always return null when there's an error loading a post-effect. If this is intentional, the try-catch block on lines 24-28 serves no purpose since loadDefaultPostEffect always returns null. Either implement the method properly or remove the dead code.
| public static void reloadShaders() { | ||
| if (reloading) return; | ||
| var client = MinecraftClient.getInstance(); | ||
| if(reloading) { |
There was a problem hiding this comment.
Inconsistent spacing in the if condition. The opening brace should be on the same line as the if statement to match Java conventions and the style used elsewhere in the file (e.g., line 43).
| if(reloading) { | |
| if (reloading) { |
| if(throwable == null) { | ||
| debugLog(Text.translatable("debug.reload_shaders.message")); | ||
| expectError = false; | ||
| return; | ||
| } | ||
| } | ||
| var translationKey = "debug.reload_shaders.error" + (builtin ? ".builtin" : ""); | ||
| ((KeyboardInvoker) client.keyboard).invokeDebugError(translationKey); | ||
| client.inGameHud.getChatHud().addMessage(Text.literal(throwable.getMessage()).formatted(Formatting.GRAY)); | ||
| } | ||
|
|
||
| // Try loading a core shader; if it fails, stop shader reloading or try loading a built-in core shader. | ||
| public static ShaderProgram onLoadShaders$new(ResourceFactory factory, String name, VertexFormat format) throws IOException { | ||
| try { | ||
| return new ShaderProgram(factory, name, format); | ||
| } catch (IOException e) { | ||
| printShaderException(e, false); | ||
| if (reloading) throw STOP; | ||
| } | ||
| try { | ||
| var defaultPack = MinecraftClient.getInstance().getDefaultResourcePack(); | ||
| return new ShaderProgram(defaultPack.getFactory(), name, format); | ||
| } catch (IOException e) { | ||
| printShaderException(e, true); | ||
| throw e; | ||
| } | ||
| if(throwable instanceof CompletionException ex && ex.getCause() != null) { | ||
| throwable = ex.getCause(); | ||
| } |
There was a problem hiding this comment.
Inconsistent spacing in the if conditions. Opening braces should be on the same line as the if statement to match Java conventions and the style used in the same file (e.g., line 66).
| if(cause != null) { | ||
| throwable = cause; | ||
| } else { |
There was a problem hiding this comment.
Inconsistent spacing in the if condition. Opening braces should be on the same line as the if statement to match Java conventions.
| @Override | ||
| public PostEffectProcessor loadPostEffect(Identifier id, Set<Identifier> availableExternalTargets) { | ||
| PostEffectProcessor result = super.loadPostEffect(id, availableExternalTargets); | ||
| if(result != null) return result; |
There was a problem hiding this comment.
Inconsistent spacing in the if condition. Opening braces should be on the same line as the if statement to match Java conventions.
| if(result != null) return result; | |
| if (result != null) { | |
| return result; | |
| } |
| @Inject(method = "onKey", at = @At(value = "HEAD"), cancellable = true) | ||
| void onOnKey(long window, int action, KeyInput input, CallbackInfo ci) { |
There was a problem hiding this comment.
The window parameter is passed to the method but not used - instead, this.client.getWindow() is used on line 26. The window parameter should either be used instead of this.client.getWindow(), or if this.client.getWindow() is necessary, document why the window parameter is ignored.
| return null; | ||
| } | ||
|
|
||
| private PostEffectProcessor loadDefaultPostEffect(Identifier id, Set<Identifier> availableExternalTargets) { | ||
| return null; |
There was a problem hiding this comment.
The method loadDefaultProgram is declared but never implemented - it only returns null. If this is a placeholder for future implementation, consider adding a TODO comment or throwing an UnsupportedOperationException to make the intent clearer.
| return null; | |
| } | |
| private PostEffectProcessor loadDefaultPostEffect(Identifier id, Set<Identifier> availableExternalTargets) { | |
| return null; | |
| // TODO: Implement loading of default shader program if needed | |
| throw new UnsupportedOperationException("loadDefaultProgram is not yet implemented"); | |
| } | |
| private PostEffectProcessor loadDefaultPostEffect(Identifier id, Set<Identifier> availableExternalTargets) { | |
| // TODO: Implement loading of default post effect if needed | |
| throw new UnsupportedOperationException("loadDefaultPostEffect is not yet implemented"); |
| public class MinecraftClientMixin { | ||
| @Redirect(method = "<init>", at = @At(value = "NEW", target = "Lnet/minecraft/client/gl/ShaderLoader;")) | ||
| ShaderLoader replaceShaderLoader(TextureManager textureManager, Consumer<Exception> onError) { | ||
| ShaderLoader loader = new CustomShaderLoader(textureManager); |
There was a problem hiding this comment.
The onError parameter is declared but never used in the method. The constructor call to CustomShaderLoader only passes textureManager. Either remove the unused parameter from the redirect signature or pass it to the CustomShaderLoader if it should be used.
| ShaderLoader loader = new CustomShaderLoader(textureManager); | |
| ShaderLoader loader = new CustomShaderLoader(textureManager, onError); |
No description provided.