mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-23 04:59:46 +00:00
explosion tweaks
This commit is contained in:
parent
90d1865cb1
commit
a5a0c0e000
3 changed files with 23 additions and 12 deletions
|
|
@ -13,5 +13,9 @@ class LiquidBlock extends TransparentBlock{
|
||||||
$this->isReplaceable = true;
|
$this->isReplaceable = true;
|
||||||
$this->isSolid = false;
|
$this->isSolid = false;
|
||||||
$this->isFullBlock = true;
|
$this->isFullBlock = true;
|
||||||
|
$this->hardness = 500;
|
||||||
|
}
|
||||||
|
public function getDrops(Item $item, Player $player){
|
||||||
|
return array();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -3,10 +3,10 @@
|
||||||
class LavaBlock extends LiquidBlock implements LightingBlock{
|
class LavaBlock extends LiquidBlock implements LightingBlock{
|
||||||
public function __construct($meta = 0){
|
public function __construct($meta = 0){
|
||||||
parent::__construct(LAVA, $meta, "Lava");
|
parent::__construct(LAVA, $meta, "Lava");
|
||||||
$this->hardness = 0;
|
$this->hardness = 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||||
$ret = $this->level->setBlock($this, $this, true, false, true);
|
$ret = $this->level->setBlock($this, $this, true, false, true);
|
||||||
ServerAPI::request()->api->block->scheduleBlockUpdate(clone $this, 40, BLOCK_UPDATE_NORMAL);
|
ServerAPI::request()->api->block->scheduleBlockUpdate(clone $this, 40, BLOCK_UPDATE_NORMAL);
|
||||||
return $ret;
|
return $ret;
|
||||||
|
|
|
||||||
|
|
@ -32,10 +32,10 @@ class Explosion{
|
||||||
$server = ServerAPI::request();
|
$server = ServerAPI::request();
|
||||||
if(!Explosion::$enableExplosions){ /*Disable Explosions*/
|
if(!Explosion::$enableExplosions){ /*Disable Explosions*/
|
||||||
foreach($server->api->entity->getRadius($this->source, $radius) as $entity){
|
foreach($server->api->entity->getRadius($this->source, $radius) as $entity){
|
||||||
$impact = (1 - $this->source->distance($entity) / $radius) * 0.5; //pla>
|
$impact = (1 - $this->source->distance($entity) / $radius) * 0.5; //pla>
|
||||||
$damage = (int) (($impact * $impact + $impact) * 8 * $this->size + 1);
|
$damage = (int) (($impact * $impact + $impact) * 8 * $this->size + 1);
|
||||||
$entity->harm($damage, "explosion");
|
$entity->harm($damage, "explosion");
|
||||||
}
|
}
|
||||||
$pk = new ExplodePacket; //sound fix
|
$pk = new ExplodePacket; //sound fix
|
||||||
$pk->x = $this->source->x;
|
$pk->x = $this->source->x;
|
||||||
$pk->y = $this->source->y;
|
$pk->y = $this->source->y;
|
||||||
|
|
@ -46,12 +46,13 @@ class Explosion{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if($this->size < 0.1 or $server->api->dhandle("entity.explosion", [
|
if($this->size < 0.1 or $server->api->dhandle("entity.explosion", [
|
||||||
"level" => $this->level,
|
"level" => $this->level,
|
||||||
"source" => $this->source,
|
"source" => $this->source,
|
||||||
"size" => $this->size
|
"size" => $this->size
|
||||||
]) === false){
|
]) === false){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
$visited = [];
|
||||||
$mRays = $this->rays - 1;
|
$mRays = $this->rays - 1;
|
||||||
for($i = 0; $i < $this->rays; ++$i){
|
for($i = 0; $i < $this->rays; ++$i){
|
||||||
for($j = 0; $j < $this->rays; ++$j){
|
for($j = 0; $j < $this->rays; ++$j){
|
||||||
|
|
@ -63,14 +64,20 @@ class Explosion{
|
||||||
|
|
||||||
for($blastForce = $this->size * (mt_rand(700, 1300) / 1000); $blastForce > 0; $blastForce -= $this->stepLen * 0.75){
|
for($blastForce = $this->size * (mt_rand(700, 1300) / 1000); $blastForce > 0; $blastForce -= $this->stepLen * 0.75){
|
||||||
$vBlock = $pointer->floor();
|
$vBlock = $pointer->floor();
|
||||||
$blockID = $this->level->level->getBlockID($vBlock->x, $vBlock->y, $vBlock->z);
|
$BIDM = $this->level->level->getBlock($vBlock->x, $vBlock->y, $vBlock->z);
|
||||||
$blockMeta = $this->level->level->getBlockDamage($vBlock->x, $vBlock->y, $vBlock->z);
|
$blockID = $BIDM[0];
|
||||||
|
$blockMeta = $BIDM[1];
|
||||||
if($blockID > 0){
|
if($blockID > 0){
|
||||||
$block = BlockAPI::get($blockID, $blockMeta);
|
$block = BlockAPI::get($blockID, $blockMeta);
|
||||||
$block->x = $vBlock->x;
|
$block->x = $vBlock->x;
|
||||||
$block->y = $vBlock->y;
|
$block->y = $vBlock->y;
|
||||||
$block->z = $vBlock->z;
|
$block->z = $vBlock->z;
|
||||||
$block->level = $this->level;
|
$block->level = $this->level;
|
||||||
|
$index = ($block->x << 15) + ($block->z << 7) + $block->y;
|
||||||
|
if($block instanceof LiquidBlock && !isset($visited[$index])){
|
||||||
|
ServerAPI::request()->api->block->scheduleBlockUpdate($block, 5, BLOCK_UPDATE_NORMAL);
|
||||||
|
$visited[$index] = true;
|
||||||
|
}
|
||||||
$blastForce -= ($block->getHardness() / 5 + 0.3) * $this->stepLen;
|
$blastForce -= ($block->getHardness() / 5 + 0.3) * $this->stepLen;
|
||||||
if($blastForce > 0){
|
if($blastForce > 0){
|
||||||
$index = ($block->x << 15) + ($block->z << 7) + $block->y;
|
$index = ($block->x << 15) + ($block->z << 7) + $block->y;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue