forked from Wurst-Imperium/Wurst7
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathKillauraHack.java
More file actions
254 lines (213 loc) · 8.25 KB
/
KillauraHack.java
File metadata and controls
254 lines (213 loc) · 8.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
/*
* Copyright (c) 2014-2026 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this
* file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt
*/
package net.wurstclient.hacks;
import com.mojang.blaze3d.vertex.PoseStack;
import java.util.Comparator;
import java.util.function.ToDoubleFunction;
import java.util.stream.Stream;
import net.minecraft.core.component.DataComponents;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.component.PiercingWeapon;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import net.wurstclient.Category;
import net.wurstclient.SearchTags;
import net.wurstclient.events.HandleInputListener;
import net.wurstclient.events.RenderListener;
import net.wurstclient.events.UpdateListener;
import net.wurstclient.hack.Hack;
import net.wurstclient.settings.AttackSpeedSliderSetting;
import net.wurstclient.settings.CheckboxSetting;
import net.wurstclient.settings.EnumSetting;
import net.wurstclient.settings.PauseAttackOnContainersSetting;
import net.wurstclient.settings.SliderSetting;
import net.wurstclient.settings.SliderSetting.ValueDisplay;
import net.wurstclient.settings.SwingHandSetting;
import net.wurstclient.settings.SwingHandSetting.SwingHand;
import net.wurstclient.settings.filterlists.EntityFilterList;
import net.wurstclient.util.BlockUtils;
import net.wurstclient.util.EntityUtils;
import net.wurstclient.util.RenderUtils;
import net.wurstclient.util.RotationUtils;
@SearchTags({"kill aura", "ForceField", "force field", "CrystalAura",
"crystal aura", "AutoCrystal", "auto crystal"})
public final class KillauraHack extends Hack
implements UpdateListener, HandleInputListener, RenderListener
{
private final SliderSetting range = new SliderSetting("Range",
"Determines how far Killaura will reach to attack entities.\n"
+ "Anything that is further away than the specified value will not be attacked.",
5, 1, 10, 0.05, ValueDisplay.DECIMAL);
private final AttackSpeedSliderSetting speed =
new AttackSpeedSliderSetting();
private final SliderSetting speedRandMS =
new SliderSetting("Speed randomization",
"Helps you bypass anti-cheat plugins by varying the delay between"
+ " attacks.\n\n" + "\u00b1100ms is recommended for Vulcan.\n\n"
+ "0 (off) is fine for NoCheat+, AAC, Grim, Verus, Spartan, and"
+ " vanilla servers.",
100, 0, 1000, 50, ValueDisplay.INTEGER.withPrefix("\u00b1")
.withSuffix("ms").withLabel(0, "off"));
private final EnumSetting<Priority> priority = new EnumSetting<>("Priority",
"Determines which entity will be attacked first.\n"
+ "\u00a7lDistance\u00a7r - Attacks the closest entity.\n"
+ "\u00a7lAngle\u00a7r - Attacks the entity that requires the least head movement.\n"
+ "\u00a7lHealth\u00a7r - Attacks the weakest entity.",
Priority.values(), Priority.ANGLE);
private final SliderSetting fov =
new SliderSetting("FOV", 360, 30, 360, 10, ValueDisplay.DEGREES);
private final SwingHandSetting swingHand = new SwingHandSetting(
SwingHandSetting.genericCombatDescription(this), SwingHand.CLIENT);
private final CheckboxSetting damageIndicator = new CheckboxSetting(
"Damage indicator",
"Renders a colored box within the target, inversely proportional to its remaining health.",
true);
private final PauseAttackOnContainersSetting pauseOnContainers =
new PauseAttackOnContainersSetting(true);
private final CheckboxSetting checkLOS =
new CheckboxSetting("Check line of sight",
"Ensures that you don't reach through blocks when attacking.\n\n"
+ "Slower but can help with anti-cheat plugins.",
false);
private final EntityFilterList entityFilters =
EntityFilterList.genericCombat();
private Entity target;
private Entity renderTarget;
public KillauraHack()
{
super("Killaura");
setCategory(Category.COMBAT);
addSetting(range);
addSetting(speed);
addSetting(speedRandMS);
addSetting(priority);
addSetting(fov);
addSetting(swingHand);
addSetting(damageIndicator);
addSetting(pauseOnContainers);
addSetting(checkLOS);
entityFilters.forEach(this::addSetting);
}
@Override
protected void onEnable()
{
// disable other killauras
WURST.getHax().aimAssistHack.setEnabled(false);
WURST.getHax().clickAuraHack.setEnabled(false);
WURST.getHax().crystalAuraHack.setEnabled(false);
WURST.getHax().fightBotHack.setEnabled(false);
WURST.getHax().killauraLegitHack.setEnabled(false);
WURST.getHax().multiAuraHack.setEnabled(false);
WURST.getHax().protectHack.setEnabled(false);
WURST.getHax().triggerBotHack.setEnabled(false);
WURST.getHax().tpAuraHack.setEnabled(false);
speed.resetTimer(speedRandMS.getValue());
EVENTS.add(UpdateListener.class, this);
EVENTS.add(HandleInputListener.class, this);
EVENTS.add(RenderListener.class, this);
}
@Override
protected void onDisable()
{
EVENTS.remove(UpdateListener.class, this);
EVENTS.remove(HandleInputListener.class, this);
EVENTS.remove(RenderListener.class, this);
target = null;
renderTarget = null;
}
@Override
public void onUpdate()
{
speed.updateTimer();
if(!speed.isTimeToAttack())
return;
if(pauseOnContainers.shouldPause())
return;
Stream<Entity> stream = EntityUtils.getAttackableEntities();
double rangeSq = range.getValueSq();
stream =
stream.filter(e -> EntityUtils.distanceToHitboxSq(e) <= rangeSq);
if(fov.getValue() < 360.0)
stream = stream.filter(e -> RotationUtils.getAngleToLookVec(
e.getBoundingBox().getCenter()) <= fov.getValue() / 2.0);
stream = entityFilters.applyTo(stream);
target = stream.min(priority.getSelected().comparator).orElse(null);
renderTarget = target;
if(target == null)
return;
WURST.getHax().autoSwordHack.setSlot(target);
Vec3 hitVec = target.getBoundingBox().getCenter();
if(checkLOS.isChecked() && !BlockUtils.hasLineOfSight(hitVec))
{
target = null;
return;
}
WURST.getRotationFaker().faceVectorPacket(hitVec);
}
@Override
public void onHandleInput()
{
if(target == null)
return;
ItemStack heldItem = MC.player.getMainHandItem();
PiercingWeapon piercingWeapon =
heldItem.get(DataComponents.PIERCING_WEAPON);
if(piercingWeapon != null
&& !WURST.getHax().attributeSwapHack.isEnabled())
MC.gameMode.piercingAttack(piercingWeapon);
else
MC.gameMode.attack(MC.player, target);
swingHand.swing(InteractionHand.MAIN_HAND);
target = null;
speed.resetTimer(speedRandMS.getValue());
}
@Override
public void onRender(PoseStack matrixStack, float partialTicks)
{
if(renderTarget == null || !damageIndicator.isChecked())
return;
float p = 1;
if(renderTarget instanceof LivingEntity le && le.getMaxHealth() > 1e-5)
p = 1 - le.getHealth() / le.getMaxHealth();
float red = p * 2F;
float green = 2 - red;
float[] rgb = {red, green, 0};
int quadColor = RenderUtils.toIntColor(rgb, 0.25F);
int lineColor = RenderUtils.toIntColor(rgb, 0.5F);
AABB box = EntityUtils.getLerpedBox(renderTarget, partialTicks);
if(p < 1)
box = box.deflate((1 - p) * 0.5 * box.getXsize(),
(1 - p) * 0.5 * box.getYsize(), (1 - p) * 0.5 * box.getZsize());
RenderUtils.drawSolidBox(matrixStack, box, quadColor, false);
RenderUtils.drawOutlinedBox(matrixStack, box, lineColor, false);
}
private enum Priority
{
DISTANCE("Distance", EntityUtils::distanceToHitboxSq),
ANGLE("Angle",
e -> RotationUtils
.getAngleToLookVec(e.getBoundingBox().getCenter())),
HEALTH("Health", e -> e instanceof LivingEntity
? ((LivingEntity)e).getHealth() : Integer.MAX_VALUE);
private final String name;
private final Comparator<Entity> comparator;
private Priority(String name, ToDoubleFunction<Entity> keyExtractor)
{
this.name = name;
comparator = Comparator.comparingDouble(keyExtractor);
}
@Override
public String toString()
{
return name;
}
}
}