src/main/java/codes/biscuit/skyblockaddons/listeners/PlayerListener.java
/**
     * The main timer for the magma boss checker.
     */
The main timer for the magma boss checker.
The main timer for the magma boss checker .
@SubscribeEvent()
    public void onClientTickMagma(TickEvent.ClientTickEvent e) {
        if (e.phase == TickEvent.Phase.START) {
            Minecraft mc = Minecraft.getMinecraft();
            if (main.getConfigValues().isEnabled(Feature.MAGMA_WARNING) && main.getUtils().isOnSkyblock()) {
                if (mc != null && mc.theWorld != null) {
                    if (magmaTick % 5 == 0) {
                        boolean foundBoss = false;
                        long currentTime = System.currentTimeMillis();
                        for (Entity entity : mc.theWorld.loadedEntityList) { 
                            if (entity instanceof EntityMagmaCube) {
                                EntitySlime magma = (EntitySlime) entity;
                                if (magma.getSlimeSize() > 10) { 
                                    foundBoss = true;
                                    if ((lastBoss == -1 || System.currentTimeMillis() - lastBoss > 1800000)) {
                                        lastBoss = System.currentTimeMillis();
                                        main.getRenderListener().setTitleFeature(Feature.MAGMA_WARNING); 
                                        magmaTick = 16; 
                                        main.getScheduler().schedule(Scheduler.CommandType.RESET_TITLE_FEATURE, main.getConfigValues().getWarningSeconds());
                                    }
                                    magmaAccuracy = EnumUtils.MagmaTimerAccuracy.SPAWNED;
                                    if (currentTime - lastBossSpawnPost > 300000) {
                                        lastBossSpawnPost = currentTime;
                                        main.getUtils().sendPostRequest(EnumUtils.MagmaEvent.BOSS_SPAWN);
                                    }
                                }
                            }
                        }
                        if (!foundBoss && main.getRenderListener().getTitleFeature() == Feature.MAGMA_WARNING) {
                            main.getRenderListener().setTitleFeature(null);
                        }
                        if (!foundBoss && magmaAccuracy == EnumUtils.MagmaTimerAccuracy.SPAWNED) {
                            magmaAccuracy = EnumUtils.MagmaTimerAccuracy.ABOUT;
                            setMagmaTime(7200, true);
                            if (currentTime - lastBossDeathPost > 300000) {
                                lastBossDeathPost = currentTime;
                                main.getUtils().sendPostRequest(EnumUtils.MagmaEvent.BOSS_DEATH);
                            }
                        }
                    }
                    if (main.getRenderListener().getTitleFeature() == Feature.MAGMA_WARNING && magmaTick % 4 == 0) { 
                        main.getUtils().playLoudSound("random.orb", 0.5);
                    }
                }
            }
            magmaTick++;
            if (magmaTick > 20) {
                if ((magmaAccuracy == EnumUtils.MagmaTimerAccuracy.EXACTLY || magmaAccuracy == EnumUtils.MagmaTimerAccuracy.ABOUT)
                        && magmaTime == 0) {
                    magmaAccuracy = EnumUtils.MagmaTimerAccuracy.SPAWNED_PREDICTION;
                    main.getScheduler().schedule(Scheduler.CommandType.RESET_MAGMA_PREDICTION, 20);
                }
                magmaTime--;
                magmaTick = 1;
            }
        }
    }
@ SubscribeEvent ( ) public void onClientTickMagma ( TickEvent . ClientTickEvent e ) { if ( e . phase == TickEvent . Phase . START ) { Minecraft mc = Minecraft . getMinecraft ( ) ; if ( main . getConfigValues ( ) . isEnabled ( Feature . MAGMA_WARNING ) && main . getUtils ( ) . isOnSkyblock ( ) ) { if ( mc != null && mc . theWorld != null ) { if ( magmaTick % 5 == 0 ) { boolean foundBoss = false ; long currentTime = System . currentTimeMillis ( ) ; for ( Entity entity : mc . theWorld . loadedEntityList ) { if ( entity instanceof EntityMagmaCube ) { EntitySlime magma = ( EntitySlime ) entity ; if ( magma . getSlimeSize ( ) > 10 ) { foundBoss = true ; if ( ( lastBoss == - 1 || System . currentTimeMillis ( ) - lastBoss > 1800000 ) ) { lastBoss = System . currentTimeMillis ( ) ; main . getRenderListener ( ) . setTitleFeature ( Feature . MAGMA_WARNING ) ; magmaTick = 16 ; main . getScheduler ( ) . schedule ( Scheduler . CommandType . RESET_TITLE_FEATURE , main . getConfigValues ( ) . getWarningSeconds ( ) ) ; } magmaAccuracy = EnumUtils . MagmaTimerAccuracy . SPAWNED ; if ( currentTime - lastBossSpawnPost > 300000 ) { lastBossSpawnPost = currentTime ; main . getUtils ( ) . sendPostRequest ( EnumUtils . MagmaEvent . BOSS_SPAWN ) ; } } } } if ( ! foundBoss && main . getRenderListener ( ) . getTitleFeature ( ) == Feature . MAGMA_WARNING ) { main . getRenderListener ( ) . setTitleFeature ( null ) ; } if ( ! foundBoss && magmaAccuracy == EnumUtils . MagmaTimerAccuracy . SPAWNED ) { magmaAccuracy = EnumUtils . MagmaTimerAccuracy . ABOUT ; setMagmaTime ( 7200 , true ) ; if ( currentTime - lastBossDeathPost > 300000 ) { lastBossDeathPost = currentTime ; main . getUtils ( ) . sendPostRequest ( EnumUtils . MagmaEvent . BOSS_DEATH ) ; } } } if ( main . getRenderListener ( ) . getTitleFeature ( ) == Feature . MAGMA_WARNING && magmaTick % 4 == 0 ) { main . getUtils ( ) . playLoudSound ( "random.orb" , 0.5 ) ; } } } magmaTick ++ ; if ( magmaTick > 20 ) { if ( ( magmaAccuracy == EnumUtils . MagmaTimerAccuracy . EXACTLY || magmaAccuracy == EnumUtils . MagmaTimerAccuracy . ABOUT ) && magmaTime == 0 ) { magmaAccuracy = EnumUtils . MagmaTimerAccuracy . SPAWNED_PREDICTION ; main . getScheduler ( ) . schedule ( Scheduler . CommandType . RESET_MAGMA_PREDICTION , 20 ) ; } magmaTime -- ; magmaTick = 1 ; } } }
The main timer for the magma boss checker.
The main timer for the magma boss checker .
// Loop through all the entities. // Find a big magma boss // Enable warning and disable again in four seconds. // so the sound plays instantly //                                logServer(mc); // Play sound every 4 ticks or 1/5 second.