Skip to content

Commit

Permalink
fix: resolve bossbar features not working with VanillaHUD
Browse files Browse the repository at this point in the history
  • Loading branch information
xthe-dev committed Aug 30, 2023
1 parent ff9d94a commit a158a6c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
2 changes: 0 additions & 2 deletions src/main/java/cc/woverflow/hytils/HytilsReborn.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,25 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

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();
}
}
1 change: 1 addition & 0 deletions src/main/resources/mixins.hytils.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"refmap": "mixins.hytils.refmap.json",
"verbose": true,
"client": [
"BossStatusMixin_HideBossbar",
"CommandLimboMixin_FixCommand",
"EntityLivingBaseMixin_MiningFatigue",
"EntityPlayerSPMixin_MessageHandling",
Expand Down

0 comments on commit a158a6c

Please sign in to comment.