improve ping handling
All checks were successful
/ Build BaseBand (push) Successful in 2m46s

This commit is contained in:
Daniella / Tove 2024-10-05 01:03:06 +02:00
parent 72d1ddc92c
commit f065209f3a
Signed by: TudbuT
GPG key ID: B3CF345217F202D3
4 changed files with 32 additions and 5 deletions

View file

@ -6,6 +6,8 @@ import de.com.baseband.client.feature.Feature;
import de.com.baseband.client.feature.category.Ingame; import de.com.baseband.client.feature.category.Ingame;
import de.com.baseband.client.mixin.mixins.IMinecraft; import de.com.baseband.client.mixin.mixins.IMinecraft;
import de.com.baseband.client.registry.annotation.Config; import de.com.baseband.client.registry.annotation.Config;
import de.com.baseband.client.registry.annotation.Description;
import de.com.baseband.client.registry.annotation.Range;
import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.settings.KeyBinding; import net.minecraft.client.settings.KeyBinding;
import net.minecraft.init.MobEffects; import net.minecraft.init.MobEffects;
@ -28,6 +30,16 @@ public class AutoEat extends Feature {
@Config("Close GUI On Eat") @Config("Close GUI On Eat")
public boolean closeGui; public boolean closeGui;
@Config("GapUp Min health (no regen)")
@Description("Health to eat a golden apple at")
@Range("5..20")
public int hp = 18;
@Config("GapUp Min health (always)")
@Description("Health to eat a golden apple at")
@Range("3..15")
public int deathHp = 10;
@Override @Override
public String toString() { public String toString() {
return "AutoEat"; return "AutoEat";
@ -102,8 +114,8 @@ public class AutoEat extends Feature {
stack.getItem() instanceof ItemFood //it has to be food bruh stack.getItem() instanceof ItemFood //it has to be food bruh
&& !(stack.getItem() instanceof ItemChorusFruit) //not a chorus fruit you ret-.... dumbfuck && !(stack.getItem() instanceof ItemChorusFruit) //not a chorus fruit you ret-.... dumbfuck
&& ((20 - currentHunger) >= ((ItemFood) stack.getItem()).getHealAmount(stack) //if hunger low and food wanted refills the amount left && ((20 - currentHunger) >= ((ItemFood) stack.getItem()).getHealAmount(stack) //if hunger low and food wanted refills the amount left
|| (stack.getItem() instanceof ItemAppleGold && mc.player.getHealth() < 18 && (mc.player.getActivePotionEffect(MobEffects.REGENERATION) == null || mc.player.getActivePotionEffect(MobEffects.ABSORPTION) == null)) //is golden apple and our health is less than 19 and we don't have regen || (stack.getItem() instanceof ItemAppleGold && mc.player.getHealth() < hp && (mc.player.getActivePotionEffect(MobEffects.REGENERATION) == null || mc.player.getActivePotionEffect(MobEffects.ABSORPTION) == null)) //is golden apple and our health is less than 19 and we don't have regen
|| (stack.getItem() instanceof ItemAppleGold && mc.player.getHealth() < 10) // we're in danger, eat! EAT EAT EAT EAT WE BOUTTA DIE || (stack.getItem() instanceof ItemAppleGold && mc.player.getHealth() < deathHp) // we're in danger, eat! EAT EAT EAT EAT WE BOUTTA DIE
|| (stack.getItem() instanceof ItemAppleGold && mc.player.getActivePotionEffect(MobEffects.FIRE_RESISTANCE) == null) && mc.player.isBurning()); //is golden apple and we don't have fire res and we're burning || (stack.getItem() instanceof ItemAppleGold && mc.player.getActivePotionEffect(MobEffects.FIRE_RESISTANCE) == null) && mc.player.isBurning()); //is golden apple and we don't have fire res and we're burning
} }
} }

View file

@ -163,7 +163,7 @@ public class Fill extends Feature {
} }
Lock value = new Lock(); Lock value = new Lock();
value.lock(Math.max(0, (int) (ServerDataManager.ping * 2))); value.lock(Math.max(0, (int) (ServerDataManager.getRealPing() * 2)));
placeCache.put(pos, value); placeCache.put(pos, value);
lastPlacedItem = curItem.getItem(); lastPlacedItem = curItem.getItem();

View file

@ -225,7 +225,8 @@ public class HUD extends Feature {
if (showTPS && showPing) if (showTPS && showPing)
infoString += " | "; infoString += " | ";
if (showPing) if (showPing)
infoString += "Ping: " + (ServerDataManager.ping + (pingJitter ? (int) (Math.random() * pingJitterAmount) : 0)) + " | Players: " + ServerDataManager.players + "/" + ServerDataManager.maxPlayers + "\n"; infoString +=
"Ping: " + (ServerDataManager.getRealPing() + (pingJitter ? (int) (Math.random() * pingJitterAmount) : 0)) + (ServerDataManager.isPingAltered() ? " (" + ServerDataManager.ping + ")" : "") + " | Players: " + ServerDataManager.players + "/" + ServerDataManager.maxPlayers + "\n";
if (showSpotify && Features.isFeatureEnabled(Spotify.class)) { if (showSpotify && Features.isFeatureEnabled(Spotify.class)) {
SpotifyAPI api = Features.getFeature(Spotify.class).api; SpotifyAPI api = Features.getFeature(Spotify.class).api;

View file

@ -4,6 +4,7 @@ import de.com.baseband.client.BaseBand;
import de.com.baseband.client.Setup; import de.com.baseband.client.Setup;
import de.com.baseband.client.feature.Features; import de.com.baseband.client.feature.Features;
import de.com.baseband.client.feature.modules.client.Client; import de.com.baseband.client.feature.modules.client.Client;
import de.com.baseband.client.feature.modules.ingame.Ping;
import de.com.baseband.client.util.adapt.ServerPing; import de.com.baseband.client.util.adapt.ServerPing;
import de.tudbut.tools.Lock; import de.tudbut.tools.Lock;
import net.minecraft.client.network.NetworkPlayerInfo; import net.minecraft.client.network.NetworkPlayerInfo;
@ -86,7 +87,20 @@ public class ServerDataManager {
} }
} }
public static boolean isPingAltered() {
return ping != getRealPing();
}
public static long getRealPing() {
if(Features.isFeatureEnabled(Ping.class)) {
Ping p = Features.getFeature(Ping.class);
if(p.holdAll)
return ping + p.milliseconds;
}
return ping;
}
public static int timeToSurelyTicked() { public static int timeToSurelyTicked() {
return (int) Math.ceil(((20f / tps) + (ping / 100f)) * (Features.getFeature(Client.class).tickTimeConservative ? 4f : 3f)); return (int) Math.ceil(((20f / tps) + (getRealPing() / 100f)) * (Features.getFeature(Client.class).tickTimeConservative ? 4f : 3f));
} }
} }