mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-01 23:59:53 +00:00
Simple Flowable Water!
Meet the 'Flowing' Water.
This commit is contained in:
parent
9373c93737
commit
77ca6da14c
@ -23,16 +23,52 @@ class WaterBlock extends LiquidBlock{
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(WATER, $meta, "Water");
|
||||
$this->hardness = 500;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
public function getSourceCount()
|
||||
{
|
||||
$count = 0;
|
||||
for($side = 2; $side <= 5; ++$side)
|
||||
{
|
||||
if( $this->getSide($side) instanceof WaterBlock )
|
||||
{
|
||||
$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 WaterBlock)
|
||||
{
|
||||
$tlevel = $b->meta & 0x07;
|
||||
$level = $this->meta & 0x07;
|
||||
if( ($tlevel + 1) == $level || ($side == 0x01 && $level == 0x01 ) )
|
||||
{
|
||||
return $b;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function onUpdate($type){
|
||||
return false;
|
||||
//return false;
|
||||
$newId = $this->id;
|
||||
$level = $this->meta & 0x07;
|
||||
if($type !== BLOCK_UPDATE_NORMAL){
|
||||
@ -42,6 +78,68 @@ class WaterBlock extends LiquidBlock{
|
||||
$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 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);
|
||||
}
|
||||
else
|
||||
{
|
||||
for($side = 2; $side <= 5; ++$side)
|
||||
{
|
||||
$b = $this->getSide($side);
|
||||
if($b instanceof WaterBlock)
|
||||
{
|
||||
if( $this->getSourceCount() >= 2)
|
||||
{
|
||||
$this->level->setBlock($this, new WaterBlock(0), false, false, true);
|
||||
}
|
||||
}
|
||||
else if($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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Extend Remove for Left Waters
|
||||
for($side = 2; $side <= 5; ++$side)
|
||||
{
|
||||
$sb = $this->getSide($side);
|
||||
if($sb instanceof WaterBlock)
|
||||
{
|
||||
$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 WaterBlock)
|
||||
{
|
||||
$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);
|
||||
}
|
||||
|
||||
/*
|
||||
if($falling === 0){
|
||||
$countSources = 0;
|
||||
$maxLevel = $level;
|
||||
@ -86,7 +184,7 @@ class WaterBlock extends LiquidBlock{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
@ -108,6 +206,7 @@ class WaterBlock extends LiquidBlock{
|
||||
ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), 10, BLOCK_UPDATE_NORMAL);
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
}
|
@ -36,8 +36,11 @@ class BucketItem extends Item{
|
||||
return true;
|
||||
}
|
||||
}elseif($this->meta === WATER){
|
||||
if($block->getID() === AIR){
|
||||
$level->setBlock($block, new StillWaterBlock(), true, false, true);
|
||||
//Support Make Non-Support Water to Support Water
|
||||
if($block->getID() === AIR || ( $block instanceof WaterBlock && ($block->getMetadata() & 0x07) != 0x00 ) ){
|
||||
$water = new WaterBlock();
|
||||
$level->setBlock($block, $water, true, false, true);
|
||||
$water->place(clone $this, $player, $block, $target, $face, $fx, $fy, $fz);
|
||||
if(($player->gamemode & 0x01) === 0){
|
||||
$this->meta = 0;
|
||||
}
|
||||
@ -45,7 +48,7 @@ class BucketItem extends Item{
|
||||
}
|
||||
}elseif($this->meta === LAVA){
|
||||
if($block->getID() === AIR){
|
||||
$level->setBlock($block, new StillLavaBlock(), true, false, true);
|
||||
$level->setBlock($block, new LavaBlock(), true, false, true);
|
||||
if(($player->gamemode & 0x01) === 0){
|
||||
$this->meta = 0;
|
||||
}
|
||||
|
@ -469,6 +469,12 @@ class PMFLevel extends PMF{
|
||||
++$this->chunkChange[$index][$Y];
|
||||
}
|
||||
$this->chunkChange[$index][-1] = true;
|
||||
$pos = new Position($x, $y, $z, $this->level);
|
||||
for($side = 0; $side <= 5; ++$side)
|
||||
{
|
||||
$b = $pos->getSide($side);
|
||||
ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($b, 0, 0, $this->level), 10, BLOCK_UPDATE_NORMAL);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -26,6 +26,7 @@ class Level{
|
||||
public function __construct(PMFLevel $level, Config $entities, Config $tiles, Config $blockUpdates, $name){
|
||||
$this->server = ServerAPI::request();
|
||||
$this->level = $level;
|
||||
$this->level->level = $this;
|
||||
$this->entities = $entities;
|
||||
$this->tiles = $tiles;
|
||||
$this->blockUpdates = $blockUpdates;
|
||||
|
Loading…
x
Reference in New Issue
Block a user