bedrock-portal-nethernet 2.8.1 → 2.8.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/dist/datatypes/compiler-minecraft.js +0 -62
- package/dist/protocol.d.ts +352 -217
- package/dist/protocol.js +891 -707
- package/package.json +1 -1
|
@@ -34,68 +34,6 @@ Write.restBuffer = ['native', (value, buffer, offset) => {
|
|
|
34
34
|
SizeOf.restBuffer = ['native', (value) => {
|
|
35
35
|
return value.length;
|
|
36
36
|
}];
|
|
37
|
-
/**
|
|
38
|
-
* Length-prefixed array whose declared count is an upper bound when reading.
|
|
39
|
-
* Writing and sizing remain identical to an ordinary array.
|
|
40
|
-
*/
|
|
41
|
-
Read.maybeIncompleteArray = ['parametrizable', (compiler, { countType, type }) => {
|
|
42
|
-
return compiler.wrapCode(`
|
|
43
|
-
const { value: count, size: countSize } = ${compiler.callType(countType)}
|
|
44
|
-
if (count > 0xffffff && !ctx.noArraySizeCheck) throw new Error("array size is abnormally large, not reading: " + count)
|
|
45
|
-
const data = []
|
|
46
|
-
let size = countSize
|
|
47
|
-
for (let i = 0; i < count && offset + size < buffer.length; i++) {
|
|
48
|
-
try {
|
|
49
|
-
const elem = ${compiler.callType(type, 'offset + size')}
|
|
50
|
-
data.push(elem.value)
|
|
51
|
-
size += elem.size
|
|
52
|
-
} catch (error) {
|
|
53
|
-
if (error.name !== "PartialReadError") throw error
|
|
54
|
-
break
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return { value: data, size }
|
|
58
|
-
`.trim());
|
|
59
|
-
}];
|
|
60
|
-
Write.maybeIncompleteArray = ['parametrizable', (compiler, { countType, type }) => {
|
|
61
|
-
return compiler.wrapCode(`
|
|
62
|
-
offset = ${compiler.callType('value.length', countType)}
|
|
63
|
-
for (let i = 0; i < value.length; i++) {
|
|
64
|
-
offset = ${compiler.callType('value[i]', type)}
|
|
65
|
-
}
|
|
66
|
-
return offset
|
|
67
|
-
`.trim());
|
|
68
|
-
}];
|
|
69
|
-
SizeOf.maybeIncompleteArray = ['parametrizable', (compiler, { countType, type }) => {
|
|
70
|
-
return compiler.wrapCode(`
|
|
71
|
-
let size = ${compiler.callType('value.length', countType)}
|
|
72
|
-
for (let i = 0; i < value.length; i++) {
|
|
73
|
-
size += ${compiler.callType('value[i]', type)}
|
|
74
|
-
}
|
|
75
|
-
return size
|
|
76
|
-
`.trim());
|
|
77
|
-
}];
|
|
78
|
-
/**
|
|
79
|
-
* Terminal field present only when unread packet bytes remain.
|
|
80
|
-
*/
|
|
81
|
-
Read.optionalOnRemaining = ['parametrizable', (compiler, { type }) => {
|
|
82
|
-
return compiler.wrapCode(`
|
|
83
|
-
if (offset >= buffer.length) return { value: undefined, size: 0 }
|
|
84
|
-
return ${compiler.callType(type)}
|
|
85
|
-
`.trim());
|
|
86
|
-
}];
|
|
87
|
-
Write.optionalOnRemaining = ['parametrizable', (compiler, { type }) => {
|
|
88
|
-
return compiler.wrapCode(`
|
|
89
|
-
if (value === undefined) return offset
|
|
90
|
-
return ${compiler.callType('value', type)}
|
|
91
|
-
`.trim());
|
|
92
|
-
}];
|
|
93
|
-
SizeOf.optionalOnRemaining = ['parametrizable', (compiler, { type }) => {
|
|
94
|
-
return compiler.wrapCode(`
|
|
95
|
-
if (value === undefined) return 0
|
|
96
|
-
return ${compiler.callType('value', type)}
|
|
97
|
-
`.trim());
|
|
98
|
-
}];
|
|
99
37
|
/**
|
|
100
38
|
* Encapsulated data with length prefix
|
|
101
39
|
*/
|