Added a way to send Player's inventory directly

This commit is contained in:
Shoghi Cervantes Pueyo
2013-04-17 19:25:53 +02:00
parent 5e4ef9732b
commit 09301f0e5f
6 changed files with 85 additions and 24 deletions

View File

@ -110,27 +110,27 @@ class ChestBlock extends TransparentBlock{
if($chest->class !== TILE_CHEST){
return true;
}
$id = $player->windowCnt = $player->windowCnt++ % 255;
$player->windowCnt++;
$player->windowCnt = $id = max(1, $player->windowCnt % 255);
$player->windows[$id] = $chest;
$player->dataPacket(MC_CONTAINER_OPEN, array(
"windowid" => $id,
"type" => WINDOW_CHEST,
"slots" => 27,
"slots" => CHEST_SLOTS,
"title" => "Chest",
));
$slots = array();
for($s = 0; $s < CHEST_SLOTS; ++$s){
$slot = $chest->getSlot($s);
if($slot->getID() > 0 and $slot->count > 0){
$player->dataPacket(MC_CONTAINER_SET_SLOT, array(
"windowid" => $id,
"slot" => $s,
"block" => $slot->getID(),
"stack" => $slot->count,
"meta" => $slot->getMetadata(),
));
$slots[] = $slot;
}
}
$player->dataPacket(MC_CONTAINER_SET_CONTENT, array(
"windowid" => $id,
"count" => count($slots),
"slots" => $slots
));
return true;
}