Skip to content

Commit

Permalink
Add option to ignore chat in Everything Chroma
Browse files Browse the repository at this point in the history
  • Loading branch information
VixidDev committed Nov 5, 2023
1 parent f6f7f64 commit 1fe1dd7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,17 @@ public class ChromaConfig {
@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.chromaDirection = 0;
SkyHanniMod.getFeature().chroma.ignoreChat = false;
}
}
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 Expand Up @@ -151,4 +158,4 @@ object FontRendererHook {
}
return false
}
}
}
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);
}
}

0 comments on commit 1fe1dd7

Please sign in to comment.