@nxg-org/mineflayer-physics-util 1.9.0 → 1.9.2
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/.vscode/settings.json +4 -4
- package/README.md +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/physics/engines/botcraft.js +1 -1
- package/dist/physics/engines/entityPhysics.js +1 -1
- package/dist/physics/engines/optimizedPhysics.js +1 -1
- package/dist/physics/settings/entityPhysicsCtx.d.ts +2 -2
- package/dist/physics/settings/entityPhysicsCtx.js +7 -2
- package/dist/physics/states/entityState.d.ts +1 -1
- package/dist/physics/states/entityState.js +15 -15
- package/dist/physics/states/index.d.ts +1 -1
- package/dist/physics/states/playerState.d.ts +1 -1
- package/dist/physics/states/playerState.js +19 -16
- package/dist/util/physicsUtils.d.ts +5 -0
- package/dist/util/physicsUtils.js +26 -16
- package/eslint.config.mjs +17 -17
- package/package.json +2 -2
package/.vscode/settings.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
{
|
|
2
|
-
"print.colourScheme": "GitHub",
|
|
3
|
-
"ecl.launchConfiguration": "not found",
|
|
4
|
-
"ecl.targetCluster": {}
|
|
1
|
+
{
|
|
2
|
+
"print.colourScheme": "GitHub",
|
|
3
|
+
"ecl.launchConfiguration": "not found",
|
|
4
|
+
"ecl.targetCluster": {}
|
|
5
5
|
}
|
package/README.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
# mineflayer-physics-utils
|
|
1
|
+
# mineflayer-physics-utils
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ declare module "mineflayer" {
|
|
|
8
8
|
}
|
|
9
9
|
export default function loader(bot: Bot): void;
|
|
10
10
|
export declare function initSetup(data: IndexedData): void;
|
|
11
|
+
export { PhysicsUtilWrapper } from "./wrapper";
|
|
11
12
|
export { EPhysicsCtx, PhysicsWorldSettings } from "./physics/settings";
|
|
12
13
|
export { BaseSimulator } from "./simulators";
|
|
13
14
|
export { EntityPhysics, BotcraftPhysics } from "./physics/engines";
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.applyToPlayerState = exports.convertPlayerState = exports.ControlStateHandler = exports.PlayerPoses = exports.PlayerState = exports.EntityState = exports.BotcraftPhysics = exports.EntityPhysics = exports.BaseSimulator = exports.PhysicsWorldSettings = exports.EPhysicsCtx = void 0;
|
|
3
|
+
exports.applyToPlayerState = exports.convertPlayerState = exports.ControlStateHandler = exports.PlayerPoses = exports.PlayerState = exports.EntityState = exports.BotcraftPhysics = exports.EntityPhysics = exports.BaseSimulator = exports.PhysicsWorldSettings = exports.EPhysicsCtx = exports.PhysicsUtilWrapper = void 0;
|
|
4
4
|
exports.default = loader;
|
|
5
5
|
exports.initSetup = initSetup;
|
|
6
6
|
const settings_1 = require("./physics/settings");
|
|
@@ -14,6 +14,8 @@ function loader(bot) {
|
|
|
14
14
|
function initSetup(data) {
|
|
15
15
|
settings_1.EPhysicsCtx.loadData(data);
|
|
16
16
|
}
|
|
17
|
+
var wrapper_2 = require("./wrapper");
|
|
18
|
+
Object.defineProperty(exports, "PhysicsUtilWrapper", { enumerable: true, get: function () { return wrapper_2.PhysicsUtilWrapper; } });
|
|
17
19
|
var settings_2 = require("./physics/settings");
|
|
18
20
|
Object.defineProperty(exports, "EPhysicsCtx", { enumerable: true, get: function () { return settings_2.EPhysicsCtx; } });
|
|
19
21
|
Object.defineProperty(exports, "PhysicsWorldSettings", { enumerable: true, get: function () { return settings_2.PhysicsWorldSettings; } });
|
|
@@ -752,7 +752,7 @@ class BotcraftPhysics {
|
|
|
752
752
|
!player.isInWater &&
|
|
753
753
|
/* !player->GetDataSharedFlagsIdImpl(EntitySharedFlagsId::FallFlying) && */ !player.fallFlying &&
|
|
754
754
|
!hasLevitationEffect) {
|
|
755
|
-
const hasElytra = player.
|
|
755
|
+
const hasElytra = player.validElytraEquipped;
|
|
756
756
|
if (hasElytra) {
|
|
757
757
|
player.fallFlying = true;
|
|
758
758
|
// https://github.com/adepierre/Botcraft/blob/6c572071b0237c27a85211a246ce10565ef4d80f/botcraft/src/Game/Physics/PhysicsManager.cpp#L792
|
|
@@ -733,7 +733,7 @@ class EntityPhysics {
|
|
|
733
733
|
entity.state.control.sprint = false;
|
|
734
734
|
}
|
|
735
735
|
entity.state.fallFlying =
|
|
736
|
-
entity.state.fallFlying && entity.state.
|
|
736
|
+
entity.state.fallFlying && entity.state.validElytraEquipped && !entity.state.onGround && !entity.state.levitation;
|
|
737
737
|
// for now, only check if this is a player.
|
|
738
738
|
if (entity.state instanceof states_1.PlayerState) {
|
|
739
739
|
if (entity.state.fireworkRocketDuration > 0) {
|
|
@@ -731,7 +731,7 @@ class EntityPhysics {
|
|
|
731
731
|
entity.state.control.sprint = false;
|
|
732
732
|
}
|
|
733
733
|
}
|
|
734
|
-
entity.state.fallFlying = entity.state.fallFlying && entity.state.
|
|
734
|
+
entity.state.fallFlying = entity.state.fallFlying && entity.state.validElytraEquipped && !entity.state.onGround && !entity.state.levitation;
|
|
735
735
|
if (entity.state.fireworkRocketDuration > 0) {
|
|
736
736
|
if (!entity.state.fallFlying) {
|
|
737
737
|
entity.state.fireworkRocketDuration = 0;
|
|
@@ -24,8 +24,6 @@ export declare class EPhysicsCtx<State extends IEntityState = IEntityState> {
|
|
|
24
24
|
static mcData: md.IndexedData;
|
|
25
25
|
static entityData: md.IndexedData["entitiesByName"];
|
|
26
26
|
static mobData: md.IndexedData["mobs"];
|
|
27
|
-
readonly position: Vec3;
|
|
28
|
-
readonly velocity: Vec3;
|
|
29
27
|
stepHeight: number;
|
|
30
28
|
gravity: number;
|
|
31
29
|
waterGravity: number;
|
|
@@ -42,6 +40,8 @@ export declare class EPhysicsCtx<State extends IEntityState = IEntityState> {
|
|
|
42
40
|
doSolidCollisions: boolean;
|
|
43
41
|
doLiquidCollisions: boolean;
|
|
44
42
|
collisionBehavior: CollisionContext;
|
|
43
|
+
get position(): Vec3;
|
|
44
|
+
get velocity(): Vec3;
|
|
45
45
|
constructor(ctx: IPhysics, worldSettings: PhysicsWorldSettings, pose: PlayerPoses, state: State, entityType?: md.Entity);
|
|
46
46
|
static FROM_BOT(ctx: IPhysics, bot: Bot, settings?: PhysicsWorldSettings): EPhysicsCtx<PlayerState>;
|
|
47
47
|
static FROM_ENTITY(ctx: IPhysics, entity: Entity, settings?: PhysicsWorldSettings): EPhysicsCtx<EntityState>;
|
|
@@ -21,6 +21,12 @@ function load(data) {
|
|
|
21
21
|
}
|
|
22
22
|
exports.emptyVec = new vec3_1.Vec3(0, 0, 0);
|
|
23
23
|
class EPhysicsCtx {
|
|
24
|
+
get position() {
|
|
25
|
+
return this.state.pos;
|
|
26
|
+
}
|
|
27
|
+
get velocity() {
|
|
28
|
+
return this.state.vel;
|
|
29
|
+
}
|
|
24
30
|
constructor(ctx, worldSettings, pose, state, entityType = physicsUtils_1.DefaultPlayer) {
|
|
25
31
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
26
32
|
this.ctx = ctx;
|
|
@@ -28,6 +34,7 @@ class EPhysicsCtx {
|
|
|
28
34
|
this.pose = pose;
|
|
29
35
|
this.state = state;
|
|
30
36
|
this.entityType = entityType;
|
|
37
|
+
// public static globalSettings = PhysicsSettings
|
|
31
38
|
this.stepHeight = 0;
|
|
32
39
|
this.gravity = 0.08;
|
|
33
40
|
this.airdrag = Math.fround(1 - 0.0);
|
|
@@ -45,8 +52,6 @@ class EPhysicsCtx {
|
|
|
45
52
|
blockEffects: false,
|
|
46
53
|
affectedAfterCollision: true,
|
|
47
54
|
};
|
|
48
|
-
this.position = state.pos;
|
|
49
|
-
this.velocity = state.vel;
|
|
50
55
|
// TODO cleanup all of this code.
|
|
51
56
|
if (entityType.type === "player" || !!EPhysicsCtx.mobData[entityType.id]) {
|
|
52
57
|
// @ts-expect-error
|
|
@@ -22,7 +22,7 @@ export declare class EntityState implements IEntityState {
|
|
|
22
22
|
isInLava: boolean;
|
|
23
23
|
isInWeb: boolean;
|
|
24
24
|
fallFlying: boolean;
|
|
25
|
-
|
|
25
|
+
validElytraEquipped: boolean;
|
|
26
26
|
isCollidedHorizontally: boolean;
|
|
27
27
|
isCollidedVertically: boolean;
|
|
28
28
|
jumpTicks: number;
|
|
@@ -40,7 +40,7 @@ class EntityState {
|
|
|
40
40
|
this.isInLava = false;
|
|
41
41
|
this.isInWeb = false;
|
|
42
42
|
this.fallFlying = false;
|
|
43
|
-
this.
|
|
43
|
+
this.validElytraEquipped = false;
|
|
44
44
|
this.isCollidedHorizontally = false;
|
|
45
45
|
this.isCollidedVertically = false;
|
|
46
46
|
this.sneakCollision = false; //TODO
|
|
@@ -92,10 +92,10 @@ class EntityState {
|
|
|
92
92
|
return this;
|
|
93
93
|
}
|
|
94
94
|
updateFromEntity(entity, all = false) {
|
|
95
|
-
var _a, _b, _c, _d
|
|
95
|
+
var _a, _b, _c, _d;
|
|
96
96
|
if (all) {
|
|
97
97
|
// most mobs don't have this defined, so ignore it (only self does).
|
|
98
|
-
this.vel
|
|
98
|
+
this.vel.set(entity.velocity.x, entity.velocity.y, entity.velocity.z);
|
|
99
99
|
this.onGround = entity.onGround;
|
|
100
100
|
this.onClimbable = entity.onClimbable;
|
|
101
101
|
this.isInWater = entity.isInWater;
|
|
@@ -106,10 +106,10 @@ class EntityState {
|
|
|
106
106
|
this.isCollidedVertically = entity.isCollidedVertically;
|
|
107
107
|
this.sneakCollision = false; //TODO
|
|
108
108
|
this.attributes || (this.attributes = entity.attributes);
|
|
109
|
-
this.
|
|
110
|
-
this.fallFlying = this.
|
|
109
|
+
this.validElytraEquipped = (0, physicsUtils_1.isUsableElytraItem)(entity.equipment[4]);
|
|
110
|
+
this.fallFlying = this.validElytraEquipped && this.fallFlying;
|
|
111
111
|
}
|
|
112
|
-
this.pos
|
|
112
|
+
this.pos.set(entity.position.x, entity.position.y, entity.position.z);
|
|
113
113
|
//not sure what to do here, ngl.
|
|
114
114
|
this.jumpTicks || (this.jumpTicks = 0);
|
|
115
115
|
this.jumpQueued || (this.jumpQueued = false);
|
|
@@ -133,7 +133,7 @@ class EntityState {
|
|
|
133
133
|
const boots = entity.equipment[5];
|
|
134
134
|
if (boots && boots.nbt) {
|
|
135
135
|
const simplifiedNbt = prismarine_nbt_1.default.simplify(boots.nbt);
|
|
136
|
-
const enchantments = (
|
|
136
|
+
const enchantments = (_d = (_c = simplifiedNbt.Enchantments) !== null && _c !== void 0 ? _c : simplifiedNbt.ench) !== null && _d !== void 0 ? _d : [];
|
|
137
137
|
this.depthStrider = this.ctx.getEnchantmentLevel(physicsUtils_1.CheapEnchantments.DEPTH_STRIDER, enchantments);
|
|
138
138
|
}
|
|
139
139
|
else {
|
|
@@ -162,7 +162,7 @@ class EntityState {
|
|
|
162
162
|
this.isInLava = (_r = other.isInLava) !== null && _r !== void 0 ? _r : this.isInLava;
|
|
163
163
|
this.isInWeb = (_s = other.isInWeb) !== null && _s !== void 0 ? _s : this.isInWeb;
|
|
164
164
|
this.fallFlying = (_u = (_t = other.fallFlying) !== null && _t !== void 0 ? _t : other.elytraFlying) !== null && _u !== void 0 ? _u : this.fallFlying;
|
|
165
|
-
this.
|
|
165
|
+
this.validElytraEquipped = (_v = other.validElytraEquipped) !== null && _v !== void 0 ? _v : this.validElytraEquipped;
|
|
166
166
|
return this;
|
|
167
167
|
}
|
|
168
168
|
applyToBot(bot) {
|
|
@@ -181,7 +181,7 @@ class EntityState {
|
|
|
181
181
|
bot.entity.isInWeb = this.isInWeb;
|
|
182
182
|
bot.entity.fallFlying = this.fallFlying;
|
|
183
183
|
bot.entity.elytraFlying = this.fallFlying;
|
|
184
|
-
bot.entity.elytraEquipped = this.
|
|
184
|
+
bot.entity.elytraEquipped = this.validElytraEquipped;
|
|
185
185
|
bot.entity.isCollidedHorizontally = this.isCollidedHorizontally;
|
|
186
186
|
bot.entity.isCollidedVertically = this.isCollidedVertically;
|
|
187
187
|
bot.entity.sneakCollision = this.sneakCollision;
|
|
@@ -193,8 +193,8 @@ class EntityState {
|
|
|
193
193
|
* No idea when you'd use this.
|
|
194
194
|
*/
|
|
195
195
|
applyToEntity(entity) {
|
|
196
|
-
entity.position
|
|
197
|
-
entity.velocity
|
|
196
|
+
entity.position.set(this.pos.x, this.pos.y, this.pos.z);
|
|
197
|
+
entity.velocity.set(this.vel.x, this.vel.y, this.vel.z);
|
|
198
198
|
// entity.position.set(this.position.x, this.position.y, this.position.z);
|
|
199
199
|
// entity.velocity.set(this.velocity.x, this.velocity.y, this.velocity.z);
|
|
200
200
|
entity.onGround = this.onGround;
|
|
@@ -213,7 +213,7 @@ class EntityState {
|
|
|
213
213
|
other.isInLava = this.isInLava;
|
|
214
214
|
other.isInWeb = this.isInWeb;
|
|
215
215
|
other.fallFlying = this.fallFlying;
|
|
216
|
-
other.
|
|
216
|
+
other.validElytraEquipped = this.validElytraEquipped;
|
|
217
217
|
other.fireworkRocketDuration = this.fireworkRocketDuration;
|
|
218
218
|
other.jumpTicks = this.jumpTicks;
|
|
219
219
|
other.jumpQueued = this.jumpQueued;
|
|
@@ -235,8 +235,8 @@ class EntityState {
|
|
|
235
235
|
}
|
|
236
236
|
merge(other) {
|
|
237
237
|
this.age = other.age;
|
|
238
|
-
this.pos
|
|
239
|
-
this.vel
|
|
238
|
+
this.pos.set(other.pos.x, other.pos.y, other.pos.z);
|
|
239
|
+
this.vel.set(other.vel.x, other.vel.y, other.vel.z);
|
|
240
240
|
this.onGround = other.onGround;
|
|
241
241
|
this.onClimbable = other.onClimbable;
|
|
242
242
|
this.isCollidedHorizontally = other.isCollidedHorizontally;
|
|
@@ -245,7 +245,7 @@ class EntityState {
|
|
|
245
245
|
this.isInLava = other.isInLava;
|
|
246
246
|
this.isInWeb = other.isInWeb;
|
|
247
247
|
this.fallFlying = other.fallFlying;
|
|
248
|
-
this.
|
|
248
|
+
this.validElytraEquipped = other.validElytraEquipped;
|
|
249
249
|
this.fireworkRocketDuration = other.fireworkRocketDuration;
|
|
250
250
|
this.jumpTicks = other.jumpTicks;
|
|
251
251
|
this.jumpQueued = other.jumpQueued;
|
|
@@ -29,7 +29,7 @@ export interface IEntityState {
|
|
|
29
29
|
isInWeb: boolean;
|
|
30
30
|
fallFlying: boolean;
|
|
31
31
|
elytraFlying: boolean;
|
|
32
|
-
|
|
32
|
+
validElytraEquipped: boolean;
|
|
33
33
|
fireworkRocketDuration: number;
|
|
34
34
|
sneakCollision: boolean;
|
|
35
35
|
isCollidedHorizontally: boolean;
|
|
@@ -40,7 +40,7 @@ export declare class PlayerState implements IEntityState {
|
|
|
40
40
|
isInLava: boolean;
|
|
41
41
|
isUnderLava: boolean;
|
|
42
42
|
isInWeb: boolean;
|
|
43
|
-
|
|
43
|
+
validElytraEquipped: boolean;
|
|
44
44
|
fireworkRocketDuration: number;
|
|
45
45
|
isCollidedHorizontally: boolean;
|
|
46
46
|
isCollidedHorizontallyMinor: boolean;
|
|
@@ -142,7 +142,7 @@ class PlayerState {
|
|
|
142
142
|
this.isInLava = false;
|
|
143
143
|
this.isUnderLava = false;
|
|
144
144
|
this.isInWeb = false;
|
|
145
|
-
this.
|
|
145
|
+
this.validElytraEquipped = false;
|
|
146
146
|
this.fireworkRocketDuration = 0;
|
|
147
147
|
this.isCollidedHorizontally = false;
|
|
148
148
|
this.isCollidedHorizontallyMinor = false;
|
|
@@ -216,7 +216,7 @@ class PlayerState {
|
|
|
216
216
|
this.update(bot, playerControls_1.ControlStateHandler.COPY_BOT(bot));
|
|
217
217
|
}
|
|
218
218
|
update(bot, control) {
|
|
219
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q
|
|
219
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
220
220
|
// const bot.entity = bot instanceof bot.entity ? bot : bot.entity;
|
|
221
221
|
// Input / Outputs
|
|
222
222
|
this.pos.set(bot.entity.position.x, bot.entity.position.y, bot.entity.position.z);
|
|
@@ -230,16 +230,16 @@ class PlayerState {
|
|
|
230
230
|
this.isInLava = bot.entity.isInLava;
|
|
231
231
|
this.isUnderLava = bot.entity.isUnderLava;
|
|
232
232
|
this.isInWeb = bot.entity.isInWeb;
|
|
233
|
-
this.
|
|
233
|
+
this.validElytraEquipped = (0, physicsUtils_1.isUsableElytraItem)(bot.inventory.slots[bot.getEquipmentDestSlot('torso')]);
|
|
234
234
|
this.fireworkRocketDuration = bot.fireworkRocketDuration;
|
|
235
235
|
this.isCollidedHorizontally = bot.entity.isCollidedHorizontally;
|
|
236
236
|
this.isCollidedHorizontallyMinor = bot.entity.isCollidedHorizontallyMinor;
|
|
237
237
|
this.isCollidedVertically = bot.entity.isCollidedVertically;
|
|
238
238
|
// dunno what to do about these, ngl.
|
|
239
|
-
this.jumpTicks = (
|
|
240
|
-
this.jumpQueued = (
|
|
241
|
-
this.flyJumpTriggerTime = (
|
|
242
|
-
this.sprintTriggerTime = (
|
|
239
|
+
this.jumpTicks = (_c = bot.jumpTicks) !== null && _c !== void 0 ? _c : 0;
|
|
240
|
+
this.jumpQueued = (_d = bot.jumpQueued) !== null && _d !== void 0 ? _d : false;
|
|
241
|
+
this.flyJumpTriggerTime = (_e = bot.flyJumpTriggerTime) !== null && _e !== void 0 ? _e : 0;
|
|
242
|
+
this.sprintTriggerTime = (_f = bot.sprintTriggerTime) !== null && _f !== void 0 ? _f : 0;
|
|
243
243
|
// Input only (not modified)
|
|
244
244
|
this.attributes = bot.entity.attributes;
|
|
245
245
|
this.yaw = bot.entity.yaw;
|
|
@@ -261,7 +261,7 @@ class PlayerState {
|
|
|
261
261
|
const boots = bot.entity.equipment[5];
|
|
262
262
|
if (boots && boots.nbt) {
|
|
263
263
|
const simplifiedNbt = nbt.simplify(boots.nbt);
|
|
264
|
-
const enchantments = (
|
|
264
|
+
const enchantments = (_h = (_g = simplifiedNbt.Enchantments) !== null && _g !== void 0 ? _g : simplifiedNbt.ench) !== null && _h !== void 0 ? _h : [];
|
|
265
265
|
this.depthStrider = this.ctx.getEnchantmentLevel(physicsUtils_1.CheapEnchantments.DEPTH_STRIDER, enchantments);
|
|
266
266
|
this.soulSpeed = this.ctx.getEnchantmentLevel(physicsUtils_1.CheapEnchantments.SOUL_SPEED, enchantments);
|
|
267
267
|
}
|
|
@@ -272,7 +272,7 @@ class PlayerState {
|
|
|
272
272
|
const leggings = bot.entity.equipment[3];
|
|
273
273
|
if (leggings && leggings.nbt) {
|
|
274
274
|
const simplifiedNbt = nbt.simplify(leggings.nbt);
|
|
275
|
-
const enchantments = (
|
|
275
|
+
const enchantments = (_k = (_j = simplifiedNbt.Enchantments) !== null && _j !== void 0 ? _j : simplifiedNbt.ench) !== null && _k !== void 0 ? _k : [];
|
|
276
276
|
this.swiftSneak = this.ctx.getEnchantmentLevel(physicsUtils_1.CheapEnchantments.SWIFT_SNEAK, enchantments);
|
|
277
277
|
}
|
|
278
278
|
else {
|
|
@@ -282,10 +282,10 @@ class PlayerState {
|
|
|
282
282
|
this.gameMode = bot.game.gameMode;
|
|
283
283
|
this.food = bot.food;
|
|
284
284
|
// TODO:
|
|
285
|
-
this.swimming = (
|
|
286
|
-
this.sprinting = (
|
|
287
|
-
this.crouching = (
|
|
288
|
-
this.fallFlying = (
|
|
285
|
+
this.swimming = (_l = bot.entity.swimming) !== null && _l !== void 0 ? _l : false;
|
|
286
|
+
this.sprinting = (_m = bot.entity.sprinting) !== null && _m !== void 0 ? _m : false;
|
|
287
|
+
this.crouching = (_o = bot.entity.crouching) !== null && _o !== void 0 ? _o : false;
|
|
288
|
+
this.fallFlying = (_q = (_p = bot.entity.fallFlying) !== null && _p !== void 0 ? _p : bot.entity.elytraFlying) !== null && _q !== void 0 ? _q : false;
|
|
289
289
|
switch (bot.game.gameMode) {
|
|
290
290
|
case "creative":
|
|
291
291
|
this.flySpeed = 0.05;
|
|
@@ -319,7 +319,7 @@ class PlayerState {
|
|
|
319
319
|
bot.entity.isInLava = this.isInLava;
|
|
320
320
|
bot.entity.isUnderLava = this.isUnderLava;
|
|
321
321
|
bot.entity.isInWeb = this.isInWeb;
|
|
322
|
-
bot.entity.elytraEquipped = this.
|
|
322
|
+
bot.entity.elytraEquipped = this.validElytraEquipped;
|
|
323
323
|
bot.fireworkRocketDuration = this.fireworkRocketDuration;
|
|
324
324
|
bot.entity.isCollidedHorizontally = this.isCollidedHorizontally;
|
|
325
325
|
bot.entity.isCollidedHorizontallyMinor = this.isCollidedHorizontallyMinor;
|
|
@@ -332,6 +332,9 @@ class PlayerState {
|
|
|
332
332
|
bot.sprintTriggerTime = this.sprintTriggerTime;
|
|
333
333
|
bot.entity.yaw = this.yaw;
|
|
334
334
|
bot.entity.pitch = this.pitch;
|
|
335
|
+
bot.entity.height = this.height;
|
|
336
|
+
bot.entity.width = this.halfWidth * 2;
|
|
337
|
+
bot.entity.eyeHeight = this.eyeHeight;
|
|
335
338
|
Object.assign(bot.entity, this.pose);
|
|
336
339
|
bot.game.gameMode = this.gameMode; // this should never actually be in charge.
|
|
337
340
|
bot.food = this.food; // this should also never actually be in charge.
|
|
@@ -358,7 +361,7 @@ class PlayerState {
|
|
|
358
361
|
tmp.isInLava = this.isInLava;
|
|
359
362
|
tmp.isUnderLava = this.isUnderLava;
|
|
360
363
|
tmp.isInWeb = this.isInWeb;
|
|
361
|
-
tmp.
|
|
364
|
+
tmp.validElytraEquipped = this.validElytraEquipped;
|
|
362
365
|
tmp.fireworkRocketDuration = this.fireworkRocketDuration;
|
|
363
366
|
tmp.isCollidedHorizontally = this.isCollidedHorizontally;
|
|
364
367
|
tmp.isCollidedHorizontallyMinor = this.isCollidedHorizontallyMinor;
|
|
@@ -414,7 +417,7 @@ class PlayerState {
|
|
|
414
417
|
this.isInLava = other.isInLava;
|
|
415
418
|
this.isUnderLava = other.isUnderLava;
|
|
416
419
|
this.isInWeb = other.isInWeb;
|
|
417
|
-
this.
|
|
420
|
+
this.validElytraEquipped = other.validElytraEquipped;
|
|
418
421
|
this.fireworkRocketDuration = other.fireworkRocketDuration;
|
|
419
422
|
this.isCollidedHorizontally = other.isCollidedHorizontally;
|
|
420
423
|
this.isCollidedHorizontallyMinor = other.isCollidedHorizontallyMinor;
|
|
@@ -27,6 +27,11 @@ export declare enum CheapEnchantments {
|
|
|
27
27
|
export declare function isEntityUsingItem(entity: Entity, supportFeature: SupportFeature): boolean;
|
|
28
28
|
export declare function whichHandIsEntityUsing(entity: Entity, supportFeature: SupportFeature): "hand" | "off-hand";
|
|
29
29
|
export declare function whichHandIsEntityUsingBoolean(entity: Entity, supportFeature: SupportFeature): boolean;
|
|
30
|
+
export declare function isUsableElytraItem(item: {
|
|
31
|
+
name?: string;
|
|
32
|
+
durabilityUsed?: number;
|
|
33
|
+
maxDurability?: number;
|
|
34
|
+
} | null): boolean;
|
|
30
35
|
export declare function getStatusEffectNamesForVersion(supportFeature: SupportFeature): {
|
|
31
36
|
jumpBoostEffectName: string;
|
|
32
37
|
speedEffectName: string;
|
|
@@ -9,6 +9,7 @@ exports.applyMdToNewEntity = applyMdToNewEntity;
|
|
|
9
9
|
exports.isEntityUsingItem = isEntityUsingItem;
|
|
10
10
|
exports.whichHandIsEntityUsing = whichHandIsEntityUsing;
|
|
11
11
|
exports.whichHandIsEntityUsingBoolean = whichHandIsEntityUsingBoolean;
|
|
12
|
+
exports.isUsableElytraItem = isUsableElytraItem;
|
|
12
13
|
exports.getStatusEffectNamesForVersion = getStatusEffectNamesForVersion;
|
|
13
14
|
exports.getEnchantmentNamesForVersion = getEnchantmentNamesForVersion;
|
|
14
15
|
exports.getBetweenRectangle = getBetweenRectangle;
|
|
@@ -71,6 +72,14 @@ function whichHandIsEntityUsing(entity, supportFeature) {
|
|
|
71
72
|
function whichHandIsEntityUsingBoolean(entity, supportFeature) {
|
|
72
73
|
return entity.metadata[getMetadataIndex(supportFeature)] > 2;
|
|
73
74
|
}
|
|
75
|
+
function isUsableElytraItem(item) {
|
|
76
|
+
if (!item || item.name !== "elytra")
|
|
77
|
+
return false;
|
|
78
|
+
if (typeof item.durabilityUsed === "number" && typeof item.maxDurability === "number") {
|
|
79
|
+
return item.durabilityUsed < item.maxDurability - 1;
|
|
80
|
+
}
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
74
83
|
function getStatusEffectNamesForVersion(supportFeature) {
|
|
75
84
|
if (supportFeature("effectNamesAreRegistryNames")) {
|
|
76
85
|
// seems to not matter right now.
|
|
@@ -177,7 +186,7 @@ function getLookingVector(entity) {
|
|
|
177
186
|
* @returns A newly formatted PlayerState instance.
|
|
178
187
|
*/
|
|
179
188
|
function convertPlayerState(bot, oldState, ctx) {
|
|
180
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
189
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
|
181
190
|
// 1. Initialize the new state.
|
|
182
191
|
// This automatically runs update() and pulls the bot's current real state.
|
|
183
192
|
const newState = new states_1.PlayerState(ctx, bot);
|
|
@@ -195,12 +204,12 @@ function convertPlayerState(bot, oldState, ctx) {
|
|
|
195
204
|
newState.isCollidedVertically = (_f = oldState.isCollidedVertically) !== null && _f !== void 0 ? _f : newState.isCollidedVertically;
|
|
196
205
|
// 4. Map movement and action states
|
|
197
206
|
newState.fallFlying = (_h = (_g = oldState.fallFlying) !== null && _g !== void 0 ? _g : oldState.elytraFlying) !== null && _h !== void 0 ? _h : newState.fallFlying;
|
|
198
|
-
newState.
|
|
199
|
-
newState.jumpTicks = (
|
|
200
|
-
newState.jumpQueued = (
|
|
201
|
-
newState.fireworkRocketDuration = (
|
|
202
|
-
newState.yaw = (
|
|
203
|
-
newState.pitch = (
|
|
207
|
+
newState.validElytraEquipped = (_k = (_j = oldState.validElytraEquipped) !== null && _j !== void 0 ? _j : oldState.elytraEquipped) !== null && _k !== void 0 ? _k : newState.validElytraEquipped;
|
|
208
|
+
newState.jumpTicks = (_l = oldState.jumpTicks) !== null && _l !== void 0 ? _l : newState.jumpTicks;
|
|
209
|
+
newState.jumpQueued = (_m = oldState.jumpQueued) !== null && _m !== void 0 ? _m : newState.jumpQueued;
|
|
210
|
+
newState.fireworkRocketDuration = (_o = oldState.fireworkRocketDuration) !== null && _o !== void 0 ? _o : newState.fireworkRocketDuration;
|
|
211
|
+
newState.yaw = (_p = oldState.yaw) !== null && _p !== void 0 ? _p : newState.yaw;
|
|
212
|
+
newState.pitch = (_q = oldState.pitch) !== null && _q !== void 0 ? _q : newState.pitch;
|
|
204
213
|
// 5. Map Control State
|
|
205
214
|
// The old state uses a standard object for controls; the new uses ControlStateHandler.
|
|
206
215
|
if (oldState.control) {
|
|
@@ -209,14 +218,14 @@ function convertPlayerState(bot, oldState, ctx) {
|
|
|
209
218
|
Object.assign(newState.control, oldState.control);
|
|
210
219
|
}
|
|
211
220
|
// 6. Map Attributes, Effects, and Enchantments
|
|
212
|
-
newState.attributes = (
|
|
213
|
-
newState.jumpBoost = (
|
|
214
|
-
newState.speed = (
|
|
215
|
-
newState.slowness = (
|
|
216
|
-
newState.dolphinsGrace = (
|
|
217
|
-
newState.slowFalling = (
|
|
218
|
-
newState.levitation = (
|
|
219
|
-
newState.depthStrider = (
|
|
221
|
+
newState.attributes = (_r = oldState.attributes) !== null && _r !== void 0 ? _r : newState.attributes;
|
|
222
|
+
newState.jumpBoost = (_s = oldState.jumpBoost) !== null && _s !== void 0 ? _s : newState.jumpBoost;
|
|
223
|
+
newState.speed = (_t = oldState.speed) !== null && _t !== void 0 ? _t : newState.speed;
|
|
224
|
+
newState.slowness = (_u = oldState.slowness) !== null && _u !== void 0 ? _u : newState.slowness;
|
|
225
|
+
newState.dolphinsGrace = (_v = oldState.dolphinsGrace) !== null && _v !== void 0 ? _v : newState.dolphinsGrace;
|
|
226
|
+
newState.slowFalling = (_w = oldState.slowFalling) !== null && _w !== void 0 ? _w : newState.slowFalling;
|
|
227
|
+
newState.levitation = (_x = oldState.levitation) !== null && _x !== void 0 ? _x : newState.levitation;
|
|
228
|
+
newState.depthStrider = (_y = oldState.depthStrider) !== null && _y !== void 0 ? _y : newState.depthStrider;
|
|
220
229
|
return newState;
|
|
221
230
|
}
|
|
222
231
|
/**
|
|
@@ -244,7 +253,8 @@ function applyToPlayerState(newState, oldState) {
|
|
|
244
253
|
// 3. Map Movement & Actions
|
|
245
254
|
oldState.fallFlying = newState.fallFlying;
|
|
246
255
|
oldState.elytraFlying = newState.fallFlying;
|
|
247
|
-
oldState.
|
|
256
|
+
oldState.validElytraEquipped = newState.validElytraEquipped;
|
|
257
|
+
oldState.elytraEquipped = newState.validElytraEquipped;
|
|
248
258
|
oldState.jumpTicks = newState.jumpTicks;
|
|
249
259
|
oldState.jumpQueued = newState.jumpQueued;
|
|
250
260
|
oldState.fireworkRocketDuration = newState.fireworkRocketDuration;
|
package/eslint.config.mjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { defineConfig } from "eslint/config";
|
|
2
|
-
import globals from "globals";
|
|
3
|
-
import js from "@eslint/js";
|
|
4
|
-
import tseslint from "typescript-eslint";
|
|
5
|
-
|
|
6
|
-
export default defineConfig([
|
|
7
|
-
{
|
|
8
|
-
files: ["**/*.{ts,tsx}"], // Only check TypeScript files
|
|
9
|
-
languageOptions: { globals: globals.browser }
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
files: ["**/*.{ts,tsx}"], // Only check TypeScript files
|
|
13
|
-
plugins: { js },
|
|
14
|
-
extends: ["js/recommended"]
|
|
15
|
-
},
|
|
16
|
-
tseslint.configs.recommended,
|
|
17
|
-
]);
|
|
1
|
+
import { defineConfig } from "eslint/config";
|
|
2
|
+
import globals from "globals";
|
|
3
|
+
import js from "@eslint/js";
|
|
4
|
+
import tseslint from "typescript-eslint";
|
|
5
|
+
|
|
6
|
+
export default defineConfig([
|
|
7
|
+
{
|
|
8
|
+
files: ["**/*.{ts,tsx}"], // Only check TypeScript files
|
|
9
|
+
languageOptions: { globals: globals.browser }
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
files: ["**/*.{ts,tsx}"], // Only check TypeScript files
|
|
13
|
+
plugins: { js },
|
|
14
|
+
extends: ["js/recommended"]
|
|
15
|
+
},
|
|
16
|
+
tseslint.configs.recommended,
|
|
17
|
+
]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nxg-org/mineflayer-physics-util",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.2",
|
|
4
4
|
"description": "Provides functionality for more accurate entity and projectile tracking.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mineflayer",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"eslint": "^9.23.0",
|
|
27
27
|
"expect": "^29.7.0",
|
|
28
28
|
"globals": "^16.0.0",
|
|
29
|
-
"minecraft-data": "^3.
|
|
29
|
+
"minecraft-data": "^3.109.0",
|
|
30
30
|
"mineflayer": "link:/home/genpc/github_stuff/mineflayer",
|
|
31
31
|
"mineflayer-pathfinder": "^2.4.4",
|
|
32
32
|
"mocha": "^11.1.0",
|