From f2868f386ededf3f75e1d46de28cb4403e83fc30 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Pueyo Date: Mon, 24 Dec 2012 14:02:04 +0100 Subject: [PATCH] Correct slab placement --- TODO.md | 1 - classes/API/BlockAPI.php | 21 ++++++++++++++++++--- classes/Player.class.php | 2 +- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/TODO.md b/TODO.md index 79fc9eeb..f5f5c490 100644 --- a/TODO.md +++ b/TODO.md @@ -8,7 +8,6 @@ __Check Milestones [here](https://github.com/shoghicp/PocketMine-MP/issues/miles ## Alpha (full Creative) - Block Updates - Random Chunk Updates -- Placing Half Slabs - Water/lava spread - Opening/closing doors, fence gates, trapdoors (reflect it to all players) - Fix spawn position resetting diff --git a/classes/API/BlockAPI.php b/classes/API/BlockAPI.php index 37cdb9f9..e20feff0 100644 --- a/classes/API/BlockAPI.php +++ b/classes/API/BlockAPI.php @@ -119,7 +119,21 @@ class BlockAPI{ return; } - //if(!isset(Material::$replaceable[$target[0]])){ + $replace = false; + switch($target[0]){ + case 44: //Slabs + if($data["face"] !== 1){ + break; + } + if(($target[1] & 0x07) === ($data["meta"] & 0x07)){ + $replace = true; + $data["block"] = 43; + $data["meta"] = $data["meta"] & 0x07; + } + break; + } + + if($replace === false){ switch($data["face"]){ case 0: --$data["y"]; @@ -140,14 +154,15 @@ class BlockAPI{ ++$data["x"]; break; } - //} + } + if($data["y"] >= 127){ return; } $block = $this->server->api->level->getBlock($data["x"], $data["y"], $data["z"]); - if(!isset(Material::$replaceable[$block[0]])){ + if($replace === false and !isset(Material::$replaceable[$block[0]])){ return; } diff --git a/classes/Player.class.php b/classes/Player.class.php index 7267f03d..045dd3a6 100644 --- a/classes/Player.class.php +++ b/classes/Player.class.php @@ -297,7 +297,7 @@ class Player{ break; case MC_REQUEST_CHUNK: $this->actionQueue(' - $max = floor(($this->MTU - 16 - 255) / 192); + $max = max(1, floor(($this->MTU - 16 - 255) / 192) - 1); $chunk = $this->server->api->level->getOrderedChunk('.$data["x"].', '.$data["z"].', $max); foreach($chunk as $d){ $this->dataPacket(MC_CHUNK_DATA, array(