mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 00:07:30 +00:00
Fixed confusing hierarchy of BlockGrow/Form/SpreadEvent, closes #2792
This commit is contained in:
parent
4122517292
commit
f8cfa191dd
46
src/event/block/BaseBlockChangeEvent.php
Normal file
46
src/event/block/BaseBlockChangeEvent.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\event\block;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\event\Cancellable;
|
||||
use pocketmine\event\CancellableTrait;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
abstract class BaseBlockChangeEvent extends BlockEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
private Block $newState;
|
||||
|
||||
public function __construct(Block $block, Block $newState){
|
||||
parent::__construct($block);
|
||||
$this->newState = $newState;
|
||||
}
|
||||
|
||||
public function getNewState() : Block{
|
||||
return $this->newState;
|
||||
}
|
||||
}
|
@ -23,6 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\event\block;
|
||||
|
||||
class BlockFormEvent extends BlockGrowEvent{
|
||||
class BlockFormEvent extends BaseBlockChangeEvent{
|
||||
|
||||
}
|
||||
|
@ -23,25 +23,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\event\block;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\event\Cancellable;
|
||||
use pocketmine\event\CancellableTrait;
|
||||
|
||||
/**
|
||||
* Called when plants or crops grow.
|
||||
*/
|
||||
class BlockGrowEvent extends BlockEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
class BlockGrowEvent extends BaseBlockChangeEvent implements Cancellable{
|
||||
|
||||
/** @var Block */
|
||||
private $newState;
|
||||
|
||||
public function __construct(Block $block, Block $newState){
|
||||
parent::__construct($block);
|
||||
$this->newState = $newState;
|
||||
}
|
||||
|
||||
public function getNewState() : Block{
|
||||
return $this->newState;
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ use pocketmine\block\Block;
|
||||
/**
|
||||
* Called when a block spreads to another block, such as grass spreading to nearby dirt blocks.
|
||||
*/
|
||||
class BlockSpreadEvent extends BlockFormEvent{
|
||||
class BlockSpreadEvent extends BaseBlockChangeEvent{
|
||||
/** @var Block */
|
||||
private $source;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user