Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Add Option to Ignore Chat in Everything Chroma #690

Merged
merged 3 commits into from
Jan 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,17 @@ public String toString() {
@ConfigEditorBoolean
public boolean allChroma = false;

@Expose
@ConfigOption(name = "Ignore Chat", desc = "Prevents Everything Chroma from applying to the chat if you unironically use that feature...")
@ConfigEditorBoolean
public boolean ignoreChat = false;

private void resetChromaSettings() {
SkyHanniMod.getFeature().chroma.chromaSize = 30f;
SkyHanniMod.getFeature().chroma.chromaSpeed = 6f;
SkyHanniMod.getFeature().chroma.chromaSaturation = 0.75f;
SkyHanniMod.getFeature().chroma.allChroma = false;
SkyHanniMod.getFeature().chroma.ignoreChat = false;
SkyHanniMod.getFeature().chroma.chromaDirection = Direction.FORWARD_RIGHT;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.features.chroma.ChromaFontRenderer
import at.hannibal2.skyhanni.mixins.transformers.AccessorFontRenderer
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.shader.ShaderManager
import net.minecraft.client.Minecraft
import net.minecraft.client.renderer.GlStateManager
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo
Expand All @@ -24,6 +25,8 @@ object FontRendererHook {
private var currentDrawState: ChromaFontRenderer? = null
private var previewChroma = false

var cameFromChat = false

/**
* Setups the [ChromaFontRenderer][at.hannibal2.skyhanni.features.chroma.ChromaFontRenderer] for rendering text
* in chroma. This should only be used when you don't have control over the color code a string uses, or it
Expand Down Expand Up @@ -61,6 +64,10 @@ object FontRendererHook {
fun beginChromaRendering(text: String, shadow: Boolean) {
if (!LorenzUtils.inSkyBlock) return
if (!SkyHanniMod.feature.chroma.enabled) return
if (SkyHanniMod.feature.chroma.allChroma && SkyHanniMod.feature.chroma.ignoreChat && cameFromChat) {
endChromaFont()
return
}

if (text == "§fPlease star the mod on GitHub!") {
previewChroma = true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package at.hannibal2.skyhanni.mixins.transformers.gui;

import at.hannibal2.skyhanni.features.chat.ChatPeek;
import at.hannibal2.skyhanni.mixins.hooks.FontRendererHook;
import net.minecraft.client.gui.GuiNewChat;
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;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(GuiNewChat.class)
Expand All @@ -14,4 +16,14 @@ public class MixinGuiNewChat {
public void onIsOpen(CallbackInfoReturnable<Boolean> cir) {
if (ChatPeek.peek()) cir.setReturnValue(true);
}

@Inject(method = "drawChat", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GlStateManager;enableBlend()V", shift = At.Shift.AFTER))
private void setTextRenderIsFromChat(int updateCounter, CallbackInfo ci) {
FontRendererHook.INSTANCE.setCameFromChat(true);
}

@Inject(method = "drawChat", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GlStateManager;disableAlpha()V", shift = At.Shift.BEFORE))
private void setTextRenderIsntFromChat(int updateCounter, CallbackInfo ci) {
FontRendererHook.INSTANCE.setCameFromChat(false);
}
}
Loading