Skip to content

Commit 75288be

Browse files
committed
Updated SpearAssist
1 parent 5270f60 commit 75288be

File tree

2 files changed

+60
-12
lines changed

2 files changed

+60
-12
lines changed

README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -376,16 +376,17 @@ I did not, nor could I copy their code directly as most are Meteor based mods. S
376376

377377
![Loot](https://i.imgur.com/7pkTPxW.png)
378378

379-
### SpearAssist
380-
- Boost Modes:
381-
- Dash - While charging with your right click you can boost yourself forward a specific distance with your left click creating a velocity based attack.
382-
- Hold - While charging you are constantly boosting forward whenever you press the left click.
383-
- Your player can optionally stay grounded when boosting as to avoid flying off into the distance on each attack.
384-
- Highlighting: You can highlight near and far entities within your attack range. Near meaning the distance you can jab at them and far the distance you can charge at them. Default set to 7 for near and 8.5 blocks for far.
385-
- Your charge is automatically and constantly resumed (no cooldown) so you can forever hold right click. It will be noisy but even if the spear is pointed down you will still be able to attack.
386-
- You can optionally allow aim assist to work whilst holding right click.
387-
- Auto Attack, your jab attack will continue to auto hit once the cooldown has expired so long as you're hitting an entity.
388-
- Designed for elytra-free ground PvP/PvE, though may be even more interesting with one.
379+
### SpearAssist
380+
- Boost Modes:
381+
- Dash - While charging with your right click you can boost yourself forward a specific distance with your left click creating a velocity based attack.
382+
- Hold - While charging you are constantly boosting forward whenever you press the left click.
383+
- Your player can optionally stay grounded when boosting as to avoid flying off into the distance on each attack.
384+
- Allow reverse toggle lets you hold S/back while attacking to flip boosts so they launch you backward instead.
385+
- Highlighting: You can highlight near and far entities within your attack range. Near meaning the distance you can jab at them and far the distance you can charge at them. Default set to 7 for near and 8.5 blocks for far.
386+
- Your charge is automatically and constantly resumed (no cooldown) so you can forever hold right click. It will be noisy but even if the spear is pointed down you will still be able to attack.
387+
- You can optionally allow aim assist to work whilst holding right click.
388+
- Auto Attack, your jab attack will continue to auto hit once the cooldown has expired so long as you're hitting an entity.
389+
- Designed for elytra-free ground PvP/PvE, though may be even more interesting with one.
389390

390391
### Custom Command Prefixes
391392
- In the Wurst Options menu you can now change your command prefix

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

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ public final class SpearAssistHack extends Hack
5454
"Extra distance to travel each time you start holding attack.", 4,
5555
0, 10, 0.1, ValueDisplay.DECIMAL.withSuffix(" blocks"));
5656

57+
private final CheckboxSetting allowReverse = new CheckboxSetting(
58+
"Allow reverse",
59+
"Hold the Back key (default: S) while attacking to boost backwards instead of forwards.",
60+
false);
61+
5762
private final SliderSetting nearHighlightRange =
5863
new SliderSetting("Near highlight range",
5964
"Distance where targets switch to the near color.", 7, 4, 10, 0.5,
@@ -97,6 +102,7 @@ public final class SpearAssistHack extends Hack
97102
private boolean useGlowFallback = true;
98103
private RenderStyleInfo currentStyle;
99104
private boolean autoAttackPrimed;
105+
private boolean reverseDashActive;
100106

101107
public SpearAssistHack()
102108
{
@@ -105,6 +111,7 @@ public SpearAssistHack()
105111
addSetting(boostMode);
106112
addSetting(boostSpeed);
107113
addSetting(dashDistance);
114+
addSetting(allowReverse);
108115
addSetting(stayGrounded);
109116
addSetting(nearHighlightRange);
110117
addSetting(farHighlightRange);
@@ -156,12 +163,21 @@ public void onUpdate()
156163
if(direction.lengthSqr() > 1.0E-4)
157164
{
158165
if(attackPressed)
166+
{
167+
updateReverseDashState();
159168
startDash();
169+
}
170+
171+
Vec3 reversed = direction.scale(-1);
172+
Vec3 holdDirection =
173+
shouldReverseHoldBoost(attackHeld) ? reversed : direction;
174+
Vec3 dashDirection =
175+
shouldReverseDashBoost() ? reversed : direction;
160176

161177
if(attackHeld)
162-
applyHoldVelocity(direction);
178+
applyHoldVelocity(holdDirection);
163179

164-
continueDash(direction);
180+
continueDash(dashDirection);
165181
}
166182
}else
167183
resetDash();
@@ -327,12 +343,16 @@ private void startDash()
327343
private void continueDash(Vec3 direction)
328344
{
329345
if(dashDistanceRemaining <= 0 || !getBoostMode().useDash())
346+
{
347+
reverseDashActive = false;
330348
return;
349+
}
331350

332351
double dashSpeed = Math.max(0, boostSpeed.getValue());
333352
if(dashSpeed <= 0)
334353
{
335354
dashDistanceRemaining = 0;
355+
reverseDashActive = false;
336356
return;
337357
}
338358

@@ -345,6 +365,9 @@ private void continueDash(Vec3 direction)
345365
MC.player.setOnGround(false);
346366
MC.player.fallDistance = 0;
347367
dashDistanceRemaining -= step;
368+
369+
if(dashDistanceRemaining <= 0)
370+
reverseDashActive = false;
348371
}
349372

350373
private void applyHoldVelocity(Vec3 direction)
@@ -367,6 +390,7 @@ private void resetDash()
367390
{
368391
dashDistanceRemaining = 0;
369392
attackKeyDown = false;
393+
reverseDashActive = false;
370394
}
371395

372396
private void resetState()
@@ -377,6 +401,7 @@ private void resetState()
377401
currentStyle = null;
378402
aimAssistTemporarilyAllowed = false;
379403
autoAttackPrimed = false;
404+
reverseDashActive = false;
380405
}
381406

382407
private void updateHighlights(boolean holdingSpear)
@@ -507,6 +532,28 @@ private boolean isSpear(ItemStack stack)
507532
return id.getPath().toLowerCase(Locale.ROOT).contains("spear");
508533
}
509534

535+
private void updateReverseDashState()
536+
{
537+
if(MC.options == null || !allowReverse.isChecked())
538+
{
539+
reverseDashActive = false;
540+
return;
541+
}
542+
543+
reverseDashActive = MC.options.keyDown.isDown();
544+
}
545+
546+
private boolean shouldReverseHoldBoost(boolean attackHeld)
547+
{
548+
return allowReverse.isChecked() && attackHeld && MC.options != null
549+
&& MC.options.keyDown.isDown();
550+
}
551+
552+
private boolean shouldReverseDashBoost()
553+
{
554+
return allowReverse.isChecked() && reverseDashActive;
555+
}
556+
510557
private enum BoostMode
511558
{
512559
HOLD_ONLY("Hold only", true, false),

0 commit comments

Comments
 (0)