Skip to content
This repository has been archived by the owner on Feb 9, 2021. It is now read-only.

Fixed commit #3595 #3724

Merged
merged 2 commits into from Mar 7, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 15 additions & 11 deletions src/pocketmine/block/Grass.php
Expand Up @@ -63,16 +63,20 @@ public function getDrops(Item $item){

public function onUpdate($type){
if($type === Level::BLOCK_UPDATE_RANDOM){
//TODO: light levels
$x = mt_rand($this->x - 1, $this->x + 1);
$y = mt_rand($this->y - 2, $this->y + 2);
$z = mt_rand($this->z - 1, $this->z + 1);
$block = $this->getLevel()->getBlock(new Vector3($x, $y, $z));
if($block->getId() === Block::DIRT){
if($block->getSide(1) instanceof Transparent){
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockSpreadEvent($block, $this, new Grass()));
if(!$ev->isCancelled()){
$this->getLevel()->setBlock($block, $ev->getNewState());
$block = $this->getLevel()->getBlock(new Vector3($this->x, $this->y, $this->z));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PEMapModder y u merge this
wtf wtf wtf

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$block = $this; 🤦

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dan of 2015..

Copy link
Contributor Author

@inxomnyaa inxomnyaa Dec 11, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SOF3 no need to shout. He isn't active.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where. is. the. FACEDESK. EMOJI. NOW.

if($block->getSide(1)->getLightLevel() < 4){
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockSpreadEvent($block, $this, new Dirt()));
}elseif($block->getSide(1)->getLightLevel() >= 9){
for($l = 0; $l < 4; ++$l){
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uhm just a simple thing: You see this line but complain about the other?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bump THIS LINE

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could understand that @PEMapModder didn't realize the getBlock leak problem since @shoghicp added it, but new Vector3($this->x, $this->y, $this->z) was totally pointless...

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shoghicp added it back in October 2014, so probably too late to blame him.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Semms so. @dktapps seems to be on a fix

$x = mt_rand($this->x - 1, $this->x + 1);
$y = mt_rand($this->y - 2, $this->y + 2);
$z = mt_rand($this->z - 1, $this->z + 1);
$block = $this->getLevel()->getBlock(new Vector3($x, $y, $z));
if($block->getId() === Block::DIRT && $block->getDamage() === 0x0F && $block->getSide(1)->getLightLevel() >= 4 && $block->z <= 2){
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockSpreadEvent($block, $this, new Grass()));
if(!$ev->isCancelled()){
$this->getLevel()->setBlock($block, $ev->getNewState());
}
}
}
}
Expand All @@ -99,4 +103,4 @@ public function onActivate(Item $item, Player $player = null){

return false;
}
}
}