mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 17:59:48 +00:00
Branch merge
This commit is contained in:
@ -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");
|
||||
}
|
||||
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
@ -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());
|
||||
}
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
@ -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");
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
@ -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");
|
||||
}
|
||||
}
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
@ -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");
|
||||
}
|
||||
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
@ -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),
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
@ -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");
|
||||
}
|
||||
}
|
@ -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");
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user