pw-js-world 0.0.1
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/LICENSE +21 -0
- package/README.md +67 -0
- package/bun.lockb +0 -0
- package/dist/Block.d.ts +117 -0
- package/dist/Block.js +156 -0
- package/dist/BufferReader.d.ts +324 -0
- package/dist/BufferReader.js +674 -0
- package/dist/Constants.d.ts +4 -0
- package/dist/Constants.js +6 -0
- package/dist/Helper.d.ts +200 -0
- package/dist/Helper.js +482 -0
- package/dist/Player.d.ts +222 -0
- package/dist/Player.js +110 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +5 -0
- package/dist/types/index.d.ts +19 -0
- package/esm.mjs +19 -0
- package/lib/Block.ts +217 -0
- package/lib/BufferReader.ts +770 -0
- package/lib/Constants.ts +4 -0
- package/lib/Helper.ts +603 -0
- package/lib/Player.ts +317 -0
- package/lib/index.ts +8 -0
- package/lib/types/index.d.ts +19 -0
- package/package.json +40 -0
- package/test/index.ts +96 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Doomester
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# pw-js-world
|
|
2
|
+
|
|
3
|
+
This is a helper for the main library [PW-JS-Api](https://www.npmjs.com/package/pw-js-api) (since v0.2.1).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
To install this dependency, you must install PW-JS-Api first before installing this helper.
|
|
8
|
+
|
|
9
|
+
NPM:
|
|
10
|
+
```bash
|
|
11
|
+
npm i pw-js-api pw-js-world
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
PNPM:
|
|
15
|
+
```bash
|
|
16
|
+
pnpm i pw-js-api pw-js-world
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Yarn:
|
|
20
|
+
```bash
|
|
21
|
+
yarn add pw-js-api pw-js-world
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Bun:
|
|
25
|
+
```bash
|
|
26
|
+
bun i pw-js-api pw-js-world
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
The code below shows an example, it does not do anything but you will get an idea on what you're expected to do before being able to use this.
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
import { BlockNames, PWApiClient } from "pw-js-api";
|
|
35
|
+
import { PWGameWorldHelper } from "pw-js-world";
|
|
36
|
+
|
|
37
|
+
const api = new PWApiClient(<YOUR_EMAIL>, <YOUR_PASSWORD>);
|
|
38
|
+
const helper = new PWGameWorldHelper();
|
|
39
|
+
|
|
40
|
+
await api.authenticate();
|
|
41
|
+
|
|
42
|
+
const con = await api.joinWorld(<WORLD_ID>, {
|
|
43
|
+
gameSettings: {
|
|
44
|
+
handlePackets: ["PING", "INIT"]
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
con
|
|
49
|
+
// This is important, you must add the hook as soon as you get the
|
|
50
|
+
// connection before it receives init event.
|
|
51
|
+
.addHook(helper.receiveHook)
|
|
52
|
+
.addCallback("playerInitPacket", (data, states) => {
|
|
53
|
+
console.log("Logged in as " + states?.player?.username);
|
|
54
|
+
})
|
|
55
|
+
.addCallback("worldBlockPlacedPacket", (data, states) => {
|
|
56
|
+
console.log("Prev Block Id: " + states?.oldBlocks[0].bId);
|
|
57
|
+
console.log("Prev Block Args: " + states?.oldBlocks[0].args);
|
|
58
|
+
console.log("New Block Id: " + states?.newBlocks[0].bId);
|
|
59
|
+
console.log("New Block Args: " + states?.newBlocks[0].args);
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Once you have added the hook, the states (second parameter) in some of the callbacks will have the variables populated, allowing you to get the player object directly without needing to do yourself.
|
|
64
|
+
|
|
65
|
+
They may be undefined if the events occur before the initialisation of helper (which can happen in the first two seconds since the bot joins).
|
|
66
|
+
|
|
67
|
+
Alternatively, you can export and use the helper directly yourself if you want.
|
package/bun.lockb
ADDED
|
Binary file
|
package/dist/Block.d.ts
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { BlockNames } from "pw-js-api";
|
|
2
|
+
import type { BlockArg, Point, SendableBlockPacket } from "./types";
|
|
3
|
+
import BufferReader, { ComponentTypeHeader } from "./BufferReader";
|
|
4
|
+
import { LayerType } from "./Constants";
|
|
5
|
+
export default class Block {
|
|
6
|
+
bId: number;
|
|
7
|
+
args: BlockArg[];
|
|
8
|
+
constructor(bId: number | keyof typeof BlockNames, args?: BlockArg[]);
|
|
9
|
+
/**
|
|
10
|
+
* I mean... Just use .args.length !== 0 to see if it has args.
|
|
11
|
+
*
|
|
12
|
+
* But anyway, this will return true if there is at least one args, otherwise false.
|
|
13
|
+
*/
|
|
14
|
+
hasArgs(): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* For helper.
|
|
17
|
+
*
|
|
18
|
+
* This is in Block class for organisation.
|
|
19
|
+
*
|
|
20
|
+
* This will deserialise by using the reader to get the block ID then retrieve the args, if applicable.
|
|
21
|
+
*/
|
|
22
|
+
static deserialize(reader: BufferReader): Block;
|
|
23
|
+
protected deserializeArgs(reader: BufferReader, flag?: boolean): this;
|
|
24
|
+
/**
|
|
25
|
+
* For helper.
|
|
26
|
+
*
|
|
27
|
+
* This is in Block class for organisation.
|
|
28
|
+
*/
|
|
29
|
+
static deserializeArgs(blockId: number, reader: BufferReader, flag?: boolean): BlockArg[];
|
|
30
|
+
/**
|
|
31
|
+
* Serializes the block into a buffer. This is used to convert
|
|
32
|
+
* the block into a binary format that can be sent over the game
|
|
33
|
+
* server. As this is static, block id and args are required.
|
|
34
|
+
*
|
|
35
|
+
* - Little Endian
|
|
36
|
+
* - With Id
|
|
37
|
+
* - Type Byte omitted
|
|
38
|
+
*/
|
|
39
|
+
static serializeArgs(bId: number, args: BlockArg[]): Buffer;
|
|
40
|
+
/**
|
|
41
|
+
* Serializes the block into a buffer. This is used to convert
|
|
42
|
+
* the block into a binary format that can be sent over the game
|
|
43
|
+
* server. As this is static, block id and args are required.
|
|
44
|
+
*
|
|
45
|
+
* - Big Endian
|
|
46
|
+
* - No Id
|
|
47
|
+
* - Type Byte included
|
|
48
|
+
*/
|
|
49
|
+
static serializeArgs(bId: number, args: BlockArg[], options: {
|
|
50
|
+
endian: "big";
|
|
51
|
+
writeId: false;
|
|
52
|
+
readTypeByte: true;
|
|
53
|
+
}): Buffer;
|
|
54
|
+
/**
|
|
55
|
+
*
|
|
56
|
+
* @param pos List of points (X and Y)
|
|
57
|
+
*/
|
|
58
|
+
toPacket(pos: Point[], layer: LayerType): SendableBlockPacket;
|
|
59
|
+
toPacket(x: number, y: number, layer: LayerType): SendableBlockPacket;
|
|
60
|
+
/**
|
|
61
|
+
* This will return the block name in UPPER_CASE form.
|
|
62
|
+
*
|
|
63
|
+
* For eg EFFECTS_INVULNERABILITY.
|
|
64
|
+
*/
|
|
65
|
+
get name(): keyof typeof BlockNames;
|
|
66
|
+
/**
|
|
67
|
+
* Returns a copy of the block.
|
|
68
|
+
*/
|
|
69
|
+
clone(obj?: false): Block;
|
|
70
|
+
clone(obj: true): {
|
|
71
|
+
bId: number;
|
|
72
|
+
args: BlockArg[];
|
|
73
|
+
name: string;
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* This mapping contains definitions of block data which require additional
|
|
78
|
+
* arguments to be sent or received with.
|
|
79
|
+
*/
|
|
80
|
+
export declare const BlockArgsHeadings: {
|
|
81
|
+
readonly COIN_GOLD_DOOR: readonly [ComponentTypeHeader.Int32];
|
|
82
|
+
readonly COIN_BLUE_DOOR: readonly [ComponentTypeHeader.Int32];
|
|
83
|
+
readonly COIN_GOLD_GATE: readonly [ComponentTypeHeader.Int32];
|
|
84
|
+
readonly COIN_BLUE_GATE: readonly [ComponentTypeHeader.Int32];
|
|
85
|
+
readonly EFFECTS_JUMP_HEIGHT: readonly [ComponentTypeHeader.Int32];
|
|
86
|
+
readonly EFFECTS_FLY: readonly [ComponentTypeHeader.Boolean];
|
|
87
|
+
readonly EFFECTS_SPEED: readonly [ComponentTypeHeader.Int32];
|
|
88
|
+
readonly EFFECTS_INVULNERABILITY: readonly [ComponentTypeHeader.Boolean];
|
|
89
|
+
readonly EFFECTS_CURSE: readonly [ComponentTypeHeader.Int32];
|
|
90
|
+
readonly EFFECTS_ZOMBIE: readonly [ComponentTypeHeader.Int32];
|
|
91
|
+
readonly EFFECTS_GRAVITYFORCE: readonly [ComponentTypeHeader.Int32];
|
|
92
|
+
readonly EFFECTS_MULTI_JUMP: readonly [ComponentTypeHeader.Int32];
|
|
93
|
+
readonly TOOL_PORTAL_WORLD_SPAWN: readonly [ComponentTypeHeader.Int32];
|
|
94
|
+
readonly SIGN_NORMAL: readonly [ComponentTypeHeader.String];
|
|
95
|
+
readonly SIGN_RED: readonly [ComponentTypeHeader.String];
|
|
96
|
+
readonly SIGN_GREEN: readonly [ComponentTypeHeader.String];
|
|
97
|
+
readonly SIGN_BLUE: readonly [ComponentTypeHeader.String];
|
|
98
|
+
readonly SIGN_GOLD: readonly [ComponentTypeHeader.String];
|
|
99
|
+
readonly PORTAL: readonly [ComponentTypeHeader.Int32, ComponentTypeHeader.Int32, ComponentTypeHeader.Int32];
|
|
100
|
+
readonly PORTAL_INVISIBLE: readonly [ComponentTypeHeader.Int32, ComponentTypeHeader.Int32, ComponentTypeHeader.Int32];
|
|
101
|
+
readonly PORTAL_WORLD: readonly [ComponentTypeHeader.String, ComponentTypeHeader.Int32];
|
|
102
|
+
readonly SWITCH_LOCAL_TOGGLE: readonly [ComponentTypeHeader.Int32];
|
|
103
|
+
readonly SWITCH_LOCAL_ACTIVATOR: readonly [ComponentTypeHeader.Int32, ComponentTypeHeader.Boolean];
|
|
104
|
+
readonly SWITCH_LOCAL_RESETTER: readonly [ComponentTypeHeader.Boolean];
|
|
105
|
+
readonly SWITCH_LOCAL_DOOR: readonly [ComponentTypeHeader.Int32];
|
|
106
|
+
readonly SWITCH_LOCAL_GATE: readonly [ComponentTypeHeader.Int32];
|
|
107
|
+
readonly SWITCH_GLOBAL_TOGGLE: readonly [ComponentTypeHeader.Int32];
|
|
108
|
+
readonly SWITCH_GLOBAL_ACTIVATOR: readonly [ComponentTypeHeader.Int32, ComponentTypeHeader.Boolean];
|
|
109
|
+
readonly SWITCH_GLOBAL_RESETTER: readonly [ComponentTypeHeader.Boolean];
|
|
110
|
+
readonly SWITCH_GLOBAL_DOOR: readonly [ComponentTypeHeader.Int32];
|
|
111
|
+
readonly SWITCH_GLOBAL_GATE: readonly [ComponentTypeHeader.Int32];
|
|
112
|
+
readonly HAZARD_DEATH_DOOR: readonly [ComponentTypeHeader.Int32];
|
|
113
|
+
readonly HAZARD_DEATH_GATE: readonly [ComponentTypeHeader.Int32];
|
|
114
|
+
readonly NOTE_DRUM: readonly [ComponentTypeHeader.ByteArray];
|
|
115
|
+
readonly NOTE_PIANO: readonly [ComponentTypeHeader.ByteArray];
|
|
116
|
+
readonly NOTE_GUITAR: readonly [ComponentTypeHeader.ByteArray];
|
|
117
|
+
};
|
package/dist/Block.js
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { BlockNames } from "pw-js-api";
|
|
2
|
+
import BufferReader, { ComponentTypeHeader } from "./BufferReader";
|
|
3
|
+
export default class Block {
|
|
4
|
+
constructor(bId, args) {
|
|
5
|
+
this.args = [];
|
|
6
|
+
if (typeof bId === "number")
|
|
7
|
+
this.bId = bId;
|
|
8
|
+
else {
|
|
9
|
+
this.bId = BlockNames[bId];
|
|
10
|
+
}
|
|
11
|
+
if (args)
|
|
12
|
+
this.args = args;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* I mean... Just use .args.length !== 0 to see if it has args.
|
|
16
|
+
*
|
|
17
|
+
* But anyway, this will return true if there is at least one args, otherwise false.
|
|
18
|
+
*/
|
|
19
|
+
hasArgs() {
|
|
20
|
+
return this.args.length !== 0;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* For helper.
|
|
24
|
+
*
|
|
25
|
+
* This is in Block class for organisation.
|
|
26
|
+
*
|
|
27
|
+
* This will deserialise by using the reader to get the block ID then retrieve the args, if applicable.
|
|
28
|
+
*/
|
|
29
|
+
static deserialize(reader) {
|
|
30
|
+
return new Block(reader.readUInt32LE()).deserializeArgs(reader);
|
|
31
|
+
}
|
|
32
|
+
deserializeArgs(reader, flag = false) {
|
|
33
|
+
var _a;
|
|
34
|
+
const format = BlockArgsHeadings[this.name];
|
|
35
|
+
for (let i = 0; i < ((_a = format === null || format === void 0 ? void 0 : format.length) !== null && _a !== void 0 ? _a : 0); i++) {
|
|
36
|
+
if (flag) {
|
|
37
|
+
reader.expectUInt8(format[i]);
|
|
38
|
+
}
|
|
39
|
+
this.args[i] = reader.read(format[i], !flag);
|
|
40
|
+
}
|
|
41
|
+
return this;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* For helper.
|
|
45
|
+
*
|
|
46
|
+
* This is in Block class for organisation.
|
|
47
|
+
*/
|
|
48
|
+
static deserializeArgs(blockId, reader, flag = false) {
|
|
49
|
+
var _a;
|
|
50
|
+
const format = BlockArgsHeadings[BlockNames[blockId]];
|
|
51
|
+
const args = [];
|
|
52
|
+
for (let i = 0; i < ((_a = format === null || format === void 0 ? void 0 : format.length) !== null && _a !== void 0 ? _a : 0); i++) {
|
|
53
|
+
if (flag) {
|
|
54
|
+
reader.expectUInt8(format[i]);
|
|
55
|
+
}
|
|
56
|
+
args[i] = reader.read(format[i], !flag);
|
|
57
|
+
}
|
|
58
|
+
return args;
|
|
59
|
+
}
|
|
60
|
+
static serializeArgs(bId, args, options) {
|
|
61
|
+
var _a;
|
|
62
|
+
options || (options = {
|
|
63
|
+
endian: "little",
|
|
64
|
+
writeId: true,
|
|
65
|
+
readTypeByte: false,
|
|
66
|
+
});
|
|
67
|
+
const buffer = [];
|
|
68
|
+
if (options.writeId) {
|
|
69
|
+
const idBuffer = Buffer.alloc(4);
|
|
70
|
+
idBuffer.writeUInt32LE(bId);
|
|
71
|
+
buffer.push(idBuffer);
|
|
72
|
+
}
|
|
73
|
+
const blockData = (_a = BlockArgsHeadings[BlockNames[bId]]) !== null && _a !== void 0 ? _a : [];
|
|
74
|
+
for (let i = 0, len = blockData.length; i < len; i++) {
|
|
75
|
+
const entry = BufferReader.Dynamic(i, args[i]);
|
|
76
|
+
buffer.push(entry);
|
|
77
|
+
}
|
|
78
|
+
return Buffer.concat(buffer);
|
|
79
|
+
}
|
|
80
|
+
toPacket(pos, y, layer) {
|
|
81
|
+
if (typeof pos === "number") {
|
|
82
|
+
pos = [{
|
|
83
|
+
x: pos, y
|
|
84
|
+
}];
|
|
85
|
+
layer = layer !== null && layer !== void 0 ? layer : 0;
|
|
86
|
+
}
|
|
87
|
+
else
|
|
88
|
+
layer = y !== null && y !== void 0 ? y : 0;
|
|
89
|
+
return {
|
|
90
|
+
isFillOperation: false,
|
|
91
|
+
blockId: this.bId,
|
|
92
|
+
layer,
|
|
93
|
+
positions: pos,
|
|
94
|
+
extraFields: Block.serializeArgs(this.bId, this.args, { endian: "big", writeId: false, readTypeByte: true })
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* This will return the block name in UPPER_CASE form.
|
|
99
|
+
*
|
|
100
|
+
* For eg EFFECTS_INVULNERABILITY.
|
|
101
|
+
*/
|
|
102
|
+
get name() {
|
|
103
|
+
return BlockNames[this.bId];
|
|
104
|
+
}
|
|
105
|
+
clone(obj = false) {
|
|
106
|
+
if (obj === true)
|
|
107
|
+
return { bId: this.bId, args: this.args, name: this.name };
|
|
108
|
+
return new Block(this.bId, this.args);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* This mapping contains definitions of block data which require additional
|
|
113
|
+
* arguments to be sent or received with.
|
|
114
|
+
*/
|
|
115
|
+
export const BlockArgsHeadings = {
|
|
116
|
+
COIN_GOLD_DOOR: [ComponentTypeHeader.Int32],
|
|
117
|
+
COIN_BLUE_DOOR: [ComponentTypeHeader.Int32],
|
|
118
|
+
COIN_GOLD_GATE: [ComponentTypeHeader.Int32],
|
|
119
|
+
COIN_BLUE_GATE: [ComponentTypeHeader.Int32],
|
|
120
|
+
EFFECTS_JUMP_HEIGHT: [ComponentTypeHeader.Int32],
|
|
121
|
+
EFFECTS_FLY: [ComponentTypeHeader.Boolean],
|
|
122
|
+
EFFECTS_SPEED: [ComponentTypeHeader.Int32],
|
|
123
|
+
EFFECTS_INVULNERABILITY: [ComponentTypeHeader.Boolean],
|
|
124
|
+
EFFECTS_CURSE: [ComponentTypeHeader.Int32],
|
|
125
|
+
EFFECTS_ZOMBIE: [ComponentTypeHeader.Int32],
|
|
126
|
+
EFFECTS_GRAVITYFORCE: [ComponentTypeHeader.Int32],
|
|
127
|
+
EFFECTS_MULTI_JUMP: [ComponentTypeHeader.Int32],
|
|
128
|
+
// gravity effects no data
|
|
129
|
+
// effects off
|
|
130
|
+
// effects zombie
|
|
131
|
+
TOOL_PORTAL_WORLD_SPAWN: [ComponentTypeHeader.Int32],
|
|
132
|
+
SIGN_NORMAL: [ComponentTypeHeader.String],
|
|
133
|
+
SIGN_RED: [ComponentTypeHeader.String],
|
|
134
|
+
SIGN_GREEN: [ComponentTypeHeader.String],
|
|
135
|
+
SIGN_BLUE: [ComponentTypeHeader.String],
|
|
136
|
+
SIGN_GOLD: [ComponentTypeHeader.String],
|
|
137
|
+
PORTAL: [ComponentTypeHeader.Int32, ComponentTypeHeader.Int32, ComponentTypeHeader.Int32],
|
|
138
|
+
PORTAL_INVISIBLE: [ComponentTypeHeader.Int32, ComponentTypeHeader.Int32, ComponentTypeHeader.Int32],
|
|
139
|
+
PORTAL_WORLD: [ComponentTypeHeader.String, ComponentTypeHeader.Int32],
|
|
140
|
+
SWITCH_LOCAL_TOGGLE: [ComponentTypeHeader.Int32],
|
|
141
|
+
SWITCH_LOCAL_ACTIVATOR: [ComponentTypeHeader.Int32, ComponentTypeHeader.Boolean],
|
|
142
|
+
SWITCH_LOCAL_RESETTER: [ComponentTypeHeader.Boolean],
|
|
143
|
+
SWITCH_LOCAL_DOOR: [ComponentTypeHeader.Int32],
|
|
144
|
+
SWITCH_LOCAL_GATE: [ComponentTypeHeader.Int32],
|
|
145
|
+
SWITCH_GLOBAL_TOGGLE: [ComponentTypeHeader.Int32],
|
|
146
|
+
SWITCH_GLOBAL_ACTIVATOR: [ComponentTypeHeader.Int32, ComponentTypeHeader.Boolean],
|
|
147
|
+
SWITCH_GLOBAL_RESETTER: [ComponentTypeHeader.Boolean],
|
|
148
|
+
SWITCH_GLOBAL_DOOR: [ComponentTypeHeader.Int32],
|
|
149
|
+
SWITCH_GLOBAL_GATE: [ComponentTypeHeader.Int32],
|
|
150
|
+
HAZARD_DEATH_DOOR: [ComponentTypeHeader.Int32],
|
|
151
|
+
HAZARD_DEATH_GATE: [ComponentTypeHeader.Int32],
|
|
152
|
+
NOTE_DRUM: [ComponentTypeHeader.ByteArray],
|
|
153
|
+
NOTE_PIANO: [ComponentTypeHeader.ByteArray],
|
|
154
|
+
NOTE_GUITAR: [ComponentTypeHeader.ByteArray],
|
|
155
|
+
};
|
|
156
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQmxvY2suanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9saWIvQmxvY2sudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFVBQVUsRUFBRSxNQUFNLFdBQVcsQ0FBQztBQUV2QyxPQUFPLFlBQVksRUFBRSxFQUFFLG1CQUFtQixFQUFFLE1BQU0sZ0JBQWdCLENBQUM7QUFHbkUsTUFBTSxDQUFDLE9BQU8sT0FBTyxLQUFLO0lBSXRCLFlBQVksR0FBcUMsRUFBRSxJQUFpQjtRQUZwRSxTQUFJLEdBQWUsRUFBRSxDQUFDO1FBR2xCLElBQUksT0FBTyxHQUFHLEtBQUssUUFBUTtZQUFFLElBQUksQ0FBQyxHQUFHLEdBQUcsR0FBRyxDQUFDO2FBQ3ZDLENBQUM7WUFDRixJQUFJLENBQUMsR0FBRyxHQUFHLFVBQVUsQ0FBQyxHQUFHLENBQUMsQ0FBQztRQUMvQixDQUFDO1FBRUQsSUFBSSxJQUFJO1lBQUUsSUFBSSxDQUFDLElBQUksR0FBRyxJQUFJLENBQUM7SUFDL0IsQ0FBQztJQUVEOzs7O09BSUc7SUFDSCxPQUFPO1FBQ0gsT0FBTyxJQUFJLENBQUMsSUFBSSxDQUFDLE1BQU0sS0FBSyxDQUFDLENBQUM7SUFDbEMsQ0FBQztJQUVEOz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DQUFDLG1CQUFtQixDQUFDLEtBQUssRUFBRSxtQkFBbUIsQ0FBQyxPQUFPLENBQUM7SUFDaEYscUJBQXFCLEVBQUUsQ0FBQyxtQkFBbUIsQ0FBQyxPQUFPLENBQUM7SUFDcEQsaUJBQWlCLEVBQUUsQ0FBQyxtQkFBbUIsQ0FBQyxLQUFLLENBQUM7SUFDOUMsaUJBQWlCLEVBQUUsQ0FBQyxtQkFBbUIsQ0FBQyxLQUFLLENBQUM7SUFDOUMsb0JBQW9CLEVBQUUsQ0FBQyxtQkFBbUIsQ0FBQyxLQUFLLENBQUM7SUFDakQsdUJBQXVCLEVBQUUsQ0FBQyxtQkFBbUIsQ0FBQyxLQUFLLEVBQUUsbUJBQW1CLENBQUMsT0FBTyxDQUFDO0lBQ2pGLHNCQUFzQixFQUFFLENBQUMsbUJBQW1CLENBQUMsT0FBTyxDQUFDO0lBQ3JELGtCQUFrQixFQUFFLENBQUMsbUJBQW1CLENBQUMsS0FBSyxDQUFDO0lBQy9DLGtCQUFrQixFQUFFLENBQUMsbUJBQW1CLENBQUMsS0FBSyxDQUFDO0lBRS9DLGlCQUFpQixFQUFFLENBQUMsbUJBQW1CLENBQUMsS0FBSyxDQUFDO0lBQzlDLGlCQUFpQixFQUFFLENBQUMsbUJBQW1CLENBQUMsS0FBSyxDQUFDO0lBRTlDLFNBQVMsRUFBRSxDQUFDLG1CQUFtQixDQUFDLFNBQVMsQ0FBQztJQUMxQyxVQUFVLEVBQUUsQ0FBQyxtQkFBbUIsQ0FBQyxTQUFTLENBQUM7SUFDM0MsV0FBVyxFQUFFLENBQUMsbUJBQW1CLENBQUMsU0FBUyxDQUFDO0NBQ3RDLENBQUMifQ==
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CREDIT: Anatoly for making this Buffer Reader so I don't have to!
|
|
3
|
+
* Source: https://github.com/Anatoly03/pixelwalker.js/blob/9bb3c7e39a45006086a2abae8c515599bd3db835/src/util/buffer-reader.ts
|
|
4
|
+
* License: ISC
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Data during the communication in the process is dynamic
|
|
8
|
+
* typed. Every entry is followed by a byte identifying the
|
|
9
|
+
* type, followed by data. The type header is noted by its'
|
|
10
|
+
* 7-bit notation.
|
|
11
|
+
*/
|
|
12
|
+
export declare enum ComponentTypeHeader {
|
|
13
|
+
String = 0,
|
|
14
|
+
Byte = 1,
|
|
15
|
+
Int16 = 2,
|
|
16
|
+
Int32 = 3,
|
|
17
|
+
Int64 = 4,
|
|
18
|
+
Float = 5,
|
|
19
|
+
Double = 6,
|
|
20
|
+
Boolean = 7,
|
|
21
|
+
ByteArray = 8
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* A Buffer reader is a special buffer extension made to perform
|
|
25
|
+
* game-specific tasks in the field of communication.
|
|
26
|
+
*
|
|
27
|
+
* @implements Buffer
|
|
28
|
+
*/
|
|
29
|
+
export default class BufferReader {
|
|
30
|
+
private buffer;
|
|
31
|
+
private offset;
|
|
32
|
+
/**
|
|
33
|
+
*
|
|
34
|
+
*/
|
|
35
|
+
private constructor();
|
|
36
|
+
/**
|
|
37
|
+
*
|
|
38
|
+
*/
|
|
39
|
+
static from(from: Uint8Array | Buffer): BufferReader;
|
|
40
|
+
/**
|
|
41
|
+
*
|
|
42
|
+
*/
|
|
43
|
+
static alloc(amount: number): BufferReader;
|
|
44
|
+
/**
|
|
45
|
+
* @param {string} value
|
|
46
|
+
* @returns {Buffer}
|
|
47
|
+
*/
|
|
48
|
+
static String(value?: string): Buffer;
|
|
49
|
+
/**
|
|
50
|
+
* @param {number} value
|
|
51
|
+
* @returns {Buffer}
|
|
52
|
+
*/
|
|
53
|
+
static Byte(value?: number): Buffer;
|
|
54
|
+
/**
|
|
55
|
+
* @param {number} value
|
|
56
|
+
* @returns {Buffer}
|
|
57
|
+
*/
|
|
58
|
+
static Int16(value?: number): Buffer;
|
|
59
|
+
/**
|
|
60
|
+
* @param {number} value
|
|
61
|
+
* @returns {Buffer}
|
|
62
|
+
*/
|
|
63
|
+
static Int32(value?: number): Buffer;
|
|
64
|
+
/**
|
|
65
|
+
* @param {bigint} value
|
|
66
|
+
* @returns {Buffer}
|
|
67
|
+
*/
|
|
68
|
+
static Int64(value?: bigint): Buffer;
|
|
69
|
+
/**
|
|
70
|
+
* @param {number} value
|
|
71
|
+
* @returns {Buffer}
|
|
72
|
+
*/
|
|
73
|
+
static Float(value?: number): Buffer;
|
|
74
|
+
/**
|
|
75
|
+
* @param {number} value
|
|
76
|
+
* @returns {Buffer}
|
|
77
|
+
*/
|
|
78
|
+
static Double(value?: number): Buffer;
|
|
79
|
+
/**
|
|
80
|
+
* @param {boolean} value
|
|
81
|
+
* @returns {Buffer}
|
|
82
|
+
*/
|
|
83
|
+
static Boolean(value?: boolean): Buffer;
|
|
84
|
+
/**
|
|
85
|
+
* @param {Uint8Array} buffer
|
|
86
|
+
* @returns {Buffer}
|
|
87
|
+
*/
|
|
88
|
+
static ByteArray(buffer?: Buffer): Buffer;
|
|
89
|
+
/**
|
|
90
|
+
* @param {number} value
|
|
91
|
+
* @returns {Buffer}
|
|
92
|
+
*/
|
|
93
|
+
static Magic(value: number): Buffer;
|
|
94
|
+
/**
|
|
95
|
+
* @param {number} value
|
|
96
|
+
* @returns {Buffer}
|
|
97
|
+
*/
|
|
98
|
+
static Bit7(value?: number): Buffer;
|
|
99
|
+
/**
|
|
100
|
+
* @param tt
|
|
101
|
+
* @param value
|
|
102
|
+
*/
|
|
103
|
+
static Dynamic(tt: ComponentTypeHeader, value: boolean | number | bigint | string | Buffer): Buffer;
|
|
104
|
+
/**
|
|
105
|
+
*
|
|
106
|
+
*/
|
|
107
|
+
get length(): number;
|
|
108
|
+
/**
|
|
109
|
+
*
|
|
110
|
+
*/
|
|
111
|
+
subarray(start?: number, end?: number): BufferReader;
|
|
112
|
+
/**
|
|
113
|
+
*
|
|
114
|
+
*/
|
|
115
|
+
write(value: string): number;
|
|
116
|
+
/**
|
|
117
|
+
*
|
|
118
|
+
*/
|
|
119
|
+
writeBigInt64BE(value: bigint): number;
|
|
120
|
+
/**
|
|
121
|
+
*
|
|
122
|
+
*/
|
|
123
|
+
writeBigInt64LE(value: bigint): number;
|
|
124
|
+
/**
|
|
125
|
+
*
|
|
126
|
+
*/
|
|
127
|
+
writeUInt8(value: number): number;
|
|
128
|
+
/**
|
|
129
|
+
*
|
|
130
|
+
*/
|
|
131
|
+
writeUInt16LE(value: number): number;
|
|
132
|
+
/**
|
|
133
|
+
*
|
|
134
|
+
*/
|
|
135
|
+
writeUInt16BE(value: number): number;
|
|
136
|
+
/**
|
|
137
|
+
*
|
|
138
|
+
*/
|
|
139
|
+
writeUInt32LE(value: number): number;
|
|
140
|
+
/**
|
|
141
|
+
*
|
|
142
|
+
*/
|
|
143
|
+
writeUInt32BE(value: number): number;
|
|
144
|
+
/**
|
|
145
|
+
*
|
|
146
|
+
*/
|
|
147
|
+
writeInt8(value: number): number;
|
|
148
|
+
/**
|
|
149
|
+
*
|
|
150
|
+
*/
|
|
151
|
+
writeInt16LE(value: number): number;
|
|
152
|
+
/**
|
|
153
|
+
*
|
|
154
|
+
*/
|
|
155
|
+
writeInt16BE(value: number): number;
|
|
156
|
+
/**
|
|
157
|
+
*
|
|
158
|
+
*/
|
|
159
|
+
writeInt32LE(value: number): number;
|
|
160
|
+
/**
|
|
161
|
+
*
|
|
162
|
+
*/
|
|
163
|
+
writeInt32BE(value: number): number;
|
|
164
|
+
/**
|
|
165
|
+
*
|
|
166
|
+
*/
|
|
167
|
+
writeFloatLE(value: number): number;
|
|
168
|
+
/**
|
|
169
|
+
*
|
|
170
|
+
*/
|
|
171
|
+
writeFloatBE(value: number): number;
|
|
172
|
+
/**
|
|
173
|
+
*
|
|
174
|
+
*/
|
|
175
|
+
writeDoubleLE(value: number): number;
|
|
176
|
+
/**
|
|
177
|
+
*
|
|
178
|
+
*/
|
|
179
|
+
writeDoubleBE(value: number): number;
|
|
180
|
+
/**
|
|
181
|
+
*
|
|
182
|
+
*/
|
|
183
|
+
readBigUInt64BE(): bigint;
|
|
184
|
+
/**
|
|
185
|
+
*
|
|
186
|
+
*/
|
|
187
|
+
readBigUInt64LE(): bigint;
|
|
188
|
+
/**
|
|
189
|
+
*
|
|
190
|
+
*/
|
|
191
|
+
readBigInt64BE(): bigint;
|
|
192
|
+
/**
|
|
193
|
+
*
|
|
194
|
+
*/
|
|
195
|
+
readBigInt64LE(): bigint;
|
|
196
|
+
/**
|
|
197
|
+
*
|
|
198
|
+
*/
|
|
199
|
+
expectUInt8(value: number): number;
|
|
200
|
+
/**
|
|
201
|
+
*
|
|
202
|
+
*/
|
|
203
|
+
readUInt8(): number;
|
|
204
|
+
/**
|
|
205
|
+
*
|
|
206
|
+
*/
|
|
207
|
+
readUInt16LE(): number;
|
|
208
|
+
/**
|
|
209
|
+
*
|
|
210
|
+
*/
|
|
211
|
+
readUInt16BE(): number;
|
|
212
|
+
/**
|
|
213
|
+
*
|
|
214
|
+
*/
|
|
215
|
+
readUInt32LE(): number;
|
|
216
|
+
/**
|
|
217
|
+
*
|
|
218
|
+
*/
|
|
219
|
+
readUInt32BE(): number;
|
|
220
|
+
/**
|
|
221
|
+
*
|
|
222
|
+
*/
|
|
223
|
+
readInt8(): number;
|
|
224
|
+
/**
|
|
225
|
+
*
|
|
226
|
+
*/
|
|
227
|
+
readInt16LE(): number;
|
|
228
|
+
/**
|
|
229
|
+
*
|
|
230
|
+
*/
|
|
231
|
+
readInt16BE(): number;
|
|
232
|
+
/**
|
|
233
|
+
*
|
|
234
|
+
*/
|
|
235
|
+
readInt32LE(): number;
|
|
236
|
+
/**
|
|
237
|
+
*
|
|
238
|
+
*/
|
|
239
|
+
readInt32BE(): number;
|
|
240
|
+
/**
|
|
241
|
+
*
|
|
242
|
+
*/
|
|
243
|
+
readFloatLE(): number;
|
|
244
|
+
/**
|
|
245
|
+
*
|
|
246
|
+
*/
|
|
247
|
+
readFloatBE(): number;
|
|
248
|
+
/**
|
|
249
|
+
*
|
|
250
|
+
*/
|
|
251
|
+
readDoubleLE(): number;
|
|
252
|
+
/**
|
|
253
|
+
*
|
|
254
|
+
*/
|
|
255
|
+
readDoubleBE(): number;
|
|
256
|
+
read(tt: ComponentTypeHeader, littleEndian?: boolean): string | number | bigint | boolean | Buffer;
|
|
257
|
+
read(tt: ComponentTypeHeader.String, littleEndian?: boolean): string;
|
|
258
|
+
read(tt: ComponentTypeHeader.Byte, littleEndian?: boolean): number;
|
|
259
|
+
read(tt: ComponentTypeHeader.Int16, littleEndian?: boolean): number;
|
|
260
|
+
read(tt: ComponentTypeHeader.Int32, littleEndian?: boolean): number;
|
|
261
|
+
read(tt: ComponentTypeHeader.Int64, littleEndian?: boolean): bigint;
|
|
262
|
+
read(tt: ComponentTypeHeader.Float, littleEndian?: boolean): number;
|
|
263
|
+
read(tt: ComponentTypeHeader.Double, littleEndian?: boolean): number;
|
|
264
|
+
read(tt: ComponentTypeHeader.Boolean, littleEndian?: boolean): boolean;
|
|
265
|
+
read(tt: ComponentTypeHeader.ByteArray, littleEndian?: boolean): Buffer;
|
|
266
|
+
/**
|
|
267
|
+
*
|
|
268
|
+
*/
|
|
269
|
+
toBuffer(): Buffer;
|
|
270
|
+
/**
|
|
271
|
+
* https://stackoverflow.com/questions/8609289/convert-a-binary-nodejs-buffer-to-javascript-arraybuffer
|
|
272
|
+
*/
|
|
273
|
+
toArrayBuffer(): ArrayBuffer;
|
|
274
|
+
/**
|
|
275
|
+
*
|
|
276
|
+
*/
|
|
277
|
+
at(idx: number): number;
|
|
278
|
+
/**
|
|
279
|
+
* Advanced the buffer reader by pffset.
|
|
280
|
+
*/
|
|
281
|
+
advanceOffset(relativeOffset?: number): this;
|
|
282
|
+
/**
|
|
283
|
+
* This function reads how many bytes a normal integer would take
|
|
284
|
+
* as a 7-bit number
|
|
285
|
+
*
|
|
286
|
+
* 1(000 0001) 0(111 1110)
|
|
287
|
+
*/
|
|
288
|
+
static length7BitInt(value: number): number;
|
|
289
|
+
/**
|
|
290
|
+
* Reads in an integer in 7-bit notation. A 7-bit integer
|
|
291
|
+
* encoding splits a number into a variable size of bits,
|
|
292
|
+
* in which the first bit is set while bytes are following.
|
|
293
|
+
*
|
|
294
|
+
* @example
|
|
295
|
+
*
|
|
296
|
+
* ```
|
|
297
|
+
* 1111 0000 1010 1010 1000 0000 0000 0001 Reading In
|
|
298
|
+
* ^--- ---- ^--- ---- ^--- ---- ^--- ----
|
|
299
|
+
* 111 0000 010 1010 000 0000 000 0001 Writing Out
|
|
300
|
+
* ```
|
|
301
|
+
*/
|
|
302
|
+
read7BitInt(): number;
|
|
303
|
+
/**
|
|
304
|
+
* Write a normal integer value into buffer at offset.
|
|
305
|
+
*/
|
|
306
|
+
write7BitInt(value: number): void;
|
|
307
|
+
/**
|
|
308
|
+
* Reads a dynamic buffer which is prepended by its' length
|
|
309
|
+
* in 7-bit encoding.
|
|
310
|
+
*/
|
|
311
|
+
readDynamicBuffer(): Buffer<ArrayBufferLike>;
|
|
312
|
+
/**
|
|
313
|
+
* Append a buffer to the current buffer. Asserts the cursor
|
|
314
|
+
* to be at the end of the current buffer.
|
|
315
|
+
*/
|
|
316
|
+
append(buffer: Buffer): this;
|
|
317
|
+
/**
|
|
318
|
+
* Keep Deserializing the buffer for typed data until
|
|
319
|
+
* you reach the end of the buffer. Typed data consists
|
|
320
|
+
* of a type indicator in 7-bit-encoding and data following
|
|
321
|
+
* accordingly.
|
|
322
|
+
*/
|
|
323
|
+
deserialize(): (string | number | bigint | boolean | Buffer<ArrayBufferLike>)[];
|
|
324
|
+
}
|