Skip to content

Commit

Permalink
cancel on sneaking feature & update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
GenerelSchwerz committed Apr 16, 2024
1 parent 7b21ac3 commit 16e384c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 8 deletions.
30 changes: 22 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ Returns if the bot should jump (if we do not jump right now, there will be an is

Returns if the bot is allowed to jump (no jump *needed*, but no detriment to jumping right now).

### `autoJump.strictBlockCollision: boolean`

If true, only jump if the bot is colliding with a block ABOVE current walking level.
If false, the bot will jump if it is colliding with a block at all.

### `autoJump.jumpOnAllEdges: boolean`

If the bot should jump on all edges. This is mainly used for descending slopes, combined with `maxBlockOffset`.
Expand All @@ -70,6 +75,10 @@ If the bot should minimize fall damage. Similar to maxBlockOffset set to 3 excep

If the bot should debug the jump checker. Your console will be spammed. Just report the information to me.

### `autoJump.cancelOnShift: boolean`

If the bot should cancel the jump if the player is holding shift. Useful for sneaking.

## Events

### `autoJump.on('shouldJump', () => {})`
Expand All @@ -80,16 +89,10 @@ Emitted when the bot should jump.

<!--
export interface JumpCheckerOpts {
jumpOnAllEdges: boolean;
jumpIntoWater: boolean;
maxBlockOffset: number;
minimizeFallDmg: boolean;
debug: boolean;
}
export const DefaultHandlerKeys: JumpCheckerOpts = {
strictBlockCollision: true,
jumpOnAllEdges: false,
jumpToClearSmallDip: false,
jumpIntoWater: false,
maxBlockOffset: 0,
minimizeFallDmg: false,
Expand All @@ -98,10 +101,21 @@ export const DefaultHandlerKeys: JumpCheckerOpts = {
export interface AutoJumperOpts {
enabled: boolean;
cancelOnShift: boolean;
}
export const DefaultKeys: AutoJumperOpts = {
enabled: false,
cancelOnShift: false
};
export const DefaultHandlerKeys: JumpCheckerOpts = {
jumpOnAllEdges: false,
jumpIntoWater: false,
maxBlockOffset: 0,
minimizeFallDmg: false,
debug: false
};
interface AutoJumperEvents {
Expand Down
2 changes: 2 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ export const DefaultHandlerKeys: JumpCheckerOpts = {

export interface AutoJumperOpts {
enabled: boolean;
cancelOnShift: boolean;
}

export const DefaultKeys: AutoJumperOpts = {
enabled: false,
cancelOnShift: false
};

interface AutoJumperEvents {
Expand Down
8 changes: 8 additions & 0 deletions src/wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export class AutoJumper extends (EventEmitter as { new (): AutoJumperEmitter })
private lastJump: boolean = false;
private _enabled: boolean = false;

public cancelOnShift: boolean = false;

public get enabled() {
return this._enabled;
}
Expand Down Expand Up @@ -60,6 +62,12 @@ export class AutoJumper extends (EventEmitter as { new (): AutoJumperEmitter })
}

private jumpListener = () => {

if (this.cancelOnShift && this.bot.getControlState("sneak")) {
this.lastJump = false;
return;
}

if (this.handler.shouldJump()) {
if (!this.lastJump) {
this.emit("shouldJump");
Expand Down

0 comments on commit 16e384c

Please sign in to comment.