generated from NeoForgeMDKs/MDK-1.21-ModDevGradle
-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show a custom message when shaderpack compilation fails
- Loading branch information
Showing
3 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
...c/main/java/dev/ferriarnus/monocle/irisCompatibility/mixin/ClientPacketListenerMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package dev.ferriarnus.monocle.irisCompatibility.mixin; | ||
|
||
import net.irisshaders.iris.Iris; | ||
import net.minecraft.ChatFormatting; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.multiplayer.ClientPacketListener; | ||
import net.minecraft.network.chat.ClickEvent; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.network.chat.HoverEvent; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(ClientPacketListener.class) | ||
public class ClientPacketListenerMixin { | ||
/** | ||
* @author embeddedt | ||
* @reason make sure the message directs users to us, not Iris, as our transformer likely has different behavior | ||
* from theirs | ||
*/ | ||
@Inject(method = "handleLogin", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/protocol/game/ClientboundLoginPacket;enforcesSecureChat()Z")) | ||
private void printMonocleErrorForIrisError(CallbackInfo ci) { | ||
var player = Minecraft.getInstance().player; | ||
|
||
if (player == null) { | ||
return; | ||
} | ||
|
||
// Same logic as Iris' mixin, but run earlier to suppress their logic | ||
Iris.getStoredError().ifPresent(e -> { | ||
player.displayClientMessage(Component.translatable( | ||
"monocle.shader_load_exception" | ||
).append(Component.literal("Copy Info").withStyle(arg -> | ||
arg.withUnderlined(true).withColor(ChatFormatting.BLUE) | ||
.withClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, e.getMessage())) | ||
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.translatable("chat.copy.click"))) | ||
)), false); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"monocle.shader_load_exception": "An internal error was encountered while loading the shaderpack. Please report this to the Monocle team. " | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters