|
| 1 | +/* |
| 2 | + * Copyright (c) 2014-2025 Wurst-Imperium and contributors. |
| 3 | + * |
| 4 | + * This source code is subject to the terms of the GNU General Public |
| 5 | + * License, version 3. If a copy of the GPL was not distributed with this |
| 6 | + * file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt |
| 7 | + */ |
| 8 | +package net.wurstclient.hacks; |
| 9 | + |
| 10 | +import java.util.Comparator; |
| 11 | +import java.util.stream.Stream; |
| 12 | +import net.minecraft.world.InteractionHand; |
| 13 | +import net.minecraft.world.entity.Entity; |
| 14 | +import net.minecraft.world.phys.EntityHitResult; |
| 15 | +import net.wurstclient.Category; |
| 16 | +import net.wurstclient.SearchTags; |
| 17 | +import net.wurstclient.events.UpdateListener; |
| 18 | +import net.wurstclient.hack.Hack; |
| 19 | +import net.wurstclient.settings.AttackSpeedSliderSetting; |
| 20 | +import net.wurstclient.settings.SliderSetting; |
| 21 | +import net.wurstclient.settings.SliderSetting.ValueDisplay; |
| 22 | +import net.wurstclient.settings.SwingHandSetting; |
| 23 | +import net.wurstclient.settings.SwingHandSetting.SwingHand; |
| 24 | +import net.wurstclient.settings.filterlists.EntityFilterList; |
| 25 | +import net.wurstclient.util.EntityUtils; |
| 26 | +import net.wurstclient.util.RotationUtils; |
| 27 | + |
| 28 | +@SearchTags({"outreach", "wall hit", "wall attack"}) |
| 29 | +public final class OutreachHack extends Hack implements UpdateListener |
| 30 | +{ |
| 31 | + private final SliderSetting range = new SliderSetting("Range", |
| 32 | + "Determines how far Outreach will reach to attack entities.", 4.25, 1, |
| 33 | + 10, 0.05, ValueDisplay.DECIMAL); |
| 34 | + |
| 35 | + private final SliderSetting fov = new SliderSetting("FOV", |
| 36 | + "Only entities within this angle from your crosshair will be hit.", 45, |
| 37 | + 5, 360, 5, ValueDisplay.DEGREES); |
| 38 | + |
| 39 | + private final AttackSpeedSliderSetting swingSpeed = |
| 40 | + new AttackSpeedSliderSetting(); |
| 41 | + |
| 42 | + private final SwingHandSetting swingHand = |
| 43 | + new SwingHandSetting(this, SwingHand.CLIENT); |
| 44 | + |
| 45 | + private final EntityFilterList entityFilters = |
| 46 | + EntityFilterList.genericCombat(); |
| 47 | + |
| 48 | + private Entity target; |
| 49 | + |
| 50 | + public OutreachHack() |
| 51 | + { |
| 52 | + super("Outreach"); |
| 53 | + setCategory(Category.COMBAT); |
| 54 | + |
| 55 | + addSetting(range); |
| 56 | + addSetting(fov); |
| 57 | + addSetting(swingHand); |
| 58 | + entityFilters.forEach(this::addSetting); |
| 59 | + } |
| 60 | + |
| 61 | + @Override |
| 62 | + protected void onEnable() |
| 63 | + { |
| 64 | + WURST.getHax().clickAuraHack.setEnabled(false); |
| 65 | + WURST.getHax().crystalAuraHack.setEnabled(false); |
| 66 | + WURST.getHax().fightBotHack.setEnabled(false); |
| 67 | + WURST.getHax().killauraLegitHack.setEnabled(false); |
| 68 | + WURST.getHax().killauraHack.setEnabled(false); |
| 69 | + WURST.getHax().multiAuraHack.setEnabled(false); |
| 70 | + WURST.getHax().protectHack.setEnabled(false); |
| 71 | + WURST.getHax().tpAuraHack.setEnabled(false); |
| 72 | + |
| 73 | + target = null; |
| 74 | + swingSpeed.resetTimer(); |
| 75 | + EVENTS.add(UpdateListener.class, this); |
| 76 | + } |
| 77 | + |
| 78 | + @Override |
| 79 | + protected void onDisable() |
| 80 | + { |
| 81 | + target = null; |
| 82 | + EVENTS.remove(UpdateListener.class, this); |
| 83 | + } |
| 84 | + |
| 85 | + @Override |
| 86 | + public void onUpdate() |
| 87 | + { |
| 88 | + if(MC.player == null || MC.gameMode == null) |
| 89 | + { |
| 90 | + target = null; |
| 91 | + swingSpeed.resetTimer(); |
| 92 | + return; |
| 93 | + } |
| 94 | + |
| 95 | + swingSpeed.updateTimer(); |
| 96 | + |
| 97 | + double rangeSq = range.getValueSq(); |
| 98 | + double halfFov = fov.getValue() / 2.0; |
| 99 | + Stream<Entity> stream = EntityUtils.getAttackableEntities(); |
| 100 | + stream = stream.filter(e -> MC.player.distanceToSqr(e) <= rangeSq); |
| 101 | + |
| 102 | + if(fov.getValue() < 360.0) |
| 103 | + stream = stream.filter(e -> RotationUtils |
| 104 | + .getAngleToLookVec(e.getBoundingBox().getCenter()) <= halfFov); |
| 105 | + |
| 106 | + stream = entityFilters.applyTo(stream); |
| 107 | + |
| 108 | + Comparator<Entity> comparator = Comparator |
| 109 | + .comparingDouble((Entity e) -> RotationUtils |
| 110 | + .getAngleToLookVec(e.getBoundingBox().getCenter())) |
| 111 | + .thenComparingDouble((Entity e) -> MC.player.distanceToSqr(e)); |
| 112 | + |
| 113 | + target = stream.min(comparator).orElse(null); |
| 114 | + |
| 115 | + if(!(MC.hitResult instanceof EntityHitResult) |
| 116 | + && MC.options.keyAttack.isDown() && target != null) |
| 117 | + { |
| 118 | + if(!swingSpeed.isTimeToAttack()) |
| 119 | + return; |
| 120 | + |
| 121 | + WURST.getHax().autoSwordHack.setSlot(target); |
| 122 | + MC.gameMode.attack(MC.player, target); |
| 123 | + swingHand.swing(InteractionHand.MAIN_HAND); |
| 124 | + swingSpeed.resetTimer(); |
| 125 | + } |
| 126 | + } |
| 127 | +} |
0 commit comments