mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-15 16:05:28 +00:00
Added Nether Wart
This commit is contained in:
parent
3135fe3c69
commit
11fae493a5
@ -187,7 +187,7 @@ class Block extends Position implements BlockIds, Metadatable{
|
|||||||
self::registerBlock(new NetherBrick());
|
self::registerBlock(new NetherBrick());
|
||||||
self::registerBlock(new NetherBrickFence());
|
self::registerBlock(new NetherBrickFence());
|
||||||
self::registerBlock(new NetherBrickStairs());
|
self::registerBlock(new NetherBrickStairs());
|
||||||
|
self::registerBlock(new NetherWartPlant());
|
||||||
self::registerBlock(new EnchantingTable());
|
self::registerBlock(new EnchantingTable());
|
||||||
self::registerBlock(new BrewingStand());
|
self::registerBlock(new BrewingStand());
|
||||||
|
|
||||||
|
83
src/pocketmine/block/NetherWartPlant.php
Normal file
83
src/pocketmine/block/NetherWartPlant.php
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
<?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\block;
|
||||||
|
|
||||||
|
|
||||||
|
use pocketmine\event\block\BlockGrowEvent;
|
||||||
|
use pocketmine\item\Item;
|
||||||
|
use pocketmine\level\Level;
|
||||||
|
use pocketmine\math\Vector3;
|
||||||
|
use pocketmine\Player;
|
||||||
|
|
||||||
|
class NetherWartPlant extends Flowable{
|
||||||
|
protected $id = Block::NETHER_WART_PLANT;
|
||||||
|
|
||||||
|
public function __construct($meta = 0){
|
||||||
|
$this->meta = $meta;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function canBeReplaced(){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
||||||
|
$down = $this->getSide(Vector3::SIDE_DOWN);
|
||||||
|
if($down->getId() === Block::SOUL_SAND){
|
||||||
|
$this->getLevel()->setBlock($block, $this, false, true);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function onUpdate($type){
|
||||||
|
switch($type){
|
||||||
|
case Level::BLOCK_UPDATE_RANDOM:
|
||||||
|
if($this->meta < 3 and mt_rand(0, 10) === 0){ //Still growing
|
||||||
|
$block = clone $this;
|
||||||
|
$block->meta++;
|
||||||
|
$this->getLevel()->getServer()->getPluginManager()->callEvent($ev = new BlockGrowEvent($this, $block));
|
||||||
|
|
||||||
|
if(!$ev->isCancelled()){
|
||||||
|
$this->getLevel()->setBlock($this, $ev->getNewState(), false, true);
|
||||||
|
|
||||||
|
return $type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Level::BLOCK_UPDATE_NORMAL:
|
||||||
|
if($this->getSide(Vector3::SIDE_DOWN)->getId() !== Block::SOUL_SAND){
|
||||||
|
$this->getLevel()->useBreakOn($this);
|
||||||
|
return $type;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDrops(Item $item){
|
||||||
|
return [[Item::NETHER_WART, 0, ($this->meta === 3 ? mt_rand(2, 4) : 1)]];
|
||||||
|
}
|
||||||
|
}
|
@ -23,8 +23,11 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\item;
|
namespace pocketmine\item;
|
||||||
|
|
||||||
|
use pocketmine\block\Block;
|
||||||
|
|
||||||
class NetherWart extends Item{
|
class NetherWart extends Item{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct($meta = 0, $count = 1){
|
||||||
|
$this->block = Block::get(Block::NETHER_WART_PLANT);
|
||||||
parent::__construct(self::NETHER_WART, $meta, $count, "Nether Wart");
|
parent::__construct(self::NETHER_WART, $meta, $count, "Nether Wart");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,7 @@ use pocketmine\block\Leaves;
|
|||||||
use pocketmine\block\Leaves2;
|
use pocketmine\block\Leaves2;
|
||||||
use pocketmine\block\MelonStem;
|
use pocketmine\block\MelonStem;
|
||||||
use pocketmine\block\Mycelium;
|
use pocketmine\block\Mycelium;
|
||||||
|
use pocketmine\block\NetherWartPlant;
|
||||||
use pocketmine\block\Potato;
|
use pocketmine\block\Potato;
|
||||||
use pocketmine\block\PumpkinStem;
|
use pocketmine\block\PumpkinStem;
|
||||||
use pocketmine\block\RedMushroom;
|
use pocketmine\block\RedMushroom;
|
||||||
@ -248,6 +249,7 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
Block::LEAVES2 => Leaves2::class,
|
Block::LEAVES2 => Leaves2::class,
|
||||||
Block::FIRE => Fire::class,
|
Block::FIRE => Fire::class,
|
||||||
Block::BEETROOT_BLOCK => Beetroot::class,
|
Block::BEETROOT_BLOCK => Beetroot::class,
|
||||||
|
Block::NETHER_WART_PLANT => NetherWartPlant::class
|
||||||
];
|
];
|
||||||
|
|
||||||
/** @var LevelTimings */
|
/** @var LevelTimings */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user