From 8b373f577d9c6dde26357ef3fc86691f1efef9b4 Mon Sep 17 00:00:00 2001 From: Wyvest Date: Wed, 22 Nov 2023 08:18:19 +0900 Subject: update PGT and relocate to org.polyfrost --- build.gradle | 111 ------- build.gradle.kts | 196 ++++++++++++ gradle.properties | 13 +- gradle/wrapper/gradle-wrapper.properties | 2 +- root.gradle.kts | 9 + settings.gradle | 16 - settings.gradle.kts | 30 ++ .../cc/woverflow/chatting/hook/ChatLineHook.java | 17 - .../cc/woverflow/chatting/hook/GuiNewChatHook.java | 21 -- .../cc/woverflow/chatting/mixin/ChatLineMixin.java | 114 ------- .../chatting/mixin/ClientCommandHandlerMixin.java | 33 -- .../chatting/mixin/EntityPlayerSPMixin.java | 41 --- .../cc/woverflow/chatting/mixin/GuiChatMixin.java | 141 -------- .../chatting/mixin/GuiNewChatAccessor.java | 20 -- .../chatting/mixin/GuiNewChatMapMixin.java | 78 ----- .../woverflow/chatting/mixin/GuiNewChatMixin.java | 259 --------------- .../chatting/mixin/GuiNewChatMixin_ChatHeight.java | 21 -- .../mixin/GuiNewChatMixin_ChatSearching.java | 31 -- .../chatting/mixin/GuiNewChatMixin_ChatTabs.java | 54 ---- .../chatting/mixin/GuiNewChatMixin_Scrolling.java | 71 ----- .../mixin/GuiNewChatMixin_SmoothMessages.java | 103 ------ .../mixin/GuiNewChatMixin_TextRendering.java | 29 -- .../cc/woverflow/chatting/mixin/GuiUtilsMixin.java | 36 --- .../org/polyfrost/chatting/hook/ChatLineHook.java | 17 + .../polyfrost/chatting/hook/GuiNewChatHook.java | 21 ++ .../polyfrost/chatting/mixin/ChatLineMixin.java | 114 +++++++ .../chatting/mixin/ClientCommandHandlerMixin.java | 33 ++ .../chatting/mixin/EntityPlayerSPMixin.java | 41 +++ .../org/polyfrost/chatting/mixin/GuiChatMixin.java | 143 +++++++++ .../chatting/mixin/GuiNewChatAccessor.java | 20 ++ .../chatting/mixin/GuiNewChatMapMixin.java | 78 +++++ .../polyfrost/chatting/mixin/GuiNewChatMixin.java | 257 +++++++++++++++ .../chatting/mixin/GuiNewChatMixin_ChatHeight.java | 21 ++ .../mixin/GuiNewChatMixin_ChatSearching.java | 31 ++ .../chatting/mixin/GuiNewChatMixin_ChatTabs.java | 54 ++++ .../chatting/mixin/GuiNewChatMixin_Scrolling.java | 71 +++++ .../mixin/GuiNewChatMixin_SmoothMessages.java | 103 ++++++ .../mixin/GuiNewChatMixin_TextRendering.java | 29 ++ .../polyfrost/chatting/mixin/GuiUtilsMixin.java | 36 +++ src/main/kotlin/cc/woverflow/chatting/Chatting.kt | 272 ---------------- .../cc/woverflow/chatting/chat/ChatRegexes.kt | 11 - .../woverflow/chatting/chat/ChatScrollingHook.kt | 5 - .../chatting/chat/ChatSearchingManager.kt | 42 --- .../cc/woverflow/chatting/chat/ChatShortcuts.kt | 79 ----- .../cc/woverflow/chatting/chat/ChatSpamBlock.kt | 124 -------- .../kotlin/cc/woverflow/chatting/chat/ChatTab.kt | 112 ------- .../kotlin/cc/woverflow/chatting/chat/ChatTabs.kt | 354 --------------------- .../cc/woverflow/chatting/chat/ChatTabsJson.kt | 15 - .../woverflow/chatting/command/ChattingCommand.kt | 14 - .../cc/woverflow/chatting/config/ChattingConfig.kt | 313 ------------------ .../chatting/gui/components/CleanButton.kt | 103 ------ .../chatting/gui/components/ClearButton.kt | 42 --- .../chatting/gui/components/RenderType.kt | 7 - .../chatting/gui/components/ScreenshotButton.kt | 36 --- .../chatting/gui/components/SearchButton.kt | 70 ---- .../woverflow/chatting/gui/components/TabButton.kt | 46 --- .../cc/woverflow/chatting/utils/EaseOutQuart.kt | 7 - .../cc/woverflow/chatting/utils/ModCompatHooks.kt | 100 ------ .../cc/woverflow/chatting/utils/RenderUtils.kt | 259 --------------- src/main/kotlin/org/polyfrost/chatting/Chatting.kt | 272 ++++++++++++++++ .../org/polyfrost/chatting/chat/ChatRegexes.kt | 11 + .../polyfrost/chatting/chat/ChatScrollingHook.kt | 5 + .../chatting/chat/ChatSearchingManager.kt | 42 +++ .../org/polyfrost/chatting/chat/ChatShortcuts.kt | 79 +++++ .../org/polyfrost/chatting/chat/ChatSpamBlock.kt | 124 ++++++++ .../kotlin/org/polyfrost/chatting/chat/ChatTab.kt | 112 +++++++ .../kotlin/org/polyfrost/chatting/chat/ChatTabs.kt | 354 +++++++++++++++++++++ .../org/polyfrost/chatting/chat/ChatTabsJson.kt | 15 + .../polyfrost/chatting/command/ChattingCommand.kt | 14 + .../polyfrost/chatting/config/ChattingConfig.kt | 313 ++++++++++++++++++ .../chatting/gui/components/CleanButton.kt | 103 ++++++ .../chatting/gui/components/ClearButton.kt | 42 +++ .../chatting/gui/components/RenderType.kt | 7 + .../chatting/gui/components/ScreenshotButton.kt | 36 +++ .../chatting/gui/components/SearchButton.kt | 70 ++++ .../polyfrost/chatting/gui/components/TabButton.kt | 46 +++ .../org/polyfrost/chatting/utils/EaseOutQuart.kt | 7 + .../org/polyfrost/chatting/utils/ModCompatHooks.kt | 100 ++++++ .../org/polyfrost/chatting/utils/RenderUtils.kt | 259 +++++++++++++++ src/main/resources/mixins.chatting.json | 30 +- versions/mainProject | 1 + 81 files changed, 3341 insertions(+), 3227 deletions(-) delete mode 100644 build.gradle create mode 100644 build.gradle.kts create mode 100644 root.gradle.kts delete mode 100644 settings.gradle create mode 100644 settings.gradle.kts delete mode 100644 src/main/java/cc/woverflow/chatting/hook/ChatLineHook.java delete mode 100644 src/main/java/cc/woverflow/chatting/hook/GuiNewChatHook.java delete mode 100644 src/main/java/cc/woverflow/chatting/mixin/ChatLineMixin.java delete mode 100644 src/main/java/cc/woverflow/chatting/mixin/ClientCommandHandlerMixin.java delete mode 100644 src/main/java/cc/woverflow/chatting/mixin/EntityPlayerSPMixin.java delete mode 100644 src/main/java/cc/woverflow/chatting/mixin/GuiChatMixin.java delete mode 100644 src/main/java/cc/woverflow/chatting/mixin/GuiNewChatAccessor.java delete mode 100644 src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMapMixin.java delete mode 100644 src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin.java delete mode 100644 src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_ChatHeight.java delete mode 100644 src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_ChatSearching.java delete mode 100644 src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_ChatTabs.java delete mode 100644 src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_Scrolling.java delete mode 100644 src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_SmoothMessages.java delete mode 100644 src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_TextRendering.java delete mode 100644 src/main/java/cc/woverflow/chatting/mixin/GuiUtilsMixin.java create mode 100644 src/main/java/org/polyfrost/chatting/hook/ChatLineHook.java create mode 100644 src/main/java/org/polyfrost/chatting/hook/GuiNewChatHook.java create mode 100644 src/main/java/org/polyfrost/chatting/mixin/ChatLineMixin.java create mode 100644 src/main/java/org/polyfrost/chatting/mixin/ClientCommandHandlerMixin.java create mode 100644 src/main/java/org/polyfrost/chatting/mixin/EntityPlayerSPMixin.java create mode 100644 src/main/java/org/polyfrost/chatting/mixin/GuiChatMixin.java create mode 100644 src/main/java/org/polyfrost/chatting/mixin/GuiNewChatAccessor.java create mode 100644 src/main/java/org/polyfrost/chatting/mixin/GuiNewChatMapMixin.java create mode 100644 src/main/java/org/polyfrost/chatting/mixin/GuiNewChatMixin.java create mode 100644 src/main/java/org/polyfrost/chatting/mixin/GuiNewChatMixin_ChatHeight.java create mode 100644 src/main/java/org/polyfrost/chatting/mixin/GuiNewChatMixin_ChatSearching.java create mode 100644 src/main/java/org/polyfrost/chatting/mixin/GuiNewChatMixin_ChatTabs.java create mode 100644 src/main/java/org/polyfrost/chatting/mixin/GuiNewChatMixin_Scrolling.java create mode 100644 src/main/java/org/polyfrost/chatting/mixin/GuiNewChatMixin_SmoothMessages.java create mode 100644 src/main/java/org/polyfrost/chatting/mixin/GuiNewChatMixin_TextRendering.java create mode 100644 src/main/java/org/polyfrost/chatting/mixin/GuiUtilsMixin.java delete mode 100644 src/main/kotlin/cc/woverflow/chatting/Chatting.kt delete mode 100644 src/main/kotlin/cc/woverflow/chatting/chat/ChatRegexes.kt delete mode 100644 src/main/kotlin/cc/woverflow/chatting/chat/ChatScrollingHook.kt delete mode 100644 src/main/kotlin/cc/woverflow/chatting/chat/ChatSearchingManager.kt delete mode 100644 src/main/kotlin/cc/woverflow/chatting/chat/ChatShortcuts.kt delete mode 100644 src/main/kotlin/cc/woverflow/chatting/chat/ChatSpamBlock.kt delete mode 100644 src/main/kotlin/cc/woverflow/chatting/chat/ChatTab.kt delete mode 100644 src/main/kotlin/cc/woverflow/chatting/chat/ChatTabs.kt delete mode 100644 src/main/kotlin/cc/woverflow/chatting/chat/ChatTabsJson.kt delete mode 100644 src/main/kotlin/cc/woverflow/chatting/command/ChattingCommand.kt delete mode 100644 src/main/kotlin/cc/woverflow/chatting/config/ChattingConfig.kt delete mode 100644 src/main/kotlin/cc/woverflow/chatting/gui/components/CleanButton.kt delete mode 100644 src/main/kotlin/cc/woverflow/chatting/gui/components/ClearButton.kt delete mode 100644 src/main/kotlin/cc/woverflow/chatting/gui/components/RenderType.kt delete mode 100644 src/main/kotlin/cc/woverflow/chatting/gui/components/ScreenshotButton.kt delete mode 100644 src/main/kotlin/cc/woverflow/chatting/gui/components/SearchButton.kt delete mode 100644 src/main/kotlin/cc/woverflow/chatting/gui/components/TabButton.kt delete mode 100644 src/main/kotlin/cc/woverflow/chatting/utils/EaseOutQuart.kt delete mode 100644 src/main/kotlin/cc/woverflow/chatting/utils/ModCompatHooks.kt delete mode 100644 src/main/kotlin/cc/woverflow/chatting/utils/RenderUtils.kt create mode 100644 src/main/kotlin/org/polyfrost/chatting/Chatting.kt create mode 100644 src/main/kotlin/org/polyfrost/chatting/chat/ChatRegexes.kt create mode 100644 src/main/kotlin/org/polyfrost/chatting/chat/ChatScrollingHook.kt create mode 100644 src/main/kotlin/org/polyfrost/chatting/chat/ChatSearchingManager.kt create mode 100644 src/main/kotlin/org/polyfrost/chatting/chat/ChatShortcuts.kt create mode 100644 src/main/kotlin/org/polyfrost/chatting/chat/ChatSpamBlock.kt create mode 100644 src/main/kotlin/org/polyfrost/chatting/chat/ChatTab.kt create mode 100644 src/main/kotlin/org/polyfrost/chatting/chat/ChatTabs.kt create mode 100644 src/main/kotlin/org/polyfrost/chatting/chat/ChatTabsJson.kt create mode 100644 src/main/kotlin/org/polyfrost/chatting/command/ChattingCommand.kt create mode 100644 src/main/kotlin/org/polyfrost/chatting/config/ChattingConfig.kt create mode 100644 src/main/kotlin/org/polyfrost/chatting/gui/components/CleanButton.kt create mode 100644 src/main/kotlin/org/polyfrost/chatting/gui/components/ClearButton.kt create mode 100644 src/main/kotlin/org/polyfrost/chatting/gui/components/RenderType.kt create mode 100644 src/main/kotlin/org/polyfrost/chatting/gui/components/ScreenshotButton.kt create mode 100644 src/main/kotlin/org/polyfrost/chatting/gui/components/SearchButton.kt create mode 100644 src/main/kotlin/org/polyfrost/chatting/gui/components/TabButton.kt create mode 100644 src/main/kotlin/org/polyfrost/chatting/utils/EaseOutQuart.kt create mode 100644 src/main/kotlin/org/polyfrost/chatting/utils/ModCompatHooks.kt create mode 100644 src/main/kotlin/org/polyfrost/chatting/utils/RenderUtils.kt create mode 100644 versions/mainProject diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 5a18999..0000000 --- a/build.gradle +++ /dev/null @@ -1,111 +0,0 @@ -//file:noinspection UnnecessaryQualifiedReference -//file:noinspection GroovyAssignabilityCheck - -plugins { - id "dev.architectury.architectury-pack200" version "0.1.3" - id 'org.jetbrains.kotlin.jvm' version '1.6.10' - id "cc.polyfrost.loom" version "0.10.0.5" - id "net.kyori.blossom" version "1.3.0" - id "java" -} - -version = mod_version -group = "cc.woverflow" -archivesBaseName = mod_name - -blossom { - String className = "src/main/kotlin/cc/woverflow/chatting/Chatting.kt" - replaceToken("@VER@", project.version, className) - replaceToken("@NAME@", mod_name, className) - replaceToken("@ID@", mod_id, className) -} -kotlin.jvmToolchain { - languageVersion = JavaLanguageVersion.of(8) -} -compileJava.options.encoding = 'UTF-8' - -loom { - launchConfigs { - client { - arg("--tweakClass", "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker") - property("mixin.debug.export", "true") - } - } - runConfigs { - client { - vmArgs.remove("-XstartOnFirstThread") - } - } - forge { - pack200Provider = new dev.architectury.pack200.java.Pack200Adapter() - mixinConfig("mixins.${mod_id}.json") - mixin.defaultRefmapName.set("mixins.${mod_id}.refmap.json") - } -} - -configurations { - include - implementation.extendsFrom(include) -} - -repositories { - maven { url 'https://repo.polyfrost.cc/releases'} -} - -dependencies { - minecraft("com.mojang:minecraft:1.8.9") - mappings("de.oceanlabs.mcp:mcp_stable:22-1.8.9") - forge("net.minecraftforge:forge:1.8.9-11.15.1.2318-1.8.9") - compileOnly ('org.spongepowered:mixin:0.7.11-SNAPSHOT') - compileOnly('cc.polyfrost:oneconfig-1.8.9-forge:0.2.0-alpha+') - include('cc.polyfrost:oneconfig-wrapper-launchwrapper:1.0.0-beta+') - modRuntimeOnly("me.djtheredstoner:DevAuth-forge-legacy:1.1.0") -} - -processResources { - // this will ensure that this task is redone when the versions change. - inputs.property "version", version - inputs.property "name", mod_name - inputs.property "id", mod_id - - filesMatching("mcmod.info") { - expand( - "id": mod_id, - "name": mod_name, - "version": version - ) - } - - filesMatching("mixins.${mod_id}.json") { - expand("id": mod_id) - } - - rename '(.+_at.cfg)', 'META-INF/$1' -} - -sourceSets { - dummy - main { - compileClasspath += dummy.output - output.resourcesDir = java.classesDirectory - } -} - -jar { - dependsOn configurations.include - from(configurations.include.collect { it.isDirectory() ? it : zipTree(it) }) { - def i = 0 - filesMatching("META-INF/NOTICE*") { name = "$name.${i++}" } - filesMatching("META-INF/LICENSE*") { name = "$name.${i++}" } - filesMatching("META-INF/mods.toml") { name = "$name.${i++}" } - filesMatching("LICENSE*") { name = "$name.${i++}" } - } - - manifest.attributes( - 'ModSide': 'CLIENT', - 'ForceLoadAsMod': true, - 'MixinConfigs': "mixins.${mod_id}.json", - "TweakOrder": "0", - "TweakClass": "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker" - ) -} \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..2c4e811 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,196 @@ +@file:Suppress("UnstableApiUsage", "PropertyName") + +import org.polyfrost.gradle.util.noServerRunConfigs +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar + +// Adds support for kotlin, and adds the Polyfrost Gradle Toolkit +// which we use to prepare the environment. +plugins { + kotlin("jvm") + id("org.polyfrost.multi-version") + id("org.polyfrost.defaults.repo") + id("org.polyfrost.defaults.java") + id("org.polyfrost.defaults.loom") + id("com.github.johnrengelman.shadow") + id("net.kyori.blossom") version "1.3.1" + id("signing") + java +} + +// Gets the mod name, version and id from the `gradle.properties` file. +val mod_name: String by project +val mod_version: String by project +val mod_id: String by project +val mod_archives_name: String by project + +// Sets up the variables for when we preprocess to other Minecraft versions. +preprocess { + vars.put("MODERN", if (project.platform.mcMinor >= 16) 1 else 0) +} + +// Replaces the variables in `ExampleMod.java` to the ones specified in `gradle.properties`. +blossom { + replaceToken("@VER@", mod_version) + replaceToken("@NAME@", mod_name) + replaceToken("@ID@", mod_id) +} + +// Sets the mod version to the one specified in `gradle.properties`. Make sure to change this following semver! +version = mod_version +// Sets the group, make sure to change this to your own. It can be a website you own backwards or your GitHub username. +// e.g. com.github. or com. +group = "org.polyfrost" + +// Sets the name of the output jar (the one you put in your mods folder and send to other people) +// It outputs all versions of the mod into the `build` directory. +base { + archivesName.set("$mod_archives_name-$platform") +} + +// Configures the Polyfrost Loom, our plugin fork to easily set up the programming environment. +loom { + // Removes the server configs from IntelliJ IDEA, leaving only client runs. + // If you're developing a server-side mod, you can remove this line. + noServerRunConfigs() + + // Adds the tweak class if we are building legacy version of forge as per the documentation (https://docs.polyfrost.org) + if (project.platform.isLegacyForge) { + runConfigs { + "client" { + programArgs("--tweakClass", "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker") + property("mixin.debug.export", "true") + } + } + } + // Configures the mixins if we are building for forge, useful for when we are dealing with cross-platform projects. + if (project.platform.isForge) { + forge { + mixinConfig("mixins.${mod_id}.json") + } + } + // Configures the name of the mixin "refmap" using an experimental loom api. + mixin.defaultRefmapName.set("mixins.${mod_id}.refmap.json") +} + +// Creates the shade/shadow configuration, so we can include libraries inside our mod, rather than having to add them separately. +val shade: Configuration by configurations.creating { + configurations.implementation.get().extendsFrom(this) +} + +// Configures the output directory for when building from the `src/resources` directory. +sourceSets { + val dummy by creating + main { + compileClasspath += dummy.output + output.setResourcesDir(java.classesDirectory) + } +} + +// Adds the Polyfrost maven repository so that we can get the libraries necessary to develop the mod. +repositories { + maven("https://repo.polyfrost.org/releases") +} + +// Configures the libraries/dependencies for your mod. +dependencies { + // Adds the OneConfig library, so we can develop with it. + modCompileOnly("cc.polyfrost:oneconfig-$platform:0.2.1-alpha+") + + modRuntimeOnly("me.djtheredstoner:DevAuth-${if (platform.isFabric) "fabric" else if (platform.isLegacyForge) "forge-legacy" else "forge-latest"}:1.1.2") + + // If we are building for legacy forge, includes the launch wrapper with `shade` as we configured earlier. + if (platform.isLegacyForge) { + compileOnly("org.spongepowered:mixin:0.7.11-SNAPSHOT") + shade("cc.polyfrost:oneconfig-wrapper-launchwrapper:1.0.0-beta+") + } +} + +tasks { + // Processes the `src/resources/mcmod.info or fabric.mod.json` and replaces + // the mod id, name and version with the ones in `gradle.properties` + processResources { + inputs.property("id", mod_id) + inputs.property("name", mod_name) + val java = if (project.platform.mcMinor >= 18) { + 17 // If we are playing on version 1.18, set the java version to 17 + } else { + // Else if we are playing on version 1.17, use java 16. + if (project.platform.mcMinor == 17) + 16 + else + 8 // For all previous versions, we **need** java 8 (for Forge support). + } + val compatLevel = "JAVA_${java}" + inputs.property("java", java) + inputs.property("java_level", compatLevel) + inputs.property("version", mod_version) + inputs.property("mcVersionStr", project.platform.mcVersionStr) + filesMatching(listOf("mcmod.info", "mixins.${mod_id}.json", "mods.toml")) { + expand( + mapOf( + "id" to mod_id, + "name" to mod_name, + "java" to java, + "java_level" to compatLevel, + "version" to mod_version, + "mcVersionStr" to project.platform.mcVersionStr + ) + ) + } + filesMatching("fabric.mod.json") { + expand( + mapOf( + "id" to mod_id, + "name" to mod_name, + "java" to java, + "java_level" to compatLevel, + "version" to mod_version, + "mcVersionStr" to project.platform.mcVersionStr.substringBeforeLast(".") + ".x" + ) + ) + } + } + + // Configures the resources to include if we are building for forge or fabric. + withType(Jar::class.java) { + if (project.platform.isFabric) { + exclude("mcmod.info", "mods.toml") + } else { + exclude("fabric.mod.json") + if (project.platform.isLegacyForge) { + exclude("mods.toml") + } else { + exclude("mcmod.info") + } + } + } + + // Configures our shadow/shade configuration, so we can + // include some dependencies within our mod jar file. + named("shadowJar") { + archiveClassifier.set("dev") // TODO: machete gets confused by the `dev` prefix. + configurations = listOf(shade) + duplicatesStrategy = DuplicatesStrategy.EXCLUDE + } + + remapJar { + inputFile.set(shadowJar.get().archiveFile) + archiveClassifier.set("") + } + + jar { + // Sets the jar manifest attributes. + if (platform.isLegacyForge) { + manifest.attributes += mapOf( + "ModSide" to "CLIENT", // We aren't developing a server-side mod, so this is fine. + "ForceLoadAsMod" to true, // We want to load this jar as a mod, so we force Forge to do so. + "TweakOrder" to "0", // Makes sure that the OneConfig launch wrapper is loaded as soon as possible. + "MixinConfigs" to "mixins.${mod_id}.json", // We want to use our mixin configuration, so we specify it here. + "TweakClass" to "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker" // Loads the OneConfig launch wrapper. + ) + } + dependsOn(shadowJar) + archiveClassifier.set("") + enabled = false + } +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index d0f26a8..7e417f2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,12 @@ -org.gradle.jvmargs=-Xmx2G mod_name = Chatting mod_id = chatting -mod_version = 1.4.2-beta5 +mod_version = 1.5.0 +mod_archives_name = Chatting -loom.platform = forge -minecraft.version = "1.8.9-forge" +# Gradle Configuration -- DO NOT TOUCH THESE VALUES. +polyfrost.defaults.loom=1 +org.gradle.daemon=true +org.gradle.parallel=true +org.gradle.configureoncommand=true +org.gradle.parallel.threads=4 +org.gradle.jvmargs=-Xmx2G \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 070cb70..e411586 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/root.gradle.kts b/root.gradle.kts new file mode 100644 index 0000000..2b3f7b0 --- /dev/null +++ b/root.gradle.kts @@ -0,0 +1,9 @@ +plugins { + kotlin("jvm") version "1.8.22" apply false + id("org.polyfrost.multi-version.root") + id("com.github.johnrengelman.shadow") version "7.1.2" apply false +} + +preprocess { + "1.8.9-forge"(10809, "srg") {} +} \ No newline at end of file diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index 8fa80f6..0000000 --- a/settings.gradle +++ /dev/null @@ -1,16 +0,0 @@ -pluginManagement { - repositories { - gradlePluginPortal() - maven { url = "https://repo.polyfrost.cc/releases" } - maven { url = "https://maven.architectury.dev"} - } - resolutionStrategy { - eachPlugin { - if (requested.id.id == "io.github.juuxel.loom-quiltflower-mini") { - useModule("com.github.wyvest:loom-quiltflower-mini:${requested.version}") - } - } - } -} - -rootProject.name = mod_name \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..9692a27 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,30 @@ +@file:Suppress("PropertyName") + +pluginManagement { + repositories { + gradlePluginPortal() + mavenCentral() + maven("https://repo.polyfrost.org/releases") // Adds the Polyfrost maven repository to get Polyfrost Gradle Toolkit + } + plugins { + val pgtVersion = "0.2.9" // Sets the default versions for Polyfrost Gradle Toolkit + id("org.polyfrost.multi-version.root") version pgtVersion + } +} + +val mod_name: String by settings + +// Configures the root project Gradle name based on the value in `gradle.properties` +rootProject.name = mod_name +rootProject.buildFileName = "root.gradle.kts" + +// Adds all of our build target versions to the classpath if we need to add version-specific code. +listOf( + "1.8.9-forge" +).forEach { version -> + include(":$version") + project(":$version").apply { + projectDir = file("versions/$version") + buildFileName = "../../build.gradle.kts" + } +} \ No newline at end of file diff --git a/src/main/java/cc/woverflow/chatting/hook/ChatLineHook.java b/src/main/java/cc/woverflow/chatting/hook/ChatLineHook.java deleted file mode 100644 index 9460e0c..0000000 --- a/src/main/java/cc/woverflow/chatting/hook/ChatLineHook.java +++ /dev/null @@ -1,17 +0,0 @@ -package cc.woverflow.chatting.hook; - -import net.minecraft.client.gui.ChatLine; -import net.minecraft.client.network.NetworkPlayerInfo; - -import java.lang.ref.WeakReference; -import java.util.HashSet; - -public interface ChatLineHook { - HashSet> chatLines = new HashSet<>(); - boolean hasDetected(); - NetworkPlayerInfo getPlayerInfo(); - - void updatePlayerInfo(); - - long getUniqueId(); -} diff --git a/src/main/java/cc/woverflow/chatting/hook/GuiNewChatHook.java b/src/main/java/cc/woverflow/chatting/hook/GuiNewChatHook.java deleted file mode 100644 index 19da778..0000000 --- a/src/main/java/cc/woverflow/chatting/hook/GuiNewChatHook.java +++ /dev/null @@ -1,21 +0,0 @@ -package cc.woverflow.chatting.hook; - -import net.minecraft.client.gui.ChatLine; - -import java.awt.datatransfer.Transferable; - -public interface GuiNewChatHook { - int getRight(); - - boolean isHovering(); - - ChatLine getHoveredLine(int mouseY); - - Transferable getChattingChatComponent(int mouseY); - - default ChatLine getFullMessage(ChatLine line) { - throw new AssertionError("getFullMessage not overridden on GuiNewChat"); - } - - int getTextOpacity(); -} diff --git a/src/main/java/cc/woverflow/chatting/mixin/ChatLineMixin.java b/src/main/java/cc/woverflow/chatting/mixin/ChatLineMixin.java deleted file mode 100644 index beef37b..0000000 --- a/src/main/java/cc/woverflow/chatting/mixin/ChatLineMixin.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * This file is from chat_heads is licensed under MPL-2.0, which can be found at https://www.mozilla.org/en-US/MPL/2.0/ - * See: https://github.com/dzwdz/chat_heads/blob/fabric-1.16.x/LICENSE - */ - -package cc.woverflow.chatting.mixin; - -import cc.woverflow.chatting.config.ChattingConfig; -import cc.woverflow.chatting.hook.ChatLineHook; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.ChatLine; -import net.minecraft.client.network.NetHandlerPlayClient; -import net.minecraft.client.network.NetworkPlayerInfo; -import net.minecraft.util.IChatComponent; -import org.jetbrains.annotations.Nullable; -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 java.lang.ref.WeakReference; -import java.util.HashMap; -import java.util.Map; - -@Mixin(ChatLine.class) -public class ChatLineMixin implements ChatLineHook { - private boolean detected = false; - private boolean first = true; - private NetworkPlayerInfo playerInfo; - private NetworkPlayerInfo detectedPlayerInfo; - private static NetworkPlayerInfo lastPlayerInfo; - private static long lastUniqueId = 0; - private long uniqueId = 0; - - @Inject(method = "", at = @At("RETURN")) - private void onInit(int i, IChatComponent iChatComponent, int j, CallbackInfo ci) { - lastUniqueId++; - uniqueId = lastUniqueId; - chatLines.add(new WeakReference<>((ChatLine) (Object) this)); - NetHandlerPlayClient netHandler = Minecraft.getMinecraft().getNetHandler(); - if (netHandler == null) return; - Map nicknameCache = new HashMap<>(); - try { - for (String word : iChatComponent.getFormattedText().split("(§.)|\\W")) { - if (word.isEmpty()) continue; - playerInfo = netHandler.getPlayerInfo(word); - if (playerInfo == null) { - playerInfo = getPlayerFromNickname(word, netHandler, nicknameCache); - } - if (playerInfo != null) { - detectedPlayerInfo = playerInfo; - detected = true; - if (playerInfo == lastPlayerInfo) { - first = false; - if (ChattingConfig.INSTANCE.getHideChatHeadOnConsecutiveMessages()) { - playerInfo = null; - } - } else { - lastPlayerInfo = playerInfo; - } - break; - } - } - } catch (Exception ignored) { - } - } - - @Nullable - private static NetworkPlayerInfo getPlayerFromNickname(String word, NetHandlerPlayClient connection, Map nicknameCache) { - if (nicknameCache.isEmpty()) { - for (NetworkPlayerInfo p : connection.getPlayerInfoMap()) { - IChatComponent displayName = p.getDisplayName(); - if (displayName != null) { - String nickname = displayName.getUnformattedTextForChat(); - if (word.equals(nickname)) { - nicknameCache.clear(); - return p; - } - - nicknameCache.put(nickname, p); - } - } - } else { - // use prepared cache - return nicknameCache.get(word); - } - - return null; - } - - @Override - public boolean hasDetected() { - return detected; - } - - @Override - public NetworkPlayerInfo getPlayerInfo() { - return playerInfo; - } - - @Override - public void updatePlayerInfo() { - if (ChattingConfig.INSTANCE.getHideChatHeadOnConsecutiveMessages() && !first) { - playerInfo = null; - } else { - playerInfo = detectedPlayerInfo; - } - } - - @Override - public long getUniqueId() { - return uniqueId; - } -} diff --git a/src/main/java/cc/woverflow/chatting/mixin/ClientCommandHandlerMixin.java b/src/main/java/cc/woverflow/chatting/mixin/ClientCommandHandlerMixin.java deleted file mode 100644 index f771c87..0000000 --- a/src/main/java/cc/woverflow/chatting/mixin/ClientCommandHandlerMixin.java +++ /dev/null @@ -1,33 +0,0 @@ -package cc.woverflow.chatting.mixin; - -import cc.woverflow.chatting.chat.ChatShortcuts; -import cc.woverflow.chatting.config.ChattingConfig; -import kotlin.Pair; -import net.minecraft.client.Minecraft; -import net.minecraft.command.CommandHandler; -import net.minecraft.command.ICommandSender; -import net.minecraft.util.BlockPos; -import net.minecraftforge.client.ClientCommandHandler; -import net.minecraftforge.fml.client.FMLClientHandler; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -import java.util.List; - -@Mixin(value = ClientCommandHandler.class, remap = false) -public class ClientCommandHandlerMixin extends CommandHandler { - @Redirect(method = "autoComplete", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/client/ClientCommandHandler;getTabCompletionOptions(Lnet/minecraft/command/ICommandSender;Ljava/lang/String;Lnet/minecraft/util/BlockPos;)Ljava/util/List;")) - private List addChatShortcuts(ClientCommandHandler instance, ICommandSender iCommandSender, String leftOfCursor, BlockPos blockPos) { - Minecraft mc = FMLClientHandler.instance().getClient(); - List autocompleteList = instance.getTabCompletionOptions(mc.thePlayer, leftOfCursor, mc.thePlayer.getPosition()); - if (ChattingConfig.INSTANCE.getChatShortcuts()) { - for (Pair pair : ChatShortcuts.INSTANCE.getShortcuts()) { - if (pair.getFirst().startsWith(leftOfCursor)) { - autocompleteList.add(pair.getFirst()); - } - } - } - return autocompleteList; - } -} diff --git a/src/main/java/cc/woverflow/chatting/mixin/EntityPlayerSPMixin.java b/src/main/java/cc/woverflow/chatting/mixin/EntityPlayerSPMixin.java deleted file mode 100644 index fa125cb..0000000 --- a/src/main/java/cc/woverflow/chatting/mixin/EntityPlayerSPMixin.java +++ /dev/null @@ -1,41 +0,0 @@ -package cc.woverflow.chatting.mixin; - -import cc.woverflow.chatting.chat.ChatTab; -import cc.woverflow.chatting.chat.ChatTabs; -import cc.woverflow.chatting.config.ChattingConfig; -import net.minecraft.client.entity.EntityPlayerSP; -import net.minecraft.client.network.NetHandlerPlayClient; -import net.minecraft.network.Packet; -import net.minecraft.network.play.client.C01PacketChatMessage; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(value = EntityPlayerSP.class, priority = 0) -public class EntityPlayerSPMixin { - @Shadow @Final public NetHandlerPlayClient sendQueue; - - @Redirect(method = "sendChatMessage", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/NetHandlerPlayClient;addToSendQueue(Lnet/minecraft/network/Packet;)V")) - private void handleSentMessages(NetHandlerPlayClient instance, Packet packet, String value) { - if (value.startsWith("/")) { - sendQueue.addToSendQueue(packet); - return; - } - if (ChattingConfig.INSTANCE.getChatTabs() && !ChatTabs.INSTANCE.getCurrentTabs().isEmpty()) { - boolean sent = false; - for (ChatTab tab : ChatTabs.INSTANCE.getCurrentTabs()) { - if (tab.getPrefix() != null && !tab.getPrefix().isEmpty()) { - sendQueue.addToSendQueue(new C01PacketChatMessage(tab.getPrefix() + value)); - sent = true; - } - } - if (!sent) { - sendQueue.addToSendQueue(packet); - } - } else { - sendQueue.addToSendQueue(packet); - } - } -} \ No newline at end of file diff --git a/src/main/java/cc/woverflow/chatting/mixin/GuiChatMixin.java b/src/main/java/cc/woverflow/chatting/mixin/GuiChatMixin.java deleted file mode 100644 index a12aea1..0000000 --- a/src/main/java/cc/woverflow/chatting/mixin/GuiChatMixin.java +++ /dev/null @@ -1,141 +0,0 @@ -package cc.woverflow.chatting.mixin; - -import cc.woverflow.chatting.chat.*; -import cc.woverflow.chatting.config.ChattingConfig; -import cc.woverflow.chatting.gui.components.ClearButton; -import cc.woverflow.chatting.gui.components.ScreenshotButton; -import cc.woverflow.chatting.gui.components.SearchButton; -import cc.woverflow.chatting.hook.ChatLineHook; -import cc.woverflow.chatting.hook.GuiNewChatHook; -import cc.woverflow.chatting.utils.ModCompatHooks; -import com.google.common.collect.Lists; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.ChatLine; -import net.minecraft.client.gui.GuiChat; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.util.MathHelper; -import net.minecraftforge.fml.client.config.GuiUtils; -import org.apache.commons.lang3.StringUtils; -import org.lwjgl.input.Mouse; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyArg; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import java.awt.*; -import java.awt.datatransfer.Transferable; -import java.util.List; - -@Mixin(GuiChat.class) -public abstract class GuiChatMixin extends GuiScreen { - - @Unique - private static final List COPY_TOOLTIP = Lists.newArrayList( - "\u00A7e\u00A7lCopy To Clipboard", - "\u00A7b\u00A7lNORMAL CLICK\u00A7r \u00A78- \u00A77Full Message", - "\u00A7b\u00A7lCTRL CLICK\u00A7r \u00A78- \u00A77Single Line", - "\u00A7b\u00A7lSHIFT CLICK\u00A7r \u00A78- \u00A77Screenshot Line", - "", - "\u00A7e\u00A7lModifiers", - "\u00A7b\u00A7lALT\u00A7r \u00A78- \u00A77Formatting Codes"); - - private SearchButton searchButton; - - @Inject(method = "initGui", at = @At("TAIL")) - private void init(CallbackInfo ci) { - if (ChattingConfig.INSTANCE.getChatSearch()) { - searchButton = new SearchButton(); - buttonList.add(searchButton); - } - buttonList.add(new ScreenshotButton()); - buttonList.add(new ClearButton()); - if (ChattingConfig.INSTANCE.getChatTabs()) { - for (ChatTab chatTab : ChatTabs.INSTANCE.getTabs()) { - buttonList.add(chatTab.getButton()); - } - } - } - - @Inject(method = "updateScreen", at = @At("HEAD")) - private void updateScreen(CallbackInfo ci) { - if (ChattingConfig.INSTANCE.getChatSearch() && searchButton.isEnabled()) { - searchButton.getInputField().updateCursorCounter(); - } - } - - @Inject(method = "keyTyped", at = @At("HEAD"), cancellable = true) - private void keyTyped(char typedChar, int keyCode, CallbackInfo ci) { - if (ChattingConfig.INSTANCE.getChatSearch() && searchButton.isEnabled()) { - ci.cancel(); - if (keyCode == 1) { - searchButton.onMousePress(); - return; - } - searchButton.getInputField().textboxKeyTyped(typedChar, keyCode); - ChatSearchingManager.INSTANCE.setLastSearch(searchButton.getInputField().getText()); - } - } - - @Inject(method = "drawScreen", at = @At("HEAD")) - private void onDrawScreen(int mouseX, int mouseY, float partialTicks, CallbackInfo ci) { - GuiNewChatHook hook = ((GuiNewChatHook) Minecraft.getMinecraft().ingameGUI.getChatGUI()); - float f = mc.ingameGUI.getChatGUI().getChatScale(); - int x = MathHelper.floor_float((float) mouseX / f); - if (hook.isHovering() && (hook.getRight() + ModCompatHooks.getXOffset() + 3) <= x && (hook.getRight() + ModCompatHooks.getXOffset()) + 13 > x) { - GuiUtils.drawHoveringText(COPY_TOOLTIP, mouseX, mouseY, width, height, -1, fontRendererObj); - GlStateManager.disableLighting(); - } - } - - @ModifyArg(method = "drawScreen", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiChat;drawRect(IIIII)V"), index = 2) - private int modifyRight(int right) { - return ChattingConfig.INSTANCE.getCompactInputBox() ? (MathHelper.ceiling_float_int((float) mc.ingameGUI.getChatGUI().getChatWidth() / mc.ingameGUI.getChatGUI().getChatScale()) + 6) : right; - } - - @ModifyArg(method = "drawScreen", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiChat;drawRect(IIIII)V"), index = 4) - private int modifyInputBoxColor(int color) { - return ChattingConfig.INSTANCE.getInputBoxBackgroundColor().getRGB(); - } - - @Inject(method = "mouseClicked", at = @At("HEAD")) - private void mouseClicked(int mouseX, int mouseY, int mouseButton, CallbackInfo ci) { - GuiNewChatHook hook = ((GuiNewChatHook) Minecraft.getMinecraft().ingameGUI.getChatGUI()); - float f = mc.ingameGUI.getChatGUI().getChatScale(); - int x = MathHelper.floor_float((float) mouseX / f); - if (hook.isHovering()) { - if (((hook.getRight() + ModCompatHooks.getXOffset() + 3) <= x && (hook.getRight() + ModCompatHooks.getXOffset()) + 13 > x) || (mouseButton == 1 && ChattingConfig.INSTANCE.getRightClickCopy())) { - Transferable message = hook.getChattingChatComponent(Mouse.getY()); - if (message == null) return; - try { - Toolkit.getDefaultToolkit().getSystemClipboard().setContents(message, null); - } catch (Exception e) { - e.printStackTrace(); - } - } else if ((hook.getRight() + ModCompatHooks.getXOffset() + 13) <= x && (hook.getRight() + ModCompatHooks.getXOffset()) + 23 > x) { - ChatLine chatLine = hook.getHoveredLine(Mouse.getY()); - if (chatLine == null) return; - ((GuiNewChatAccessor) Minecraft.getMinecraft().ingameGUI.getChatGUI()).getDrawnChatLines().removeIf(line -> ((ChatLineHook) line).getUniqueId() == ((ChatLineHook) chatLine).getUniqueId()); - ((GuiNewChatAccessor) Minecraft.getMinecraft().ingameGUI.getChatGUI()).getChatLines().removeIf(line -> ((ChatLineHook) line).getUniqueId() == ((ChatLineHook) chatLine).getUniqueId()); - } - } - - } - - @ModifyArg(method = "keyTyped", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiChat;sendChatMessage(Ljava/lang/String;)V"), index = 0) - private String modifySentMessage(String original) { - if (ChattingConfig.INSTANCE.getChatShortcuts()) { - if (original.startsWith("/")) { - return "/" + ChatShortcuts.INSTANCE.handleSentCommand(StringUtils.substringAfter(original, "/")); - } - } - return original; - } - - @Inject(method = "handleMouseInput", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiNewChat;scroll(I)V")) - private void handleMouseInput(CallbackInfo ci) { - ChatScrollingHook.INSTANCE.setShouldSmooth(true); - } -} diff --git a/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatAccessor.java b/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatAccessor.java deleted file mode 100644 index d4fd524..0000000 --- a/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatAccessor.java +++ /dev/null @@ -1,20 +0,0 @@ -package cc.woverflow.chatting.mixin; - -import net.minecraft.client.gui.ChatLine; -import net.minecraft.client.gui.GuiNewChat; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -import java.util.List; - -@Mixin(GuiNewChat.class) -public interface GuiNewChatAccessor { - @Accessor - List getDrawnChatLines(); - - @Accessor - List getChatLines(); - - @Accessor - int getScrollPos(); -} diff --git a/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMapMixin.java b/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMapMixin.java deleted file mode 100644 index 5b38bda..0000000 --- a/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMapMixin.java +++ /dev/null @@ -1,78 +0,0 @@ -package cc.woverflow.chatting.mixin; - -import cc.woverflow.chatting.hook.GuiNewChatHook; -import net.minecraft.client.gui.ChatLine; -import net.minecraft.client.gui.GuiNewChat; -import net.minecraft.util.IChatComponent; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.Unique; -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.LocalCapture; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -@Mixin(value = GuiNewChat.class, priority = Integer.MIN_VALUE) -public abstract class GuiNewChatMapMixin implements GuiNewChatHook { - - @Unique private final Map drawnToFull = new HashMap<>(); - @Unique private final List tempDrawnLines = new ArrayList<>(); - @Unique private ChatLine lastTempLine = null; - - @Shadow @Final private List drawnChatLines; - @Shadow @Final private List chatLines; - - @Inject(method = "setChatLine", at = @At("HEAD")) - private void handleSetChatLine(IChatComponent chatComponent, int chatLineId, int updateCounter, boolean displayOnly, CallbackInfo ci) { - tempDrawnLines.clear(); - } - - @Inject(method = "setChatLine", at = @At(value = "INVOKE", target = "Ljava/util/List;add(ILjava/lang/Object;)V", ordinal = 0, shift = At.Shift.AFTER, remap = false)) - private void handleDrawnLineAdded(IChatComponent chatComponent, int chatLineId, int updateCounter, boolean displayOnly, CallbackInfo ci) { - if (!displayOnly) tempDrawnLines.add(drawnChatLines.get(0)); - else if (lastTempLine != null) { - drawnToFull.put(drawnChatLines.get(0), lastTempLine); - } - } - - @Inject(method = "setChatLine", at = @At(value = "INVOKE", target = "Ljava/util/List;remove(I)Ljava/lang/Object;", ordinal = 0, shift = At.Shift.BEFORE, remap = false)) - private void handleDrawnLineRemoved(IChatComponent chatComponent, int chatLineId, int updateCounter, boolean displayOnly, CallbackInfo ci) { - drawnToFull.remove(drawnChatLines.get(drawnChatLines.size() - 1)); - } - - @Inject(method = "setChatLine", at = @At("RETURN")) - private void handleLineAdded(IChatComponent chatComponent, int chatLineId, int updateCounter, boolean displayOnly, CallbackInfo ci) { - if (!displayOnly) { - ChatLine masterLine = chatLines.get(0); - for (ChatLine tempDrawnLine : tempDrawnLines) drawnToFull.put(tempDrawnLine, masterLine); - }else { - lastTempLine = null; - } - } - - @Inject(method = "refreshChat", at = @At("HEAD")) - private void handleRefreshedChat(CallbackInfo ci) { - drawnToFull.clear(); - } - - @Inject(method = "refreshChat", locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiNewChat;setChatLine(Lnet/minecraft/util/IChatComponent;IIZ)V", ordinal = 0, shift = At.Shift.BEFORE)) - private void handleLineRefresh(CallbackInfo ci, int i, ChatLine chatline) { - lastTempLine = chatline; - } - - @Inject(method = "clearChatMessages", at = @At("HEAD")) - private void handleChatCleared(CallbackInfo ci) { - drawnToFull.clear(); - } - - @Override - public ChatLine getFullMessage(ChatLine line) { - return drawnToFull.getOrDefault(line, null); - } -} diff --git a/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin.java b/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin.java deleted file mode 100644 index e0a3b56..0000000 --- a/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin.java +++ /dev/null @@ -1,259 +0,0 @@ -package cc.woverflow.chatting.mixin; - -import cc.polyfrost.oneconfig.config.core.OneColor; -import cc.polyfrost.oneconfig.libs.universal.UMouse; -import cc.polyfrost.oneconfig.utils.Notifications; -import cc.woverflow.chatting.Chatting; -import cc.woverflow.chatting.chat.ChatSearchingManager; -import cc.woverflow.chatting.config.ChattingConfig; -import cc.woverflow.chatting.gui.components.CleanButton; -import cc.woverflow.chatting.hook.GuiNewChatHook; -import cc.woverflow.chatting.utils.ModCompatHooks; -import cc.woverflow.chatting.utils.RenderUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.*; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.MathHelper; -import net.minecraft.util.ResourceLocation; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.*; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.invoke.arg.Args; - -import java.awt.datatransfer.StringSelection; -import java.awt.datatransfer.Transferable; -import java.awt.image.BufferedImage; -import java.util.List; - -@Mixin(value = GuiNewChat.class, priority = 990) -public abstract class GuiNewChatMixin extends Gui implements GuiNewChatHook { - @Unique - private int chatting$right = 0; - @Unique - private boolean chatting$isHovering; - @Unique - private boolean chatting$chatCheck; - @Unique - private int chatting$textOpacity; - @Shadow - @Final - private Minecraft mc; - @Shadow - @Final - private List drawnChatLines; - @Shadow - public abstract boolean getChatOpen(); - - @Shadow - public abstract float getChatScale(); - - @Shadow - public abstract int getLineCount(); - - @Shadow - private int scrollPos; - - @Shadow public abstract int getChatWidth(); - - @Unique - private static final ResourceLocation COPY = new ResourceLocation("chatting:copy.png"); - @Unique - private static final ResourceLocation DELETE = new ResourceLocation("chatting:delete.png"); - - /*? - @Unique - private final SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss"); - @ModifyArg(method = "setChatLine", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/ChatLine;(ILnet/minecraft/util/IChatComponent;I)V")) - private IChatComponent handleAddDrawnLine(IChatComponent iChatComponent) { - if (!ChattingConfig.INSTANCE.getShowTimestamp()) return iChatComponent; - String time = " §7["+ sdf.format(new Date(System.currentTimeMillis())) + "]§r"; - iChatComponent.appendSibling(new ChatComponentText(time)); - return iChatComponent; - } - - */ - - @Inject(method = "drawChat", at = @At("HEAD")) - private void checkScreenshotKeybind(int j2, CallbackInfo ci) { - if (Chatting.INSTANCE.getKeybind().isPressed()) { - Chatting.INSTANCE.setDoTheThing(true); - } - chatting$chatCheck = false; - } - - @ModifyVariable(method = "drawChat", at = @At("HEAD"), argsOnly = true) - private int setUpdateCounterWhenYes(int updateCounter) { - return Chatting.INSTANCE.getDoTheThing() ? 0 : updateCounter; - } - - @ModifyVariable(method = "drawChat", at = @At("STORE"), index = 2) - private int setChatLimitWhenYes(int linesToDraw) { - return Chatting.INSTANCE.getDoTheThing() - ? GuiNewChat.calculateChatboxHeight(mc.gameSettings.chatHeightFocused) / 9 - : linesToDraw; - } - - private boolean lineInBounds = false; - - @ModifyArgs(method = "drawChat", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiNewChat;drawRect(IIIII)V"), slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/util/MathHelper;clamp_double(DDD)D"), to = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GlStateManager;enableBlend()V"))) - private void captureDrawRect(Args args) { - args.set(4, ChattingConfig.INSTANCE.getChatBackgroundColor().getRGB()); - if (mc.currentScreen instanceof GuiChat) { - int left = args.get(0); - int top = args.get(1); - int right = args.get(2); - int bottom = args.get(3); - if (isInBounds(left, top, right, bottom, getChatScale())) { - chatting$isHovering = true; - lineInBounds = true; - args.set(4, ChattingConfig.INSTANCE.getHoveredChatBackgroundColor().getRGB()); - } - } - } - - @ModifyArgs(method = "drawChat", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/FontRenderer;drawStringWithShadow(Ljava/lang/String;FFI)I")) - private void drawChatBox(Args args) { - if (mc.currentScreen instanceof GuiChat) { - float f = this.getChatScale(); - int left = 0; - int top = (int) ((float) args.get(2) - 1); - int right = MathHelper.ceiling_float_int((float)getChatWidth() / f) + 4; - int bottom = (int) ((float) args.get(2) + 8); - if ((chatting$isHovering && lineInBounds) || isInBounds(left, top, right, bottom, f)) { - chatting$isHovering = true; - drawCopyChatBox(right, top); - } - } - lineInBounds = false; - } - - private boolean isInBounds(int left, int top, int right, int bottom, float chatScale) { - int mouseX = MathHelper.floor_double(UMouse.getScaledX()) - 3; - int mouseY = MathHelper.floor_double(UMouse.getScaledY()) - 27 + ModCompatHooks.getYOffset() - ModCompatHooks.getChatPosition(); - mouseX = MathHelper.floor_float((float) mouseX / chatScale); - mouseY = -(MathHelper.floor_float((float) mouseY / chatScale)); //WHY DO I NEED TO DO THIS - return mouseX >= (left + ModCompatHooks.getXOffset()) && mouseY < bottom && mouseX < (right + 23 + ModCompatHooks.getXOffset()) && mouseY >= top; - } - - @ModifyVariable(method = "drawChat", at = @At("STORE"), ordinal = 7) - private int modifyYeah(int value) { - return chatting$textOpacity = (int) (((float) (getChatOpen() ? 255 : value)) * (mc.gameSettings.chatOpacity * 0.9F + 0.1F)); - } - /*/ - @Inject(method = "drawChat", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GlStateManager;scale(FFF)V")) - private void drawPre(int updateCounter, CallbackInfo ci) { - RenderUtils.timestampPre(); - } - - @Inject(method = "drawChat", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GlStateManager;popMatrix()V")) - private void drawPost(int updateCounter, CallbackInfo ci) { - RenderUtils.timestampPost(); - } - - */ - - @Inject(method = "drawChat", at = @At("RETURN")) - private void checkStuff(int j2, CallbackInfo ci) { - if (!chatting$chatCheck && chatting$isHovering) { - chatting$isHovering = false; - } - } - - @Override - public int getRight() { - return chatting$right; - } - - @Override - public boolean isHovering() { - return chatting$isHovering; - } - - private void drawCopyChatBox(int right, int top) { - chatting$chatCheck = true; - GlStateManager.enableRescaleNormal(); - GlStateManager.enableBlend(); - GlStateManager.enableDepth(); - GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); - GlStateManager.pushMatrix(); - mc.getTextureManager().bindTexture(COPY); - GlStateManager.enableRescaleNormal(); - GlStateManager.enableAlpha(); - GlStateManager.alphaFunc(516, 0.1f); - GlStateManager.enableBlend(); - GlStateManager.blendFunc(770, 771); - GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); - chatting$right = right; - drawModalRectWithCustomSizedTexture(right + 1, top, 0f, 0f, 9, 9, 9, 9); - drawRect(right + 1, top, right + 10, top + 9, (((right + ModCompatHooks.getXOffset() + 3) <= (UMouse.getScaledX() / mc.ingameGUI.getChatGUI().getChatScale()) && (right + ModCompatHooks.getXOffset()) + 13 > (UMouse.getScaledX() / mc.ingameGUI.getChatGUI().getChatScale())) ? ChattingConfig.INSTANCE.getChatButtonHoveredBackgroundColor().getRGB() : ChattingConfig.INSTANCE.getChatButtonBackgroundColor().getRGB())); - GlStateManager.disableAlpha(); - GlStateManager.disableRescaleNormal(); - mc.getTextureManager().bindTexture(DELETE); - GlStateManager.enableRescaleNormal(); - GlStateManager.enableAlpha(); - GlStateManager.alphaFunc(516, 0.1f); - GlStateManager.enableBlend(); - GlStateManager.blendFunc(770, 771); - GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); - drawModalRectWithCustomSizedTexture(right + 11, top, 0f, 0f, 9, 9, 9, 9); - drawRect(right + 11, top, right + 20, top + 9, (((right + ModCompatHooks.getXOffset() + 13) <= (UMouse.getScaledX() / mc.ingameGUI.getChatGUI().getChatScale()) && (right + ModCompatHooks.getXOffset()) + 23 > (UMouse.getScaledX() / mc.ingameGUI.getChatGUI().getChatScale())) ? ChattingConfig.INSTANCE.getChatButtonHoveredBackgroundColor().getRGB() : ChattingConfig.INSTANCE.getChatButtonBackgroundColor().getRGB())); - GlStateManager.disableLighting(); - GlStateManager.popMatrix(); - } - - @Override - public ChatLine getHoveredLine(int mouseY) { - if (this.getChatOpen()) { - ScaledResolution scaledresolution = new ScaledResolution(this.mc); - int i = scaledresolution.getScaleFactor(); - float f = this.getChatScale(); - int k = mouseY / i - 27 + ModCompatHooks.getYOffset() - ModCompatHooks.getChatPosition(); - k = MathHelper.floor_float((float) k / f); - - if (k >= 0) { - int l = Math.min(this.getLineCount(), this.drawnChatLines.size()); - - if (k < this.mc.fontRendererObj.FONT_HEIGHT * l + l) { - int i1 = k / this.mc.fontRendererObj.FONT_HEIGHT + this.scrollPos; - - if (i1 >= 0 && i1 < this.drawnChatLines.size()) { - List m = ChatSearchingManager.filterMessages(ChatSearchingManager.INSTANCE.getLastSearch(), this.drawnChatLines); - return m != null ? m.get(i1) : null; - } - - } - } - } - return null; - } - - @Override - public Transferable getChattingChatComponent(int mouseY) { - ChatLine subLine = getHoveredLine(mouseY); - if (subLine != null) { - ChatLine fullLine = this.getFullMessage(subLine); - if (GuiScreen.isShiftKeyDown()) { - if (fullLine != null) { - BufferedImage image = Chatting.INSTANCE.screenshotLine(subLine); - if (image != null) RenderUtils.copyToClipboard(image); - } - return null; - } - ChatLine line = GuiScreen.isCtrlKeyDown() ? subLine : fullLine; - String message = line == null ? "Could not find chat message." : line.getChatComponent().getFormattedText(); - String actualMessage = GuiScreen.isAltKeyDown() ? message : EnumChatFormatting.getTextWithoutFormattingCodes(message); - Notifications.INSTANCE.send("Chatting", line == null ? "Could not find chat message." : "Copied following text: " + actualMessage); - return new StringSelection(actualMessage); - } - return null; - } - - @Override - public int getTextOpacity() { - return chatting$textOpacity; - } -} diff --git a/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_ChatHeight.java b/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_ChatHeight.java deleted file mode 100644 index d0b4db1..0000000 --- a/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_ChatHeight.java +++ /dev/null @@ -1,21 +0,0 @@ -package cc.woverflow.chatting.mixin; - -import cc.woverflow.chatting.Chatting; -import cc.woverflow.chatting.config.ChattingConfig; -import net.minecraft.client.gui.GuiNewChat; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(GuiNewChat.class) -public abstract class GuiNewChatMixin_ChatHeight { - @Shadow public abstract boolean getChatOpen(); - - @Inject(method = "getChatHeight", at = @At("HEAD"), cancellable = true) - private void customHeight_getChatHeight(CallbackInfoReturnable cir) { - if (ChattingConfig.INSTANCE.getCustomChatHeight()) - cir.setReturnValue(Chatting.INSTANCE.getChatHeight(getChatOpen())); - } -} diff --git a/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_ChatSearching.java b/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_ChatSearching.java deleted file mode 100644 index b40ba52..0000000 --- a/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_ChatSearching.java +++ /dev/null @@ -1,31 +0,0 @@ -package cc.woverflow.chatting.mixin; - -import cc.woverflow.chatting.chat.ChatSearchingManager; -import net.minecraft.client.gui.ChatLine; -import net.minecraft.client.gui.GuiNewChat; -import net.minecraft.util.IChatComponent; -import org.objectweb.asm.Opcodes; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import java.util.List; - -@Mixin(GuiNewChat.class) -public class GuiNewChatMixin_ChatSearching { - @Shadow @Final private List drawnChatLines; - - @Inject(method = "setChatLine", at = @At("HEAD")) - private void handleSetChatLine(IChatComponent chatComponent, int chatLineId, int updateCounter, boolean displayOnly, CallbackInfo ci) { - ChatSearchingManager.getCache().invalidateAll(); - } - - @Redirect(method = "drawChat", at = @At(value = "FIELD", target = "Lnet/minecraft/client/gui/GuiNewChat;drawnChatLines:Ljava/util/List;", opcode = Opcodes.GETFIELD)) - private List injected(GuiNewChat instance) { - return ChatSearchingManager.filterMessages(ChatSearchingManager.INSTANCE.getLastSearch(), drawnChatLines); - } -} diff --git a/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_ChatTabs.java b/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_ChatTabs.java deleted file mode 100644 index d21097d..0000000 --- a/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_ChatTabs.java +++ /dev/null @@ -1,54 +0,0 @@ -package cc.woverflow.chatting.mixin; - -import cc.woverflow.chatting.chat.ChatTabs; -import cc.woverflow.chatting.config.ChattingConfig; -import cc.woverflow.chatting.utils.ModCompatHooks; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.ChatLine; -import net.minecraft.client.gui.GuiNewChat; -import net.minecraft.util.IChatComponent; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import java.util.List; - -@Mixin(value = GuiNewChat.class, priority = 990) -public abstract class GuiNewChatMixin_ChatTabs { - @Shadow @Final private Minecraft mc; - - @Shadow public abstract void deleteChatLine(int