Lava flow code reformatting

This commit is contained in:
Shoghi Cervantes 2013-11-23 11:04:36 +01:00
parent 809ca802b3
commit f32f379e97

View File

@ -31,17 +31,13 @@ class LavaBlock extends LiquidBlock{
return $ret; return $ret;
} }
public function getSourceCount() public function getSourceCount(){
{
$count = 0; $count = 0;
for($side = 2; $side <= 5; ++$side) for($side = 2; $side <= 5; ++$side){
{ if($this->getSide($side) instanceof LavaBlock ){
if( $this->getSide($side) instanceof LavaBlock )
{
$b = $this->getSide($side); $b = $this->getSide($side);
$level = $b->meta & 0x07; $level = $b->meta & 0x07;
if($level == 0x00) if($level == 0x00){
{
$count++; $count++;
} }
} }
@ -49,37 +45,27 @@ class LavaBlock extends LiquidBlock{
return $count; return $count;
} }
public function checkWater() public function checkWater(){
{ for($side = 1; $side <= 5; ++$side){
for($side = 1; $side <= 5; ++$side)
{
$b = $this->getSide($side); $b = $this->getSide($side);
if($b instanceof WaterBlock) if($b instanceof WaterBlock){
{
$level = $this->meta & 0x07; $level = $this->meta & 0x07;
if($level == 0x00) if($level == 0x00){
{
$this->level->setBlock($this, new ObsidianBlock(), false, false, true); $this->level->setBlock($this, new ObsidianBlock(), false, false, true);
} }else{
else
{
$this->level->setBlock($this, new CobblestoneBlock(), false, false, true); $this->level->setBlock($this, new CobblestoneBlock(), false, false, true);
} }
} }
} }
} }
public function getFrom() public function getFrom(){
{ for($side = 0; $side <= 5; ++$side){
for($side = 0; $side <= 5; ++$side)
{
$b = $this->getSide($side); $b = $this->getSide($side);
if($b instanceof LavaBlock) if($b instanceof LavaBlock){
{
$tlevel = $b->meta & 0x07; $tlevel = $b->meta & 0x07;
$level = $this->meta & 0x07; $level = $this->meta & 0x07;
if( ($tlevel + 2) == $level || ($side == 0x01 && $level == 0x01 ) || ($tlevel == 6 && $level == 7 )) if( ($tlevel + 2) == $level || ($side == 0x01 && $level == 0x01 ) || ($tlevel == 6 && $level == 7 )){
{
return $b; return $b;
} }
} }
@ -95,66 +81,51 @@ class LavaBlock extends LiquidBlock{
return false; return false;
} }
if( $this->checkWater() ) { return; } if( $this->checkWater()){
return;
}
$falling = $this->meta >> 3; $falling = $this->meta >> 3;
$down = $this->getSide(0); $down = $this->getSide(0);
$from = $this->getFrom(); $from = $this->getFrom();
//출처가 있거나 이 자체가 출처이면 if($from !== null || $level == 0x00){
if($from !== null || $level == 0x00) if($level !== 0x07){
{ if($down instanceof AirBlock || $down instanceof LavaBlock){
if($level !== 0x07)
{
if($down instanceof AirBlock || $down instanceof LavaBlock)
{
$this->level->setBlock($down, new LavaBlock(0x01), false, false, true); $this->level->setBlock($down, new LavaBlock(0x01), false, false, true);
ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($down, 0, 0, $this->level), 40, BLOCK_UPDATE_NORMAL); ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($down, 0, 0, $this->level), 40, BLOCK_UPDATE_NORMAL);
} }else{
else for($side = 2; $side <= 5; ++$side){
{
for($side = 2; $side <= 5; ++$side)
{
$b = $this->getSide($side); $b = $this->getSide($side);
if($b instanceof LavaBlock) if($b instanceof LavaBlock){
{
} }else if($b->isFlowable === true){
else if($b->isFlowable === true)
{
$this->level->setBlock($b, new LavaBlock( min($level + 2,7) ), false, false, true); $this->level->setBlock($b, new LavaBlock( min($level + 2,7) ), false, false, true);
ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($b, 0, 0, $this->level), 40, BLOCK_UPDATE_NORMAL); ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($b, 0, 0, $this->level), 40, BLOCK_UPDATE_NORMAL);
} }
} }
} }
} }
} }else{
else
{
//Extend Remove for Left Lavas //Extend Remove for Left Lavas
for($side = 2; $side <= 5; ++$side) for($side = 2; $side <= 5; ++$side){
{
$sb = $this->getSide($side); $sb = $this->getSide($side);
if($sb instanceof LavaBlock) if($sb instanceof LavaBlock){
{
$tlevel = $sb->meta & 0x07; $tlevel = $sb->meta & 0x07;
if($tlevel != 0x00) if($tlevel != 0x00){
{
$this->level->setBlock($sb, new AirBlock(), false, false, true); $this->level->setBlock($sb, new AirBlock(), false, false, true);
} }
} }
$b = $this->getSide(0)->getSide($side); $b = $this->getSide(0)->getSide($side);
if($b instanceof LavaBlock) if($b instanceof LavaBlock){
{
$tlevel = $b->meta & 0x07; $tlevel = $b->meta & 0x07;
if($tlevel != 0x00) if($tlevel != 0x00){
{
$this->level->setBlock($b, new AirBlock(), false, false, true); $this->level->setBlock($b, new AirBlock(), 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), 10, BLOCK_UPDATE_NORMAL);
} }
//출처가 제거된 경우 이 블록 제거
$this->level->setBlock($this, new AirBlock(), false, false, true); $this->level->setBlock($this, new AirBlock(), false, false, true);
} }
return false; return false;