src/main/java/codes/biscuit/skyblockaddons/listeners/PlayerListener.java
/**
     * The main timer for a bunch of stuff.
     */
The main timer for a bunch of stuff.
The main timer for a bunch of stuff .
@SubscribeEvent()
    public void onTick(TickEvent.ClientTickEvent e) {
        if (e.phase == TickEvent.Phase.START) {
            timerTick++;
            Minecraft mc = Minecraft.getMinecraft();
            if (mc != null) { 
                if (actionBarParser.getHealthUpdate() != null && System.currentTimeMillis() - actionBarParser.getLastHealthUpdate() > 3000) {
                    actionBarParser.setHealthUpdate(null);
                }
                if (main.getRenderListener().isPredictHealth()) {
                    EntityPlayerSP p = mc.thePlayer;
                    if (p != null) { 
                        int newHealth = Math.round(getAttribute(Attribute.MAX_HEALTH) * (p.getHealth() / p.getMaxHealth()));
                        main.getScheduler().schedule(Scheduler.CommandType.SET_LAST_SECOND_HEALTH, 1, newHealth);
                        if (actionBarParser.getLastSecondHealth() != -1 && actionBarParser.getLastSecondHealth() != newHealth) {
                            actionBarParser.setHealthUpdate(newHealth - actionBarParser.getLastSecondHealth());
                            actionBarParser.setLastHealthUpdate(System.currentTimeMillis());
                        }
                        setAttribute(Attribute.HEALTH, newHealth);
                    }
                }
                if (shouldTriggerFishingIndicator()) { 
                    main.getUtils().playLoudSound("random.successful_hit", 0.8);
                }
                if (timerTick == 20) { 
                    if (main.getRenderListener().isPredictMana()) {
                        changeMana(getAttribute(Attribute.MAX_MANA) / 50);
                        if (getAttribute(Attribute.MANA) > getAttribute(Attribute.MAX_MANA))
                            setAttribute(Attribute.MANA, getAttribute(Attribute.MAX_MANA));
                    }
                } else if (timerTick % 5 == 0) { 
                    EntityPlayerSP p = mc.thePlayer;
                    if (p != null) {
                        main.getUtils().checkGameLocationDate();
                        main.getInventoryUtils().checkIfInventoryIsFull(mc, p);
                        main.getInventoryUtils().checkIfWearingSkeletonHelmet(p);
                        main.getInventoryUtils().checkIfWearingRevenantArmor(p);
                        if (!sentUpdate) {
                            main.getUtils().checkUpdates();
                            sentUpdate = true;
                        }
                        if (mc.currentScreen == null && main.getConfigValues().isEnabled(Feature.ITEM_PICKUP_LOG)
                                && main.getPlayerListener().didntRecentlyJoinWorld()) {
                            main.getInventoryUtils().getInventoryDifference(p.inventory.mainInventory);
                        }
                        if(main.getUtils().isOnSkyblock() && main.getConfigValues().isEnabled(Feature.TAB_EFFECT_TIMERS)){
                            TabEffectManager.getInstance().updatePotionEffects();
                        }
                    }
                    main.getInventoryUtils().cleanUpPickupLog();
                } else if (timerTick > 20) { 
                    timerTick = 1;
                }
            }
        }
    }
@ SubscribeEvent ( ) public void onTick ( TickEvent . ClientTickEvent e ) { if ( e . phase == TickEvent . Phase . START ) { timerTick ++ ; Minecraft mc = Minecraft . getMinecraft ( ) ; if ( mc != null ) { if ( actionBarParser . getHealthUpdate ( ) != null && System . currentTimeMillis ( ) - actionBarParser . getLastHealthUpdate ( ) > 3000 ) { actionBarParser . setHealthUpdate ( null ) ; } if ( main . getRenderListener ( ) . isPredictHealth ( ) ) { EntityPlayerSP p = mc . thePlayer ; if ( p != null ) { int newHealth = Math . round ( getAttribute ( Attribute . MAX_HEALTH ) * ( p . getHealth ( ) / p . getMaxHealth ( ) ) ) ; main . getScheduler ( ) . schedule ( Scheduler . CommandType . SET_LAST_SECOND_HEALTH , 1 , newHealth ) ; if ( actionBarParser . getLastSecondHealth ( ) != - 1 && actionBarParser . getLastSecondHealth ( ) != newHealth ) { actionBarParser . setHealthUpdate ( newHealth - actionBarParser . getLastSecondHealth ( ) ) ; actionBarParser . setLastHealthUpdate ( System . currentTimeMillis ( ) ) ; } setAttribute ( Attribute . HEALTH , newHealth ) ; } } if ( shouldTriggerFishingIndicator ( ) ) { main . getUtils ( ) . playLoudSound ( "random.successful_hit" , 0.8 ) ; } if ( timerTick == 20 ) { if ( main . getRenderListener ( ) . isPredictMana ( ) ) { changeMana ( getAttribute ( Attribute . MAX_MANA ) / 50 ) ; if ( getAttribute ( Attribute . MANA ) > getAttribute ( Attribute . MAX_MANA ) ) setAttribute ( Attribute . MANA , getAttribute ( Attribute . MAX_MANA ) ) ; } } else if ( timerTick % 5 == 0 ) { EntityPlayerSP p = mc . thePlayer ; if ( p != null ) { main . getUtils ( ) . checkGameLocationDate ( ) ; main . getInventoryUtils ( ) . checkIfInventoryIsFull ( mc , p ) ; main . getInventoryUtils ( ) . checkIfWearingSkeletonHelmet ( p ) ; main . getInventoryUtils ( ) . checkIfWearingRevenantArmor ( p ) ; if ( ! sentUpdate ) { main . getUtils ( ) . checkUpdates ( ) ; sentUpdate = true ; } if ( mc . currentScreen == null && main . getConfigValues ( ) . isEnabled ( Feature . ITEM_PICKUP_LOG ) && main . getPlayerListener ( ) . didntRecentlyJoinWorld ( ) ) { main . getInventoryUtils ( ) . getInventoryDifference ( p . inventory . mainInventory ) ; } if ( main . getUtils ( ) . isOnSkyblock ( ) && main . getConfigValues ( ) . isEnabled ( Feature . TAB_EFFECT_TIMERS ) ) { TabEffectManager . getInstance ( ) . updatePotionEffects ( ) ; } } main . getInventoryUtils ( ) . cleanUpPickupLog ( ) ; } else if ( timerTick > 20 ) { timerTick = 1 ; } } } }
The main timer for a bunch of stuff.
The main timer for a bunch of stuff .
// Predict health every tick if needed. //Reverse calculate the player's health by using the player's vanilla hearts. Also calculate the health change for the gui item. // The logic fits better in its own function // Add natural mana every second (increase is based on your max mana). // Check inventory, location, updates, and skeleton helmet every 1/4 second. // To keep the timer going from 1 to 21 only.