forked from Wurst-Imperium/Wurst7
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMaceDmgHack.java
More file actions
83 lines (72 loc) · 2.32 KB
/
MaceDmgHack.java
File metadata and controls
83 lines (72 loc) · 2.32 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
/*
* 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 net.minecraft.network.protocol.game.ServerboundMovePlayerPacket.Pos;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.item.Items;
import net.wurstclient.Category;
import net.wurstclient.SearchTags;
import net.wurstclient.events.PlayerAttacksEntityListener;
import net.wurstclient.hack.Hack;
import net.wurstclient.settings.SliderSetting;
import net.wurstclient.settings.SliderSetting.ValueDisplay;
@SearchTags({"mace dmg", "MaceDamage", "mace damage"})
public final class MaceDmgHack extends Hack
implements PlayerAttacksEntityListener
{
private static final double DEFAULT_HEIGHT = Math.sqrt(500);
private final SliderSetting height = new SliderSetting("Height",
"How high to fake before slamming. Height determines the damage boost.",
DEFAULT_HEIGHT, 1.6, 50, 0.1, ValueDisplay.DECIMAL);
private long lastSmashTick = -1;
public MaceDmgHack()
{
super("MaceDMG");
setCategory(Category.COMBAT);
addSetting(height);
}
@Override
protected void onEnable()
{
EVENTS.add(PlayerAttacksEntityListener.class, this);
}
@Override
protected void onDisable()
{
EVENTS.remove(PlayerAttacksEntityListener.class, this);
}
@Override
public void onPlayerAttacksEntity(Entity target)
{
doSmash();
}
public void doSmash()
{
if(!isEnabled() || MC.player == null || MC.player.connection == null)
return;
if(!MC.player.getMainHandItem().is(Items.MACE))
return;
long now = MC.player.tickCount;
if(now == lastSmashTick)
return;
lastSmashTick = now;
// See ServerGamePacketListenerImpl.handleMovePlayer()
// for why it's using these numbers.
// Also, let me know if you find a way to bypass that check.
for(int i = 0; i < 4; i++)
sendFakeY(0);
sendFakeY(height.getValue());
sendFakeY(0);
}
private void sendFakeY(double offset)
{
MC.player.connection
.send(new Pos(MC.player.getX(), MC.player.getY() + offset,
MC.player.getZ(), false, MC.player.horizontalCollision));
}
}