Skip to content
This repository has been archived by the owner on Aug 1, 2023. It is now read-only.

Commit

Permalink
Started the protocol update from 1.6.4 to 1.7.2, which is pretty major.
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeDoyle23 committed Dec 14, 2013
1 parent 1c6d08e commit 4bf0355
Show file tree
Hide file tree
Showing 8 changed files with 685 additions and 581 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ BurningPig

![burningpig](http://joedoyle.us/burningpig.png)

###A Minecraft 1.6.4 Server in Node.js
###A Minecraft 1.7.2 Server in Node.js

** The protocol change from 1.6.4 to 1.7.2 is huge and in progress**


BurningPig is a custom server for the creative game Minecraft:
<a href="http://minecraft.net">www.minecraft.net</a>
Expand Down
6 changes: 4 additions & 2 deletions handlers/timeHandler.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
var packets = require('../network/packetList').serverPackets;

var TimeHandler = function(world) {

var dayTime = new Buffer(8);
Expand All @@ -14,7 +16,7 @@ var TimeHandler = function(world) {
dayTime.fill(0);
dayTime.writeUInt16BE(timeLow % 24000, 6);

var time = world.packetWriter.build({ ptype: 0x04, time: world.worldTime, daytime: dayTime });
var time = world.packetWriter.build({ ptype: packets.TimeUpdate, worldAge: world.worldTime, time: dayTime });
world.packetSender.sendToAllPlayers(time);

var packetLength = 0;
Expand All @@ -23,7 +25,7 @@ var TimeHandler = function(world) {
var cPing = player.getPing();

var playerlist = world.packetWriter.build({
ptype: 0xC9,
ptype: packets.PlayerListItem,
playerName: player.name,
online: true,
ping: cPing > 0x7FFF ? 0x7FFF : cPing
Expand Down
8 changes: 4 additions & 4 deletions network/packet.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var util = require('util');
var int64 = require('node-int64');
var varint = require('varint');

var Packet = function(size) {
this.buffer = new Buffer(size);
Expand All @@ -16,11 +17,10 @@ Packet.prototype.getPosition = function() {

Packet.prototype.writeString = function (data) {
var stringBuf = new Buffer(data, 'binary');
var length = varint.encode(data.length);

this.writeShort(data.length);
for (var i = 0; i < data.length; i++) {
this.writeShort(stringBuf[i]);
}
this.writeArray(length);
this.writeArray(stringBuf);

return this;
};
Expand Down
95 changes: 95 additions & 0 deletions network/packetList.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
module.exports = {
serverPackets: {
KeepAlive: 0x00,
JoinGame: 0x01,
ChatMessage: 0x02,
TimeUpdate: 0x03,
EntityEquipment: 0x04,
SpawnPosition: 0x05,
UpdateHealth: 0x06,
Respawn: 0x07,
PlayerPositionAndLook: 0x08,
HeldItemChange: 0x09,
UseBed: 0x0A,
Animation: 0x0B,
SpawnPlayer: 0x0C,
CollectItem: 0x0D,
SpawnObject: 0x0E,
SpawnMob: 0x0F,
SpawnPainting: 0x10,
SpawnExperienceOrb: 0x11,
EntityVelocity: 0x12,
DestroyEntities: 0x13,
Entity: 0x14,
EntityRelativeMove: 0x15,
EntityLook: 0x16,
EntityLookAndRelativeMove: 0x17,
EntityTeleport: 0x18,
EntityHeadLook: 0x19,
EntityStatus: 0x1A,
AttachEntity: 0x1B,
EntityMetadata: 0x1C,
EntityEffect: 0x1D,
RemoveEntityEffect: 0x1E,
SetExperience: 0x1F,
EntityProperties: 0x20,
ChunkData: 0x21,
MultiBlockChange: 0x22,
BlockChange: 0x23,
BlockAction: 0x24,
BlockBreakAnimation: 0x25,
MapChunkBulk: 0x26,
Explosion: 0x27,
Effect: 0x28,
SoundEffect: 0x29,
Particle: 0x2A,
ChangeGameState: 0x2B,
SpawnGlobalEntity: 0x2C,
OpenWindow: 0x2D,
CloseWindow: 0x2E,
SetSlot: 0x2F,
WindowItems: 0x30,
WindowProperty: 0x31,
ConfirmTransaction : 0x32,
UpdateSign: 0x33,
Maps: 0x34,
UpdateBlockEntity: 0x35,
SignEditorOpen: 0x36,
Statistics: 0x37,
PlayerListItem: 0x38,
PlayerAbilities: 0x39,
TabComplete: 0x3A,
ScoreboardObjective: 0x3B,
UpdateScore: 0x3C,
DisplayScoreboard: 0x3D,
Teams: 0x3E,
PluginMessage: 0x3F,
Disconnect: 0x40,
},
clientPackets: {
KeepAlive: 0x00,
ChatMessage: 0x01,
UseEntity: 0x02,
Player: 0x03,
PlayerPosition: 0x04,
PlayerLook: 0x05,
PlayerPositionAndLook: 0x06,
PlayerDigging: 0x07,
PlayerBlockPlacement: 0x08,
HeldItemChange: 0x09,
Animation: 0x0A,
EntityAction: 0x0B,
SteerVehicle: 0x0C,
CloseWindow: 0x0D,
ClickWindow: 0x0E,
ConfirmTransaction: 0x0F,
CreativeInventoryAction: 0x10,
EnchantItem: 0x11,
UpdateSign: 0x12,
PlayerAbilities: 0x13,
TabComplete: 0x14,
ClientSettings: 0x15,
ClientStatus: 0x16,
PluginMessage: 0x17,
}
};
Loading

0 comments on commit 4bf0355

Please sign in to comment.