From e8c273fc1082f966db3dd7943ff324013c8fb979 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Tue, 27 Aug 2013 02:08:04 +0200 Subject: [PATCH] Updated Chests [part1] --- src/Player.php | 4 ++-- src/constants/GeneralConstants.php | 2 +- src/inventory/Window.php | 1 + src/material/block/solid/BurningFurnace.php | 2 +- src/material/block/solid/Chest.php | 6 +++--- src/network/CustomPacketHandler.php | 21 ++------------------- 6 files changed, 10 insertions(+), 26 deletions(-) diff --git a/src/Player.php b/src/Player.php index 3912dbd1..0434d0ca 100644 --- a/src/Player.php +++ b/src/Player.php @@ -1651,7 +1651,7 @@ class Player{ } $this->craftingItems = 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( "x" => $this->windows[$data["windowid"]]->x, "y" => $this->windows[$data["windowid"]]->y, @@ -1659,7 +1659,7 @@ class Player{ "case1" => 1, "case2" => 0, )); - }*/ + } unset($this->windows[$data["windowid"]]); $this->dataPacket(MC_CONTAINER_CLOSE, array( diff --git a/src/constants/GeneralConstants.php b/src/constants/GeneralConstants.php index 14c1e9f6..026d37bd 100644 --- a/src/constants/GeneralConstants.php +++ b/src/constants/GeneralConstants.php @@ -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_SURVIVAL_SLOTS", 36); -define("PLAYER_CREATIVE_SLOTS", 111); +define("PLAYER_CREATIVE_SLOTS", 112); //Block Updates diff --git a/src/inventory/Window.php b/src/inventory/Window.php index 7ab9b92f..20a19d4e 100644 --- a/src/inventory/Window.php +++ b/src/inventory/Window.php @@ -28,6 +28,7 @@ the Free Software Foundation, either version 3 of the License, or define("WINDOW_CHEST", 0); define("WINDOW_WORKBENCH", 1); define("WINDOW_FURNACE", 2); +define("WINDOW_STONECUTTER", 3); class Window{ private $server; diff --git a/src/material/block/solid/BurningFurnace.php b/src/material/block/solid/BurningFurnace.php index de60a893..ec186358 100644 --- a/src/material/block/solid/BurningFurnace.php +++ b/src/material/block/solid/BurningFurnace.php @@ -69,7 +69,7 @@ class BurningFurnaceBlock extends SolidBlock{ return true; } $player->windowCnt++; - $player->windowCnt = $id = max(2, $player->windowCnt % 16); + $player->windowCnt = $id = max(2, $player->windowCnt % 99); $player->windows[$id] = $furnace; $player->dataPacket(MC_CONTAINER_OPEN, array( "windowid" => $id, diff --git a/src/material/block/solid/Chest.php b/src/material/block/solid/Chest.php index a4a760f6..7219c474 100644 --- a/src/material/block/solid/Chest.php +++ b/src/material/block/solid/Chest.php @@ -108,7 +108,7 @@ class ChestBlock extends TransparentBlock{ return true; } $player->windowCnt++; - $player->windowCnt = $id = max(2, $player->windowCnt % 16); + $player->windowCnt = $id = max(2, $player->windowCnt % 99); $player->windows[$id] = $chest; $player->dataPacket(MC_CONTAINER_OPEN, array( "windowid" => $id, @@ -116,13 +116,13 @@ class ChestBlock extends TransparentBlock{ "slots" => CHEST_SLOTS, "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, "y" => $this->y, "z" => $this->z, "case1" => 1, "case2" => 2, - ));*/ + )); $slots = array(); for($s = 0; $s < CHEST_SLOTS; ++$s){ $slot = $chest->getSlot($s); diff --git a/src/network/CustomPacketHandler.php b/src/network/CustomPacketHandler.php index fe137d52..8208e7de 100644 --- a/src/network/CustomPacketHandler.php +++ b/src/network/CustomPacketHandler.php @@ -745,12 +745,12 @@ class CustomPacketHandler{ if($this->c === false){ $this->data["windowid"] = 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)); }else{ $this->raw .= chr($this->data["windowid"]); $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"]; } break; @@ -810,23 +810,6 @@ class CustomPacketHandler{ $this->raw .= Utils::writeShort(strlen($this->data["message"])).$this->data["message"]; } 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: if($this->c === false){ $this->data["flags"] = Utils::readInt($this->get(4));