Branch merge

This commit is contained in:
Dylan K. Taylor
2017-08-20 21:07:19 +01:00
112 changed files with 931 additions and 800 deletions

View File

@ -24,10 +24,11 @@ declare(strict_types=1);
namespace pocketmine\item;
use pocketmine\block\Block;
use pocketmine\block\BlockFactory;
class Bed extends Item{
public function __construct($meta = 0, $count = 1){
$this->block = Block::get(Block::BED_BLOCK);
$this->block = BlockFactory::get(Block::BED_BLOCK);
parent::__construct(self::BED, $meta, $count, "Bed");
}

View File

@ -24,10 +24,11 @@ declare(strict_types=1);
namespace pocketmine\item;
use pocketmine\block\Block;
use pocketmine\block\BlockFactory;
class BeetrootSeeds extends Item{
public function __construct($meta = 0, $count = 1){
$this->block = Block::get(Block::BEETROOT_BLOCK);
$this->block = BlockFactory::get(Block::BEETROOT_BLOCK);
parent::__construct(self::BEETROOT_SEEDS, $meta, $count, "Beetroot Seeds");
}
}

View File

@ -25,9 +25,11 @@ namespace pocketmine\item;
use pocketmine\block\Air;
use pocketmine\block\Block;
use pocketmine\block\BlockFactory;
use pocketmine\block\Liquid;
use pocketmine\event\player\PlayerBucketFillEvent;
use pocketmine\level\Level;
use pocketmine\math\Vector3;
use pocketmine\Player;
class Bucket extends Item{
@ -47,8 +49,8 @@ class Bucket extends Item{
return 0;
}
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
$targetBlock = Block::get($this->meta);
public function onActivate(Level $level, Player $player, Block $block, Block $target, int $face, Vector3 $facePos) : bool{
$targetBlock = BlockFactory::get($this->meta);
if($targetBlock instanceof Air){
if($target instanceof Liquid and $target->getDamage() === 0){
@ -56,7 +58,7 @@ class Bucket extends Item{
$result->setDamage($target->getId());
$player->getServer()->getPluginManager()->callEvent($ev = new PlayerBucketFillEvent($player, $block, $face, $this, $result));
if(!$ev->isCancelled()){
$player->getLevel()->setBlock($target, Block::get(Block::AIR), true, true);
$player->getLevel()->setBlock($target, BlockFactory::get(Block::AIR), true, true);
if($player->isSurvival()){
$player->getInventory()->setItemInHand($ev->getItem());
}

View File

@ -24,10 +24,11 @@ declare(strict_types=1);
namespace pocketmine\item;
use pocketmine\block\Block;
use pocketmine\block\BlockFactory;
class Cake extends Item{
public function __construct($meta = 0, $count = 1){
$this->block = Block::get(Block::CAKE_BLOCK);
$this->block = BlockFactory::get(Block::CAKE_BLOCK);
parent::__construct(self::CAKE, $meta, $count, "Cake");
}

View File

@ -24,10 +24,11 @@ declare(strict_types=1);
namespace pocketmine\item;
use pocketmine\block\Block;
use pocketmine\block\BlockFactory;
class Carrot extends Food{
public function __construct($meta = 0, $count = 1){
$this->block = Block::get(Block::CARROT_BLOCK);
$this->block = BlockFactory::get(Block::CARROT_BLOCK);
parent::__construct(self::CARROT, $meta, $count, "Carrot");
}

View File

@ -24,9 +24,11 @@ declare(strict_types=1);
namespace pocketmine\item;
use pocketmine\block\Block;
use pocketmine\block\BlockFactory;
use pocketmine\block\Fire;
use pocketmine\block\Solid;
use pocketmine\level\Level;
use pocketmine\math\Vector3;
use pocketmine\Player;
class FlintSteel extends Tool{
@ -34,9 +36,9 @@ class FlintSteel extends Tool{
parent::__construct(self::FLINT_STEEL, $meta, $count, "Flint and Steel");
}
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
public function onActivate(Level $level, Player $player, Block $block, Block $target, int $face, Vector3 $facePos) : bool{
if($block->getId() === self::AIR and ($target instanceof Solid)){
$level->setBlock($block, Block::get(Block::FIRE), true);
$level->setBlock($block, BlockFactory::get(Block::FIRE), true);
if(($player->gamemode & 0x01) === 0 and $this->useOn($block)){
if($this->getDamage() >= $this->getMaxDurability()){
$player->getInventory()->setItemInHand(new Item(Item::AIR, 0, 0));

View File

@ -24,10 +24,11 @@ declare(strict_types=1);
namespace pocketmine\item;
use pocketmine\block\Block;
use pocketmine\block\BlockFactory;
class FlowerPot extends Item{
public function __construct($meta = 0, $count = 1){
$this->block = Block::get(Block::FLOWER_POT_BLOCK);
$this->block = BlockFactory::get(Block::FLOWER_POT_BLOCK);
parent::__construct(self::FLOWER_POT, $meta, $count, "Flower Pot");
}
}

View File

@ -24,10 +24,11 @@ declare(strict_types=1);
namespace pocketmine\item;
use pocketmine\block\Block;
use pocketmine\block\BlockFactory;
class IronDoor extends Item{
public function __construct($meta = 0, $count = 1){
$this->block = Block::get(Block::IRON_DOOR_BLOCK);
$this->block = BlockFactory::get(Block::IRON_DOOR_BLOCK);
parent::__construct(self::IRON_DOOR, $meta, $count, "Iron Door");
}

View File

@ -27,9 +27,11 @@ declare(strict_types=1);
namespace pocketmine\item;
use pocketmine\block\Block;
use pocketmine\block\BlockFactory;
use pocketmine\entity\Entity;
use pocketmine\item\enchantment\Enchantment;
use pocketmine\level\Level;
use pocketmine\math\Vector3;
use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\ByteTag;
use pocketmine\nbt\tag\CompoundTag;
@ -327,7 +329,7 @@ class Item implements ItemIds, \JsonSerializable{
public static function get(int $id, int $meta = 0, int $count = 1, $tags = "") : Item{
try{
if($id < 256){
return (new ItemBlock(Block::get($id, $meta), $meta, $count))->setCompoundTag($tags);
return (new ItemBlock(BlockFactory::get($id, $meta), $meta, $count))->setCompoundTag($tags);
}else{
$class = self::$list[$id];
if($class === null){
@ -387,8 +389,8 @@ class Item implements ItemIds, \JsonSerializable{
$this->meta = $meta !== -1 ? $meta & 0xffff : -1;
$this->count = $count;
$this->name = $name;
if(!isset($this->block) and $this->id <= 0xff and isset(Block::$list[$this->id])){
$this->block = Block::get($this->id, $this->meta);
if(!isset($this->block) and $this->id <= 0xff and isset(BlockFactory::$list[$this->id])){
$this->block = BlockFactory::get($this->id, $this->meta);
$this->name = $this->block->getName();
}
}
@ -877,7 +879,7 @@ class Item implements ItemIds, \JsonSerializable{
if($this->block instanceof Block){
return clone $this->block;
}else{
return Block::get(self::AIR);
return BlockFactory::get(self::AIR);
}
}
@ -982,18 +984,16 @@ class Item implements ItemIds, \JsonSerializable{
/**
* Called when a player uses this item on a block.
*
* @param Level $level
* @param Player $player
* @param Block $block
* @param Block $target
* @param int $face
* @param float $fx
* @param float $fy
* @param float $fz
* @param Level $level
* @param Player $player
* @param Block $block
* @param Block $target
* @param int $face
* @param Vector3 $facePos
*
* @return bool
*/
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
public function onActivate(Level $level, Player $player, Block $block, Block $target, int $face, Vector3 $facePos) : bool{
return false;
}

View File

@ -24,10 +24,11 @@ declare(strict_types=1);
namespace pocketmine\item;
use pocketmine\block\Block;
use pocketmine\block\BlockFactory;
class ItemFrame extends Item{
public function __construct($meta = 0, $count = 1){
$this->block = Block::get(Block::ITEM_FRAME_BLOCK);
$this->block = BlockFactory::get(Block::ITEM_FRAME_BLOCK);
parent::__construct(self::ITEM_FRAME, $meta, $count, "Item Frame");
}
}

View File

@ -24,10 +24,11 @@ declare(strict_types=1);
namespace pocketmine\item;
use pocketmine\block\Block;
use pocketmine\block\BlockFactory;
class MelonSeeds extends Item{
public function __construct($meta = 0, $count = 1){
$this->block = Block::get(Block::MELON_STEM);
$this->block = BlockFactory::get(Block::MELON_STEM);
parent::__construct(self::MELON_SEEDS, $meta, $count, "Melon Seeds");
}
}

View File

@ -24,10 +24,11 @@ declare(strict_types=1);
namespace pocketmine\item;
use pocketmine\block\Block;
use pocketmine\block\BlockFactory;
class NetherWart extends Item{
public function __construct($meta = 0, $count = 1){
$this->block = Block::get(Block::NETHER_WART_PLANT);
$this->block = BlockFactory::get(Block::NETHER_WART_PLANT);
parent::__construct(self::NETHER_WART, $meta, $count, "Nether Wart");
}
}

View File

@ -25,6 +25,7 @@ namespace pocketmine\item;
use pocketmine\block\Block;
use pocketmine\level\Level;
use pocketmine\math\Vector3;
use pocketmine\Player;
class Painting extends Item{
@ -32,7 +33,7 @@ class Painting extends Item{
parent::__construct(self::PAINTING, $meta, $count, "Painting");
}
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
public function onActivate(Level $level, Player $player, Block $block, Block $target, int $face, Vector3 $facePos) : bool{
if($target->isTransparent() === false and $face > 1 and $block->isSolid() === false){
$faces = [
2 => 1,

View File

@ -24,10 +24,11 @@ declare(strict_types=1);
namespace pocketmine\item;
use pocketmine\block\Block;
use pocketmine\block\BlockFactory;
class Potato extends Food{
public function __construct($meta = 0, $count = 1){
$this->block = Block::get(Block::POTATO_BLOCK);
$this->block = BlockFactory::get(Block::POTATO_BLOCK);
parent::__construct(self::POTATO, $meta, $count, "Potato");
}

View File

@ -24,10 +24,11 @@ declare(strict_types=1);
namespace pocketmine\item;
use pocketmine\block\Block;
use pocketmine\block\BlockFactory;
class PumpkinSeeds extends Item{
public function __construct($meta = 0, $count = 1){
$this->block = Block::get(Block::PUMPKIN_STEM);
$this->block = BlockFactory::get(Block::PUMPKIN_STEM);
parent::__construct(self::PUMPKIN_SEEDS, $meta, $count, "Pumpkin Seeds");
}
}

View File

@ -24,10 +24,11 @@ declare(strict_types=1);
namespace pocketmine\item;
use pocketmine\block\Block;
use pocketmine\block\BlockFactory;
class Sign extends Item{
public function __construct($meta = 0, $count = 1){
$this->block = Block::get(Block::SIGN_POST);
$this->block = BlockFactory::get(Block::SIGN_POST);
parent::__construct(self::SIGN, $meta, $count, "Sign");
}

View File

@ -24,10 +24,11 @@ declare(strict_types=1);
namespace pocketmine\item;
use pocketmine\block\Block;
use pocketmine\block\BlockFactory;
class Skull extends Item{
public function __construct($meta = 0, $count = 1){
$this->block = Block::get(Block::SKULL_BLOCK);
$this->block = BlockFactory::get(Block::SKULL_BLOCK);
parent::__construct(self::SKULL, $meta, $count, "Mob Head");
}
}

View File

@ -26,6 +26,7 @@ namespace pocketmine\item;
use pocketmine\block\Block;
use pocketmine\entity\Entity;
use pocketmine\level\Level;
use pocketmine\math\Vector3;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\DoubleTag;
use pocketmine\nbt\tag\FloatTag;
@ -38,7 +39,7 @@ class SpawnEgg extends Item{
parent::__construct(self::SPAWN_EGG, $meta, $count, "Spawn Egg");
}
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
public function onActivate(Level $level, Player $player, Block $block, Block $target, int $face, Vector3 $facePos) : bool{
$nbt = new CompoundTag("", [
new ListTag("Pos", [
new DoubleTag("", $block->getX() + 0.5),

View File

@ -24,10 +24,11 @@ declare(strict_types=1);
namespace pocketmine\item;
use pocketmine\block\Block;
use pocketmine\block\BlockFactory;
class Sugarcane extends Item{
public function __construct($meta = 0, $count = 1){
$this->block = Block::get(Block::SUGARCANE_BLOCK);
$this->block = BlockFactory::get(Block::SUGARCANE_BLOCK);
parent::__construct(self::SUGARCANE, $meta, $count, "Sugar Cane");
}
}

View File

@ -24,10 +24,11 @@ declare(strict_types=1);
namespace pocketmine\item;
use pocketmine\block\Block;
use pocketmine\block\BlockFactory;
class WheatSeeds extends Item{
public function __construct($meta = 0, $count = 1){
$this->block = Block::get(Block::WHEAT_BLOCK);
$this->block = BlockFactory::get(Block::WHEAT_BLOCK);
parent::__construct(self::WHEAT_SEEDS, $meta, $count, "Wheat Seeds");
}
}

View File

@ -24,10 +24,11 @@ declare(strict_types=1);
namespace pocketmine\item;
use pocketmine\block\Block;
use pocketmine\block\BlockFactory;
class WoodenDoor extends Item{
public function __construct($meta = 0, $count = 1){
$this->block = Block::get(Block::WOODEN_DOOR_BLOCK);
$this->block = BlockFactory::get(Block::WOODEN_DOOR_BLOCK);
parent::__construct(self::WOODEN_DOOR, $meta, $count, "Wooden Door");
}