Skip to content

Commit

Permalink
Document all packets
Browse files Browse the repository at this point in the history
  • Loading branch information
DryByte committed Mar 12, 2023
1 parent 3516d0b commit 88091ec
Show file tree
Hide file tree
Showing 27 changed files with 383 additions and 4 deletions.
9 changes: 9 additions & 0 deletions src/extraPackets/VersionGet.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
const BasePacket = require("../packets/BasePacket.js");

/**
* Tells the client to send version info
* @category Ext Packets
* @extends {BasePacket}
*/
class VersionGet extends BasePacket {
constructor(packet) {
super();

/**
* Packet Id
* @type Integer
*/
this.id = 33;
this.fields = {};

Expand Down
14 changes: 14 additions & 0 deletions src/extraPackets/VersionHandshakeInit.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
const BasePacket = require("../packets/BasePacket.js");
const { LEIntType } = require("../types");

/**
* Server starts handshake for version info
* @category Ext Packets
* @extends {BasePacket}
*/
class VersionHandshakeInit extends BasePacket {
constructor(packet) {
super();

/**
* Packet Id
* @type Integer
*/
this.id = 31;

/**
* Fields Object
* @property {LEIntType} challenge Number sent to validate handshake
*/
this.fields = {
challenge: new LEIntType(),
};
Expand Down
5 changes: 5 additions & 0 deletions src/extraPackets/VersionHandshakeRes.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
const BasePacket = require("../packets/BasePacket.js");
const { LEIntType } = require("../types");

/**
* Response for a VersionHandshakeInit
* @category Ext Packets
* @extends {BasePacket}
*/
class VersionHandshakeRes extends BasePacket {
constructor(packet) {
super();
Expand Down
18 changes: 18 additions & 0 deletions src/extraPackets/VersionSend.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
const BasePacket = require("../packets/BasePacket.js");
const { ByteType, StringType } = require("../types");

/**
* Send version infos
* @category Ext Packets
* @extends {BasePacket}
*/
class VersionSend extends BasePacket {
constructor(packet) {
super();

/**
* Packet Id
* @type Integer
*/
this.id = 34;

/**
* Fields Object
* @property {ByteType} client_identifier ASCII Client Identifier
* @property {ByteType} version_major Major Version
* @property {ByteType} version_minor Minor Version
* @property {ByteType} version_revision Revision Version
* @property {StringType} os Operational System Infos
*/
this.fields = {
client_identifier: new ByteType(),
version_major: new ByteType(),
Expand Down
3 changes: 1 addition & 2 deletions src/packets/BlockAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ const BasePacket = require("./BasePacket.js");
const { UByteType, LEIntType } = require("../types");

/**
* Block Action Packet
* @category Packets
* @extends BasePacket
* @extends {BasePacket}
*/
class BlockAction extends BasePacket {
constructor(packet) {
Expand Down
3 changes: 1 addition & 2 deletions src/packets/BlockLine.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ const BasePacket = require("./BasePacket.js");
const { UByteType, LEIntType } = require("../types");

/**
* Block Line Packet
* @category Packets
* @extends BasePacket
* @extends {BasePacket}
*/
class BlockLine extends BasePacket {
constructor(packet) {
Expand Down
14 changes: 14 additions & 0 deletions src/packets/ChangeTeam.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
const BasePacket = require("./BasePacket.js");
const { UByteType, ByteType } = require("../types");

/**
* @category Packets
* @extends {BasePacket}
*/
class ChangeTeam extends BasePacket {
constructor(packet) {
super();

/**
* Packet Id
* @type Integer
*/
this.id = 29;

/**
* Fields Object
* @property {UByteType} player_id Player's id
* @property {ByteType} team_id Team ID to change
*/
this.fields = {
player_id: new UByteType(),
team_id: new ByteType(),
Expand Down
14 changes: 14 additions & 0 deletions src/packets/ChangeWeapon.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
const BasePacket = require("./BasePacket.js");
const { UByteType } = require("../types");

/**
* @category Packets
* @extends {BasePacket}
*/
class ChangeWeapon extends BasePacket {
constructor(packet) {
super();

/**
* Packet Id
* @type Integer
*/
this.id = 30;

/**
* Fields Object
* @property {UByteType} player_id Player's id
* @property {UByteType} weapon_id Weapon ID to change
*/
this.fields = {
player_id: new UByteType(),
weapon_id: new UByteType(),
Expand Down
15 changes: 15 additions & 0 deletions src/packets/ChatMessage.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
const BasePacket = require("./BasePacket.js");
const { UByteType, StringType } = require("../types");

/**
* @category Packets
* @extends {BasePacket}
*/
class ChatMessage extends BasePacket {
constructor(packet) {
super();

/**
* Packet Id
* @type Integer
*/
this.id = 17;

/**
* Fields Object
* @property {UByteType} player_id Player's id
* @property {UByteType} chat_type Chat Type to send the message
* @property {StringType} chat_message Chat Message to send
*/
this.fields = {
player_id: new UByteType(),
chat_type: new UByteType(),
Expand Down
19 changes: 19 additions & 0 deletions src/packets/CreatePlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,30 @@ const BasePacket = require("./BasePacket.js");
const Player = require("../game/Player.js");
const { ByteType, UByteType, LEFloatType, StringType } = require("../types");

/**
* @category Packets
* @extends {BasePacket}
*/
class CreatePlayer extends BasePacket {
constructor(packet) {
super();

/**
* Packet Id
* @type Integer
*/
this.id = 12;

/**
* Fields Object
* @property {UByteType} player_id Player's id
* @property {UByteType} weapon Weapon id
* @property {ByteType} team Team id
* @property {LEFloatType} x Spawn X coordinate
* @property {LEFloatType} y Spawn Y coordinate
* @property {LEFloatType} z Spawn Z coordinate
* @property {StringType} name Player's name
*/
this.fields = {
player_id: new UByteType(),
weapon: new UByteType(),
Expand Down
21 changes: 21 additions & 0 deletions src/packets/ExistingPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,32 @@ const BasePacket = require("./BasePacket.js");
const Player = require("../game/Player.js");
const { ByteType, UByteType, StringType, UInt32Type } = require("../types");

/**
* @category Packets
* @extends {BasePacket}
*/
class ExistingPlayer extends BasePacket {
constructor(packet) {
super();

/**
* Packet Id
* @type Integer
*/
this.id = 9;

/**
* Fields Object
* @property {UByteType} player_id Player's id
* @property {ByteType} team Team id
* @property {UByteType} weapon Weapon id
* @property {UByteType} held_item Which tool player is holding
* @property {UInt32Type} kills Kill count
* @property {UByteType} block_blue Player's block blue color
* @property {UByteType} block_green Player's block green color
* @property {UByteType} block_red Player's block red color
* @property {StringType} name Player's name
*/
this.fields = {
player_id: new UByteType(),
team: new ByteType(),
Expand Down
22 changes: 22 additions & 0 deletions src/packets/InputData.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
const BasePacket = require("./BasePacket.js");
const { UByteType } = require("../types");

/**
* @category Packets
* @extends {BasePacket}
*/
class InputData extends BasePacket {
constructor(packet) {
super();

/**
* Packet Id
* @type Integer
*/
this.id = 3;

/**
* Fields Object
* @property {UByteType} player_id Player's id
* @property {UByteType} key_states A byte that each bit is a key state
*/
this.fields = {
player_id: new UByteType(),
key_states: new UByteType()
Expand All @@ -19,6 +33,10 @@ class InputData extends BasePacket {
game.players[this.getValue("player_id")].inputs = this.getKeyStates();
}

/**
* Set key states field using object
* @param {WalkInputs} KeyStates Object with key states.
*/
setKeyStates(state_obj) {
let bits = 0;
let current_state = 0;
Expand All @@ -31,6 +49,10 @@ class InputData extends BasePacket {
this.fields.key_states.value = bits;
}

/**
* Get the an object with the key_states fields
* @returns {WalkInputs}
*/
getKeyStates() {
let r_obj = {up: false, down: false, left: false, right: false, jump: false, crouch: false, sneak: false, sprint: false};
let current_state = 0;
Expand Down
14 changes: 14 additions & 0 deletions src/packets/IntelCapture.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
const BasePacket = require("./BasePacket.js");
const { UByteType } = require("../types");

/**
* @category Packets
* @extends {BasePacket}
*/
class IntelCapture extends BasePacket {
constructor(packet) {
super();

/**
* Packet Id
* @type Integer
*/
this.id = 23;

/**
* Fields Object
* @property {UByteType} player_id Player's id
* @property {UByteType} winning Boolean if thats the winning intel
*/
this.fields = {
player_id: new UByteType(),
winning: new UByteType(),
Expand Down
16 changes: 16 additions & 0 deletions src/packets/IntelDrop.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
const BasePacket = require("./BasePacket.js");
const { UByteType, LEFloatType } = require("../types");

/**
* @category Packets
* @extends {BasePacket}
*/
class IntelDrop extends BasePacket {
constructor(packet) {
super();

/**
* Packet Id
* @type Integer
*/
this.id = 25;

/**
* Fields Object
* @property {UByteType} player_id Player's id
* @property {LEFloatType} x Drop X coordinate
* @property {LEFloatType} y Drop Y coordinate
* @property {LEFloatType} z Drop Z coordinate
*/
this.fields = {
player_id: new UByteType(),
x: new LEFloatType(),
Expand Down
13 changes: 13 additions & 0 deletions src/packets/IntelPickup.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
const BasePacket = require("./BasePacket.js");
const { UByteType } = require("../types");

/**
* @category Packets
* @extends {BasePacket}
*/
class IntelPickup extends BasePacket {
constructor(packet) {
super();

/**
* Packet Id
* @type Integer
*/
this.id = 24;

/**
* Fields Object
* @property {UByteType} player_id Player's id
*/
this.fields = {
player_id: new UByteType()
};
Expand Down
Loading

0 comments on commit 88091ec

Please sign in to comment.