diff options
author | My-Name-Is-Jeff <37018278+My-Name-Is-Jeff@users.noreply.github.com> | 2021-09-08 01:32:27 -0400 |
---|---|---|
committer | My-Name-Is-Jeff <37018278+My-Name-Is-Jeff@users.noreply.github.com> | 2021-09-08 01:36:24 -0400 |
commit | 4f7add0a130a120c09654db5c168e2a875f3e209 (patch) | |
tree | c5eed51241ad44fed7a3bd83ccd0b3533231ccc5 | |
parent | c549fea59b0c0457da7ba0e050b5eb6bd0835468 (diff) | |
download | SkytilsMod-4f7add0a130a120c09654db5c168e2a875f3e209.tar.gz SkytilsMod-4f7add0a130a120c09654db5c168e2a875f3e209.tar.bz2 SkytilsMod-4f7add0a130a120c09654db5c168e2a875f3e209.zip |
asm professional here
yes its deprecated but who cares
5 files changed, 103 insertions, 2 deletions
diff --git a/build.gradle.kts b/build.gradle.kts index 607a449c..e960561b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -42,7 +42,8 @@ minecraft { setOf( "-Dfml.coreMods.load=skytils.skytilsmod.tweaker.SkytilsLoadingPlugin", "-Delementa.dev=true", - "-Delementa.debug=true" + "-Delementa.debug=true", + "-Dasmhelper.verbose=true" ) ) clientRunArgs.addAll( @@ -76,6 +77,15 @@ dependencies { shadowMe("com.github.Skytils:Hylin:a9899c8c03") { exclude(module = "kotlin-reflect") exclude(module = "kotlin-stdlib-jdk8") + exclude(module = "kotlin-stdlib-jdk7") + exclude(module = "kotlin-stdlib") + exclude(module = "kotlinx-coroutines-core") + } + shadowMe("com.github.Skytils:AsmHelper:5e61aebfae") { + exclude(module = "kotlin-reflect") + exclude(module = "kotlin-stdlib-jdk8") + exclude(module = "kotlin-stdlib-jdk7") + exclude(module = "kotlin-stdlib") exclude(module = "kotlinx-coroutines-core") } } @@ -127,6 +137,7 @@ tasks { relocate("org.apache.hc", "skytils.apacheorg.hc") relocate("org.apache.commons.codec", "skytils.apacheorg.commons.codec") + relocate("dev.falsehonesty.asmhelper", "skytils.asmhelper") exclude( "**/LICENSE.md", diff --git a/src/main/java/skytils/skytilsmod/tweaker/SkytilsLoadingPlugin.java b/src/main/java/skytils/skytilsmod/tweaker/SkytilsLoadingPlugin.java index ea3efb37..59415ace 100644 --- a/src/main/java/skytils/skytilsmod/tweaker/SkytilsLoadingPlugin.java +++ b/src/main/java/skytils/skytilsmod/tweaker/SkytilsLoadingPlugin.java @@ -33,6 +33,8 @@ import java.net.URISyntaxException; import java.net.URL; import java.util.Map; +@IFMLLoadingPlugin.Name("Skytils On Top") +@IFMLLoadingPlugin.SortingIndex(69) public class SkytilsLoadingPlugin implements IFMLLoadingPlugin { public static final String missingDependency = diff --git a/src/main/kotlin/skytils/skytilsmod/asm/SkytilsTransformer.kt b/src/main/kotlin/skytils/skytilsmod/asm/SkytilsTransformer.kt new file mode 100644 index 00000000..b2a87b5f --- /dev/null +++ b/src/main/kotlin/skytils/skytilsmod/asm/SkytilsTransformer.kt @@ -0,0 +1,33 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +package skytils.skytilsmod.asm + +import dev.falsehonesty.asmhelper.BaseClassTransformer +import skytils.skytilsmod.asm.transformers.addColoredNamesCheck + +class SkytilsTransformer : BaseClassTransformer() { + var transformed = false + + override fun makeTransformers() { + if (!transformed) { + transformed = true + addColoredNamesCheck() + } + } +}
\ No newline at end of file diff --git a/src/main/kotlin/skytils/skytilsmod/asm/transformers/DSMColoredNamesTransformer.kt b/src/main/kotlin/skytils/skytilsmod/asm/transformers/DSMColoredNamesTransformer.kt new file mode 100644 index 00000000..0d577dca --- /dev/null +++ b/src/main/kotlin/skytils/skytilsmod/asm/transformers/DSMColoredNamesTransformer.kt @@ -0,0 +1,55 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +package skytils.skytilsmod.asm.transformers + +import dev.falsehonesty.asmhelper.dsl.modify +import net.minecraft.entity.Entity +import org.objectweb.asm.Opcodes +import org.objectweb.asm.tree.MethodInsnNode + +fun addColoredNamesCheck() = modify("me.Danker.features.ColouredNames") { + findMethod("onRenderLiving", "(Lnet.minecraftforge.client.event.RenderLivingEvent.Specials.Pre;)V").also { n -> + for (insn in n.instructions) { + if (insn is MethodInsnNode) { + if (insn.owner == "net/minecraft/entity/Entity" && insn.name == "func_145818_k_" && insn.desc == "()Z") { + n.instructions.insert( + insn, + MethodInsnNode( + Opcodes.INVOKESTATIC, + "skytils/skytilsmod/asm/transformers/DSMColoredNamesTransformer", + "modifyColoredNamesCheck", + "(Lnet/minecraft/entity/Entity;)Z" + ) + ) + n.instructions.remove(insn) + break + } + } + } + } +} + +object DSMColoredNamesTransformer { + @JvmStatic + fun modifyColoredNamesCheck(entity: Entity): Boolean { + val customName = entity.customNameTag + return customName.isNotEmpty() && !customName.endsWith("§c❤") && !customName + .endsWith(" Hits") + } +}
\ No newline at end of file diff --git a/src/main/kotlin/skytils/skytilsmod/tweaker/SkytilsLoadingPluginKt.kt b/src/main/kotlin/skytils/skytilsmod/tweaker/SkytilsLoadingPluginKt.kt index 2e1882d3..8cdf0750 100644 --- a/src/main/kotlin/skytils/skytilsmod/tweaker/SkytilsLoadingPluginKt.kt +++ b/src/main/kotlin/skytils/skytilsmod/tweaker/SkytilsLoadingPluginKt.kt @@ -134,7 +134,7 @@ class SkytilsLoadingPluginKt : IFMLLoadingPlugin { } override fun getASMTransformerClass(): Array<String> { - return emptyArray() + return arrayOf("skytils.skytilsmod.asm.SkytilsTransformer") } override fun getModContainerClass(): String? { |