mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 18:32:55 +00:00
Added a way to send Player's inventory directly
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user