mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 04:17:07 +00:00
Added LeavesDecayEvent
This commit is contained in:
parent
0af3dfedd5
commit
312f377483
@ -21,9 +21,11 @@
|
|||||||
|
|
||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
|
use pocketmine\event\block\LeavesDecayEvent;
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
use pocketmine\level\Level;
|
use pocketmine\level\Level;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
|
use pocketmine\Server;
|
||||||
|
|
||||||
class Leaves extends Transparent{
|
class Leaves extends Transparent{
|
||||||
const OAK = 0;
|
const OAK = 0;
|
||||||
@ -121,10 +123,13 @@ class Leaves extends Transparent{
|
|||||||
$this->meta &= 0x03;
|
$this->meta &= 0x03;
|
||||||
$visited = [];
|
$visited = [];
|
||||||
$check = 0;
|
$check = 0;
|
||||||
if($this->findLog($this, $visited, 0, $check) === true){
|
|
||||||
$this->getLevel()->setBlock($this, $this, false, false, true);
|
Server::getInstance()->getPluginManager()->callEvent($ev = new LeavesDecayEvent($this));
|
||||||
|
|
||||||
|
if($ev->isCancelled() or $this->findLog($this, $visited, 0, $check) === true){
|
||||||
|
$this->getLevel()->setBlock($this, $this, false, false);
|
||||||
}else{
|
}else{
|
||||||
$this->getLevel()->setBlock($this, new Air(), false, false, true);
|
$this->getLevel()->setBlock($this, new Air(), false, false);
|
||||||
if(mt_rand(1, 20) === 1){ //Saplings
|
if(mt_rand(1, 20) === 1){ //Saplings
|
||||||
$this->getLevel()->dropItem($this, Item::get($this->id, $this->meta & 0x03, 1));
|
$this->getLevel()->dropItem($this, Item::get($this->id, $this->meta & 0x03, 1));
|
||||||
}
|
}
|
||||||
|
@ -21,9 +21,11 @@
|
|||||||
|
|
||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
|
use pocketmine\event\block\LeavesDecayEvent;
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
use pocketmine\level\Level;
|
use pocketmine\level\Level;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
|
use pocketmine\Server;
|
||||||
|
|
||||||
class Leaves2 extends Leaves{
|
class Leaves2 extends Leaves{
|
||||||
|
|
||||||
@ -113,8 +115,11 @@ class Leaves2 extends Leaves{
|
|||||||
$this->meta &= 0x03;
|
$this->meta &= 0x03;
|
||||||
$visited = [];
|
$visited = [];
|
||||||
$check = 0;
|
$check = 0;
|
||||||
if($this->findLog($this, $visited, 0, $check) === true){
|
|
||||||
$this->getLevel()->setBlock($this, $this, false, false, true);
|
Server::getInstance()->getPluginManager()->callEvent($ev = new LeavesDecayEvent($this));
|
||||||
|
|
||||||
|
if($ev->isCancelled() or $this->findLog($this, $visited, 0, $check) === true){
|
||||||
|
$this->getLevel()->setBlock($this, $this, false, false);
|
||||||
}else{
|
}else{
|
||||||
$this->getLevel()->setBlock($this, new Air(), false, false, true);
|
$this->getLevel()->setBlock($this, new Air(), false, false, true);
|
||||||
if(mt_rand(1, 20) === 1){ //Saplings
|
if(mt_rand(1, 20) === 1){ //Saplings
|
||||||
|
34
src/pocketmine/event/block/LeavesDecayEvent.php
Normal file
34
src/pocketmine/event/block/LeavesDecayEvent.php
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* ____ _ _ __ __ _ __ __ ____
|
||||||
|
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||||
|
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||||
|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||||
|
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* @author PocketMine Team
|
||||||
|
* @link http://www.pocketmine.net/
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace pocketmine\event\block;
|
||||||
|
|
||||||
|
use pocketmine\block\Block;
|
||||||
|
use pocketmine\event\Cancellable;
|
||||||
|
|
||||||
|
class LeavesDecayEvent extends BlockEvent implements Cancellable{
|
||||||
|
public static $handlerList = null;
|
||||||
|
|
||||||
|
public function __construct(Block $block){
|
||||||
|
parent::__construct($block);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user