Skip to content

Commit 9ee181a

Browse files
authored
Merge pull request #8 from Altidias/master
Fix MaceDMG reliability with Killaura, spear hits, and AttributeSwap swaps + spear aura fix
2 parents 28be8e9 + c47f2b7 commit 9ee181a

3 files changed

Lines changed: 78 additions & 11 deletions

File tree

src/main/java/net/wurstclient/hacks/AttributeSwapHack.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@
1818
import net.minecraft.world.item.enchantment.Enchantment;
1919
import net.minecraft.world.item.enchantment.EnchantmentHelper;
2020
import net.minecraft.world.item.enchantment.Enchantments;
21+
import net.minecraft.world.phys.EntityHitResult;
22+
import net.minecraft.world.phys.HitResult;
2123
import net.wurstclient.Category;
2224
import net.wurstclient.SearchTags;
25+
import net.wurstclient.events.LeftClickListener;
26+
import net.wurstclient.events.LeftClickListener.LeftClickEvent;
2327
import net.wurstclient.events.PlayerAttacksEntityListener;
2428
import net.wurstclient.events.UpdateListener;
2529
import net.wurstclient.hack.Hack;
@@ -33,7 +37,7 @@
3337
"auto swap", "auto shield break", "auto mace", "disable shield",
3438
"item swap", "hotbar swap", "item saver", "durability saver"})
3539
public final class AttributeSwapHack extends Hack
36-
implements PlayerAttacksEntityListener, UpdateListener
40+
implements LeftClickListener, PlayerAttacksEntityListener, UpdateListener
3741
{
3842
private final EnumSetting<Mode> mode = new EnumSetting<>("Mode",
3943
"Simple: swaps to a fixed hotbar slot on attack.\n"
@@ -92,13 +96,15 @@ protected void onEnable()
9296
awaitingBack = false;
9397
originalSlot = -1;
9498

99+
EVENTS.add(LeftClickListener.class, this);
95100
EVENTS.add(PlayerAttacksEntityListener.class, this);
96101
EVENTS.add(UpdateListener.class, this);
97102
}
98103

99104
@Override
100105
protected void onDisable()
101106
{
107+
EVENTS.remove(LeftClickListener.class, this);
102108
EVENTS.remove(PlayerAttacksEntityListener.class, this);
103109
EVENTS.remove(UpdateListener.class, this);
104110

@@ -111,6 +117,22 @@ protected void onDisable()
111117
originalSlot = -1;
112118
}
113119

120+
@Override
121+
public void onLeftClick(LeftClickEvent event)
122+
{
123+
if(onlyWithKillAura.isChecked()
124+
&& !WURST.getHax().killauraHack.isEnabled())
125+
return;
126+
127+
if(MC.hitResult != null
128+
&& MC.hitResult.getType() == HitResult.Type.BLOCK)
129+
return;
130+
131+
Entity target = MC.hitResult instanceof EntityHitResult hit
132+
? hit.getEntity() : null;
133+
performSwap(target);
134+
}
135+
114136
@Override
115137
public void onPlayerAttacksEntity(Entity target)
116138
{
@@ -119,6 +141,7 @@ public void onPlayerAttacksEntity(Entity target)
119141
return;
120142

121143
performSwap(target);
144+
WURST.getHax().maceDmgHack.doSmash();
122145
}
123146

124147
@Override

src/main/java/net/wurstclient/hacks/KillauraHack.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@
1111
import java.util.Comparator;
1212
import java.util.function.ToDoubleFunction;
1313
import java.util.stream.Stream;
14+
import net.minecraft.core.component.DataComponents;
1415
import net.minecraft.world.InteractionHand;
1516
import net.minecraft.world.entity.Entity;
1617
import net.minecraft.world.entity.LivingEntity;
18+
import net.minecraft.world.item.ItemStack;
19+
import net.minecraft.world.item.component.PiercingWeapon;
1720
import net.minecraft.world.phys.AABB;
1821
import net.minecraft.world.phys.Vec3;
1922
import net.wurstclient.Category;
@@ -184,7 +187,14 @@ public void onHandleInput()
184187
if(target == null)
185188
return;
186189

187-
MC.gameMode.attack(MC.player, target);
190+
ItemStack heldItem = MC.player.getMainHandItem();
191+
PiercingWeapon piercingWeapon =
192+
heldItem.get(DataComponents.PIERCING_WEAPON);
193+
if(piercingWeapon != null
194+
&& !WURST.getHax().attributeSwapHack.isEnabled())
195+
MC.gameMode.piercingAttack(piercingWeapon);
196+
else
197+
MC.gameMode.attack(MC.player, target);
188198
swingHand.swing(InteractionHand.MAIN_HAND);
189199

190200
target = null;

src/main/java/net/wurstclient/hacks/MaceDmgHack.java

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket.Pos;
1111
import net.minecraft.world.entity.Entity;
1212
import net.minecraft.world.item.Items;
13-
import net.minecraft.world.phys.HitResult;
13+
import net.minecraft.world.phys.AABB;
1414
import net.wurstclient.Category;
1515
import net.wurstclient.SearchTags;
1616
import net.wurstclient.events.PlayerAttacksEntityListener;
1717
import net.wurstclient.hack.Hack;
18+
import net.wurstclient.settings.CheckboxSetting;
1819
import net.wurstclient.settings.SliderSetting;
1920
import net.wurstclient.settings.SliderSetting.ValueDisplay;
2021

@@ -23,16 +24,26 @@ public final class MaceDmgHack extends Hack
2324
implements PlayerAttacksEntityListener
2425
{
2526
private static final double DEFAULT_HEIGHT = Math.sqrt(500);
26-
27+
private static final double MIN_FALL = 1.6;
28+
private static final double SCAN_STEP = 0.25;
29+
2730
private final SliderSetting height = new SliderSetting("Height",
2831
"How high to fake before slamming. Height determines the damage boost.",
2932
DEFAULT_HEIGHT, 1.6, 50, 0.1, ValueDisplay.DECIMAL);
30-
33+
34+
private final CheckboxSetting caveMode = new CheckboxSetting("Cave mode",
35+
"Scans for an air gap above you to fall through, so smashes work under"
36+
+ " a ceiling. Fully sealed spaces still can't be smashed.",
37+
true);
38+
39+
private long lastSmashTick = -1;
40+
3141
public MaceDmgHack()
3242
{
3343
super("MaceDMG");
3444
setCategory(Category.COMBAT);
3545
addSetting(height);
46+
addSetting(caveMode);
3647
}
3748

3849
@Override
@@ -50,22 +61,45 @@ protected void onDisable()
5061
@Override
5162
public void onPlayerAttacksEntity(Entity target)
5263
{
53-
if(MC.hitResult == null
54-
|| MC.hitResult.getType() != HitResult.Type.ENTITY)
64+
doSmash();
65+
}
66+
67+
public void doSmash()
68+
{
69+
if(!isEnabled() || MC.player == null || MC.player.connection == null)
5570
return;
56-
5771
if(!MC.player.getMainHandItem().is(Items.MACE))
5872
return;
59-
73+
74+
long now = MC.player.tickCount;
75+
if(now == lastSmashTick)
76+
return;
77+
lastSmashTick = now;
6078
// See ServerGamePacketListenerImpl.handleMovePlayer()
6179
// for why it's using these numbers.
6280
// Also, let me know if you find a way to bypass that check.
6381
for(int i = 0; i < 4; i++)
6482
sendFakeY(0);
65-
sendFakeY(height.getValue());
83+
sendFakeY(findFallOffset());
6684
sendFakeY(0);
6785
}
68-
86+
87+
private double findFallOffset()
88+
{
89+
double cap = height.getValue();
90+
if(!caveMode.isChecked() || MC.level == null)
91+
return cap;
92+
93+
for(double off = cap; off >= MIN_FALL; off -= SCAN_STEP)
94+
{
95+
AABB box = MC.player.getBoundingBox().move(0, off, 0);
96+
if(MC.level.noCollision(MC.player, box))
97+
return off;
98+
}
99+
100+
return cap;
101+
}
102+
69103
private void sendFakeY(double offset)
70104
{
71105
MC.player.connection

0 commit comments

Comments
 (0)