diff --git a/build.gradle.kts b/build.gradle.kts index ccab9ea..90ae6f4 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -57,7 +57,7 @@ loom { if (project.platform.isLegacyForge) { runConfigs { "client" { - programArgs("--tweakClass", "co.skyclient.scc.hooks.ReplacedModRemover") + programArgs("--tweakClass", "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker") property("mixin.debug.export", "true") } } @@ -192,7 +192,7 @@ tasks { "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.scc.json", // We want to use our mixin configuration, so we specify it here. - "TweakClass" to "co.skyclient.scc.hooks.ReplacedModRemover" // Loads the OneConfig launch wrapper. + "TweakClass" to "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker" // Loads the OneConfig launch wrapper. ) } dependsOn(shadowJar) diff --git a/gradle.properties b/gradle.properties index 7c7a208..fd13a4c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ mod_id=skyclientcosmetics mod_name=SkyClientCosmetics -mod_version=1.2.0 +mod_version=1.2.1 mod_archives_name=SkyClientCosmetics # Gradle Configuration -- DO NOT TOUCH THESE VALUES. diff --git a/src/main/java/co/skyclient/scc/SkyclientCosmetics.java b/src/main/java/co/skyclient/scc/SkyclientCosmetics.java index faa18b0..cfda0c4 100644 --- a/src/main/java/co/skyclient/scc/SkyclientCosmetics.java +++ b/src/main/java/co/skyclient/scc/SkyclientCosmetics.java @@ -90,7 +90,7 @@ public void onPreInit(FMLPreInitializationEvent event) { Files.setup(); - progress.step("Loading Vigilance"); + progress.step("Loading config"); config = new Settings(); config.preload(); diff --git a/src/main/java/co/skyclient/scc/hooks/GuiPlayerTabOverlayHook.java b/src/main/java/co/skyclient/scc/hooks/GuiPlayerTabOverlayHook.java new file mode 100644 index 0000000..50a1978 --- /dev/null +++ b/src/main/java/co/skyclient/scc/hooks/GuiPlayerTabOverlayHook.java @@ -0,0 +1,23 @@ +package co.skyclient.scc.hooks; + +import cc.polyfrost.oneconfig.utils.hypixel.HypixelUtils; +import co.skyclient.scc.SkyclientCosmetics; +import co.skyclient.scc.config.Settings; +import co.skyclient.scc.cosmetics.Tag; +import net.minecraft.client.network.NetworkPlayerInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +public class GuiPlayerTabOverlayHook { + public static void iHateMixinZeroPointSeven(NetworkPlayerInfo networkPlayerInfoIn, CallbackInfoReturnable cir) { + if (SkyclientCosmetics.config.enabled) { + if (Settings.showTags) { + if (HypixelUtils.INSTANCE.isHypixel()) { + Tag tag = ((NetworkPlayerInfoHook) networkPlayerInfoIn).scc$getTag(); + if (tag != null) { + cir.setReturnValue(tag.getTag() + " " + cir.getReturnValue()); + } + } + } + } + } +} diff --git a/src/main/java/co/skyclient/scc/hooks/ReplacedModRemover.java b/src/main/java/co/skyclient/scc/hooks/ReplacedModRemover.java deleted file mode 100644 index 3e319c4..0000000 --- a/src/main/java/co/skyclient/scc/hooks/ReplacedModRemover.java +++ /dev/null @@ -1,151 +0,0 @@ -package co.skyclient.scc.hooks; - -import cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import com.google.gson.stream.MalformedJsonException; -import net.minecraft.launchwrapper.ITweaker; -import net.minecraft.launchwrapper.Launch; -import net.minecraft.launchwrapper.LaunchClassLoader; -import net.minecraftforge.fml.relauncher.CoreModManager; -import org.apache.logging.log4j.LogManager; -import org.spongepowered.asm.launch.MixinBootstrap; -import org.spongepowered.asm.launch.MixinTweaker; - -import java.io.File; -import java.io.InputStream; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; -import java.security.CodeSource; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; - -public class ReplacedModRemover extends LaunchWrapperTweaker { - private static final JsonParser PARSER = new JsonParser(); - - @Override - public void injectIntoClassLoader(LaunchClassLoader classLoader) { - try { - File modsFolder = new File(Launch.minecraftHome, "mods"); - HashMap> modsMap = new HashMap<>(); //modid : file, version, name - File[] modFolder = modsFolder.listFiles((dir, name) -> name.endsWith(".jar")); - if (modFolder != null) { - for (File file : modFolder) { - try { - try (ZipFile mod = new ZipFile(file)) { - ZipEntry entry = mod.getEntry("mcmod.info"); - if (entry != null) { - try (InputStream inputStream = mod.getInputStream(entry)) { - byte[] availableBytes = new byte[inputStream.available()]; - inputStream.read(availableBytes, 0, inputStream.available()); - JsonObject modInfo = PARSER.parse(new String(availableBytes)).getAsJsonArray().get(0).getAsJsonObject(); - if (!modInfo.has("modid") || !modInfo.has("version")) { - continue; - } - - String modid = modInfo.get("modid").getAsString().toLowerCase(Locale.ENGLISH); - if (!modsMap.containsKey(modid)) { - modsMap.put(modid, new Triple<>(file, modInfo.get("version").getAsString(), modInfo.has("name") ? modInfo.get("name").getAsString() : modid)); - } - } - } - } - } catch (MalformedJsonException | IllegalStateException ignored) { - } catch (Exception e) { - e.printStackTrace(); - } - } - } - - if (modsMap.containsKey("itlt")) { - tryDeleting(modsMap.get("itlt").first); - } - if (modsMap.containsKey("custommainmenu")) { - tryDeleting(modsMap.get("custommainmenu").first); - } - } catch (Exception e) { - e.printStackTrace(); - } - - CodeSource codeSource = this.getClass().getProtectionDomain().getCodeSource(); - if (codeSource != null) { - URL location = codeSource.getLocation(); - try { - File file = new File(location.toURI()); - if (file.isFile()) { - CoreModManager.getIgnoredMods().remove(file.getName()); - CoreModManager.getReparseableCoremods().add(file.getName()); - try { - try { - List tweakClasses = (List) Launch.blackboard.get("TweakClasses"); // tweak classes before other mod trolling - if (tweakClasses.contains("org.spongepowered.asm.launch.MixinTweaker")) { // if there's already a mixin tweaker, we'll just load it like "usual" - new MixinTweaker(); // also we might not need to make a new mixin tweawker all the time but im just making sure - } else if (!Launch.blackboard.containsKey("mixin.initialised")) { // if there isnt, we do our own trolling - List tweaks = (List) Launch.blackboard.get("Tweaks"); - tweaks.add(new MixinTweaker()); - } - } catch (Exception ignored) { - // if it fails i *think* we can just ignore it - } - try { - MixinBootstrap.getPlatform().addContainer(location.toURI()); - } catch (Exception ignore) { - // fuck you essential - try { - Class containerClass = Class.forName("org.spongepowered.asm.launch.platform.container.IContainerHandle"); - Class urlContainerClass = Class.forName("org.spongepowered.asm.launch.platform.container.ContainerHandleURI"); - Object container = urlContainerClass.getConstructor(URI.class).newInstance(location.toURI()); - MixinBootstrap.getPlatform().getClass().getDeclaredMethod("addContainer", containerClass).invoke(MixinBootstrap.getPlatform(), container); - } catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException("OneConfig's Mixin loading failed. Please contact https://polyfrost.org/discord to resolve this issue!"); - } - } - } catch (Exception ignored) { - - } - } - } catch (URISyntaxException ignored) {} - } else { - LogManager.getLogger().warn("No CodeSource, if this is not a development environment we might run into problems!"); - LogManager.getLogger().warn(this.getClass().getProtectionDomain()); - } - - super.injectIntoClassLoader(classLoader); - } - - private void tryDeleting(File file) { - if (!file.delete()) { - if (!file.delete()) { - if (!file.delete()) { - file.deleteOnExit(); - } - } - } - } - - public static class Triple { - public A first; - public B second; - public C third; - - public Triple(A a, B b, C c) { - first = a; - second = b; - third = c; - } - - @Override - public String toString() { - return "Triple{" + - "first=" + first + - ", second=" + second + - ", third=" + third + - '}'; - } - } -} diff --git a/src/main/java/co/skyclient/scc/listeners/TagListeners.java b/src/main/java/co/skyclient/scc/listeners/TagListeners.java index b1e348a..a9153df 100644 --- a/src/main/java/co/skyclient/scc/listeners/TagListeners.java +++ b/src/main/java/co/skyclient/scc/listeners/TagListeners.java @@ -48,7 +48,7 @@ public class TagListeners { private static final HashMap filteredPotentialRanks = new HashMap<>(50); public static Map nametags = new HashMap<>(400); - @SubscribeEvent + @SubscribeEvent(priority = EventPriority.LOWEST) public void onChatMsgTags(ClientChatReceivedEvent event) { if (SkyclientCosmetics.config.enabled && Settings.showTags && HypixelUtils.INSTANCE.isHypixel()) { try { @@ -72,7 +72,7 @@ public void onChatMsgTags(ClientChatReceivedEvent event) { } } - @SubscribeEvent + @SubscribeEvent(priority = EventPriority.LOWEST) public void onTooltip(ItemTooltipEvent event) { if (SkyclientCosmetics.config.enabled && Settings.showTags && HypixelUtils.INSTANCE.isHypixel()) { for (int i = 0; i < event.toolTip.size(); i++) { @@ -87,7 +87,7 @@ public void onTooltip(ItemTooltipEvent event) { } } - @SubscribeEvent(priority = EventPriority.LOW) + @SubscribeEvent(priority = EventPriority.LOWEST) public void onRenderLiving(RenderLivingEvent.Specials.Pre event) { if (SkyclientCosmetics.config.enabled && Settings.showTags && HypixelUtils.INSTANCE.isHypixel()) { Entity entity = event.entity; @@ -115,7 +115,7 @@ public void onRenderLiving(RenderLivingEvent.Specials.Pre even } } - @SubscribeEvent + @SubscribeEvent(priority = EventPriority.LOWEST) public void onWorldChange(WorldEvent.Load event) { nametags.clear(); } diff --git a/src/main/java/co/skyclient/scc/mixins/GuiPlayerTabOverlayMixin.java b/src/main/java/co/skyclient/scc/mixins/GuiPlayerTabOverlayMixin.java index 160637e..022ce31 100644 --- a/src/main/java/co/skyclient/scc/mixins/GuiPlayerTabOverlayMixin.java +++ b/src/main/java/co/skyclient/scc/mixins/GuiPlayerTabOverlayMixin.java @@ -1,10 +1,6 @@ package co.skyclient.scc.mixins; -import cc.polyfrost.oneconfig.utils.hypixel.HypixelUtils; -import co.skyclient.scc.SkyclientCosmetics; -import co.skyclient.scc.config.Settings; -import co.skyclient.scc.cosmetics.Tag; -import co.skyclient.scc.hooks.NetworkPlayerInfoHook; +import co.skyclient.scc.hooks.GuiPlayerTabOverlayHook; import net.minecraft.client.gui.GuiPlayerTabOverlay; import net.minecraft.client.network.NetworkPlayerInfo; import org.spongepowered.asm.mixin.Mixin; @@ -16,11 +12,6 @@ public class GuiPlayerTabOverlayMixin { @Inject(method = "getPlayerName", at = @At("RETURN"), cancellable = true) private void getPlayerName(NetworkPlayerInfo networkPlayerInfoIn, CallbackInfoReturnable cir) { - if (SkyclientCosmetics.config.enabled && Settings.showTags && HypixelUtils.INSTANCE.isHypixel()) { - Tag tag = ((NetworkPlayerInfoHook) networkPlayerInfoIn).scc$getTag(); - if (tag != null) { - cir.setReturnValue(tag.getTag() + " " + cir.getReturnValue()); - } - } + GuiPlayerTabOverlayHook.iHateMixinZeroPointSeven(networkPlayerInfoIn, cir); } }