Reuse even more objects!

This commit is contained in:
Shoghi Cervantes
2014-10-29 14:23:51 +01:00
parent 72c09045d5
commit 6f64af3066
6 changed files with 46 additions and 59 deletions

View File

@ -26,6 +26,7 @@ use pocketmine\item\Item;
use pocketmine\level\generator\object\TallGrass as TallGrassObject;
use pocketmine\level\Level;
use pocketmine\level\Position;
use pocketmine\math\Vector3;
use pocketmine\Player;
use pocketmine\Server;
use pocketmine\utils\Random;
@ -54,9 +55,8 @@ class Grass extends Solid{
$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()->getBlockIdAt($x, $y, $z);
if($block === Block::DIRT){
$block = Block::get($block, $this->getLevel()->getBlockDataAt($x, $y, $z), Position::createPosition($x, $y, $z, $this->getLevel()));
$block = $this->getLevel()->getBlock(Vector3::createVector($x, $y, $z));
if($block->getID() === Block::DIRT){
if($block->getSide(1) instanceof Transparent){
Server::getInstance()->getPluginManager()->callEvent($ev = BlockSpreadEvent::createEvent($block, $this, new Grass()));
if(!$ev->isCancelled()){