Skip to content

Commit 26fbdf3

Browse files
committed
phantom blocks aura
1 parent cc260ec commit 26fbdf3

File tree

4 files changed

+155
-18
lines changed

4 files changed

+155
-18
lines changed

src/skyblock/AntiAFK.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export class AntiAFK {
2929
// State management for tick-based logic
3030
private processingActionUntil = 0;
3131
private unsneakAt = 0;
32+
private unjumpAt = 0;
3233
private checkScreenAt = 0;
3334

3435
constructor(onActivityChange?: (active: boolean) => void) {
@@ -114,7 +115,8 @@ export class AntiAFK {
114115
matched = true;
115116
} else if (lowerText.includes('jump')) {
116117
Chat.log('§aAntiAFK: §7Jumping');
117-
this.keys.jump.click();
118+
this.keys.jump.set(true);
119+
this.unjumpAt = Date.now() + 100;
118120
matched = true;
119121
} else if (lowerText.includes('sneak')) {
120122
Chat.log('§aAntiAFK: §7Sneaking');
@@ -158,6 +160,12 @@ export class AntiAFK {
158160
this.unsneakAt = 0;
159161
}
160162

163+
// Handle Delayed Unjump
164+
if (this.unjumpAt > 0 && Date.now() > this.unjumpAt) {
165+
this.keys.jump.set(false);
166+
this.unjumpAt = 0;
167+
}
168+
161169
// Handle Delayed Screen Check
162170
if (this.checkScreenAt > 0 && Date.now() > this.checkScreenAt) {
163171
this.handleOpenScreenLogic();
@@ -215,7 +223,7 @@ export class AntiAFK {
215223
this.saveConfig();
216224
Chat.log('§7AntiAFK is now §cDISABLED');
217225
});
218-
226+
219227
cmd.register();
220228
}
221229
}

src/skyblock/PhantomBlocks.ts

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
import Config from '../libs/Config';
2+
import { CommandManager } from '../libs/CommandBuilderWrapper';
3+
4+
interface PhantomBlocksConfig {
5+
enabled: boolean;
6+
range: number;
7+
}
8+
9+
export class PhantomBlocks {
10+
private readonly configPath = './config/jayc331-config.json';
11+
private readonly scriptId = 'phantomBlocks';
12+
13+
private readonly defaultConfig: PhantomBlocksConfig = {
14+
enabled: true,
15+
range: 4.5,
16+
};
17+
18+
private config: PhantomBlocksConfig;
19+
20+
constructor() {
21+
this.config = Config.readConfig(this.configPath, { ...this.defaultConfig }, this.scriptId);
22+
this.registerListeners();
23+
this.registerCommands();
24+
}
25+
26+
private registerListeners() {
27+
JsMacros.on(
28+
'Tick',
29+
JavaWrapper.methodToJava((event) => this.onTick(event as Events.Tick))
30+
);
31+
}
32+
33+
private onTick(event: Events.Tick) {
34+
if (!this.config.enabled) return;
35+
36+
const player = Player.getPlayer();
37+
if (!player) return;
38+
39+
// 1.0 means fully charged attack indicator
40+
if (player.getAttackCooldownProgress() < 1.0) return;
41+
42+
const pPos = player.getPos();
43+
const entities = World.getEntities();
44+
45+
let target = null;
46+
let minDst = this.config.range;
47+
48+
for (let i = 0; i < entities.size(); i++) {
49+
const entity = entities.get(i);
50+
// Check if entity is alive and is a Vex
51+
// entity.getType() returns string like 'minecraft:vex'
52+
if (entity.getType() === 'minecraft:vex') {
53+
const ePos = entity.getPos();
54+
const dst = Math.sqrt(
55+
Math.pow(pPos.getX() - ePos.getX(), 2) +
56+
Math.pow(pPos.getY() - ePos.getY(), 2) +
57+
Math.pow(pPos.getZ() - ePos.getZ(), 2)
58+
);
59+
60+
if (dst <= minDst) {
61+
minDst = dst;
62+
target = entity;
63+
}
64+
}
65+
}
66+
67+
if (target) {
68+
const originalYaw = player.getYaw();
69+
const originalPitch = player.getPitch();
70+
71+
const eyePos = target.getEyePos();
72+
player.lookAt(eyePos.x, eyePos.y, eyePos.z);
73+
player.attack(target);
74+
75+
player.lookAt(originalYaw, originalPitch);
76+
}
77+
}
78+
79+
private saveConfig() {
80+
Config.writeConfig(this.configPath, this.config, this.scriptId);
81+
}
82+
83+
private registerCommands() {
84+
const cmd = CommandManager.create('phantomblocks');
85+
86+
cmd.literal('toggle').executes(() => {
87+
this.config.enabled = !this.config.enabled;
88+
this.saveConfig();
89+
Chat.log(`§7PhantomBlocks is now ${this.config.enabled ? '§aENABLED' : '§cDISABLED'}`);
90+
});
91+
92+
cmd.literal('range')
93+
.argument('range', 'double')
94+
.executes((ctx) => {
95+
const range = ctx.getArg('range');
96+
this.config.range = range;
97+
this.saveConfig();
98+
Chat.log(`§7PhantomBlocks range set to §a${range}`);
99+
});
100+
101+
cmd.register();
102+
}
103+
}

src/skyblock/main.ts

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ updateScript(file.getAbsolutePath(), 'jayc331/JSMacros-Scripts', './config/jayc3
33

44
import Config from '../libs/Config';
55
import { AntiAFK } from './AntiAFK';
6+
import { PhantomBlocks } from './PhantomBlocks';
67
import { BaritoneAPI, BetterBlockPos } from '../libs/BaritoneAPIProvider';
78
import { Key } from '../libs/KeyManager';
89
import { CommandManager } from '../libs/CommandBuilderWrapper';
@@ -37,6 +38,7 @@ interface StrafingOptions {
3738
interact: DirectionConfig<InteractionConfig>;
3839
pitch: DirectionConfig<number | null>;
3940
threshold: DirectionConfig<number>;
41+
flight: boolean;
4042
}
4143

4244
interface StrafingConfig {
@@ -68,6 +70,7 @@ class StrafingScript {
6870
},
6971
pitch: { left: -2, right: -10 },
7072
threshold: { left: 0.5, right: 0.5 },
73+
flight: true,
7174
},
7275
};
7376

@@ -135,7 +138,7 @@ class StrafingScript {
135138
/**
136139
* Updates a directional configuration option safely.
137140
*/
138-
private updateOption<K extends keyof StrafingOptions>(
141+
private updateOption<K extends 'sneak' | 'interact' | 'pitch' | 'threshold'>(
139142
key: K,
140143
direction: Direction,
141144
updater: (current: StrafingOptions[K]['left']) => StrafingOptions[K]['left']
@@ -190,6 +193,12 @@ class StrafingScript {
190193
this.showStatus(`§7Interact set to §a${ref.mode}§7 (${ref.key}, ${ref.cps} CPS) for §e${direction}`);
191194
}
192195

196+
public setFlight(state: boolean) {
197+
this.config.options.flight = state;
198+
this.saveConfig();
199+
this.showStatus(`§7Flight recovery set to §a${state}`);
200+
}
201+
193202
// =========================================================================
194203
// Control Logic
195204
// =========================================================================
@@ -202,7 +211,7 @@ class StrafingScript {
202211
JsMacros.off(this.tickListener);
203212
this.tickListener = null;
204213
}
205-
214+
206215
// Clear visuals
207216
try {
208217
if (this.currentSelection) {
@@ -231,7 +240,7 @@ class StrafingScript {
231240

232241
this.isRunning = true;
233242
this.captchaProceed = true;
234-
this.isStarting = true;
243+
this.isStarting = this.config.options.flight;
235244
this.startTickCounter = 0;
236245
this.currentTarget = 2;
237246
this.startTime = Date.now();
@@ -252,13 +261,18 @@ class StrafingScript {
252261
JavaWrapper.methodToJava(() => this.tick())
253262
);
254263
}
255-
this.showStatus('§aStrafing initializing...');
264+
265+
if (this.isStarting) {
266+
this.showStatus('§aStrafing initializing...');
267+
} else {
268+
this.showStatus('§aStrafing started!');
269+
}
256270
}
257271

258272
private updateVisuals() {
259273
try {
260274
const primary = BaritoneAPI.getProvider().getPrimaryBaritone();
261-
275+
262276
if (this.currentSelection) {
263277
primary.getSelectionManager().removeSelection(this.currentSelection);
264278
this.currentSelection = null;
@@ -315,6 +329,12 @@ class StrafingScript {
315329

316330
private tick() {
317331
try {
332+
// Force allowPaused to true (field_1695)
333+
const mc = Client.getMinecraft();
334+
const field = Reflection.getDeclaredField(mc.getClass(), 'field_1695');
335+
field.setAccessible(true);
336+
field.set(mc, true);
337+
318338
if (!this.isRunning) return;
319339

320340
const player = Player.getPlayer();
@@ -333,15 +353,15 @@ class StrafingScript {
333353
this.showStatus('§eStrafing paused (Out of Bounds).', 100);
334354
return;
335355
}
336-
356+
337357
// 3. Screen Check (Inventory Open)
338358
if (Hud.getOpenScreen()) {
339-
this.cleanupKeys();
340-
return;
359+
this.cleanupKeys();
360+
return;
341361
}
342362

343363
// 4. Flight Recovery
344-
if (!player.getAbilities().getFlying() && !this.isStarting) {
364+
if (this.config.options.flight && !player.getAbilities().getFlying() && !this.isStarting) {
345365
this.isStarting = true;
346366
this.startTickCounter = 0;
347367
this.cleanupKeys();
@@ -383,7 +403,7 @@ class StrafingScript {
383403
// Tick 2: Release
384404
// Tick 4: Press (Toggle flight)
385405
// Tick 6: Release
386-
406+
387407
if (tick === 0) this.keys.jump.set(true);
388408
if (tick === 2) this.keys.jump.set(false);
389409
if (tick === 4) this.keys.jump.set(true);
@@ -393,8 +413,9 @@ class StrafingScript {
393413
if (player.getAbilities().getFlying()) {
394414
this.isStarting = false;
395415
this.showStatus('§aStrafing started!');
396-
} else if (tick > 20) { // Retry after 1 second
397-
this.startTickCounter = 0;
416+
} else if (tick > 20) {
417+
// Retry after 1 second
418+
this.startTickCounter = 0;
398419
}
399420
}
400421
}
@@ -508,15 +529,15 @@ class StrafingScript {
508529
// Dynamic hold time based on CPS to ensure reliability
509530
// Aim for ~60-70% duty cycle, but ensure at least 60ms if possible (for reliable server tick detection)
510531
// and ensure we leave at least 25ms gap for the release logic.
511-
532+
512533
const maxPossibleHold = Math.max(0, interval - 40); // Leave ~40ms gap
513534
const targetHold = Math.min(maxPossibleHold, Math.max(60, interval * 0.6));
514535
const randomness = Math.min(30, maxPossibleHold - targetHold); // Add jitter if room exists
515536

516537
const holdTime = targetHold + Math.random() * randomness;
517-
538+
518539
state.releaseTime = now + holdTime;
519-
540+
520541
// Schedule next press
521542
state.nextPressTime = Math.max(now, state.nextPressTime) + interval;
522543
}
@@ -536,6 +557,7 @@ const strafer = new StrafingScript();
536557
const antiAFK = new AntiAFK((active) => {
537558
strafer.captchaProceed = !active;
538559
});
560+
const phantomBlocks = new PhantomBlocks();
539561

540562
(event as any).stopListener = JavaWrapper.methodToJava(() => strafer.stop());
541563

@@ -620,6 +642,10 @@ set.literal('threshold')
620642
.suggestMatching(['both', 'left', 'right'])
621643
.executes((ctx) => strafer.setDistanceThreshold(ctx.getArg('value'), ctx.getArg('direction')));
622644

645+
set.literal('flight')
646+
.argument('state', 'boolean')
647+
.executes((ctx) => strafer.setFlight(ctx.getArg('state')));
648+
623649
strafe.register();
624650

625651
export default event;

src/skyblock/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "0.1.3",
2+
"version": "0.1.4",
33
"title": "Skyblock",
44
"description": "Macros for hub.mc-complex.com"
55
}

0 commit comments

Comments
 (0)