@nxg-org/mineflayer-physics-util 1.3.8 → 1.3.10
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.
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { AABB } from "@nxg-org/mineflayer-util-plugin";
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import { IPhysics } from "../engines/IPhysics";
|
|
2
|
+
import md from "minecraft-data";
|
|
3
|
+
import type { Bot } from "mineflayer";
|
|
5
4
|
import { Entity } from "prismarine-entity";
|
|
6
5
|
import { Vec3 } from "vec3";
|
|
7
|
-
import
|
|
6
|
+
import { IPhysics } from "../engines/IPhysics";
|
|
7
|
+
import { EntityState } from "../states/entityState";
|
|
8
|
+
import { PlayerPoses } from "../states/poses";
|
|
8
9
|
export declare const emptyVec: Vec3;
|
|
9
10
|
declare type PlayerPoseContext = {
|
|
10
11
|
[key in PlayerPoses]: {
|
|
@@ -46,6 +47,7 @@ export declare class EPhysicsCtx {
|
|
|
46
47
|
readonly useControls: boolean;
|
|
47
48
|
readonly collisionBehavior: CollisionContext;
|
|
48
49
|
constructor(ctx: IPhysics, pose: PlayerPoses, state: EntityState, entityType?: md.Entity);
|
|
50
|
+
static FROM_BOT(ctx: IPhysics, bot: Bot): EPhysicsCtx;
|
|
49
51
|
static FROM_ENTITY(ctx: IPhysics, entity: Entity): EPhysicsCtx;
|
|
50
52
|
static FROM_ENTITY_TYPE(ctx: IPhysics, entityType: md.Entity, options?: Partial<Entity>): EPhysicsCtx;
|
|
51
53
|
static FROM_ENTITY_STATE(ctx: IPhysics, entityState: EntityState, entityType: md.Entity): EPhysicsCtx;
|
|
@@ -5,14 +5,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.EPhysicsCtx = exports.emptyVec = void 0;
|
|
7
7
|
const mineflayer_util_plugin_1 = require("@nxg-org/mineflayer-util-plugin");
|
|
8
|
-
const poses_1 = require("../states/poses");
|
|
9
|
-
const entityState_1 = require("../states/entityState");
|
|
10
|
-
const physicsUtils_1 = require("../../util/physicsUtils");
|
|
11
8
|
const prismarine_entity_1 = __importDefault(require("prismarine-entity"));
|
|
12
9
|
const vec3_1 = require("vec3");
|
|
10
|
+
const physicsUtils_1 = require("../../util/physicsUtils");
|
|
11
|
+
const entityState_1 = require("../states/entityState");
|
|
12
|
+
const poses_1 = require("../states/poses");
|
|
13
13
|
const entity_physics_json_1 = __importDefault(require("../info/entity_physics.json"));
|
|
14
14
|
function getPose(entity) {
|
|
15
|
-
const pose = entity.metadata.find((e) => e.type === 18);
|
|
15
|
+
const pose = entity.metadata.find((e) => { var _a; return ((_a = e) === null || _a === void 0 ? void 0 : _a.type) === 18; });
|
|
16
16
|
return pose ? pose.value : poses_1.PlayerPoses.STANDING;
|
|
17
17
|
}
|
|
18
18
|
function load(data) {
|
|
@@ -133,6 +133,9 @@ class EPhysicsCtx {
|
|
|
133
133
|
this.lavaGravity = 0.02;
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
|
+
static FROM_BOT(ctx, bot) {
|
|
137
|
+
return new EPhysicsCtx(ctx, getPose(bot.entity), entityState_1.EntityState.CREATE_FROM_BOT(ctx, bot));
|
|
138
|
+
}
|
|
136
139
|
static FROM_ENTITY(ctx, entity) {
|
|
137
140
|
return new EPhysicsCtx(ctx, getPose(entity), entityState_1.EntityState.CREATE_FROM_ENTITY(ctx, entity), EPhysicsCtx.entityData[entity.name]);
|
|
138
141
|
}
|