Skip to content

Commit

Permalink
Surround and Crystal Aura fixes, and some other things (MeteorDevelop…
Browse files Browse the repository at this point in the history
  • Loading branch information
tyrannus00 authored Dec 16, 2022
1 parent 790d9b3 commit d8f48db
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import meteordevelopment.meteorclient.systems.modules.Module;
import meteordevelopment.meteorclient.utils.entity.EntityUtils;
import meteordevelopment.meteorclient.utils.entity.Target;
import meteordevelopment.meteorclient.utils.entity.fakeplayer.FakePlayerManager;
import meteordevelopment.meteorclient.utils.misc.Keybind;
import meteordevelopment.meteorclient.utils.player.*;
import meteordevelopment.meteorclient.utils.render.NametagUtils;
Expand Down Expand Up @@ -688,9 +687,10 @@ private double getBreakDamage(Entity entity, boolean checkCrystalAge) {

// Check damage to targets and face place
double damage = getDamageToTargets(entity.getPos(), blockPos, true, false);
boolean facePlaced = (facePlace.get() && shouldFacePlace(entity.getBlockPos()) || forceFacePlace.get().isPressed());
boolean shouldFacePlace = shouldFacePlace();
double minimumDamage = Math.min(minDamage.get(), shouldFacePlace ? 1.5 : minDamage.get());

if (!facePlaced && damage < minDamage.get()) return 0;
if (damage < minimumDamage) return 0;

return damage;
}
Expand Down Expand Up @@ -823,9 +823,10 @@ private void doPlace() {
// Check damage to targets and face place
double damage = getDamageToTargets(vec3d, bp, false, !hasBlock && support.get() == SupportMode.Fast);

boolean facePlaced = (facePlace.get() && shouldFacePlace(blockPos)) || (forceFacePlace.get().isPressed());
boolean shouldFacePlace = shouldFacePlace();
double minimumDamage = Math.min(minDamage.get(), shouldFacePlace ? 1.5 : minDamage.get());

if (!facePlaced && damage < minDamage.get()) return;
if (damage < minimumDamage) return;

// Check if it can be placed
double x = bp.getX();
Expand Down Expand Up @@ -977,21 +978,21 @@ private static double distanceBetweenAngles(double alpha, double beta) {

// Face place

private boolean shouldFacePlace(BlockPos crystal) {
private boolean shouldFacePlace() {
if (!facePlace.get()) return false;

if (forceFacePlace.get().isPressed()) return true;

// Checks if the provided crystal position should face place to any target
for (PlayerEntity target : targets) {
BlockPos pos = target.getBlockPos();

if (crystal.getY() == pos.getY() + 1 && Math.abs(pos.getX() - crystal.getX()) <= 1 && Math.abs(pos.getZ() - crystal.getZ()) <= 1) {
if (EntityUtils.getTotalHealth(target) <= facePlaceHealth.get()) return true;

for (ItemStack itemStack : target.getArmorItems()) {
if (itemStack == null || itemStack.isEmpty()) {
if (facePlaceArmor.get()) return true;
}
else {
if ((double) (itemStack.getMaxDamage() - itemStack.getDamage()) / itemStack.getMaxDamage() * 100 <= facePlaceDurability.get()) return true;
}
if (EntityUtils.getTotalHealth(target) <= facePlaceHealth.get()) return true;

for (ItemStack itemStack : target.getArmorItems()) {
if (itemStack == null || itemStack.isEmpty()) {
if (facePlaceArmor.get()) return true;
}
else {
if ((double) (itemStack.getMaxDamage() - itemStack.getDamage()) / itemStack.getMaxDamage() * 100 <= facePlaceDurability.get()) return true;
}
}
}
Expand Down Expand Up @@ -1070,13 +1071,6 @@ private void findTargets() {
targets.add(player);
}
}

// Fake players
FakePlayerManager.forEach(fp -> {
if (!fp.isDead() && fp.isAlive() && Friends.get().shouldAttack(fp) && PlayerUtils.isWithin(fp, targetRange.get())) {
targets.add(fp);
}
});
}

private boolean intersectsWithEntities(Box box) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,11 @@ private Text appendAntiSpam(Text text) {
((ChatHudAccessor) mc.inGameHud.getChatHud()).getMessages().remove(messageIndex);

List<OrderedText> list = ChatMessages.breakRenderedChatMessageLines(originalMessage, MathHelper.floor((double)mc.inGameHud.getChatHud().getWidth() / mc.inGameHud.getChatHud().getChatScale()), mc.textRenderer);
int lines = list.size();
List<ChatHudLine.Visible> visibleMessages = ((ChatHudAccessor) mc.inGameHud.getChatHud()).getVisibleMessages();
int lines = Math.min(list.size(), visibleMessages.size());

for (int i = 0; i < lines; i++) {
((ChatHudAccessor) mc.inGameHud.getChatHud()).getVisibleMessages().remove(messageIndex);
visibleMessages.remove(messageIndex);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void onDeactivate() {

@EventHandler
private void onMouseButton(MouseButtonEvent event) {
if (event.action != KeyAction.Press || event.button != GLFW_MOUSE_BUTTON_MIDDLE) return;
if (event.action != KeyAction.Press || event.button != GLFW_MOUSE_BUTTON_MIDDLE || mc.currentScreen != null) return;

FindItemResult result = InvUtils.findInHotbar(mode.get().item);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public static FindItemResult find(Predicate<ItemStack> isGood, int start, int en
}

public static FindItemResult findFastestTool(BlockState state) {
float bestScore = -1;
float bestScore = 1;
int slot = -1;

for (int i = 0; i < 9; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public static boolean canPlace(BlockPos blockPos, boolean checkEntities) {
if (!mc.world.getBlockState(blockPos).getMaterial().isReplaceable()) return false;

// Check if intersects entities
return !checkEntities || mc.world.canPlace(mc.world.getBlockState(blockPos), blockPos, ShapeContext.absent());
return !checkEntities || mc.world.canPlace(Blocks.OBSIDIAN.getDefaultState(), blockPos, ShapeContext.absent());
}

public static boolean canPlace(BlockPos blockPos) {
Expand Down

0 comments on commit d8f48db

Please sign in to comment.