Sign NBT data on Player, send chests NBT

This commit is contained in:
Shoghi Cervantes 2013-08-27 00:02:07 +02:00
parent 291ba5c499
commit 4a05f04a00
3 changed files with 31 additions and 24 deletions

View File

@ -1628,21 +1628,6 @@ class Player{
$this->entity->updateMetadata(); $this->entity->updateMetadata();
} }
break; break;
/*case MC_SIGN_UPDATE:
if($this->spawned === false or $this->blocked === true){
break;
}
$this->craftingItems = array();
$this->toCraft = array();
$t = $this->server->api->tile->get(new Position($data["x"], $data["y"], $data["z"], $this->level));
if(($t instanceof Tile) and $t->class === TILE_SIGN){
if($t->data["creator"] !== $this->username){
$t->spawn($this);
}else{
$t->setText($data["line0"], $data["line1"], $data["line2"], $data["line3"]);
}
}
break;*/
case MC_CHAT: case MC_CHAT:
if($this->spawned === false){ if($this->spawned === false){
break; break;
@ -1786,6 +1771,28 @@ class Player{
break; break;
} }
break; break;
case MC_ENTITY_DATA:
if($this->spawned === false or $this->blocked === true){
break;
}
$this->craftingItems = array();
$this->toCraft = array();
$t = $this->server->api->tile->get(new Position($data["x"], $data["y"], $data["z"], $this->level));
if(($t instanceof Tile) and $t->class === TILE_SIGN){
if($t->data["creator"] !== $this->username){
$t->spawn($this);
}else{
$nbt = new NBT();
$nbt->load($data["namedtag"]);
$d = array_shift($nbt->tree);
if($d["id"] !== TILE_SIGN){
$t->spawn($this);
}else{
$t->setText($d["Text1"], $d["Text2"], $d["Text3"], $d["Text4"]);
}
}
}
break;
default: default:
console("[DEBUG] Unhandled 0x".dechex($pid)." Data Packet for Client ID ".$this->clientID.": ".print_r($data, true), true, true, 2); console("[DEBUG] Unhandled 0x".dechex($pid)." Data Packet for Client ID ".$this->clientID.": ".print_r($data, true), true, true, 2);
break; break;

View File

@ -844,7 +844,7 @@ class CustomPacketHandler{
$this->raw .= Utils::writeShort($this->data["x"]); $this->raw .= Utils::writeShort($this->data["x"]);
$this->raw .= chr($this->data["y"]); $this->raw .= chr($this->data["y"]);
$this->raw .= Utils::writeShort($this->data["z"]); $this->raw .= Utils::writeShort($this->data["z"]);
$this->raw .= Utils::writeShort($this->data["namedtag"]); $this->raw .= $this->data["namedtag"];
} }
break; break;
default: default:

View File

@ -244,24 +244,24 @@ class Tile extends Position{
$nbt->write(chr(NBT::TAG_INT)); $nbt->write(chr(NBT::TAG_INT));
$nbt->writeTAG_String("x"); $nbt->writeTAG_String("x");
$nbt->writeTAG_String((int) $this->x); $nbt->writeTAG_Int((int) $this->x);
$nbt->write(chr(NBT::TAG_INT)); $nbt->write(chr(NBT::TAG_INT));
$nbt->writeTAG_String("y"); $nbt->writeTAG_String("y");
$nbt->writeTAG_String((int) $this->y); $nbt->writeTAG_Int((int) $this->y);
$nbt->write(chr(NBT::TAG_INT)); $nbt->write(chr(NBT::TAG_INT));
$nbt->writeTAG_String("z"); $nbt->writeTAG_String("z");
$nbt->writeTAG_String((int) $this->z); $nbt->writeTAG_Int((int) $this->z);
if($this->isPaired()){ if($this->isPaired()){
$nbt->write(chr(NBT::TAG_INT)); $nbt->write(chr(NBT::TAG_INT));
$nbt->writeTAG_String("pairx"); $nbt->writeTAG_String("pairx");
$nbt->writeTAG_String((int) $this->data["pairx"]); $nbt->writeTAG_Int((int) $this->data["pairx"]);
$nbt->write(chr(NBT::TAG_INT)); $nbt->write(chr(NBT::TAG_INT));
$nbt->writeTAG_String("pairz"); $nbt->writeTAG_String("pairz");
$nbt->writeTAG_String((int) $this->data["pairz"]); $nbt->writeTAG_Int((int) $this->data["pairz"]);
} }
$nbt->write(chr(NBT::TAG_END)); $nbt->write(chr(NBT::TAG_END));
@ -299,15 +299,15 @@ class Tile extends Position{
$nbt->write(chr(NBT::TAG_INT)); $nbt->write(chr(NBT::TAG_INT));
$nbt->writeTAG_String("x"); $nbt->writeTAG_String("x");
$nbt->writeTAG_String((int) $this->x); $nbt->writeTAG_Int((int) $this->x);
$nbt->write(chr(NBT::TAG_INT)); $nbt->write(chr(NBT::TAG_INT));
$nbt->writeTAG_String("y"); $nbt->writeTAG_String("y");
$nbt->writeTAG_String((int) $this->y); $nbt->writeTAG_Int((int) $this->y);
$nbt->write(chr(NBT::TAG_INT)); $nbt->write(chr(NBT::TAG_INT));
$nbt->writeTAG_String("z"); $nbt->writeTAG_String("z");
$nbt->writeTAG_String((int) $this->z); $nbt->writeTAG_Int((int) $this->z);
$nbt->write(chr(NBT::TAG_END)); $nbt->write(chr(NBT::TAG_END));