Added new packets

This commit is contained in:
Shoghi Cervantes Pueyo 2013-01-30 20:21:18 +01:00
parent 0e889b0139
commit d0a08d16e7
4 changed files with 27 additions and 9 deletions

View File

@ -192,9 +192,9 @@ class Player{
if($data["eid"] === $this->eid){
$data["eid"] = 0;
$this->armor = array($data["slot0"], $data["slot1"], $data["slot2"], $data["slot3"]);
$this->dataPacket(MC_SET_ARMOR, $data);
$this->dataPacket(MC_PLAYER_ARMOR_EQUIPMENT, $data);
}else{
$this->dataPacket(MC_SET_ARMOR, $data);
$this->dataPacket(MC_PLAYER_ARMOR_EQUIPMENT, $data);
}
break;
case "player.block.place":
@ -574,7 +574,7 @@ class Player{
}
$this->server->handle("player.block.break", $data);
break;
case MC_SET_ARMOR:
case MC_PLAYER_ARMOR_EQUIPMENT:
$data["eid"] = $this->eid;
$this->server->handle("player.armor", $data);
break;

View File

@ -445,7 +445,7 @@ class CustomPacketHandler{
$this->raw .= Utils::writeShort($this->data["meta"]);
}
break;
case MC_SET_ARMOR:
case MC_PLAYER_ARMOR_EQUIPMENT:
if($this->c === false){
$this->data["eid"] = Utils::readInt($this->get(4));
$this->data["slot0"] = ord($this->get(1));
@ -514,6 +514,13 @@ class CustomPacketHandler{
$this->raw .= Utils::writeShort($this->data["speedZ"]);
}
break;
case MC_HURT_ARMOR:
if($this->c === false){
$this->data["health"] = Utils::readByte($this->get(1));
}else{
$this->raw .= Utils::writeByte($this->data["health"]);
}
break;
case MC_SET_HEALTH:
if($this->c === false){
$this->data["health"] = Utils::readByte($this->get(1));
@ -521,6 +528,17 @@ class CustomPacketHandler{
$this->raw .= Utils::writeByte($this->data["health"]);
}
break;
case MC_SET_SPAWN_POSITION:
if($this->c === false){
$this->data["x"] = Utils::readInt($this->get(4));
$this->data["z"] = Utils::readInt($this->get(4));
$this->data["y"] = ord($this->get(1));
}else{
$this->raw .= Utils::writeInt($this->data["x"]);
$this->raw .= Utils::writeInt($this->data["z"]);
$this->raw .= chr($this->data["y"]);
}
break;
case MC_ANIMATE:
if($this->c === false){
$this->data["action"] = Utils::readByte($this->get(1));
@ -626,8 +644,7 @@ class CustomPacketHandler{
$this->data["line$i"] = $this->get(Utils::readLShort($this->get(2), false));
}
}else{
$this->raw .= $this->data["unknown1"];
$this->raw .= $this->data["unknown2"];
$this->raw .= "\xff";
}
break;
default:

View File

@ -64,13 +64,13 @@ define("MC_ENTITY_EVENT", 0x9c);
define("MC_REQUEST_CHUNK", 0x9d);
define("MC_CHUNK_DATA", 0x9e);
define("MC_PLAYER_EQUIPMENT", 0x9f);
define("MC_SET_ARMOR", 0xa0);
define("MC_PLAYER_ARMOR_EQUIPMENT", 0xa0);
define("MC_INTERACT", 0xa1);
define("MC_USE_ITEM", 0xa2);
define("MC_PLAYER_ACTION", 0xa3);
define("MC_SET_ENTITY_DATA", 0xa4);
define("MC_SET_ENTITY_MOTION", 0xa5);
//define("MC_UNKNOWN_A5", 0xa5);
define("MC_HURT_ARMOR", 0xa5);
//define("MC_UNKNOWN_A6", 0xa6);
//define("MC_UNKNOWN_A7", 0xa7);
define("MC_SET_HEALTH", 0xa8);

View File

@ -69,12 +69,13 @@ $dataName = array(
MC_CHUNK_DATA => "ChunkData",
MC_PLAYER_EQUIPMENT => "PlayerEquipment",
MC_SET_ARMOR => "SetArmorSlot",
MC_PLAYER_ARMOR_EQUIPMENT => "PlayerArmorEquipment",
MC_INTERACT => "Interact",
MC_USE_ITEM => "UseItem",
MC_PLAYER_ACTION => "PlayerAction",
MC_SET_ENTITY_DATA => "SetEntityData",
MC_SET_ENTITY_MOTION => "SetEntityMotion",
MC_HURT_ARMOR => "HurtArmor",
MC_SET_HEALTH => "SetHealth",
MC_SET_SPAWN_POSITION => "SetSpawnPosition",
MC_ANIMATE => "Animate",