@nxg-org/mineflayer-physics-util 1.3.2 → 1.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.EntityState = exports.EntityPhysics = exports.BaseSimulator = exports.PhysicsSettings = exports.EPhysicsCtx = exports.initSetup = void 0;
|
|
7
4
|
const settings_1 = require("./physics/settings");
|
|
8
5
|
const wrapper_1 = require("./wrapper");
|
|
9
|
-
const prismarine_registry_1 = __importDefault(require("prismarine-registry"));
|
|
10
6
|
function loader(bot) {
|
|
11
7
|
if (!bot.physicsUtil) {
|
|
12
|
-
initSetup(
|
|
8
|
+
initSetup(bot.registry);
|
|
13
9
|
bot.physicsUtil = new wrapper_1.PhysicsUtilWrapper(bot);
|
|
14
10
|
}
|
|
15
11
|
}
|
|
@@ -4,7 +4,7 @@ import { EntityState } from "../physics/states";
|
|
|
4
4
|
import { IPhysics } from "../physics/engines";
|
|
5
5
|
import { Entity } from "prismarine-entity";
|
|
6
6
|
import { Vec3 } from "vec3";
|
|
7
|
-
export declare type SimulationGoal = (state: EntityState) => boolean;
|
|
7
|
+
export declare type SimulationGoal = (state: EntityState, ticks?: number) => boolean;
|
|
8
8
|
export declare type OnGoalReachFunction = (state: EntityState) => void;
|
|
9
9
|
export declare type Controller = (state: EntityState, ticks: number) => void;
|
|
10
10
|
export declare abstract class BaseSimulator {
|
|
@@ -23,13 +23,13 @@ class BaseSimulator {
|
|
|
23
23
|
}
|
|
24
24
|
simulateUntil(goal, onGoalReach, controller, simCtx, world, ticks = 1) {
|
|
25
25
|
for (let i = 0; i < ticks; i++) {
|
|
26
|
-
if (goal(simCtx.state)) {
|
|
26
|
+
if (goal(simCtx.state, i)) {
|
|
27
27
|
onGoalReach(simCtx.state);
|
|
28
28
|
break;
|
|
29
29
|
}
|
|
30
30
|
if (simCtx.state.isInLava)
|
|
31
31
|
break;
|
|
32
|
-
controller(simCtx.state,
|
|
32
|
+
controller(simCtx.state, i);
|
|
33
33
|
this.ctx.simulate(simCtx, world);
|
|
34
34
|
simCtx.state.age++;
|
|
35
35
|
}
|
|
@@ -52,10 +52,10 @@ class BaseSimulator {
|
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
54
|
static buildAnyGoal(...goals) {
|
|
55
|
-
return (state) => goals.map((goal) => goal(state)).some(g => !!g);
|
|
55
|
+
return (state, ticks) => goals.map((goal) => goal(state, ticks)).some(g => !!g);
|
|
56
56
|
}
|
|
57
57
|
static buildAllGoal(...goals) {
|
|
58
|
-
return (state) => goals.map((goal) => goal(state)).every(g => !!g);
|
|
58
|
+
return (state, ticks) => goals.map((goal) => goal(state, ticks)).every(g => !!g);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
exports.BaseSimulator = BaseSimulator;
|