diff --git a/src/main/java/cc/woverflow/hytils/HytilsReborn.java b/src/main/java/cc/woverflow/hytils/HytilsReborn.java index 8a68c903..d698f0ff 100644 --- a/src/main/java/cc/woverflow/hytils/HytilsReborn.java +++ b/src/main/java/cc/woverflow/hytils/HytilsReborn.java @@ -46,7 +46,6 @@ import cc.woverflow.hytils.handlers.general.SoundHandler; import cc.woverflow.hytils.handlers.language.LanguageHandler; import cc.woverflow.hytils.handlers.lobby.armorstands.ArmorStandHider; -import cc.woverflow.hytils.handlers.lobby.bossbar.LobbyBossbar; import cc.woverflow.hytils.handlers.lobby.limbo.LimboLimiter; import cc.woverflow.hytils.handlers.lobby.limbo.LimboPmDing; import cc.woverflow.hytils.handlers.lobby.limbo.LimboTitle; @@ -167,7 +166,6 @@ private void registerHandlers() { // lobby eventBus.register(new ArmorStandHider()); eventBus.register(new NPCHandler()); - eventBus.register(new LobbyBossbar()); eventBus.register(new LimboLimiter()); eventBus.register(new LimboTitle()); eventBus.register(new LimboPmDing()); diff --git a/src/main/java/cc/woverflow/hytils/handlers/lobby/bossbar/LobbyBossbar.java b/src/main/java/cc/woverflow/hytils/mixin/BossStatusMixin_HideBossbar.java similarity index 52% rename from src/main/java/cc/woverflow/hytils/handlers/lobby/bossbar/LobbyBossbar.java rename to src/main/java/cc/woverflow/hytils/mixin/BossStatusMixin_HideBossbar.java index 9ab8a493..a8255771 100644 --- a/src/main/java/cc/woverflow/hytils/handlers/lobby/bossbar/LobbyBossbar.java +++ b/src/main/java/cc/woverflow/hytils/mixin/BossStatusMixin_HideBossbar.java @@ -16,22 +16,25 @@ * along with this program. If not, see . */ -package cc.woverflow.hytils.handlers.lobby.bossbar; +package cc.woverflow.hytils.mixin; import cc.polyfrost.oneconfig.utils.hypixel.LocrawUtil; import cc.woverflow.hytils.HytilsReborn; import cc.woverflow.hytils.config.HytilsConfig; import net.minecraft.entity.boss.BossStatus; -import net.minecraftforge.client.event.RenderGameOverlayEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraft.entity.boss.IBossDisplayData; +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; -public class LobbyBossbar { +@Mixin(BossStatus.class) +public abstract class BossStatusMixin_HideBossbar { - @SubscribeEvent - public void onBossbarRender(RenderGameOverlayEvent.Pre event) { - if (event.type == RenderGameOverlayEvent.ElementType.BOSSHEALTH && BossStatus.bossName != null && - ((HytilsConfig.gameAdBossbar && BossStatus.bossName.matches(HytilsReborn.INSTANCE.getLanguageHandler().getCurrent().gameBossbarAdvertisementRegex.pattern())) || (HytilsConfig.lobbyBossbar && LocrawUtil.INSTANCE.getLocrawInfo() != null && !LocrawUtil.INSTANCE.isInGame()))) { - event.setCanceled(true); - } + @Inject(method = "setBossStatus", at = @At("HEAD"), cancellable = true) + private static void cancelBossStatus(IBossDisplayData displayData, boolean hasColorModifierIn, CallbackInfo ci) { + if (displayData == null) return; + if (HytilsConfig.lobbyBossbar && !LocrawUtil.INSTANCE.isInGame() || HytilsConfig.gameAdBossbar && displayData.getDisplayName().getFormattedText().matches(HytilsReborn.INSTANCE.getLanguageHandler().getCurrent().gameBossbarAdvertisementRegex.pattern())) + ci.cancel(); } } diff --git a/src/main/resources/mixins.hytils.json b/src/main/resources/mixins.hytils.json index 5a1a242f..685b7201 100644 --- a/src/main/resources/mixins.hytils.json +++ b/src/main/resources/mixins.hytils.json @@ -6,6 +6,7 @@ "refmap": "mixins.hytils.refmap.json", "verbose": true, "client": [ + "BossStatusMixin_HideBossbar", "CommandLimboMixin_FixCommand", "EntityLivingBaseMixin_MiningFatigue", "EntityPlayerSPMixin_MessageHandling",