mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 09:56:06 +00:00
Implement new dye types, split bonemeal and cocoa beans into their own classes
This commit is contained in:
34
src/pocketmine/item/CocoaBeans.php
Normal file
34
src/pocketmine/item/CocoaBeans.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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\block\BlockFactory;
|
||||
|
||||
class CocoaBeans extends Item{
|
||||
|
||||
public function getBlock() : Block{
|
||||
return BlockFactory::get(Block::COCOA);
|
||||
}
|
||||
}
|
@ -23,20 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\block\BlockFactory;
|
||||
|
||||
class Dye extends Item{
|
||||
public function __construct(int $variant, string $name){
|
||||
parent::__construct(self::DYE, $variant, $name);
|
||||
}
|
||||
|
||||
public function getBlock() : Block{
|
||||
if($this->meta === 3){ //cocoa beans
|
||||
return BlockFactory::get(Block::COCOA);
|
||||
}
|
||||
return parent::getBlock();
|
||||
}
|
||||
|
||||
//TODO: names
|
||||
}
|
||||
|
28
src/pocketmine/item/Fertilizer.php
Normal file
28
src/pocketmine/item/Fertilizer.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?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\item;
|
||||
|
||||
class Fertilizer extends Item{
|
||||
|
||||
}
|
@ -154,11 +154,22 @@ class ItemFactory{
|
||||
self::register(new Item(Item::GLOWSTONE_DUST, 0, "Glowstone Dust"));
|
||||
self::register(new RawFish());
|
||||
self::register(new CookedFish());
|
||||
|
||||
self::register(new Item(Item::DYE, 0, "Ink Sac"));
|
||||
self::register(new CocoaBeans(Item::DYE, 3, "Cocoa Beans"));
|
||||
self::register(new Item(Item::DYE, 4, "Lapis Lazuli"));
|
||||
self::register(new Fertilizer(Item::DYE, 15, "Bone Meal"));
|
||||
|
||||
/** @var int[]|\SplObjectStorage $dyeMap */
|
||||
$dyeMap = new \SplObjectStorage();
|
||||
$dyeMap[DyeColor::BLACK()] = 16;
|
||||
$dyeMap[DyeColor::BROWN()] = 17;
|
||||
$dyeMap[DyeColor::BLUE()] = 18;
|
||||
$dyeMap[DyeColor::WHITE()] = 19;
|
||||
foreach(DyeColor::getAll() as $color){
|
||||
//TODO: use colour object directly
|
||||
//TODO: add interface to dye-colour objects
|
||||
//TODO: new dedicated dyes
|
||||
self::register(new Dye($color->getInvertedMagicNumber(), $color->getDisplayName() . " Dye"));
|
||||
self::register(new Dye($dyeMap[$color] ?? $color->getInvertedMagicNumber(), $color->getDisplayName() . " Dye"));
|
||||
self::register(new Bed($color->getMagicNumber(), $color->getDisplayName() . " Bed"));
|
||||
self::register(new Banner($color->getInvertedMagicNumber(), $color->getDisplayName() . " Banner"));
|
||||
}
|
||||
|
Reference in New Issue
Block a user