diff --git a/.gitignore b/.gitignore index 3c37caf..d5f737e 100644 --- a/.gitignore +++ b/.gitignore @@ -113,6 +113,7 @@ gradle-app.setting # Common working directory run/ +runs/ # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) !gradle-wrapper.jar diff --git a/build.gradle b/build.gradle index 3d825b4..04c0f44 100644 --- a/build.gradle +++ b/build.gradle @@ -15,7 +15,7 @@ apply plugin: 'net.minecraftforge.gradle' apply plugin: 'org.spongepowered.mixin' group = 'com.buuz135' -version = '1.20.1-1.2.2' +version = '1.20.1-1.2.3' java { diff --git a/src/main/java/com/buuz135/darkmodeeverywhere/mixins/FontMixin.java b/src/main/java/com/buuz135/darkmodeeverywhere/mixins/FontMixin.java index 03b7c3f..eb28695 100644 --- a/src/main/java/com/buuz135/darkmodeeverywhere/mixins/FontMixin.java +++ b/src/main/java/com/buuz135/darkmodeeverywhere/mixins/FontMixin.java @@ -2,33 +2,33 @@ import com.buuz135.darkmodeeverywhere.ClientProxy; import com.buuz135.darkmodeeverywhere.ShaderConfig; +import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; import net.minecraft.util.FastColor; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyArg; - +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(Font.class) public class FontMixin { - @ModifyArg(method = "drawInternal(Lnet/minecraft/util/FormattedCharSequence;FFIZLorg/joml/Matrix4f;Lnet/minecraft/client/renderer/MultiBufferSource;Lnet/minecraft/client/gui/Font$DisplayMode;II)I", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/Font;adjustColor(I)I"), index = 0) - public int drawInternalA(int color) { - return modifyColor(color); - } - - private int modifyColor(int color){ - if (color == 0) return color; + @Inject(method = "adjustColor", at = @At(value = "HEAD", target = "Lnet/minecraft/client/gui/Font;adjustColor(I)I"), cancellable = true) + private static void adjustColorA(int color, CallbackInfoReturnable cir) { if (ClientProxy.SELECTED_SHADER_VALUE != null && Minecraft.getInstance().screen != null) { int threshold = 65; ShaderConfig.ShaderValue shaderValue = ClientProxy.SELECTED_SHADER_VALUE; - if (shaderValue.darkColorReplacement == -1) return color; - if (FastColor.ARGB32.red(color) < threshold && FastColor.ARGB32.green(color) < threshold && FastColor.ARGB32.blue(color) < threshold){ - return shaderValue.darkColorReplacement; + if (shaderValue.darkColorReplacement == -1) return; + if (ChatFormatting.GRAY.getColor().equals(color) || ChatFormatting.DARK_GRAY.getColor().equals(color)) { + cir.setReturnValue(0xFF000000 | shaderValue.darkColorReplacement); + return; + } + if (FastColor.ARGB32.red(color) < threshold && FastColor.ARGB32.green(color) < threshold && FastColor.ARGB32.blue(color) < threshold){ + cir.setReturnValue(0xFF000000 | shaderValue.darkColorReplacement); + return; } } - return color; } }