From 9373c93737d3bfc1dffd7484bf554f9cadf27878 Mon Sep 17 00:00:00 2001 From: "beN39sGroup (Blue Electric)" Date: Sun, 10 Nov 2013 13:52:41 +0900 Subject: [PATCH 1/4] Prefix for Kick Flying when Player on Fence --- src/world/Entity.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/world/Entity.php b/src/world/Entity.php index 33cd7a4cd..373bbe6d1 100644 --- a/src/world/Entity.php +++ b/src/world/Entity.php @@ -410,7 +410,8 @@ class Entity extends Position{ if($this->isStatic === false){ $startX = floor($this->x - 0.5 - $this->size - 1); - $y = (int) round($this->y - 1); + //prefix for flying when player on fence + $y = (int) floor($this->y - 1); $startZ = floor($this->z - 0.5 - $this->size - 1); $endX = ceil($this->x - 0.5 + $this->size + 1); $endZ = ceil($this->z - 0.5 + $this->size + 1); From 77ca6da14cc804e7b85e4720134d6f19282927a5 Mon Sep 17 00:00:00 2001 From: "beN39sGroup (Blue Electric)" Date: Sun, 10 Nov 2013 17:19:50 +0900 Subject: [PATCH 2/4] Simple Flowable Water! Meet the 'Flowing' Water. --- src/material/block/liquid/Water.php | 107 ++++++++++++++++++++++++++- src/material/item/generic/Bucket.php | 9 ++- src/pmf/Level.php | 6 ++ src/world/Level.php | 1 + 4 files changed, 116 insertions(+), 7 deletions(-) diff --git a/src/material/block/liquid/Water.php b/src/material/block/liquid/Water.php index 2faacf2bb..aa76230d3 100644 --- a/src/material/block/liquid/Water.php +++ b/src/material/block/liquid/Water.php @@ -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; } } \ No newline at end of file diff --git a/src/material/item/generic/Bucket.php b/src/material/item/generic/Bucket.php index 40fc11e87..d011f9ee2 100644 --- a/src/material/item/generic/Bucket.php +++ b/src/material/item/generic/Bucket.php @@ -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; } diff --git a/src/pmf/Level.php b/src/pmf/Level.php index 5870085d8..73091db12 100644 --- a/src/pmf/Level.php +++ b/src/pmf/Level.php @@ -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; diff --git a/src/world/Level.php b/src/world/Level.php index 497ce8b86..396668e43 100644 --- a/src/world/Level.php +++ b/src/world/Level.php @@ -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; From b822b314cb28851d03398b31e258a3ecfa7fc24f Mon Sep 17 00:00:00 2001 From: "beN39sGroup (Blue Electric)" Date: Sun, 10 Nov 2013 17:59:36 +0900 Subject: [PATCH 3/4] Simple Flowable Lava & English Comment Still A Flowing --- src/material/block/liquid/Lava.php | 113 ++++++++++++++++++++++++++++ src/material/block/liquid/Water.php | 72 +----------------- 2 files changed, 114 insertions(+), 71 deletions(-) diff --git a/src/material/block/liquid/Lava.php b/src/material/block/liquid/Lava.php index eb0b8758c..7d7bc85e4 100644 --- a/src/material/block/liquid/Lava.php +++ b/src/material/block/liquid/Lava.php @@ -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; + } + } \ No newline at end of file diff --git a/src/material/block/liquid/Water.php b/src/material/block/liquid/Water.php index aa76230d3..43137ca35 100644 --- a/src/material/block/liquid/Water.php +++ b/src/material/block/liquid/Water.php @@ -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; } } \ No newline at end of file From db289f9871a77efc860253e2b9367d7476e97024 Mon Sep 17 00:00:00 2001 From: "beN39sGroup (Blue Electric)" Date: Sun, 10 Nov 2013 22:11:45 +0900 Subject: [PATCH 4/4] Mixable Lava & Water I Wanna Make Cobblestone Generator! --- src/material/block/liquid/Lava.php | 22 ++++++++++++++++++++++ src/material/block/liquid/Water.php | 25 +++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/src/material/block/liquid/Lava.php b/src/material/block/liquid/Lava.php index 7d7bc85e4..5f38b6d36 100644 --- a/src/material/block/liquid/Lava.php +++ b/src/material/block/liquid/Lava.php @@ -49,6 +49,26 @@ class LavaBlock extends LiquidBlock{ return $count; } + public function checkWater() + { + for($side = 1; $side <= 5; ++$side) + { + $b = $this->getSide($side); + if($b instanceof WaterBlock) + { + $level = $this->meta & 0x07; + if($level == 0x00) + { + $this->level->setBlock($this, new ObsidianBlock(), false, false, true); + } + else + { + $this->level->setBlock($this, new CobblestoneBlock(), false, false, true); + } + } + } + } + public function getFrom() { for($side = 0; $side <= 5; ++$side) @@ -75,6 +95,8 @@ class LavaBlock extends LiquidBlock{ return false; } + if( $this->checkWater() ) { return; } + $falling = $this->meta >> 3; $down = $this->getSide(0); diff --git a/src/material/block/liquid/Water.php b/src/material/block/liquid/Water.php index 43137ca35..215978f2b 100644 --- a/src/material/block/liquid/Water.php +++ b/src/material/block/liquid/Water.php @@ -49,6 +49,29 @@ class WaterBlock extends LiquidBlock{ return $count; } + public function checkLava() + { + for($side = 0; $side <= 5; ++$side) + { + if($side == 1) { continue; } + $b = $this->getSide($side); + if($b instanceof LavaBlock) + { + $level = $b->meta & 0x07; + if($level == 0x00) + { + $this->level->setBlock($b, new ObsidianBlock(), false, false, true); + } + else + { + $this->level->setBlock($b, new CobblestoneBlock(), false, false, true); + } + return true; + } + } + return false; + } + public function getFrom() { for($side = 0; $side <= 5; ++$side) @@ -75,6 +98,8 @@ class WaterBlock extends LiquidBlock{ return false; } + $this->checkLava(); + $falling = $this->meta >> 3; $down = $this->getSide(0);