Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into 1.21.2-update
Browse files Browse the repository at this point in the history
  • Loading branch information
Big-Iron-Cheems committed Oct 29, 2024
2 parents 957e741 + 38b6659 commit 862de25
Show file tree
Hide file tree
Showing 18 changed files with 236 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void init() {
screen.locked = true;

MeteorExecutor.execute(() -> {
if (account.login()) {
if (account.fetchInfo() && account.login()) {
name.set(account.getUsername());

Accounts.get().save();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public class BaritoneSettings implements IPathManager.ISettings {
private Setting<Boolean> walkOnWater, walkOnLava;
private Setting<Boolean> step, noFall;

private static final Map<String, Double> SETTING_MAX_VALUES = new HashMap<>();

public BaritoneSettings() {
createWrappers();
}
Expand Down Expand Up @@ -58,6 +60,10 @@ public void save() {
SettingsUtil.save(BaritoneAPI.getSettings());
}

static {
SETTING_MAX_VALUES.put("pathCutoffFactor", 1.0);
}

// Wrappers

@SuppressWarnings({"rawtypes", "unchecked"})
Expand Down Expand Up @@ -103,6 +109,8 @@ else if (value instanceof Double) {
.name(setting.getName())
.description(getDescription(setting.getName()))
.defaultValue((double) setting.defaultValue)
.max(SETTING_MAX_VALUES.getOrDefault(setting.getName(), 10.0))
.sliderMax(SETTING_MAX_VALUES.getOrDefault(setting.getName(), 10.0))
.onChanged(aDouble -> setting.value = aDouble)
.onModuleActivated(doubleSetting -> doubleSetting.set((Double) setting.value))
.build()
Expand All @@ -113,6 +121,8 @@ else if (value instanceof Float) {
.name(setting.getName())
.description(getDescription(setting.getName()))
.defaultValue(((Float) setting.defaultValue).doubleValue())
.max(SETTING_MAX_VALUES.getOrDefault(setting.getName(), 10.0))
.sliderMax(SETTING_MAX_VALUES.getOrDefault(setting.getName(), 10.0))
.onChanged(aDouble -> setting.value = aDouble.floatValue())
.onModuleActivated(doubleSetting -> doubleSetting.set(((Float) setting.value).doubleValue()))
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,14 @@ public Accounts fromTag(NbtCompound tag) {
AccountType type = AccountType.valueOf(t.getString("type"));

try {
Account<?> account = switch (type) {
return switch (type) {
case Cracked -> new CrackedAccount(null).fromTag(t);
case Microsoft -> new MicrosoftAccount(null).fromTag(t);
case TheAltening -> new TheAlteningAccount(null).fromTag(t);
};

if (account.fetchInfo()) return account;
} catch (NbtException e) {
return null;
}

return null;
}));

return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,34 @@
import meteordevelopment.meteorclient.systems.accounts.AccountType;
import meteordevelopment.meteorclient.systems.accounts.MicrosoftLogin;
import net.minecraft.client.session.Session;
import org.jetbrains.annotations.Nullable;

import java.util.Optional;

public class MicrosoftAccount extends Account<MicrosoftAccount> {
private @Nullable String token;
public MicrosoftAccount(String refreshToken) {
super(AccountType.Microsoft, refreshToken);
}

@Override
public boolean fetchInfo() {
return auth() != null;
token = auth();
return token != null;
}

@Override
public boolean login() {
super.login();

String token = auth();
if (token == null) return false;

super.login();
cache.loadHead();

setSession(new Session(cache.username, UndashedUuid.fromStringLenient(cache.uuid), token, Optional.empty(), Optional.empty(), Session.AccountType.MSA));
return true;
}

private String auth() {
private @Nullable String auth() {
MicrosoftLogin.LoginData data = MicrosoftLogin.login(name);
if (!data.isGood()) return null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import meteordevelopment.meteorclient.utils.misc.NbtException;
import net.minecraft.client.session.Session;
import net.minecraft.nbt.NbtCompound;
import org.jetbrains.annotations.Nullable;

import java.util.Optional;

Expand All @@ -27,6 +28,7 @@ public class TheAlteningAccount extends Account<TheAlteningAccount> implements T
private static final Environment ENVIRONMENT = new Environment("http://sessionserver.thealtening.com", "http://authserver.thealtening.com", "The Altening");
private static final YggdrasilAuthenticationService SERVICE = new YggdrasilAuthenticationService(((MinecraftClientAccessor) mc).getProxy(), ENVIRONMENT);
private String token;
private @Nullable WaybackAuthLib auth;

public TheAlteningAccount(String token) {
super(AccountType.TheAltening, token);
Expand All @@ -35,37 +37,33 @@ public TheAlteningAccount(String token) {

@Override
public boolean fetchInfo() {
WaybackAuthLib auth = getAuth();
auth = getAuth();

try {
auth.logIn();

cache.username = auth.getCurrentProfile().getName();
cache.uuid = auth.getCurrentProfile().getId().toString();
cache.loadHead();

return true;
} catch (InvalidCredentialsException e) {
MeteorClient.LOG.error("Invalid TheAltening credentials.");
return false;
} catch (Exception e) {
MeteorClient.LOG.error("Failed to fetch info for TheAltening account!");
return false;
}
}

@Override
public boolean login() {
if (auth == null) return false;
applyLoginEnvironment(SERVICE, YggdrasilMinecraftSessionServiceAccessor.createYggdrasilMinecraftSessionService(SERVICE.getServicesKeySet(), SERVICE.getProxy(), ENVIRONMENT));

WaybackAuthLib auth = getAuth();

try {
auth.logIn();
setSession(new Session(auth.getCurrentProfile().getName(), auth.getCurrentProfile().getId(), auth.getAccessToken(), Optional.empty(), Optional.empty(), Session.AccountType.MOJANG));

cache.username = auth.getCurrentProfile().getName();
cache.loadHead();

return true;
} catch (InvalidCredentialsException e) {
MeteorClient.LOG.error("Invalid TheAltening credentials.");
return false;
} catch (Exception e) {
MeteorClient.LOG.error("Failed to login with TheAltening.");
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
import meteordevelopment.meteorclient.settings.*;
import meteordevelopment.meteorclient.systems.modules.Categories;
import meteordevelopment.meteorclient.systems.modules.Module;
import meteordevelopment.meteorclient.utils.entity.EntityUtils;
import meteordevelopment.meteorclient.utils.entity.DamageUtils;
import meteordevelopment.meteorclient.utils.player.InvUtils;
import meteordevelopment.orbit.EventHandler;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.AxeItem;
import net.minecraft.item.ItemStack;
import net.minecraft.item.SwordItem;
Expand Down Expand Up @@ -47,10 +47,12 @@ public AutoWeapon() {

@EventHandler
private void onAttack(AttackEntityEvent event) {
InvUtils.swap(getBestWeapon(EntityUtils.getGroup(event.entity)), false);
if (event.entity instanceof LivingEntity livingEntity) {
InvUtils.swap(getBestWeapon(livingEntity), false);
}
}

private int getBestWeapon(EntityType<?> group) {
private int getBestWeapon(LivingEntity target) {
int slotS = mc.player.getInventory().selectedSlot;
int slotA = mc.player.getInventory().selectedSlot;
double damageS = 0;
Expand All @@ -59,16 +61,16 @@ private int getBestWeapon(EntityType<?> group) {
double currentDamageA;
for (int i = 0; i < 9; i++) {
ItemStack stack = mc.player.getInventory().getStack(i);
if (stack.getItem() instanceof SwordItem swordItem
if (stack.getItem() instanceof SwordItem
&& (!antiBreak.get() || (stack.getMaxDamage() - stack.getDamage()) > 10)) {
currentDamageS = swordItem.getMaterial().getAttackDamage() /*fixme + EnchantmentHelper.getAttackDamage(stack, group)*/ + 2;
currentDamageS = DamageUtils.getAttackDamage(mc.player, target, stack);
if (currentDamageS > damageS) {
damageS = currentDamageS;
slotS = i;
}
} else if (stack.getItem() instanceof AxeItem axeItem
} else if (stack.getItem() instanceof AxeItem
&& (!antiBreak.get() || (stack.getMaxDamage() - stack.getDamage()) > 10)) {
currentDamageA = axeItem.getMaterial().getAttackDamage() /*fixme + EnchantmentHelper.getAttackDamage(stack, group)*/ + 2;
currentDamageA = DamageUtils.getAttackDamage(mc.player, target, stack);
if (currentDamageA > damageA) {
damageA = currentDamageA;
slotA = i;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import net.minecraft.entity.passive.AnimalEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ArrowItem;
import net.minecraft.item.BowItem;
import net.minecraft.item.Items;
import net.minecraft.util.math.Vec3d;

Expand Down Expand Up @@ -130,23 +131,16 @@ private boolean itemInHand() {
return InvUtils.testInMainHand(Items.BOW, Items.CROSSBOW);
}

private void aim(double tickDelta) {
private void aim(float tickDelta) {
// Velocity based on bow charge.
float velocity = (mc.player.getItemUseTime() - mc.player.getItemUseTimeLeft()) / 20f;
velocity = (velocity * velocity + velocity * 2) / 3;
if (velocity > 1) velocity = 1;
float velocity = BowItem.getPullProgress(mc.player.getItemUseTime());

// Positions
double posX = target.getPos().getX() + (target.getPos().getX() - target.prevX) * tickDelta;
double posY = target.getPos().getY() + (target.getPos().getY() - target.prevY) * tickDelta;
double posZ = target.getPos().getZ() + (target.getPos().getZ() - target.prevZ) * tickDelta;
Vec3d pos = target.getLerpedPos(tickDelta);

// Adjusting for hitbox heights
posY -= 1.9f - target.getHeight();

double relativeX = posX - mc.player.getX();
double relativeY = posY - mc.player.getY();
double relativeZ = posZ - mc.player.getZ();
double relativeX = pos.x - mc.player.getX();
double relativeY = pos.y + (target.getHeight() / 2) - mc.player.getEyeY();
double relativeZ = pos.z - mc.player.getZ();

// Calculate the pitch
double hDistance = Math.sqrt(relativeX * relativeX + relativeZ * relativeZ);
Expand All @@ -159,7 +153,7 @@ private void aim(double tickDelta) {
if (Float.isNaN(pitch)) {
Rotations.rotate(Rotations.getYaw(target), Rotations.getPitch(target));
} else {
Rotations.rotate(Rotations.getYaw(new Vec3d(posX, posY, posZ)), pitch);
Rotations.rotate(Rotations.getYaw(new Vec3d(pos.x, pos.y, pos.z)), pitch);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ private void onTick(TickEvent.Post event) {
if (!isBow) return;

if (mc.player.getItemUseTime() >= charge.get()) {
mc.player.stopUsingItem();
mc.interactionManager.stopUsingItem(mc.player);
} else {
setPressed(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ public class PotionSpoof extends Module {
.build()
);

private final Setting<Integer> effectDuration = sgGeneral.add(new IntSetting.Builder()
.name("effect-duration")
.description("How many ticks to spoof the effect for.")
.range(1, 32767)
.sliderRange(20, 500)
.defaultValue(420)
.build()
);

public PotionSpoof() {
super(Categories.Player, "potion-spoof", "Spoofs potion statuses for you. SOME effects DO NOT work.");
}
Expand All @@ -73,9 +82,9 @@ private void onTick(TickEvent.Post event) {
if (mc.player.hasStatusEffect(Registries.STATUS_EFFECT.getEntry(entry.getKey()))) {
StatusEffectInstance instance = mc.player.getStatusEffect(Registries.STATUS_EFFECT.getEntry(entry.getKey()));
((StatusEffectInstanceAccessor) instance).setAmplifier(level - 1);
if (instance.getDuration() < 20) ((StatusEffectInstanceAccessor) instance).setDuration(20);
if (instance.getDuration() < effectDuration.get()) ((StatusEffectInstanceAccessor) instance).setDuration(effectDuration.get());
} else {
mc.player.addStatusEffect(new StatusEffectInstance(Registries.STATUS_EFFECT.getEntry(entry.getKey()), 20, level - 1));
mc.player.addStatusEffect(new StatusEffectInstance(Registries.STATUS_EFFECT.getEntry(entry.getKey()), effectDuration.get(), level - 1));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@

package meteordevelopment.meteorclient.systems.modules.render;

import meteordevelopment.meteorclient.events.world.TickEvent;
import meteordevelopment.meteorclient.mixin.StatusEffectInstanceAccessor;
import meteordevelopment.meteorclient.settings.EnumSetting;
import meteordevelopment.meteorclient.settings.IntSetting;
import meteordevelopment.meteorclient.settings.Setting;
import meteordevelopment.meteorclient.settings.SettingGroup;
import meteordevelopment.meteorclient.systems.modules.Categories;
import meteordevelopment.meteorclient.systems.modules.Module;
import meteordevelopment.orbit.EventHandler;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.registry.Registries;
import net.minecraft.world.LightType;

public class Fullbright extends Module {
Expand All @@ -21,7 +27,10 @@ public class Fullbright extends Module {
.description("The mode to use for Fullbright.")
.defaultValue(Mode.Gamma)
.onChanged(mode -> {
if (mc.worldRenderer != null && isActive()) mc.worldRenderer.reload();
if (isActive()) {
if (mode != Mode.Potion) disableNightVision();
if (mc.worldRenderer != null) mc.worldRenderer.reload();
}
})
.build()
);
Expand Down Expand Up @@ -62,6 +71,7 @@ public void onActivate() {
@Override
public void onDeactivate() {
if (mode.get() == Mode.Luminance) mc.worldRenderer.reload();
else if (mode.get() == Mode.Potion) disableNightVision();
}

public int getLuminance(LightType type) {
Expand All @@ -73,8 +83,27 @@ public boolean getGamma() {
return isActive() && mode.get() == Mode.Gamma;
}

@EventHandler
private void onTick(TickEvent.Post event) {
if (mc.player == null || !mode.get().equals(Mode.Potion)) return;
if (mc.player.hasStatusEffect(Registries.STATUS_EFFECT.getEntry(StatusEffects.NIGHT_VISION.value()))) {
StatusEffectInstance instance = mc.player.getStatusEffect(Registries.STATUS_EFFECT.getEntry(StatusEffects.NIGHT_VISION.value()));
if (instance != null && instance.getDuration() < 420) ((StatusEffectInstanceAccessor) instance).setDuration(420);
} else {
mc.player.addStatusEffect(new StatusEffectInstance(Registries.STATUS_EFFECT.getEntry(StatusEffects.NIGHT_VISION.value()), 420, 0));
}
}

private void disableNightVision() {
if (mc.player == null) return;
if (mc.player.hasStatusEffect(Registries.STATUS_EFFECT.getEntry(StatusEffects.NIGHT_VISION.value()))) {
mc.player.removeStatusEffect(Registries.STATUS_EFFECT.getEntry(StatusEffects.NIGHT_VISION.value()));
}
}

public enum Mode {
Gamma,
Potion,
Luminance
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ private Path getEmptyPath() {
return path;
}

private void calculatePath(PlayerEntity player, double tickDelta) {
private void calculatePath(PlayerEntity player, float tickDelta) {
// Clear paths
for (Path path : paths) path.clear();

Expand Down
Loading

0 comments on commit 862de25

Please sign in to comment.