mirror of
https://github.com/unmojang/node-minecraft-protocol.git
synced 2025-09-28 21:52:17 -04:00
add direction variable in createPacketBuffer
This commit is contained in:
parent
188848b364
commit
a62e7a2712
@ -62,16 +62,17 @@ var packetStates = packetIndexes.packetStates;
|
|||||||
// TODO : This does NOT contain the length prefix anymore.
|
// TODO : This does NOT contain the length prefix anymore.
|
||||||
function createPacketBuffer(packetId, state, params, isServer) {
|
function createPacketBuffer(packetId, state, params, isServer) {
|
||||||
var length = 0;
|
var length = 0;
|
||||||
|
var direction=!isServer ? 'toServer' : 'toClient';
|
||||||
if(typeof packetId === 'string' && typeof state !== 'string' && !params) {
|
if(typeof packetId === 'string' && typeof state !== 'string' && !params) {
|
||||||
// simplified two-argument usage, createPacketBuffer(name, params)
|
// simplified two-argument usage, createPacketBuffer(name, params)
|
||||||
params = state;
|
params = state;
|
||||||
state = packetStates[!isServer ? 'toServer' : 'toClient'][packetId];
|
state = packetStates[direction][packetId];
|
||||||
}
|
}
|
||||||
if(typeof packetId === 'string') packetId = packetIds[state][!isServer ? 'toServer' : 'toClient'][packetId];
|
if(typeof packetId === 'string') packetId = packetIds[state][direction][packetId];
|
||||||
assert.notEqual(packetId, undefined);
|
assert.notEqual(packetId, undefined);
|
||||||
|
|
||||||
var packet = get(packetId, state, !isServer);
|
var packet = get(packetId, state, !isServer);
|
||||||
var packetName = packetNames[state][!isServer ? 'toServer' : 'toClient'][packetId];
|
var packetName = packetNames[state][direction][packetId];
|
||||||
assert.notEqual(packet, null);
|
assert.notEqual(packet, null);
|
||||||
packet.forEach(function(fieldInfo) {
|
packet.forEach(function(fieldInfo) {
|
||||||
tryCatch(() => {
|
tryCatch(() => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user