mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-13 15:05:33 +00:00
Implement carving pumpkin (#4637)
This commit is contained in:
parent
a94b88424e
commit
9e75c1463a
@ -291,7 +291,7 @@ class BlockFactory{
|
|||||||
$this->registerAllMeta(new Stair(new BID(Ids::PRISMARINE_STAIRS, 0), "Prismarine Stairs", $prismarineBreakInfo));
|
$this->registerAllMeta(new Stair(new BID(Ids::PRISMARINE_STAIRS, 0), "Prismarine Stairs", $prismarineBreakInfo));
|
||||||
|
|
||||||
$pumpkinBreakInfo = new BlockBreakInfo(1.0, BlockToolType::AXE);
|
$pumpkinBreakInfo = new BlockBreakInfo(1.0, BlockToolType::AXE);
|
||||||
$this->registerAllMeta($pumpkin = new Opaque(new BID(Ids::PUMPKIN, 0), "Pumpkin", $pumpkinBreakInfo));
|
$this->registerAllMeta(new Pumpkin(new BID(Ids::PUMPKIN, 0), "Pumpkin", $pumpkinBreakInfo));
|
||||||
$this->registerAllMeta(new CarvedPumpkin(new BID(Ids::CARVED_PUMPKIN, 0), "Carved Pumpkin", $pumpkinBreakInfo));
|
$this->registerAllMeta(new CarvedPumpkin(new BID(Ids::CARVED_PUMPKIN, 0), "Carved Pumpkin", $pumpkinBreakInfo));
|
||||||
$this->registerAllMeta(new LitPumpkin(new BID(Ids::JACK_O_LANTERN, 0), "Jack o'Lantern", $pumpkinBreakInfo));
|
$this->registerAllMeta(new LitPumpkin(new BID(Ids::JACK_O_LANTERN, 0), "Jack o'Lantern", $pumpkinBreakInfo));
|
||||||
|
|
||||||
|
45
src/block/Pumpkin.php
Normal file
45
src/block/Pumpkin.php
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
<?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\block;
|
||||||
|
|
||||||
|
use pocketmine\item\Item;
|
||||||
|
use pocketmine\item\Shears;
|
||||||
|
use pocketmine\item\VanillaItems;
|
||||||
|
use pocketmine\math\Facing;
|
||||||
|
use pocketmine\math\Vector3;
|
||||||
|
use pocketmine\player\Player;
|
||||||
|
use function in_array;
|
||||||
|
|
||||||
|
class Pumpkin extends Opaque{
|
||||||
|
|
||||||
|
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||||
|
if($item instanceof Shears and in_array($face, Facing::HORIZONTAL, true)){
|
||||||
|
$item->applyDamage(1);
|
||||||
|
$this->position->getWorld()->setBlock($this->position, VanillaBlocks::CARVED_PUMPKIN()->setFacing($face));
|
||||||
|
$this->position->getWorld()->dropItem($this->position->add(0.5, 0.5, 0.5), VanillaItems::PUMPKIN_SEEDS()->setCount(1));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -445,7 +445,7 @@ use pocketmine\utils\CloningRegistryTrait;
|
|||||||
* @method static Slab PRISMARINE_SLAB()
|
* @method static Slab PRISMARINE_SLAB()
|
||||||
* @method static Stair PRISMARINE_STAIRS()
|
* @method static Stair PRISMARINE_STAIRS()
|
||||||
* @method static Wall PRISMARINE_WALL()
|
* @method static Wall PRISMARINE_WALL()
|
||||||
* @method static Opaque PUMPKIN()
|
* @method static Pumpkin PUMPKIN()
|
||||||
* @method static PumpkinStem PUMPKIN_STEM()
|
* @method static PumpkinStem PUMPKIN_STEM()
|
||||||
* @method static GlazedTerracotta PURPLE_GLAZED_TERRACOTTA()
|
* @method static GlazedTerracotta PURPLE_GLAZED_TERRACOTTA()
|
||||||
* @method static Torch PURPLE_TORCH()
|
* @method static Torch PURPLE_TORCH()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user