From 2d3ba111e0b5d4d83f64fe17f4100fb69fb34ff0 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Tue, 26 Nov 2013 12:24:57 +0100 Subject: [PATCH] Rewrote Generic Explosion drop --- src/config.php | 2 +- src/world/Explosion.php | 32 +++++++++++--------------------- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/src/config.php b/src/config.php index 9c0b0bd2a..1dafcfa87 100644 --- a/src/config.php +++ b/src/config.php @@ -60,7 +60,7 @@ ini_set("memory_limit", "128M"); //Default define("LOG", true); define("START_TIME", microtime(true)); define("MAJOR_VERSION", "Alpha_1.3.11dev"); -define("CURRENT_MINECRAFT_VERSION", "v0.8.0 alpha build 2"); +define("CURRENT_MINECRAFT_VERSION", "v0.8.0 alpha build 3"); define("CURRENT_API_VERSION", 11); define("CURRENT_PHP_VERSION", "5.5"); $gitsha1 = false; diff --git a/src/world/Explosion.php b/src/world/Explosion.php index 35efded3e..5ed0bf533 100644 --- a/src/world/Explosion.php +++ b/src/world/Explosion.php @@ -20,6 +20,13 @@ */ class Explosion{ + public static $specialDrops = array( + GRASS => DIRT, + STONE => COBBLESTONE, + COAL_ORE => COAL, + DIAMOND_ORE => DIAMOND, + REDSTONE_ORE => REDSTONE, + ); private $rays = 16; //Rays public $level; public $source; @@ -98,27 +105,10 @@ class Explosion{ $e = $server->api->entity->add($this->level, ENTITY_OBJECT, OBJECT_PRIMEDTNT, $data); $server->api->entity->spawnToAll($e); }elseif(mt_rand(0, 10000) < ((1/$this->size) * 10000)){ - switch ($block->getID()) { - - case GRASS: - $server->api->entity->drop(new Position($block->x + 0.5, $block->y, $block->z + 0.5, $this->level), BlockAPI::getItem(DIRT, $this->level->level->getBlockDamage($block->x, $block->y, $block->z))); - break; - - case STONE: - $server->api->entity->drop(new Position($block->x + 0.5, $block->y, $block->z + 0.5, $this->level), BlockAPI::getItem(COBBLESTONE, $this->level->level->getBlockDamage($block->x, $block->y, $block->z))); - break; - - case COAL_ORE: - $server->api->entity->drop(new Position($block->x + 0.5, $block->y, $block->z + 0.5, $this->level), new CoalItem()); - break; - - case DIAMOND_ORE: - $server->api->entity->drop(new Position($block->x + 0.5, $block->y, $block->z + 0.5, $this->level), new DiamondItem()); - break; - - default: - $server->api->entity->drop(new Position($block->x + 0.5, $block->y, $block->z + 0.5, $this->level), BlockAPI::getItem($block->getID(), $this->level->level->getBlockDamage($block->x, $block->y, $block->z))); - break; + if(isset(self::$specialDrops[$block->getID()])){ + $server->api->entity->drop(new Position($block->x + 0.5, $block->y, $block->z + 0.5, $this->level), BlockAPI::getItem(self::$specialDrops[$block->getID()], 0)); + }else{ + $server->api->entity->drop(new Position($block->x + 0.5, $block->y, $block->z + 0.5, $this->level), BlockAPI::getItem($block->getID(), $this->level->level->getBlockDamage($block->x, $block->y, $block->z))); } } $this->level->level->setBlockID($block->x, $block->y, $block->z, 0);