aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.gradle55
-rw-r--r--src/main/java/com/raeids/stratus/hook/GuiNewChatHook.java2
-rw-r--r--src/main/java/com/raeids/stratus/mixin/GuiNewChatMixin.java20
-rw-r--r--src/main/kotlin/com/raeids/stratus/config/StratusConfig.kt23
-rw-r--r--src/main/kotlin/com/raeids/stratus/gui/ChatShortcutEditGui.kt5
-rw-r--r--src/main/kotlin/com/raeids/stratus/gui/ChatShortcutViewGui.kt3
-rw-r--r--src/main/kotlin/com/raeids/stratus/gui/components/TextBlock.kt8
-rw-r--r--src/main/kotlin/com/raeids/stratus/updater/DownloadGui.kt3
-rw-r--r--src/main/kotlin/com/raeids/stratus/updater/Updater.kt2
-rw-r--r--src/main/kotlin/com/raeids/stratus/utils/ModCompatHooks.kt15
-rw-r--r--src/main/kotlin/com/raeids/stratus/utils/RenderHelper.kt34
-rw-r--r--src/main/resources/mixins.stratus.json2
12 files changed, 139 insertions, 33 deletions
diff --git a/build.gradle b/build.gradle
index 673e9d4..9c45bec 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"
@@ -48,8 +48,20 @@ dependencies {
include ('gg.essential:loader-launchwrapper:1.1.3') {
transitive = false
}
- implementation 'gg.essential:essential-1.8.9-forge:1626+release-launch'
- annotationProcessor 'org.spongepowered:mixin:0.7.11-SNAPSHOT'
+ 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")
}
/**
@@ -87,30 +99,13 @@ 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 {
@@ -124,6 +119,22 @@ sourceSets {
dummy
main {
compileClasspath += dummy.output
- ext.refMap = "mixins.${mod_id}.refmap.json"
+ output.resourcesDir = file("${buildDir}/classes/kotlin/main")
}
}
+
+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
diff --git a/src/main/java/com/raeids/stratus/hook/GuiNewChatHook.java b/src/main/java/com/raeids/stratus/hook/GuiNewChatHook.java
index 4db0b51..67552c4 100644
--- a/src/main/java/com/raeids/stratus/hook/GuiNewChatHook.java
+++ b/src/main/java/com/raeids/stratus/hook/GuiNewChatHook.java
@@ -18,4 +18,6 @@ public interface GuiNewChatHook {
String getPrevText();
void setPrevText(String prevText);
+
+ int getTextOpacity();
}
diff --git a/src/main/java/com/raeids/stratus/mixin/GuiNewChatMixin.java b/src/main/java/com/raeids/stratus/mixin/GuiNewChatMixin.java
index 4e79cac..e701758 100644
--- a/src/main/java/com/raeids/stratus/mixin/GuiNewChatMixin.java
+++ b/src/main/java/com/raeids/stratus/mixin/GuiNewChatMixin.java
@@ -3,9 +3,9 @@ package com.raeids.stratus.mixin;
import com.raeids.stratus.Stratus;
import com.raeids.stratus.chat.ChatSearchingManager;
import com.raeids.stratus.chat.ChatTabs;
-import com.raeids.stratus.utils.ModCompatHooks;
import com.raeids.stratus.config.StratusConfig;
import com.raeids.stratus.hook.GuiNewChatHook;
+import com.raeids.stratus.utils.ModCompatHooks;
import com.raeids.stratus.utils.RenderHelper;
import gg.essential.universal.UMouse;
import net.minecraft.client.Minecraft;
@@ -15,7 +15,7 @@ import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IChatComponent;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
-import org.spongepowered.asm.lib.Opcodes;
+import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@@ -36,6 +36,7 @@ public abstract class GuiNewChatMixin extends Gui implements GuiNewChatHook {
@Unique private int stratus$right = 0;
@Unique private boolean stratus$shouldCopy;
@Unique private boolean stratus$chatCheck;
+ @Unique private int stratus$textOpacity;
@Shadow @Final private Minecraft mc;
@Shadow @Final private List<ChatLine> drawnChatLines;
@SuppressWarnings({"FieldCanBeLocal", "unused"})
@@ -113,6 +114,16 @@ 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")
+ private int modifyYeah(int value) {
+ return stratus$textOpacity = value;
+ }
+
+ @Redirect(method = "drawChat", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/FontRenderer;drawStringWithShadow(Ljava/lang/String;FFI)I"))
+ private int redirectDrawString(FontRenderer instance, String text, float x, float y, int color) {
+ return ModCompatHooks.redirectDrawString(text, x, y, color);
+ }
+
@Inject(method = "drawChat", at = @At("RETURN"))
private void checkStuff(int j2, CallbackInfo ci) {
if (!stratus$chatCheck && stratus$shouldCopy) {
@@ -221,4 +232,9 @@ public abstract class GuiNewChatMixin extends Gui implements GuiNewChatHook {
public void setPrevText(String prevText) {
stratus$previousText = prevText;
}
+
+ @Override
+ public int getTextOpacity() {
+ return stratus$textOpacity;
+ }
}
diff --git a/src/main/kotlin/com/raeids/stratus/config/StratusConfig.kt b/src/main/kotlin/com/raeids/stratus/config/StratusConfig.kt
index de26dcb..4e00bf8 100644
--- a/src/main/kotlin/com/raeids/stratus/config/StratusConfig.kt
+++ b/src/main/kotlin/com/raeids/stratus/config/StratusConfig.kt
@@ -9,11 +9,22 @@ import com.raeids.stratus.updater.DownloadGui
import com.raeids.stratus.updater.Updater
import gg.essential.api.EssentialAPI
import gg.essential.vigilance.Vigilant
+import gg.essential.vigilance.data.Category
import gg.essential.vigilance.data.Property
import gg.essential.vigilance.data.PropertyType
+import gg.essential.vigilance.data.SortingBehavior
import java.io.File
-object StratusConfig : Vigilant(File(Stratus.modDir, "${Stratus.ID}.toml"), Stratus.NAME) {
+object StratusConfig : Vigilant(File(Stratus.modDir, "${Stratus.ID}.toml"), Stratus.NAME, sortingBehavior = ConfigSorting) {
+
+ @Property(
+ type = PropertyType.SELECTOR,
+ name = "Text Render Type",
+ description = "Choose the type of rendering for the text.",
+ category = "General",
+ options = ["No Shadow", "Shadow", "Full Shadow"]
+ )
+ var textRenderType = 1
@Property(
type = PropertyType.SWITCH,
@@ -163,4 +174,14 @@ object StratusConfig : Vigilant(File(Stratus.modDir, "${Stratus.ID}.toml"), Stra
ChatShortcuts.initialize()
}
}
+
+ private object ConfigSorting : SortingBehavior() {
+ override fun getCategoryComparator(): Comparator<in Category> = Comparator { o1, o2 ->
+ if (o1.name == "General") return@Comparator -1
+ if (o2.name == "General") return@Comparator 1
+ else compareValuesBy(o1, o2) {
+ it.name
+ }
+ }
+ }
} \ No newline at end of file
diff --git a/src/main/kotlin/com/raeids/stratus/gui/ChatShortcutEditGui.kt b/src/main/kotlin/com/raeids/stratus/gui/ChatShortcutEditGui.kt
index 5a52ea3..6552c36 100644
--- a/src/main/kotlin/com/raeids/stratus/gui/ChatShortcutEditGui.kt
+++ b/src/main/kotlin/com/raeids/stratus/gui/ChatShortcutEditGui.kt
@@ -3,6 +3,7 @@ package com.raeids.stratus.gui
import com.raeids.stratus.chat.ChatShortcuts
import gg.essential.api.EssentialAPI
import gg.essential.api.gui.buildConfirmationModal
+import gg.essential.elementa.ElementaVersion
import gg.essential.elementa.WindowScreen
import gg.essential.elementa.components.UIBlock
import gg.essential.elementa.constraints.CenterConstraint
@@ -16,7 +17,7 @@ import gg.essential.vigilance.gui.settings.ButtonComponent
import gg.essential.vigilance.gui.settings.TextComponent
class ChatShortcutEditGui(private var alias: String, private var command: String, private val editing: Boolean) :
- WindowScreen(restoreCurrentGuiOnClose = true) {
+ WindowScreen(restoreCurrentGuiOnClose = true, version = ElementaVersion.V1) {
private val initialAlias = alias
private val initialCommand = command
@@ -71,7 +72,7 @@ class ChatShortcutEditGui(private var alias: String, private var command: String
}
inner class ChatShortcutConfirmGui(private var alias: String, private var command: String) :
- WindowScreen(restoreCurrentGuiOnClose = true) {
+ WindowScreen(restoreCurrentGuiOnClose = true, version = ElementaVersion.V1) {
override fun initScreen(width: Int, height: Int) {
super.initScreen(width, height)
EssentialAPI.getEssentialComponentFactory().buildConfirmationModal {
diff --git a/src/main/kotlin/com/raeids/stratus/gui/ChatShortcutViewGui.kt b/src/main/kotlin/com/raeids/stratus/gui/ChatShortcutViewGui.kt
index 06dfcbd..6efd29c 100644
--- a/src/main/kotlin/com/raeids/stratus/gui/ChatShortcutViewGui.kt
+++ b/src/main/kotlin/com/raeids/stratus/gui/ChatShortcutViewGui.kt
@@ -3,6 +3,7 @@ package com.raeids.stratus.gui
import com.raeids.stratus.chat.ChatShortcuts
import com.raeids.stratus.gui.components.TextBlock
import gg.essential.api.EssentialAPI
+import gg.essential.elementa.ElementaVersion
import gg.essential.elementa.WindowScreen
import gg.essential.elementa.components.UIBlock
import gg.essential.elementa.constraints.CenterConstraint
@@ -12,7 +13,7 @@ import gg.essential.elementa.dsl.*
import gg.essential.vigilance.gui.VigilancePalette
import gg.essential.vigilance.gui.settings.ButtonComponent
-class ChatShortcutViewGui : WindowScreen() {
+class ChatShortcutViewGui : WindowScreen(version = ElementaVersion.V1) {
override fun initScreen(width: Int, height: Int) {
super.initScreen(width, height)
for ((yes, shortcut) in ChatShortcuts.shortcuts.withIndex()) {
diff --git a/src/main/kotlin/com/raeids/stratus/gui/components/TextBlock.kt b/src/main/kotlin/com/raeids/stratus/gui/components/TextBlock.kt
index 9b36fa4..63b3d01 100644
--- a/src/main/kotlin/com/raeids/stratus/gui/components/TextBlock.kt
+++ b/src/main/kotlin/com/raeids/stratus/gui/components/TextBlock.kt
@@ -9,6 +9,10 @@ import gg.essential.elementa.state.BasicState
import gg.essential.vigilance.gui.VigilancePalette
import gg.essential.vigilance.gui.settings.SettingComponent
+/**
+ * Heavily modified from Vigilance under LGPLv3 (modified to be just a text block)
+ * https://github.com/Sk1erLLC/Vigilance/blob/master/LICENSE
+ */
class TextBlock(
text: String
) : SettingComponent() {
@@ -21,13 +25,13 @@ class TextBlock(
1f
).bindColor(BasicState(VigilancePalette.getDivider()))
- private val textInput: UIText = UIText(text) constrain {
+ private val text: UIText = UIText(text) constrain {
x = 3.pixels()
y = 3.pixels()
}
init {
- textInput childOf textHolder
+ this.text childOf textHolder
constrain {
width = ChildBasedSizeConstraint()
diff --git a/src/main/kotlin/com/raeids/stratus/updater/DownloadGui.kt b/src/main/kotlin/com/raeids/stratus/updater/DownloadGui.kt
index d3fa69e..4fc465f 100644
--- a/src/main/kotlin/com/raeids/stratus/updater/DownloadGui.kt
+++ b/src/main/kotlin/com/raeids/stratus/updater/DownloadGui.kt
@@ -4,11 +4,12 @@ import com.raeids.stratus.Stratus
import gg.essential.api.EssentialAPI
import gg.essential.api.gui.buildConfirmationModal
import gg.essential.api.utils.Multithreading
+import gg.essential.elementa.ElementaVersion
import gg.essential.elementa.WindowScreen
import gg.essential.elementa.dsl.childOf
import java.io.File
-class DownloadGui : WindowScreen(true, true, true, -1) {
+class DownloadGui : WindowScreen(ElementaVersion.V1, true, true, true, -1) {
override fun initScreen(width: Int, height: Int) {
super.initScreen(width, height)
EssentialAPI.getEssentialComponentFactory().buildConfirmationModal {
diff --git a/src/main/kotlin/com/raeids/stratus/updater/Updater.kt b/src/main/kotlin/com/raeids/stratus/updater/Updater.kt
index 11368fd..22ac905 100644
--- a/src/main/kotlin/com/raeids/stratus/updater/Updater.kt
+++ b/src/main/kotlin/com/raeids/stratus/updater/Updater.kt
@@ -27,7 +27,7 @@ object Updater {
DefaultArtifactVersion(Stratus.VER.substringBefore("-"))
val latestVersion = DefaultArtifactVersion(latestTag!!.substringAfter("v").substringBefore("-"))
if (currentVersion >= latestVersion) {
- if (!Stratus.VER.contains("-")) {
+ if (currentVersion != latestVersion || !Stratus.VER.contains("-")) {
return@runAsync
}
}
diff --git a/src/main/kotlin/com/raeids/stratus/utils/ModCompatHooks.kt b/src/main/kotlin/com/raeids/stratus/utils/ModCompatHooks.kt
index b28e9ea..dde7165 100644
--- a/src/main/kotlin/com/raeids/stratus/utils/ModCompatHooks.kt
+++ b/src/main/kotlin/com/raeids/stratus/utils/ModCompatHooks.kt
@@ -4,6 +4,8 @@ import club.sk1er.patcher.config.PatcherConfig
import com.llamalad7.betterchat.BetterChat
import com.raeids.stratus.Stratus.isBetterChat
import com.raeids.stratus.Stratus.isPatcher
+import com.raeids.stratus.config.StratusConfig.textRenderType
+import com.raeids.stratus.utils.RenderHelper.drawBorderedString
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.FontRenderer
@@ -28,4 +30,17 @@ object ModCompatHooks {
@JvmStatic
val fontRenderer: FontRenderer
get() = Minecraft.getMinecraft().fontRendererObj
+
+ @JvmStatic
+ fun redirectDrawString(text: String, x: Float, y: Float, color: Int): Int {
+ return when (textRenderType) {
+ 0 -> {
+ fontRenderer.drawString(text, x, y, color, false)
+ }
+ 2 -> {
+ drawBorderedString(fontRenderer, text, x.toInt(), y.toInt(), color)
+ }
+ else -> fontRenderer.drawString(text, x, y, color, true)
+ }
+ }
}
diff --git a/src/main/kotlin/com/raeids/stratus/utils/RenderHelper.kt b/src/main/kotlin/com/raeids/stratus/utils/RenderHelper.kt
index 95de4d8..8fd417b 100644
--- a/src/main/kotlin/com/raeids/stratus/utils/RenderHelper.kt
+++ b/src/main/kotlin/com/raeids/stratus/utils/RenderHelper.kt
@@ -1,6 +1,9 @@
package com.raeids.stratus.utils
import com.raeids.stratus.config.StratusConfig
+import com.raeids.stratus.hook.GuiNewChatHook
+import net.minecraft.client.Minecraft
+import net.minecraft.client.gui.FontRenderer
import net.minecraft.client.renderer.GlStateManager
import net.minecraft.client.renderer.texture.TextureUtil
import net.minecraft.client.shader.Framebuffer
@@ -18,9 +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]")
+
/**
* Taken from https://github.com/Moulberry/HyChat
* Modified so if not on Windows just in case it will switch it to RGB and remove the transparent background.
@@ -208,4 +214,32 @@ object RenderHelper {
framebuffer.bindFramebuffer(true)
return framebuffer
}
+
+ /**
+ * Taken from https://github.com/Moulberry/HyChat
+ */
+ fun drawBorderedString(
+ fontRendererIn: FontRenderer,
+ text: String,
+ x: Int,
+ y: Int,
+ color: Int
+ ): Int {
+ val noColors = text.replace(regex, "\u00A7r")
+ var yes = 0
+ if (((Minecraft.getMinecraft().ingameGUI.chatGUI as GuiNewChatHook).textOpacity / 4) > 3) {
+ for (xOff in -2..2) {
+ for (yOff in -2..2) {
+ if (xOff * xOff != yOff * yOff) {
+ yes += fontRendererIn.drawString(
+ noColors,
+ (xOff / 2f) + x, (yOff / 2f) + y, ((Minecraft.getMinecraft().ingameGUI.chatGUI as GuiNewChatHook).textOpacity / 4) shl 24, false
+ )
+ }
+ }
+ }
+ }
+ yes += fontRendererIn.drawString(text, x, y, color)
+ return yes
+ }
} \ No newline at end of file
diff --git a/src/main/resources/mixins.stratus.json b/src/main/resources/mixins.stratus.json
index fc3d100..71ce68e 100644
--- a/src/main/resources/mixins.stratus.json
+++ b/src/main/resources/mixins.stratus.json
@@ -1,6 +1,6 @@
{
"compatibilityLevel": "JAVA_8",
- "minVersion": "0.7",
+ "minVersion": "0.8",
"package": "com.raeids.stratus.mixin",
"refmap": "mixins.${id}.refmap.json",
"mixins": [