From a6a47f8ce6f829c04ad111acc101877f6c7b0c22 Mon Sep 17 00:00:00 2001 From: XThe <101992755+SirXThe@users.noreply.github.com> Date: Mon, 8 May 2023 16:38:04 +0200 Subject: [PATCH] new: added silent lobby (#76) --- .../cc/woverflow/hytils/HytilsReborn.java | 2 + .../woverflow/hytils/config/HytilsConfig.java | 9 +++++ .../handlers/cache/BedLocationHandler.java | 11 +++--- .../modules/blockers/TipMessageRemover.java | 2 +- .../hytils/handlers/general/SoundHandler.java | 1 - .../handlers/language/LanguageHandler.java | 1 + .../lobby/armorstands/ArmorStandHider.java | 3 +- .../handlers/lobby/sound/SilentLobby.java | 37 +++++++++++++++++++ .../LayerArmorBaseMixin_HideIngameArmour.java | 2 +- 9 files changed, 59 insertions(+), 9 deletions(-) create mode 100644 src/main/java/cc/woverflow/hytils/handlers/lobby/sound/SilentLobby.java diff --git a/src/main/java/cc/woverflow/hytils/HytilsReborn.java b/src/main/java/cc/woverflow/hytils/HytilsReborn.java index 762326ff..5bed0334 100644 --- a/src/main/java/cc/woverflow/hytils/HytilsReborn.java +++ b/src/main/java/cc/woverflow/hytils/HytilsReborn.java @@ -51,6 +51,7 @@ import cc.woverflow.hytils.handlers.lobby.limbo.LimboTitle; import cc.woverflow.hytils.handlers.lobby.mysterybox.MysteryBoxStar; import cc.woverflow.hytils.handlers.lobby.npc.NPCHandler; +import cc.woverflow.hytils.handlers.lobby.sound.SilentLobby; import cc.woverflow.hytils.handlers.render.ChestHighlighter; import cc.woverflow.hytils.util.HypixelAPIUtils; import cc.woverflow.hytils.util.friends.FriendCache; @@ -170,6 +171,7 @@ private void registerHandlers() { eventBus.register(new LimboTitle()); eventBus.register(new LimboPmDing()); eventBus.register(new MysteryBoxStar()); + eventBus.register(new SilentLobby()); // specific games eventBus.register(new PitLagReducer()); diff --git a/src/main/java/cc/woverflow/hytils/config/HytilsConfig.java b/src/main/java/cc/woverflow/hytils/config/HytilsConfig.java index 9dd61dd6..35f649a4 100644 --- a/src/main/java/cc/woverflow/hytils/config/HytilsConfig.java +++ b/src/main/java/cc/woverflow/hytils/config/HytilsConfig.java @@ -1004,6 +1004,13 @@ public class HytilsConfig extends Config { ) public static boolean mysteryBoxStar = true; + @Switch( + name = "Silent Lobby", + description = "Prevent all sounds from playing when you are in a lobby.", + category = "Lobby", subcategory = "Sounds" + ) + public static boolean silentLobby; + @Switch( name = "Remove Limbo AFK Title", description = "Remove the AFK title when you get sent to limbo for being AFK.", @@ -1111,6 +1118,8 @@ public HytilsConfig() { addDependency("putInCaps", "notifyWhenKick"); + addListener("coloredBeds", () -> Minecraft.getMinecraft().renderGlobal.loadRenderers()); + addListener("heightOverlay", () -> Minecraft.getMinecraft().renderGlobal.loadRenderers()); addListener("overlayAmount", () -> { DarkColorUtils.invalidateCache(); diff --git a/src/main/java/cc/woverflow/hytils/handlers/cache/BedLocationHandler.java b/src/main/java/cc/woverflow/hytils/handlers/cache/BedLocationHandler.java index e3ed3bdc..7908d988 100644 --- a/src/main/java/cc/woverflow/hytils/handlers/cache/BedLocationHandler.java +++ b/src/main/java/cc/woverflow/hytils/handlers/cache/BedLocationHandler.java @@ -83,7 +83,7 @@ private int[] processColors(JsonArray array) { public int[] getBedLocations() { LocrawInfo locrawInfo = LocrawUtil.INSTANCE.getLocrawInfo(); - if (locations == null || locrawInfo == null || locrawInfo.getGameType() != LocrawInfo.GameType.BEDWARS) { + if (locations == null || locrawInfo == null || !LocrawUtil.INSTANCE.isInGame() || locrawInfo.getGameType() != LocrawInfo.GameType.BEDWARS || locrawInfo.getGameMode().equals("BEDWARS_PRACTICE")) { return (this.bedLocations = null); } if (!setDefault) { @@ -124,18 +124,19 @@ public int[] getBedLocations() { return (this.bedLocations = defaultBedLocations); } + @SuppressWarnings("unused") @Subscribe private void onLocraw(LocrawEvent event) { - if (!LocrawUtil.INSTANCE.isInGame() || event.info.getGameType() != LocrawInfo.GameType.BEDWARS || event.info.getGameMode().equals("BEDWARS_PRACTICE")) { - return; - } - String serverId = event.info.getServerId(); if (Objects.equals(lastServer, serverId)) { return; } lastServer = serverId; + if (!LocrawUtil.INSTANCE.isInGame() || event.info.getGameType() != LocrawInfo.GameType.BEDWARS) { + return; + } + bedLocations = null; if (getBedLocations() != null) { Minecraft.getMinecraft().renderGlobal.loadRenderers(); diff --git a/src/main/java/cc/woverflow/hytils/handlers/chat/modules/blockers/TipMessageRemover.java b/src/main/java/cc/woverflow/hytils/handlers/chat/modules/blockers/TipMessageRemover.java index 931c70d9..83bda480 100644 --- a/src/main/java/cc/woverflow/hytils/handlers/chat/modules/blockers/TipMessageRemover.java +++ b/src/main/java/cc/woverflow/hytils/handlers/chat/modules/blockers/TipMessageRemover.java @@ -27,7 +27,7 @@ public class TipMessageRemover implements ChatReceiveModule { @Override public void onMessageReceived(@NotNull ClientChatReceivedEvent event) { - String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText()); + String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText().replace("\n", "")); if (getLanguage().chatCleanerTipRegex.matcher(message).matches()) { event.setCanceled(true); } diff --git a/src/main/java/cc/woverflow/hytils/handlers/general/SoundHandler.java b/src/main/java/cc/woverflow/hytils/handlers/general/SoundHandler.java index c0a6c02c..147a47ea 100644 --- a/src/main/java/cc/woverflow/hytils/handlers/general/SoundHandler.java +++ b/src/main/java/cc/woverflow/hytils/handlers/general/SoundHandler.java @@ -49,7 +49,6 @@ public void onTick(TickEvent.ClientTickEvent e) { return; } else if (ticks == 20) { playSound(); - System.out.println(ticks); return; } if (ticks > 40) ticks = -1; diff --git a/src/main/java/cc/woverflow/hytils/handlers/language/LanguageHandler.java b/src/main/java/cc/woverflow/hytils/handlers/language/LanguageHandler.java index ea3baac7..9fe47b18 100644 --- a/src/main/java/cc/woverflow/hytils/handlers/language/LanguageHandler.java +++ b/src/main/java/cc/woverflow/hytils/handlers/language/LanguageHandler.java @@ -54,6 +54,7 @@ public LanguageHandler() { } private void initialize() { + fallback.initialize(); final String username = Minecraft.getMinecraft().getSession().getUsername(); final JsonObject json = NetworkUtils.getJsonElement("https://api.sk1er.club/player/" + username).getAsJsonObject(); final JsonObject player = json.getAsJsonObject("player"); diff --git a/src/main/java/cc/woverflow/hytils/handlers/lobby/armorstands/ArmorStandHider.java b/src/main/java/cc/woverflow/hytils/handlers/lobby/armorstands/ArmorStandHider.java index d7bb5621..1760567a 100644 --- a/src/main/java/cc/woverflow/hytils/handlers/lobby/armorstands/ArmorStandHider.java +++ b/src/main/java/cc/woverflow/hytils/handlers/lobby/armorstands/ArmorStandHider.java @@ -25,6 +25,7 @@ import cc.woverflow.hytils.handlers.cache.ArmorStandHandler; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityArmorStand; +import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.client.event.RenderLivingEvent; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; @@ -35,7 +36,7 @@ public void onEntityRenderer(RenderLivingEvent.Pre event) { final LocrawInfo locraw = LocrawUtil.INSTANCE.getLocrawInfo(); if (HypixelUtils.INSTANCE.isHypixel() && ((!LocrawUtil.INSTANCE.isInGame() && HytilsConfig.hideUselessArmorStands) || (HytilsConfig.hideUselessArmorStandsGame && LocrawUtil.INSTANCE.isInGame() && locraw != null && (locraw.getGameType() == LocrawInfo.GameType.SKYBLOCK || locraw.getGameType() == LocrawInfo.GameType.BEDWARS || locraw.getGameType() == LocrawInfo.GameType.SKYWARS || locraw.getGameMode().contains("BRIDGE"))))) { if (event.entity instanceof EntityArmorStand) { - String unformattedArmorStandName = event.entity.getCustomNameTag().toLowerCase(); + String unformattedArmorStandName = EnumChatFormatting.getTextWithoutFormattingCodes(event.entity.getCustomNameTag().toLowerCase()); for (String armorStands : ArmorStandHandler.INSTANCE.armorStandNames) { if (unformattedArmorStandName.contains(armorStands)) { event.setCanceled(true); diff --git a/src/main/java/cc/woverflow/hytils/handlers/lobby/sound/SilentLobby.java b/src/main/java/cc/woverflow/hytils/handlers/lobby/sound/SilentLobby.java new file mode 100644 index 00000000..ec4d44ab --- /dev/null +++ b/src/main/java/cc/woverflow/hytils/handlers/lobby/sound/SilentLobby.java @@ -0,0 +1,37 @@ +/* + * Hytils Reborn - Hypixel focused Quality of Life mod. + * Copyright (C) 2020, 2021, 2022, 2023 Polyfrost, Sk1er LLC and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package cc.woverflow.hytils.handlers.lobby.sound; + +import cc.polyfrost.oneconfig.utils.hypixel.HypixelUtils; +import cc.polyfrost.oneconfig.utils.hypixel.LocrawUtil; +import cc.woverflow.hytils.config.HytilsConfig; +import net.minecraftforge.client.event.sound.PlaySoundEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +public class SilentLobby { + + @SubscribeEvent + public void onSoundPlay(PlaySoundEvent event) { + if (HypixelUtils.INSTANCE.isHypixel() && !LocrawUtil.INSTANCE.isInGame() && HytilsConfig.silentLobby) { + if (!event.name.startsWith("gui.")) { + event.result = null; + } + } + } +} diff --git a/src/main/java/cc/woverflow/hytils/mixin/LayerArmorBaseMixin_HideIngameArmour.java b/src/main/java/cc/woverflow/hytils/mixin/LayerArmorBaseMixin_HideIngameArmour.java index d9eccf6e..284d184d 100644 --- a/src/main/java/cc/woverflow/hytils/mixin/LayerArmorBaseMixin_HideIngameArmour.java +++ b/src/main/java/cc/woverflow/hytils/mixin/LayerArmorBaseMixin_HideIngameArmour.java @@ -40,7 +40,7 @@ public abstract class LayerArmorBaseMixin_HideIngameArmour { @Inject(method = "renderLayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/layers/LayerArmorBase;getArmorModel(I)Lnet/minecraft/client/model/ModelBase;"), cancellable = true) private void cancelArmor(EntityLivingBase entitylivingbaseIn, float p_177182_2_, float p_177182_3_, float partialTicks, float p_177182_5_, float p_177182_6_, float p_177182_7_, float scale, int armorSlot, CallbackInfo ci) { - if (shouldCancel(getCurrentArmor(entitylivingbaseIn, armorSlot))) { + if (shouldCancel(getCurrentArmor(entitylivingbaseIn, armorSlot)) && !entitylivingbaseIn.isInvisible()) { ci.cancel(); } }