mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 11:39:43 +00:00
liquid fixes, explosion algorithm was reverted to the old pocketmine's one
This commit is contained in:
parent
b73205744e
commit
80e767b257
3 changed files with 38 additions and 42 deletions
|
|
@ -50,14 +50,14 @@ class LavaBlock extends LiquidBlock implements LightingBlock{
|
|||
}
|
||||
|
||||
public function checkWater(){
|
||||
for($side = 1; $side <= 5; ++$side){
|
||||
for($side = 0; $side <= 5; ++$side){
|
||||
$b = $this->getSide($side);
|
||||
if($b instanceof WaterBlock){
|
||||
$level = $this->meta & 0x06;
|
||||
if($level == 0x00){
|
||||
$this->level->setBlock($this, new ObsidianBlock(), false, false, true);
|
||||
$this->level->setBlock($b, new ObsidianBlock(), false, false, true);
|
||||
}else{
|
||||
$this->level->setBlock($this, new CobblestoneBlock(), false, false, true);
|
||||
$this->level->setBlock($b, new CobblestoneBlock(), false, false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -85,7 +85,7 @@ class LavaBlock extends LiquidBlock implements LightingBlock{
|
|||
return false;
|
||||
}
|
||||
|
||||
if( $this->checkWater()){
|
||||
if($this->checkWater()){
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class WaterBlock extends LiquidBlock{
|
|||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
$ret = $this->level->setBlock($this, $this, true, false, true);
|
||||
ServerAPI::request()->api->block->scheduleBlockUpdate(clone $this, 10, BLOCK_UPDATE_NORMAL);
|
||||
ServerAPI::request()->api->block->scheduleBlockUpdate(clone $this, 5, BLOCK_UPDATE_NORMAL);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
|
@ -96,7 +96,7 @@ class WaterBlock extends LiquidBlock{
|
|||
if($from !== null || $level == 0x00){
|
||||
if($down instanceof AirBlock || $down instanceof WaterBlock){
|
||||
$this->level->setBlock($down, new WaterBlock(0x01), false, false, true);
|
||||
ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($down, 0, 0, $this->level), 10, BLOCK_UPDATE_NORMAL);
|
||||
ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($down, 0, 0, $this->level), 5, BLOCK_UPDATE_NORMAL);
|
||||
}elseif($level !== 0x07){{
|
||||
for($side = 2; $side <= 5; ++$side){
|
||||
$b = $this->getSide($side);
|
||||
|
|
@ -106,7 +106,7 @@ class WaterBlock extends LiquidBlock{
|
|||
}
|
||||
}elseif($b->isFlowable === true){
|
||||
$this->level->setBlock($b, new WaterBlock($level + 1), false, false, true);
|
||||
ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($b, 0, 0, $this->level), 10, BLOCK_UPDATE_NORMAL);
|
||||
ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($b, 0, 0, $this->level), 5, BLOCK_UPDATE_NORMAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -120,7 +120,7 @@ class WaterBlock extends LiquidBlock{
|
|||
if($tlevel != 0x00){
|
||||
for ($s = 0; $s <= 5; $s++) {
|
||||
$ssb = $sb->getSide($s);
|
||||
ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($ssb, 0, 0, $this->level), 10, BLOCK_UPDATE_NORMAL);
|
||||
ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($ssb, 0, 0, $this->level), 5, BLOCK_UPDATE_NORMAL);
|
||||
}
|
||||
$this->level->setBlock($sb, new AirBlock(), false, false, true);
|
||||
}
|
||||
|
|
@ -131,7 +131,7 @@ class WaterBlock extends LiquidBlock{
|
|||
if($tlevel != 0x00){
|
||||
for ($s = 0; $s <= 5; $s++) {
|
||||
$ssb = $sb->getSide($s);
|
||||
ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($ssb, 0, 0, $this->level), 10, BLOCK_UPDATE_NORMAL);
|
||||
ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($ssb, 0, 0, $this->level), 5, BLOCK_UPDATE_NORMAL);
|
||||
}
|
||||
$this->level->setBlock($b, new AirBlock(), false, false, true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,30 +43,7 @@ class Explosion{
|
|||
$this->air = BlockAPI::getItem(AIR, 0, 1);
|
||||
$this->nullPlayer = new PlayerNull();
|
||||
}
|
||||
private function explodeBlocks($send, $source, $block){
|
||||
$server = ServerAPI::request();
|
||||
if($block instanceof TNTBlock){
|
||||
$data = array(
|
||||
"x" => $block->x + 0.5,
|
||||
"y" => $block->y + 0.5,
|
||||
"z" => $block->z + 0.5,
|
||||
"power" => 4,
|
||||
"fuse" => mt_rand(10, 30), //0.5 to 1.5 seconds
|
||||
);
|
||||
$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)){
|
||||
$tmp = $block->getDrops($this->air, $this->nullPlayer);
|
||||
if(is_array($tmp)){
|
||||
foreach($tmp as $drop){
|
||||
$server->api->entity->drop(new Position($block->x + 0.5, $block->y, $block->z + 0.5, $this->level), BlockAPI::getItem($drop[0], $drop[1],$drop[2])); //id, meta, count
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->level->level->setBlockID($block->x, $block->y, $block->z, 0);
|
||||
$send[] = new Vector3($block->x - $source->x, $block->y - $source->y, $block->z - $source->z);
|
||||
return $send;
|
||||
}
|
||||
|
||||
public function explode(){
|
||||
if(!Explosion::$enableExplosions){ /*Disable Explosions*/
|
||||
return;
|
||||
|
|
@ -79,11 +56,7 @@ class Explosion{
|
|||
)) === false){
|
||||
return false;
|
||||
}
|
||||
|
||||
$send = array();
|
||||
$source = $this->source->floor();
|
||||
$radius = 2 * $this->size;
|
||||
|
||||
|
||||
$mRays = $this->rays - 1;
|
||||
for($i = 0; $i < $this->rays; ++$i){
|
||||
for($j = 0; $j < $this->rays; ++$j){
|
||||
|
|
@ -106,7 +79,7 @@ class Explosion{
|
|||
if($blastForce > 0){
|
||||
$index = ($block->x << 15) + ($block->z << 7) + $block->y;
|
||||
if(!isset($this->affectedBlocks[$index])){
|
||||
$send = $this->explodeBlocks($send, $source,$block);
|
||||
$this->affectedBlocks[$index] = $block;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -116,14 +89,37 @@ class Explosion{
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
$send = array();
|
||||
$source = $this->source->floor();
|
||||
$radius = 2 * $this->size;
|
||||
foreach($server->api->entity->getRadius($this->source, $radius) as $entity){
|
||||
if($entity->type === OBJECT_PRIMEDTNT){
|
||||
continue;
|
||||
}
|
||||
$impact = (1 - $this->source->distance($entity) / $radius) * 0.5; //placeholder, 0.7 should be exposure
|
||||
$damage = (int) (($impact * $impact + $impact) * 8 * $this->size + 1);
|
||||
$entity->harm($damage, "explosion");
|
||||
}
|
||||
|
||||
foreach($this->affectedBlocks as $block){
|
||||
|
||||
if($block instanceof TNTBlock){
|
||||
$data = array(
|
||||
"x" => $block->x + 0.5,
|
||||
"y" => $block->y + 0.5,
|
||||
"z" => $block->z + 0.5,
|
||||
"power" => 4,
|
||||
"fuse" => mt_rand(10, 30), //0.5 to 1.5 seconds
|
||||
);
|
||||
$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)){
|
||||
foreach($block->getDrops($this->air, $this->nullPlayer) as $drop){
|
||||
$server->api->entity->drop(new Position($block->x + 0.5, $block->y, $block->z + 0.5, $this->level), BlockAPI::getItem($drop[0], $drop[1],$drop[2])); //id, meta, count
|
||||
}
|
||||
}
|
||||
$this->level->level->setBlockID($block->x, $block->y, $block->z, 0);
|
||||
ServerAPI::request()->api->block->blockUpdateAround(new Position($block->x, $block->y, $block->z, $this->level), BLOCK_UPDATE_NORMAL, 5);
|
||||
$send[] = new Vector3($block->x - $source->x, $block->y - $source->y, $block->z - $source->z);
|
||||
}
|
||||
$pk = new ExplodePacket;
|
||||
$pk->x = $this->source->x;
|
||||
$pk->y = $this->source->y;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue