From 21594d699df39a40834e32b4885a2c890e38277f Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Pueyo Date: Sun, 6 Jan 2013 17:31:28 +0100 Subject: [PATCH] Fake explosions! --- src/API/BlockAPI.php | 13 ++++++++++++ src/classes/CustomPacketHandler.class.php | 25 +++++++++++++++++++++++ src/pstruct/dataName.php | 2 ++ src/pstruct/protocol.php | 2 ++ 4 files changed, 42 insertions(+) diff --git a/src/API/BlockAPI.php b/src/API/BlockAPI.php index 7e74702ca..ce9fe8cc6 100644 --- a/src/API/BlockAPI.php +++ b/src/API/BlockAPI.php @@ -160,6 +160,17 @@ class BlockAPI{ 2, ); break; + case 46: //TNT + if(($player = $this->server->api->player->getByEID($data["eid"])) !== false){ + $player->dataPacket(MC_EXPLOSION, array( + "x" => $data["x"], + "y" => $data["y"], + "z" => $data["z"], + "radius" => 2, + "records" => array(), + )); + } + break; case 60: case 2: $drop = array(3, 0, 1); @@ -232,6 +243,7 @@ class BlockAPI{ if(isset(Material::$activable[$target[0]])){ switch($target[0]){ case 54: + $cancelPlace = true; if($this->server->gamemode === 1){ break; } @@ -244,6 +256,7 @@ class BlockAPI{ break; case 61: case 62: + $cancelPlace = true; if($this->server->gamemode === 1){ break; } diff --git a/src/classes/CustomPacketHandler.class.php b/src/classes/CustomPacketHandler.class.php index 26320ceb1..a97cc5de9 100644 --- a/src/classes/CustomPacketHandler.class.php +++ b/src/classes/CustomPacketHandler.class.php @@ -391,6 +391,31 @@ class CustomPacketHandler{ $this->raw .= chr($this->data["meta"]); } break; + case MC_EXPLOSION: + if($this->c === false){ + $this->data["x"] = Utils::readFloat($this->get(4)); + $this->data["y"] = Utils::readFloat($this->get(4)); + $this->data["z"] = Utils::readFloat($this->get(4)); + $this->data["radius"] = Utils::readFloat($this->get(4)); + $this->data["count"] = Utils::readInt($this->get(4)); + $this->data["records"] = array(); + for($r = 0; $r < $this->data["count"]; ++$r){ + $this->data["records"][] = array(Utils::readByte($this->get(1)), Utils::readByte($this->get(1)), Utils::readByte($this->get(1))); + } + }else{ + $this->raw .= Utils::writeFloat($this->data["x"]); + $this->raw .= Utils::writeFloat($this->data["y"]); + $this->raw .= Utils::writeFloat($this->data["z"]); + $this->raw .= Utils::writeFloat($this->data["radius"]); + $this->data["records"] = (array) $this->data["records"]; + $this->raw .= Utils::writeInt(count($this->data["records"])); + if(count($this->data["records"]) > 0){ + foreach($this->data["records"] as $record){ + $this->raw .= Utils::writeByte($record[0]) . Utils::writeByte($record[1]) . Utils::writeByte($record[2]); + } + } + } + break; case MC_REQUEST_CHUNK: if($this->c === false){ $this->data["x"] = Utils::readInt($this->get(4)); diff --git a/src/pstruct/dataName.php b/src/pstruct/dataName.php index f01878b8b..b14604d06 100644 --- a/src/pstruct/dataName.php +++ b/src/pstruct/dataName.php @@ -59,6 +59,8 @@ $dataName = array( MC_PLACE_BLOCK => "PlaceBlock", MC_REMOVE_BLOCK => "RemoveBlock", MC_UPDATE_BLOCK => "UpdateBlock", + + MC_EXPLOSION => "Explosion", MC_REQUEST_CHUNK => "RequestChunk", MC_CHUNK_DATA => "ChunkData", diff --git a/src/pstruct/protocol.php b/src/pstruct/protocol.php index dad9b8d97..e58ac84a9 100644 --- a/src/pstruct/protocol.php +++ b/src/pstruct/protocol.php @@ -60,6 +60,8 @@ define("MC_PLACE_BLOCK", 0x95); define("MC_REMOVE_BLOCK", 0x96); define("MC_UPDATE_BLOCK", 0x97); +define("MC_EXPLOSION", 0x99); + define("MC_REQUEST_CHUNK", 0x9d); define("MC_CHUNK_DATA", 0x9e);