mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-09 21:24:53 +00:00
Simple Flowable Lava & English Comment
Still A Flowing
This commit is contained in:
parent
77ca6da14c
commit
b822b314cb
@ -25,4 +25,117 @@ class LavaBlock extends LiquidBlock{
|
||||
$this->hardness = 0;
|
||||
}
|
||||
|
||||
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, 40, BLOCK_UPDATE_NORMAL);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function getSourceCount()
|
||||
{
|
||||
$count = 0;
|
||||
for($side = 2; $side <= 5; ++$side)
|
||||
{
|
||||
if( $this->getSide($side) instanceof LavaBlock )
|
||||
{
|
||||
$b = $this->getSide($side);
|
||||
$level = $b->meta & 0x07;
|
||||
if($level == 0x00)
|
||||
{
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $count;
|
||||
}
|
||||
|
||||
public function getFrom()
|
||||
{
|
||||
for($side = 0; $side <= 5; ++$side)
|
||||
{
|
||||
$b = $this->getSide($side);
|
||||
if($b instanceof LavaBlock)
|
||||
{
|
||||
$tlevel = $b->meta & 0x07;
|
||||
$level = $this->meta & 0x07;
|
||||
if( ($tlevel + 2) == $level || ($side == 0x01 && $level == 0x01 ) || ($tlevel == 6 && $level == 7 ))
|
||||
{
|
||||
return $b;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function onUpdate($type){
|
||||
//return false;
|
||||
$newId = $this->id;
|
||||
$level = $this->meta & 0x07;
|
||||
if($type !== BLOCK_UPDATE_NORMAL){
|
||||
return false;
|
||||
}
|
||||
|
||||
$falling = $this->meta >> 3;
|
||||
$down = $this->getSide(0);
|
||||
|
||||
$from = $this->getFrom();
|
||||
//출처가 있거나 이 자체가 출처이면
|
||||
if($from !== null || $level == 0x00)
|
||||
{
|
||||
if($level !== 0x07)
|
||||
{
|
||||
if($down instanceof AirBlock || $down instanceof LavaBlock)
|
||||
{
|
||||
$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);
|
||||
}
|
||||
else
|
||||
{
|
||||
for($side = 2; $side <= 5; ++$side)
|
||||
{
|
||||
$b = $this->getSide($side);
|
||||
if($b instanceof LavaBlock)
|
||||
{
|
||||
|
||||
}
|
||||
else if($b->isFlowable === 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Extend Remove for Left Lavas
|
||||
for($side = 2; $side <= 5; ++$side)
|
||||
{
|
||||
$sb = $this->getSide($side);
|
||||
if($sb instanceof LavaBlock)
|
||||
{
|
||||
$tlevel = $sb->meta & 0x07;
|
||||
if($tlevel != 0x00)
|
||||
{
|
||||
$this->level->setBlock($sb, new AirBlock(), false, false, true);
|
||||
}
|
||||
}
|
||||
$b = $this->getSide(0)->getSide($side);
|
||||
if($b instanceof LavaBlock)
|
||||
{
|
||||
$tlevel = $b->meta & 0x07;
|
||||
if($tlevel != 0x00)
|
||||
{
|
||||
$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);
|
||||
}
|
||||
//출처가 제거된 경우 이 블록 제거
|
||||
$this->level->setBlock($this, new AirBlock(), false, false, true);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -79,7 +79,7 @@ class WaterBlock extends LiquidBlock{
|
||||
$down = $this->getSide(0);
|
||||
|
||||
$from = $this->getFrom();
|
||||
//출처가 있거나 이 자체가 출처이면
|
||||
//Has Source or Its Source
|
||||
if($from !== null || $level == 0x00)
|
||||
{
|
||||
if($level !== 0x07)
|
||||
@ -135,78 +135,8 @@ class WaterBlock extends LiquidBlock{
|
||||
}
|
||||
//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);
|
||||
}
|
||||
|
||||
/*
|
||||
if($falling === 0){
|
||||
$countSources = 0;
|
||||
$maxLevel = $level;
|
||||
$hasPath = false;
|
||||
for($side = 2; $side <= 5; ++$side){
|
||||
$b = $this->getSide($side);
|
||||
if($b->isFlowable === true and $level < 0x07){
|
||||
$d = $b->getSide(0);
|
||||
$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);
|
||||
}elseif($b instanceof WaterBlock){
|
||||
$oLevel = $b->getMetadata();
|
||||
$oFalling = $oLevel >> 3;
|
||||
$oLevel &= 0x07;
|
||||
if($oFalling === 0){
|
||||
if($oLevel === 0){
|
||||
++$countSources;
|
||||
$maxLevel = 1;
|
||||
$hasPath = true;
|
||||
}elseif($oLevel < 0x07 and ($oLevel + 1) <= $maxLevel){
|
||||
$maxLevel = $oLevel + 1;
|
||||
$hasPath = true;
|
||||
}elseif(($level + 1) < $oLevel){
|
||||
$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);
|
||||
}elseif($level === $oLevel){
|
||||
ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($b, 0, 0, $this->level), 10, BLOCK_UPDATE_NORMAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($countSources >= 2){
|
||||
$level = 0; //Source block
|
||||
}elseif($maxLevel < $level){
|
||||
$level = $maxLevel;
|
||||
}elseif($maxLevel === $level and $level > 0 and $hasPath === false){
|
||||
if($level < 0x07){
|
||||
++$level;
|
||||
}else{
|
||||
$newId = AIR;
|
||||
$level = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($down->isFlowable){
|
||||
$this->level->setBlock($down, new WaterBlock(0b1001), false, false, true);
|
||||
ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($down, 0, 0, $this->level), 5, BLOCK_UPDATE_NORMAL);
|
||||
return false;
|
||||
}elseif($down instanceof LiquidBlock){
|
||||
if($down instanceof WaterBlock and ($down->getMetadata() >> 3) === 0){
|
||||
$this->level->setBlock($down, new WaterBlock(0b1000 & min($down->getMetadata(), 1)), false, false, true);
|
||||
ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($down, 0, 0, $this->level), 5, BLOCK_UPDATE_NORMAL);
|
||||
}
|
||||
}else{
|
||||
$falling = 0;
|
||||
}
|
||||
|
||||
$newMeta = ($falling << 0x03) | $level;
|
||||
if($newMeta !== $this->meta or $newId !== $this->id){
|
||||
$this->id = $newId;
|
||||
$this->meta = $newMeta;
|
||||
$this->level->setBlock($this, $this, false, false, true);
|
||||
ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), 10, BLOCK_UPDATE_NORMAL);
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user