Updated Chests [part1]

This commit is contained in:
Shoghi Cervantes 2013-08-27 02:08:04 +02:00
parent 9e337e21d2
commit e8c273fc10
6 changed files with 10 additions and 26 deletions

View File

@ -1651,7 +1651,7 @@ class Player{
} }
$this->craftingItems = array(); $this->craftingItems = array();
$this->toCraft = array(); $this->toCraft = array();
/*if(isset($this->windows[$data["windowid"]]) and $this->windows[$data["windowid"]]->class === TILE_CHEST){ if(isset($this->windows[$data["windowid"]]) and $this->windows[$data["windowid"]]->class === TILE_CHEST){
$this->server->api->player->broadcastPacket($this->server->api->player->getAll($this->level), MC_TILE_EVENT, array( $this->server->api->player->broadcastPacket($this->server->api->player->getAll($this->level), MC_TILE_EVENT, array(
"x" => $this->windows[$data["windowid"]]->x, "x" => $this->windows[$data["windowid"]]->x,
"y" => $this->windows[$data["windowid"]]->y, "y" => $this->windows[$data["windowid"]]->y,
@ -1659,7 +1659,7 @@ class Player{
"case1" => 1, "case1" => 1,
"case2" => 0, "case2" => 0,
)); ));
}*/ }
unset($this->windows[$data["windowid"]]); unset($this->windows[$data["windowid"]]);
$this->dataPacket(MC_CONTAINER_CLOSE, array( $this->dataPacket(MC_CONTAINER_CLOSE, array(

View File

@ -41,7 +41,7 @@ define("MAX_CHUNK_RATE", 20 / arg("max-chunks-per-second", 3.5)); //Default rate
define("PLAYER_MAX_QUEUE", 1024); define("PLAYER_MAX_QUEUE", 1024);
define("PLAYER_SURVIVAL_SLOTS", 36); define("PLAYER_SURVIVAL_SLOTS", 36);
define("PLAYER_CREATIVE_SLOTS", 111); define("PLAYER_CREATIVE_SLOTS", 112);
//Block Updates //Block Updates

View File

@ -28,6 +28,7 @@ the Free Software Foundation, either version 3 of the License, or
define("WINDOW_CHEST", 0); define("WINDOW_CHEST", 0);
define("WINDOW_WORKBENCH", 1); define("WINDOW_WORKBENCH", 1);
define("WINDOW_FURNACE", 2); define("WINDOW_FURNACE", 2);
define("WINDOW_STONECUTTER", 3);
class Window{ class Window{
private $server; private $server;

View File

@ -69,7 +69,7 @@ class BurningFurnaceBlock extends SolidBlock{
return true; return true;
} }
$player->windowCnt++; $player->windowCnt++;
$player->windowCnt = $id = max(2, $player->windowCnt % 16); $player->windowCnt = $id = max(2, $player->windowCnt % 99);
$player->windows[$id] = $furnace; $player->windows[$id] = $furnace;
$player->dataPacket(MC_CONTAINER_OPEN, array( $player->dataPacket(MC_CONTAINER_OPEN, array(
"windowid" => $id, "windowid" => $id,

View File

@ -108,7 +108,7 @@ class ChestBlock extends TransparentBlock{
return true; return true;
} }
$player->windowCnt++; $player->windowCnt++;
$player->windowCnt = $id = max(2, $player->windowCnt % 16); $player->windowCnt = $id = max(2, $player->windowCnt % 99);
$player->windows[$id] = $chest; $player->windows[$id] = $chest;
$player->dataPacket(MC_CONTAINER_OPEN, array( $player->dataPacket(MC_CONTAINER_OPEN, array(
"windowid" => $id, "windowid" => $id,
@ -116,13 +116,13 @@ class ChestBlock extends TransparentBlock{
"slots" => CHEST_SLOTS, "slots" => CHEST_SLOTS,
"title" => "Chest", "title" => "Chest",
)); ));
/*$server->api->player->broadcastPacket($server->api->player->getAll($this->level), MC_TILE_EVENT, array( $server->api->player->broadcastPacket($server->api->player->getAll($this->level), MC_TILE_EVENT, array(
"x" => $this->x, "x" => $this->x,
"y" => $this->y, "y" => $this->y,
"z" => $this->z, "z" => $this->z,
"case1" => 1, "case1" => 1,
"case2" => 2, "case2" => 2,
));*/ ));
$slots = array(); $slots = array();
for($s = 0; $s < CHEST_SLOTS; ++$s){ for($s = 0; $s < CHEST_SLOTS; ++$s){
$slot = $chest->getSlot($s); $slot = $chest->getSlot($s);

View File

@ -745,12 +745,12 @@ class CustomPacketHandler{
if($this->c === false){ if($this->c === false){
$this->data["windowid"] = ord($this->get(1)); $this->data["windowid"] = ord($this->get(1));
$this->data["type"] = ord($this->get(1)); $this->data["type"] = ord($this->get(1));
$this->data["slots"] = Utils::readShort($this->get(2), false); $this->data["slots"] = ord($this->get(1));
$this->data["title"] = $this->get(Utils::readShort($this->get(2), false)); $this->data["title"] = $this->get(Utils::readShort($this->get(2), false));
}else{ }else{
$this->raw .= chr($this->data["windowid"]); $this->raw .= chr($this->data["windowid"]);
$this->raw .= chr($this->data["type"]); $this->raw .= chr($this->data["type"]);
$this->raw .= Utils::writeShort($this->data["slots"]); $this->raw .= chr($this->data["slots"]);
$this->raw .= Utils::writeShort(strlen($this->data["title"])).$this->data["title"]; $this->raw .= Utils::writeShort(strlen($this->data["title"])).$this->data["title"];
} }
break; break;
@ -810,23 +810,6 @@ class CustomPacketHandler{
$this->raw .= Utils::writeShort(strlen($this->data["message"])).$this->data["message"]; $this->raw .= Utils::writeShort(strlen($this->data["message"])).$this->data["message"];
} }
break; break;
/*case MC_SIGN_UPDATE:
if($this->c === false){
$this->data["x"] = Utils::readShort($this->get(2));
$this->data["y"] = ord($this->get(1));
$this->data["z"] = Utils::readShort($this->get(2));
for($i = 0; $i < 4; ++$i){
$this->data["line$i"] = $this->get(Utils::readLShort($this->get(2), false));
}
}else{
$this->raw .= Utils::writeShort($this->data["x"]);
$this->raw .= chr($this->data["y"]);
$this->raw .= Utils::writeShort($this->data["z"]);
for($i = 0; $i < 4; ++$i){
$this->raw .= Utils::writeLShort(strlen($this->data["line$i"])).$this->data["line$i"];
}
}
break;*/
case MC_ADVENTURE_SETTINGS: case MC_ADVENTURE_SETTINGS:
if($this->c === false){ if($this->c === false){
$this->data["flags"] = Utils::readInt($this->get(4)); $this->data["flags"] = Utils::readInt($this->get(4));