aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorMy-Name-Is-Jeff <37018278+My-Name-Is-Jeff@users.noreply.github.com>2021-07-17 19:30:21 -0400
committerMy-Name-Is-Jeff <37018278+My-Name-Is-Jeff@users.noreply.github.com>2021-07-17 19:30:21 -0400
commitff38bffdeff61a3a7e71a0683aef07bd73320289 (patch)
treee73ee6ad1439f470f08a141dce9729021a5533b0 /src/main
parentc47f812844efa027d63f5fa59aaf991671430a3a (diff)
downloadSkytilsMod-ff38bffdeff61a3a7e71a0683aef07bd73320289.tar.gz
SkytilsMod-ff38bffdeff61a3a7e71a0683aef07bd73320289.tar.bz2
SkytilsMod-ff38bffdeff61a3a7e71a0683aef07bd73320289.zip
SBA Chroma fix
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/skytils/skytilsmod/mixins/patcher/MixinFontRendererHook.java65
-rw-r--r--src/main/kotlin/skytils/skytilsmod/core/Config.kt8
-rw-r--r--src/main/resources/mixins.skytils.json1
3 files changed, 74 insertions, 0 deletions
diff --git a/src/main/java/skytils/skytilsmod/mixins/patcher/MixinFontRendererHook.java b/src/main/java/skytils/skytilsmod/mixins/patcher/MixinFontRendererHook.java
new file mode 100644
index 00000000..3e6d6260
--- /dev/null
+++ b/src/main/java/skytils/skytilsmod/mixins/patcher/MixinFontRendererHook.java
@@ -0,0 +1,65 @@
+/*
+ * 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.mixins.patcher;
+
+import net.minecraft.client.gui.FontRenderer;
+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.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+import skytils.skytilsmod.Skytils;
+
+import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodHandles;
+import java.lang.invoke.MethodType;
+
+@Pseudo
+@Mixin(targets = "club.sk1er.patcher.hooks.FontRendererHook", remap = false)
+public class MixinFontRendererHook {
+
+ MethodHandle sbaOverridePatcher = null;
+
+ @Dynamic
+ @Inject(method = "<init>", at = @At("RETURN"))
+ private void onCtor(FontRenderer fontRenderer, CallbackInfo ci) {
+ try {
+ Class<?> sbaClass = Class.forName("codes.biscuit.skyblockaddons.asm.hooks.FontRendererHook");
+ MethodType mt = MethodType.methodType(boolean.class, String.class);
+ sbaOverridePatcher = MethodHandles.publicLookup().findStatic(sbaClass, "shouldOverridePatcher", mt);
+ } catch (Throwable e) {
+ System.out.println("SBA override method not found.");
+ e.printStackTrace();
+ }
+ }
+
+ @Dynamic
+ @Inject(method = "renderStringAtPos", at = @At("HEAD"), cancellable = true)
+ private void overridePatcherFontRendererHook(String text, boolean shadow, CallbackInfoReturnable<Boolean> cir) {
+ try {
+ if (sbaOverridePatcher != null && Skytils.config != null && Skytils.config.fixSbaChroma) {
+ if ((boolean) sbaOverridePatcher.invokeExact(text)) cir.setReturnValue(false);
+ }
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/src/main/kotlin/skytils/skytilsmod/core/Config.kt b/src/main/kotlin/skytils/skytilsmod/core/Config.kt
index 34b6f246..4ef6e07e 100644
--- a/src/main/kotlin/skytils/skytilsmod/core/Config.kt
+++ b/src/main/kotlin/skytils/skytilsmod/core/Config.kt
@@ -946,6 +946,14 @@ class Config : Vigilant(File("./config/skytils/config.toml"), "Skytils", sorting
)
var hollowChatCoords = false
+ @Property(
+ type = PropertyType.SWITCH, name = "Fix SBA Chroma",
+ description = "Fixes SBA chroma with Patcher 1.6",
+ category = "Miscellaneous", subcategory = "Fixes"
+ )
+ @JvmField
+ var fixSbaChroma = false
+
/*
@Property(
type = PropertyType.SWITCH, name = "Block Useless Zombie Sword",
diff --git a/src/main/resources/mixins.skytils.json b/src/main/resources/mixins.skytils.json
index a190e72f..c30fa36b 100644
--- a/src/main/resources/mixins.skytils.json
+++ b/src/main/resources/mixins.skytils.json
@@ -34,6 +34,7 @@
"neu.MixinGuiProfileViewer",
"neu.MixinStorageManager",
"neu.MixinTradeWindow",
+ "patcher.MixinFontRendererHook",
"renderer.MixinBlockRendererDispatcher",
"renderer.MixinEntityRenderer",
"renderer.MixinInventoryEffectRenderer",