Rewrote Generic Explosion drop

This commit is contained in:
Shoghi Cervantes 2013-11-26 12:24:57 +01:00
parent 98097b0703
commit 2d3ba111e0
2 changed files with 12 additions and 22 deletions

View File

@ -60,7 +60,7 @@ ini_set("memory_limit", "128M"); //Default
define("LOG", true); define("LOG", true);
define("START_TIME", microtime(true)); define("START_TIME", microtime(true));
define("MAJOR_VERSION", "Alpha_1.3.11dev"); 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_API_VERSION", 11);
define("CURRENT_PHP_VERSION", "5.5"); define("CURRENT_PHP_VERSION", "5.5");
$gitsha1 = false; $gitsha1 = false;

View File

@ -20,6 +20,13 @@
*/ */
class Explosion{ class Explosion{
public static $specialDrops = array(
GRASS => DIRT,
STONE => COBBLESTONE,
COAL_ORE => COAL,
DIAMOND_ORE => DIAMOND,
REDSTONE_ORE => REDSTONE,
);
private $rays = 16; //Rays private $rays = 16; //Rays
public $level; public $level;
public $source; public $source;
@ -98,27 +105,10 @@ class Explosion{
$e = $server->api->entity->add($this->level, ENTITY_OBJECT, OBJECT_PRIMEDTNT, $data); $e = $server->api->entity->add($this->level, ENTITY_OBJECT, OBJECT_PRIMEDTNT, $data);
$server->api->entity->spawnToAll($e); $server->api->entity->spawnToAll($e);
}elseif(mt_rand(0, 10000) < ((1/$this->size) * 10000)){ }elseif(mt_rand(0, 10000) < ((1/$this->size) * 10000)){
switch ($block->getID()) { 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));
case GRASS: }else{
$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))); $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;
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;
} }
} }
$this->level->level->setBlockID($block->x, $block->y, $block->z, 0); $this->level->level->setBlockID($block->x, $block->y, $block->z, 0);