aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWyvest <45589059+Wyvest@users.noreply.github.com>2022-01-01 17:39:01 +0700
committerWyvest <45589059+Wyvest@users.noreply.github.com>2022-01-01 17:39:01 +0700
commit856df4d08d3c392b35f256966f6263da86fdb7ab (patch)
treedab1e788630985ead522c0a073cfeaeb73ac2571
parent503bbd969e929c42221d835c7f124940648100f2 (diff)
downloadChatting-856df4d08d3c392b35f256966f6263da86fdb7ab.tar.gz
Chatting-856df4d08d3c392b35f256966f6263da86fdb7ab.tar.bz2
Chatting-856df4d08d3c392b35f256966f6263da86fdb7ab.zip
fix text opacity ruining full shadow and fix full shadow with wyvtils
-rw-r--r--build.gradle55
-rw-r--r--src/main/java/com/raeids/stratus/mixin/GuiNewChatMixin.java4
-rw-r--r--src/main/java/com/raeids/stratus/mixin/WyvtilsListenerMixin.java21
-rw-r--r--src/main/kotlin/com/raeids/stratus/gui/ChatShortcutViewGui.kt4
-rw-r--r--src/main/kotlin/com/raeids/stratus/utils/RenderHelper.kt5
-rw-r--r--src/main/resources/mixins.stratus.json3
6 files changed, 53 insertions, 39 deletions
diff --git a/build.gradle b/build.gradle
index 9c45bec..60ab0a8 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,7 +1,7 @@
-//file:noinspection GradlePackageUpdate
plugins {
id "net.minecraftforge.gradle.forge" version "6f53277"
id "com.github.johnrengelman.shadow" version "6.1.0"
+ id 'org.spongepowered.mixin' version "d5f9873"
id 'org.jetbrains.kotlin.jvm' version "1.6.10"
id "net.kyori.blossom" version "1.3.0"
id "java"
@@ -49,19 +49,7 @@ dependencies {
transitive = false
}
compileOnly 'gg.essential:essential-1.8.9-forge:1725'
- compileOnly 'org.spongepowered:mixin:0.8.4'
- annotationProcessor 'org.spongepowered:mixin:0.8.4:processor'
-
- // dependencies for mixin that aren't applied
- annotationProcessor 'com.google.code.gson:gson:2.2.4'
- annotationProcessor 'com.google.guava:guava:21.0'
- annotationProcessor 'org.ow2.asm:asm-tree:6.2'
- annotationProcessor 'org.apache.logging.log4j:log4j-core:2.0-beta9'
-}
-
-ext {
- mixinSrg = new File(project.buildDir, 'tmp/mixins/mixins.srg')
- mixinRefMap = new File(project.buildDir, "tmp/mixins/mixins.${mod_id}.refmap.json")
+ compileOnly annotationProcessor('org.spongepowered:mixin:0.7.11-SNAPSHOT')
}
/**
@@ -99,13 +87,30 @@ jar {
enabled = false
}
+/**
+ * This task simply moves resources so they can be accessed at runtime, Forge is quite weird isn't it
+ */
+task moveResources {
+ doLast {
+ ant.move file: "${buildDir}/resources/main",
+ todir: "${buildDir}/classes/kotlin"
+ }
+}
+
+moveResources.dependsOn processResources
+classes.dependsOn moveResources
+
+mixin {
+ disableRefMapWarning = true
+ defaultObfuscationEnv searge
+ add sourceSets.main, "mixins.${mod_id}.refmap.json"
+}
// This adds support to ("include") libraries into our JAR
shadowJar {
archiveClassifier.set('')
configurations = [project.configurations.include]
duplicatesStrategy DuplicatesStrategy.EXCLUDE
- from files(project.mixinRefMap.canonicalPath)
}
reobf {
@@ -119,22 +124,6 @@ sourceSets {
dummy
main {
compileClasspath += dummy.output
- output.resourcesDir = file("${buildDir}/classes/kotlin/main")
+ ext.refMap = "mixins.${mod_id}.refmap.json"
}
-}
-
-compileJava {
- options.compilerArgs += [
- "-AoutSrgFile=${project.mixinSrg.canonicalPath}",
- "-AoutRefMapFile=${project.mixinRefMap.canonicalPath}",
- "-AreobfSrgFile=${project.file('build/mcp-srg.srg').canonicalPath}"
- ]
-}
-
-task copySrg(type: Copy, dependsOn: 'genSrgs') {
- from { project.tasks.genSrgs.mcpToSrg }
- into 'build'
-}
-compileJava.dependsOn copySrg
-
-reobfJar.addSecondarySrgFile project.mixinSrg
+} \ No newline at end of file
diff --git a/src/main/java/com/raeids/stratus/mixin/GuiNewChatMixin.java b/src/main/java/com/raeids/stratus/mixin/GuiNewChatMixin.java
index e701758..f606d4e 100644
--- a/src/main/java/com/raeids/stratus/mixin/GuiNewChatMixin.java
+++ b/src/main/java/com/raeids/stratus/mixin/GuiNewChatMixin.java
@@ -114,9 +114,9 @@ public abstract class GuiNewChatMixin extends Gui implements GuiNewChatHook {
return ChatSearchingManager.filterMessages(stratus$previousText, drawnChatLines);
}
- @ModifyVariable(method = "drawChat", at = @At("STORE"), slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/util/MathHelper;clamp_double(DDD)D"), to = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/ChatLine;getChatComponent()Lnet/minecraft/util/IChatComponent;")), name = "l1")
+ @ModifyVariable(method = "drawChat", at = @At("STORE"), ordinal = 7)
private int modifyYeah(int value) {
- return stratus$textOpacity = value;
+ return stratus$textOpacity = (int) (((float) (getChatOpen() ? 255 : value)) * (mc.gameSettings.chatOpacity * 0.9F + 0.1F));
}
@Redirect(method = "drawChat", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/FontRenderer;drawStringWithShadow(Ljava/lang/String;FFI)I"))
diff --git a/src/main/java/com/raeids/stratus/mixin/WyvtilsListenerMixin.java b/src/main/java/com/raeids/stratus/mixin/WyvtilsListenerMixin.java
new file mode 100644
index 0000000..768b7c7
--- /dev/null
+++ b/src/main/java/com/raeids/stratus/mixin/WyvtilsListenerMixin.java
@@ -0,0 +1,21 @@
+package com.raeids.stratus.mixin;
+
+import com.raeids.stratus.utils.RenderHelper;
+import org.spongepowered.asm.mixin.Dynamic;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Pseudo;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Coerce;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+
+@Pseudo
+@Mixin(targets = "net.wyvest.wyvtils.core.listener.Listener")
+public class WyvtilsListenerMixin {
+
+ @Dynamic("Wyvtils")
+ @Inject(method = "onStringRendered", at = @At("HEAD"), cancellable = true)
+ private void cancelStringRender(@Coerce Object a, CallbackInfo ci) {
+ if (RenderHelper.INSTANCE.getBypassWyvtils()) ci.cancel();
+ }
+}
diff --git a/src/main/kotlin/com/raeids/stratus/gui/ChatShortcutViewGui.kt b/src/main/kotlin/com/raeids/stratus/gui/ChatShortcutViewGui.kt
index 6efd29c..86989c4 100644
--- a/src/main/kotlin/com/raeids/stratus/gui/ChatShortcutViewGui.kt
+++ b/src/main/kotlin/com/raeids/stratus/gui/ChatShortcutViewGui.kt
@@ -16,10 +16,10 @@ import gg.essential.vigilance.gui.settings.ButtonComponent
class ChatShortcutViewGui : WindowScreen(version = ElementaVersion.V1) {
override fun initScreen(width: Int, height: Int) {
super.initScreen(width, height)
- for ((yes, shortcut) in ChatShortcuts.shortcuts.withIndex()) {
+ for ((index, shortcut) in ChatShortcuts.shortcuts.withIndex()) {
val block = UIBlock(VigilancePalette.getBackground()).constrain {
x = 3.percent()
- y = (yes * 12).percent()
+ y = (index * 12).percent()
this.width = 94.percent()
this.height = 25.pixels()
} childOf this.window
diff --git a/src/main/kotlin/com/raeids/stratus/utils/RenderHelper.kt b/src/main/kotlin/com/raeids/stratus/utils/RenderHelper.kt
index 8fd417b..9e454d7 100644
--- a/src/main/kotlin/com/raeids/stratus/utils/RenderHelper.kt
+++ b/src/main/kotlin/com/raeids/stratus/utils/RenderHelper.kt
@@ -21,11 +21,12 @@ import java.lang.reflect.Method
import java.nio.ByteBuffer
import java.nio.ByteOrder
import javax.imageio.ImageIO
-import kotlin.math.roundToInt
object RenderHelper {
private val regex = Regex("(?i)\\u00A7[0-9a-f]")
+ var bypassWyvtils = false
+ private set
/**
* Taken from https://github.com/Moulberry/HyChat
@@ -228,6 +229,7 @@ object RenderHelper {
val noColors = text.replace(regex, "\u00A7r")
var yes = 0
if (((Minecraft.getMinecraft().ingameGUI.chatGUI as GuiNewChatHook).textOpacity / 4) > 3) {
+ bypassWyvtils = true
for (xOff in -2..2) {
for (yOff in -2..2) {
if (xOff * xOff != yOff * yOff) {
@@ -238,6 +240,7 @@ object RenderHelper {
}
}
}
+ bypassWyvtils = false
}
yes += fontRendererIn.drawString(text, x, y, color)
return yes
diff --git a/src/main/resources/mixins.stratus.json b/src/main/resources/mixins.stratus.json
index 71ce68e..b7deede 100644
--- a/src/main/resources/mixins.stratus.json
+++ b/src/main/resources/mixins.stratus.json
@@ -9,7 +9,8 @@
"GuiChatMixin",
"GuiNewChatAccessor",
"GuiNewChatMapMixin",
- "GuiNewChatMixin"
+ "GuiNewChatMixin",
+ "WyvtilsListenerMixin"
],
"verbose": true
} \ No newline at end of file