Merge branch 'mcpe-0.13'

This commit is contained in:
Intyre
2015-12-19 11:38:05 +01:00
274 changed files with 7872 additions and 1668 deletions

View File

@ -0,0 +1,82 @@
<?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\inventory\AnvilInventory;
use pocketmine\item\Item;
use pocketmine\item\Tool;
use pocketmine\Player;
class Anvil extends Fallable{
protected $id = self::ANVIL;
public function isSolid(){
return false;
}
public function __construct($meta = 0){
$this->meta = $meta;
}
public function canBeActivated(){
return true;
}
public function getHardness(){
return 5;
}
public function getResistance(){
return 6000;
}
public function getName(){
return "Anvil";
}
public function getToolType(){
return Tool::TYPE_PICKAXE;
}
public function onActivate(Item $item, Player $player = null){
if($player instanceof Player){
if($player->isCreative()){
return true;
}
$player->addWindow(new AnvilInventory($this));
}
return true;
}
public function getDrops(Item $item){
if($item->isPickaxe() >= Tool::TIER_WOODEN){
return [
[$this->id, 0, 1], //TODO break level
];
}else{
return [];
}
}
}

View File

@ -25,9 +25,8 @@
namespace pocketmine\block;
use pocketmine\entity\Entity;
use pocketmine\entity\Squid;
use pocketmine\entity\Villager;
use pocketmine\entity\Zombie;
use pocketmine\item\Item;
use pocketmine\item\Tool;
use pocketmine\level\Level;
@ -182,9 +181,13 @@ class Block extends Position implements Metadatable{
const LILY_PAD = 111;
const NETHER_BRICKS = 112;
const NETHER_BRICK_BLOCK = 112;
const NETHER_BRICK_FENCE = 113;
const NETHER_BRICKS_STAIRS = 114;
const ENCHANTING_TABLE = 116;
const ENCHANT_TABLE = 116;
const ENCHANTMENT_TABLE = 116;
const BREWING_STAND = 117;
const END_PORTAL_FRAME = 120;
const END_STONE = 121;
@ -202,10 +205,13 @@ class Block extends Position implements Metadatable{
const COBBLE_WALL = 139;
const STONE_WALL = 139;
const COBBLESTONE_WALL = 139;
const FLOWER_POT_BLOCK = 140;
const CARROT_BLOCK = 141;
const POTATO_BLOCK = 142;
const ANVIL = 145;
const TRAPPED_CHEST = 146;
const REDSTONE_BLOCK = 152;
const QUARTZ_BLOCK = 155;
@ -231,11 +237,12 @@ class Block extends Position implements Metadatable{
const DARK_OAK_WOOD_STAIRS = 164;
const DARK_OAK_WOODEN_STAIRS = 164;
const IRON_TRAPDOOR = 167;
const HAY_BALE = 170;
const CARPET = 171;
const HARDENED_CLAY = 172;
const COAL_BLOCK = 173;
const PACKED_ICE = 174;
const DOUBLE_PLANT = 175;
const FENCE_GATE_SPRUCE = 183;
@ -250,7 +257,6 @@ class Block extends Position implements Metadatable{
const BEETROOT_BLOCK = 244;
const STONECUTTER = 245;
const GLOWING_OBSIDIAN = 246;
const NETHER_REACTOR = 247;
/** @var \SplFixedArray */
public static $list = null;
@ -408,9 +414,11 @@ class Block extends Position implements Metadatable{
self::$list[self::MYCELIUM] = Mycelium::class;
self::$list[self::WATER_LILY] = WaterLily::class;
self::$list[self::NETHER_BRICKS] = NetherBrick::class;
self::$list[self::NETHER_BRICK_FENCE] = NetherBrickFence::class;
self::$list[self::NETHER_BRICKS_STAIRS] = NetherBrickStairs::class;
self::$list[self::ENCHANTING_TABLE] = EnchantingTable::class;
self::$list[self::BREWING_STAND] = BrewingStand::class;
self::$list[self::END_PORTAL_FRAME] = EndPortalFrame::class;
self::$list[self::END_STONE] = EndStone::class;
self::$list[self::SANDSTONE_STAIRS] = SandstoneStairs::class;
@ -421,10 +429,11 @@ class Block extends Position implements Metadatable{
self::$list[self::BIRCH_WOOD_STAIRS] = BirchWoodStairs::class;
self::$list[self::JUNGLE_WOOD_STAIRS] = JungleWoodStairs::class;
self::$list[self::STONE_WALL] = StoneWall::class;
self::$list[self::FLOWER_POT_BLOCK] = FlowerPot::class;
self::$list[self::CARROT_BLOCK] = Carrot::class;
self::$list[self::POTATO_BLOCK] = Potato::class;
self::$list[self::ANVIL] = Anvil::class;
self::$list[self::TRAPPED_CHEST] = TrappedChest::class;
self::$list[self::REDSTONE_BLOCK] = Redstone::class;
self::$list[self::QUARTZ_BLOCK] = Quartz::class;
@ -438,11 +447,12 @@ class Block extends Position implements Metadatable{
self::$list[self::ACACIA_WOOD_STAIRS] = AcaciaWoodStairs::class;
self::$list[self::DARK_OAK_WOOD_STAIRS] = DarkOakWoodStairs::class;
self::$list[self::IRON_TRAPDOOR] = IronTrapdoor::class;
self::$list[self::HAY_BALE] = HayBale::class;
self::$list[self::CARPET] = Carpet::class;
self::$list[self::HARDENED_CLAY] = HardenedClay::class;
self::$list[self::COAL_BLOCK] = Coal::class;
self::$list[self::PACKED_ICE] = PackedIce::class;
self::$list[self::DOUBLE_PLANT] = DoublePlant::class;
self::$list[self::FENCE_GATE_SPRUCE] = FenceGateSpruce::class;
@ -457,7 +467,6 @@ class Block extends Position implements Metadatable{
self::$list[self::BEETROOT_BLOCK] = Beetroot::class;
self::$list[self::STONECUTTER] = Stonecutter::class;
self::$list[self::GLOWING_OBSIDIAN] = GlowingObsidian::class;
self::$list[self::NETHER_REACTOR] = NetherReactor::class;
foreach(self::$list as $id => $class){
if($class !== null){
@ -788,6 +797,10 @@ class Block extends Position implements Metadatable{
$base *= 3.33;
}
if($item->isSword()){
$base *= 0.5;
}
return $base;
}

View File

@ -0,0 +1,46 @@
<?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\item\Item;
use pocketmine\item\Tool;
class BrewingStand extends Transparent{
protected $id = self::BREWING_STAND;
public function __construct(){
}
public function getName(){
return "Brewing Stand";
}
public function getHardness(){
return 0.5;
}
public function getToolType(){
return Tool::TYPE_PICKAXE;
}
}

View File

@ -49,7 +49,7 @@ class Bricks extends Solid{
}
public function getDrops(Item $item){
if($item->isPickaxe() >= 1){
if($item->isPickaxe() >= Tool::TIER_WOODEN){
return [
[Item::BRICKS_BLOCK, 0, 1],
];

View File

@ -77,6 +77,17 @@ class BurningFurnace extends Solid{
new Int("z", $this->z)
]);
$nbt->Items->setTagType(NBT::TAG_Compound);
if($item->hasCustomName()){
$nbt->CustomName = new String("CustomName", $item->getCustomName());
}
if($item->hasCustomBlockData()){
foreach($item->getCustomBlockData() as $key => $v){
$nbt->{$key} = $v;
}
}
Tile::createTile("Furnace", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
return true;
@ -106,6 +117,12 @@ class BurningFurnace extends Solid{
$furnace = Tile::createTile("Furnace", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
}
if(isset($furnace->namedtag->Lock) and $furnace->namedtag->Lock instanceof String){
if($furnace->namedtag->Lock->getValue() !== $item->getCustomName()){
return true;
}
}
if($player->isCreative()){
return true;
}
@ -118,7 +135,7 @@ class BurningFurnace extends Solid{
public function getDrops(Item $item){
$drops = [];
if($item->isPickaxe() >= 1){
if($item->isPickaxe() >= Tool::TIER_WOODEN){
$drops[] = [Item::FURNACE, 0, 1];
}

View File

@ -26,7 +26,7 @@ use pocketmine\item\Item;
use pocketmine\level\Level;
use pocketmine\math\AxisAlignedBB;
use pocketmine\Player;
use pocketmine\Server;
class Cake extends Transparent{

View File

@ -104,6 +104,17 @@ class Chest extends Transparent{
new Int("z", $this->z)
]);
$nbt->Items->setTagType(NBT::TAG_Compound);
if($item->hasCustomName()){
$nbt->CustomName = new String("CustomName", $item->getCustomName());
}
if($item->hasCustomBlockData()){
foreach($item->getCustomBlockData() as $key => $v){
$nbt->{$key} = $v;
}
}
$tile = Tile::createTile("Chest", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
if($chest instanceof TileChest and $tile instanceof TileChest){
@ -147,6 +158,11 @@ class Chest extends Transparent{
$chest = Tile::createTile("Chest", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
}
if(isset($chest->namedtag->Lock) and $chest->namedtag->Lock instanceof String){
if($chest->namedtag->Lock->getValue() !== $item->getCustomName()){
return true;
}
}
if($player->isCreative()){
return true;

View File

@ -45,7 +45,7 @@ class Coal extends Solid{
}
public function getDrops(Item $item){
if($item->isPickaxe() >= 1){
if($item->isPickaxe() >= Tool::TIER_WOODEN){
return [
[Item::COAL_BLOCK, 0, 1],
];

View File

@ -45,7 +45,7 @@ class CoalOre extends Solid{
}
public function getDrops(Item $item){
if($item->isPickaxe() >= 1){
if($item->isPickaxe() >= Tool::TIER_WOODEN){
return [
[Item::COAL, 0, 1],
];

View File

@ -45,7 +45,7 @@ class Cobblestone extends Solid{
}
public function getDrops(Item $item){
if($item->isPickaxe() >= 1){
if($item->isPickaxe() >= Tool::TIER_WOODEN){
return [
[Item::COBBLESTONE, 0, 1],
];

View File

@ -45,7 +45,7 @@ class Diamond extends Solid{
}
public function getDrops(Item $item){
if($item->isPickaxe() >= 4){
if($item->isPickaxe() >= Tool::TIER_IRON){
return [
[Item::DIAMOND_BLOCK, 0, 1],
];

View File

@ -45,7 +45,7 @@ class DiamondOre extends Solid{
}
public function getDrops(Item $item){
if($item->isPickaxe() >= 4){
if($item->isPickaxe() >= Tool::TIER_IRON){
return [
[Item::DIAMOND, 0, 1],
];

View File

@ -26,9 +26,7 @@ use pocketmine\level\Level;
use pocketmine\level\sound\DoorSound;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Vector3;
use pocketmine\network\protocol\LevelEventPacket;
use pocketmine\Player;
use pocketmine\Server;
abstract class Door extends Transparent{

View File

@ -49,13 +49,13 @@ class DoubleSlab extends Solid{
4 => "Brick",
5 => "Stone Brick",
6 => "Quartz",
7 => "",
7 => "Nether Brick",
];
return "Double " . $names[$this->meta & 0x07] . " Slab";
}
public function getDrops(Item $item){
if($item->isPickaxe() >= 1){
if($item->isPickaxe() >= Tool::TIER_WOODEN){
return [
[Item::SLAB, $this->meta & 0x07, 2],
];

View File

@ -45,7 +45,7 @@ class Emerald extends Solid{
}
public function getDrops(Item $item){
if($item->isPickaxe() >= 4){
if($item->isPickaxe() >= Tool::TIER_IRON){
return [
[Item::EMERALD_BLOCK, 0, 1],
];

View File

@ -45,7 +45,7 @@ class EmeraldOre extends Solid{
}
public function getDrops(Item $item){
if($item->isPickaxe() >= 4){
if($item->isPickaxe() >= Tool::TIER_IRON){
return [
[Item::EMERALD, 0, 1],
];

View File

@ -0,0 +1,108 @@
<?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\inventory\EnchantInventory;
use pocketmine\item\Item;
use pocketmine\item\Tool;
use pocketmine\nbt\tag\Compound;
use pocketmine\nbt\tag\Int;
use pocketmine\nbt\tag\String;
use pocketmine\Player;
use pocketmine\tile\Tile;
class EnchantingTable extends Transparent{
protected $id = self::ENCHANTING_TABLE;
public function __construct(){
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$this->getLevel()->setBlock($block, $this, true, true);
$nbt = new Compound("", [
new String("id", Tile::ENCHANT_TABLE),
new Int("x", $this->x),
new Int("y", $this->y),
new Int("z", $this->z)
]);
if($item->hasCustomName()){
$nbt->CustomName = new String("CustomName", $item->getCustomName());
}
if($item->hasCustomBlockData()){
foreach($item->getCustomBlockData() as $key => $v){
$nbt->{$key} = $v;
}
}
Tile::createTile(Tile::ENCHANT_TABLE, $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
return true;
}
public function canBeActivated(){
return true;
}
public function getHardness(){
return 5;
}
public function getResistance(){
return 6000;
}
public function getName(){
return "Enchanting Table";
}
public function getToolType(){
return Tool::TYPE_PICKAXE;
}
public function onActivate(Item $item, Player $player = null){
if($player instanceof Player){
//TODO lock
if($player->isCreative()){
return true;
}
$player->addWindow(new EnchantInventory($this));
}
return true;
}
public function getDrops(Item $item){
if($item->isPickaxe() >= Tool::TIER_WOODEN){
return [
[$this->id, 0, 1],
];
}else{
return [];
}
}
}

View File

@ -21,7 +21,7 @@
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\Tool;
class EndStone extends Solid{

View File

@ -26,7 +26,13 @@ use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Vector3;
class Fence extends Transparent{
const FENCE_OAK = 0;
const FENCE_SPRUCE = 1;
const FENCE_BIRCH = 2;
const FENCE_JUNGLE = 3;
const FENCE_ACACIA = 4;
const FENCE_DARKOAK = 5;
protected $id = self::FENCE;
public function __construct($meta = 0){
@ -38,18 +44,18 @@ class Fence extends Transparent{
}
public function getToolType(){
return Tool::TYPE_PICKAXE;
return Tool::TYPE_AXE;
}
public function getName(){
static $names = [
0 => "Oak Fence",
1 => "Spruce Fence",
2 => "Birch Fence",
3 => "Jungle Fence",
4 => "Acacia Fence",
5 => "Dark Oak Fence",
self::FENCE_OAK => "Oak Fence",
self::FENCE_SPRUCE => "Spruce Fence",
self::FENCE_BIRCH => "Birch Fence",
self::FENCE_JUNGLE => "Jungle Fence",
self::FENCE_ACACIA => "Acacia Fence",
self::FENCE_DARKOAK => "Dark Oak Fence",
"",
""
];

View File

@ -22,7 +22,7 @@
namespace pocketmine\block;
use pocketmine\item\Item;
abstract class Flowable extends Transparent{

View File

@ -21,21 +21,18 @@
namespace pocketmine\block;
use pocketmine\item\Item;
class NetherReactor extends Solid{
class FlowerPot extends Transparent{
protected $id = self::NETHER_REACTOR;
protected $id = self::FLOWER_POT_BLOCK;
public function __construct($meta = 0){
$this->meta = $meta;
}
public function getName(){
return "Nether Reactor";
}
public function canBeActivated(){
return true;
return "Flower Pot Block";
}
}

View File

@ -60,7 +60,7 @@ class GlowingRedstoneOre extends Solid{
}
public function getDrops(Item $item){
if($item->isPickaxe() >= 4){
if($item->isPickaxe() >= Tool::TIER_IRON){
return [
[Item::REDSTONE_DUST, 0, mt_rand(4, 5)],
];

View File

@ -45,7 +45,7 @@ class Gold extends Solid{
}
public function getDrops(Item $item){
if($item->isPickaxe() >= 4){
if($item->isPickaxe() >= Tool::TIER_IRON){
return [
[Item::GOLD_BLOCK, 0, 1],
];

View File

@ -45,7 +45,7 @@ class GoldOre extends Solid{
}
public function getDrops(Item $item){
if($item->isPickaxe() >= 4){
if($item->isPickaxe() >= Tool::TIER_IRON){
return [
[Item::GOLD_ORE, 0, 1],
];

View File

@ -21,16 +21,13 @@
namespace pocketmine\block;
use pocketmine\event\block\BlockSpreadEvent;
use pocketmine\item\Item;
use pocketmine\item\Tool;
use pocketmine\level\generator\object\TallGrass as TallGrassObject;
use pocketmine\level\Level;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Vector3;
use pocketmine\Player;
use pocketmine\Server;
use pocketmine\utils\Random;
class GrassPath extends Transparent{

View File

@ -21,7 +21,7 @@
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\Tool;
class HardenedClay extends Solid{

View File

@ -45,7 +45,7 @@ class Iron extends Solid{
}
public function getDrops(Item $item){
if($item->isPickaxe() >= 3){
if($item->isPickaxe() >= Tool::TIER_STONE){
return [
[Item::IRON_BLOCK, 0, 1],
];

View File

@ -45,7 +45,7 @@ class IronBars extends Thin{
}
public function getDrops(Item $item){
if($item->isPickaxe() >= 1){
if($item->isPickaxe() >= Tool::TIER_WOODEN){
return [
[Item::IRON_BARS, 0, 1],
];

View File

@ -45,7 +45,7 @@ class IronDoor extends Door{
}
public function getDrops(Item $item){
if($item->isPickaxe() >= 1){
if($item->isPickaxe() >= Tool::TIER_WOODEN){
return [
[Item::IRON_DOOR, 0, 1],
];

View File

@ -45,7 +45,7 @@ class IronOre extends Solid{
}
public function getDrops(Item $item){
if($item->isPickaxe() >= 3){
if($item->isPickaxe() >= Tool::TIER_STONE){
return [
[Item::IRON_ORE, 0, 1],
];

View File

@ -0,0 +1,156 @@
<?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\item\Item;
use pocketmine\item\Tool;
use pocketmine\math\AxisAlignedBB;
use pocketmine\Player;
class IronTrapdoor extends Transparent{
protected $id = self::IRON_TRAPDOOR;
public function __construct($meta = 0){
$this->meta = $meta;
}
public function getName(){
return "Iron Trapdoor";
}
public function getHardness(){
return 5;
}
public function canBeActivated(){
return true;
}
protected function recalculateBoundingBox(){
$damage = $this->getDamage();
$f = 0.1875;
if(($damage & 0x08) > 0){
$bb = new AxisAlignedBB(
$this->x,
$this->y + 1 - $f,
$this->z,
$this->x + 1,
$this->y + 1,
$this->z + 1
);
}else{
$bb = new AxisAlignedBB(
$this->x,
$this->y,
$this->z,
$this->x + 1,
$this->y + $f,
$this->z + 1
);
}
if(($damage & 0x04) > 0){
if(($damage & 0x03) === 0){
$bb->setBounds(
$this->x,
$this->y,
$this->z + 1 - $f,
$this->x + 1,
$this->y + 1,
$this->z + 1
);
}elseif(($damage & 0x03) === 1){
$bb->setBounds(
$this->x,
$this->y,
$this->z,
$this->x + 1,
$this->y + 1,
$this->z + $f
);
}
if(($damage & 0x03) === 2){
$bb->setBounds(
$this->x + 1 - $f,
$this->y,
$this->z,
$this->x + 1,
$this->y + 1,
$this->z + 1
);
}
if(($damage & 0x03) === 3){
$bb->setBounds(
$this->x,
$this->y,
$this->z,
$this->x + $f,
$this->y + 1,
$this->z + 1
);
}
}
return $bb;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
if(($target->isTransparent() === false or $target->getId() === self::SLAB) and $face !== 0 and $face !== 1){
$faces = [
2 => 0,
3 => 1,
4 => 2,
5 => 3,
];
$this->meta = $faces[$face] & 0x03;
if($fy > 0.5){
$this->meta |= 0x08;
}
$this->getLevel()->setBlock($block, $this, true, true);
return true;
}
return false;
}
public function getDrops(Item $item){
return [
[$this->id, 0, 1],
];
}
public function onActivate(Item $item, Player $player = null){
$this->meta ^= 0x04;
$this->getLevel()->setBlock($this, $this, true);
$this->level->addSound(new DoorSound($this));
return true;
}
public function getToolType(){
return Tool::TYPE_PICKAXE;
}
}

View File

@ -45,7 +45,7 @@ class Lapis extends Solid{
}
public function getDrops(Item $item){
if($item->isPickaxe() >= 3){
if($item->isPickaxe() >= Tool::TIER_STONE){
return [
[Item::LAPIS_BLOCK, 0, 1],
];

View File

@ -45,7 +45,7 @@ class LapisOre extends Solid{
}
public function getDrops(Item $item){
if($item->isPickaxe() >= 3){
if($item->isPickaxe() >= Tool::TIER_STONE){
return [
[Item::DYE, 4, mt_rand(4, 8)],
];

View File

@ -45,7 +45,7 @@ class MossStone extends Solid{
}
public function getDrops(Item $item){
if($item->isPickaxe() >= 1){
if($item->isPickaxe() >= Tool::TIER_WOODEN){
return [
[Item::MOSS_STONE, $this->meta, 1],
];

View File

@ -45,7 +45,7 @@ class NetherBrick extends Solid{
}
public function getDrops(Item $item){
if($item->isPickaxe() >= 1){
if($item->isPickaxe() >= Tool::TIER_WOODEN){
return [
[Item::NETHER_BRICKS, 0, 1],
];

View File

@ -0,0 +1,71 @@
<?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\item\Item;
use pocketmine\item\Tool;
class NetherBrickFence extends Transparent {
protected $id = self::NETHER_BRICK_FENCE;
public function __construct($meta = 0){
$this->meta = $meta;
}
public function getBreakTime(Item $item){
if ($item instanceof Air){
//Breaking by hand
return 10;
}
else{
// Other breaktimes are equal to woodfences.
return parent::getBreakTime($item);
}
}
public function getHardness(){
return 2;
}
public function getToolType(){
return Tool::TYPE_PICKAXE;
}
public function getName(){
return "Nether Brick Fence";
}
public function canConnect(Block $block){
//TODO: activate comments when the NetherBrickFenceGate class has been created.
return ($block instanceof NetherBrickFence /* or $block instanceof NetherBrickFenceGate */) ? true : $block->isSolid() and !$block->isTransparent();
}
public function getDrops(Item $item){
if($item->isPickaxe() >= Tool::TIER_WOODEN){
return [
[$this->id, $this->meta, 1],
];
}else{
return [];
}
}
}

View File

@ -45,7 +45,7 @@ class Netherrack extends Solid{
}
public function getDrops(Item $item){
if($item->isPickaxe() >= 1){
if($item->isPickaxe() >= Tool::TIER_WOODEN){
return [
[Item::NETHERRACK, 0, 1],
];

View File

@ -45,7 +45,7 @@ class Obsidian extends Solid{
}
public function getDrops(Item $item){
if($item->isPickaxe() >= 5){
if($item->isPickaxe() >= Tool::TIER_DIAMOND){
return [
[Item::OBSIDIAN, 0, 1],
];

View File

@ -0,0 +1,47 @@
<?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\item\Item;
use pocketmine\item\Tool;
class PackedIce extends Solid{
protected $id = self::PACKED_ICE;
public function __construct(){
}
public function getName(){
return "Packed Ice";
}
public function getHardness(){
return 0.5;
}
public function getToolType(){
return Tool::TYPE_PICKAXE;
}
}

View File

@ -26,6 +26,11 @@ use pocketmine\item\Tool;
class Quartz extends Solid{
const QUARTZ_NORMAL = 0;
const QUARTZ_CHISELED = 1;
const QUARTZ_PILLAR = 2;
const QUARTZ_PILLAR2 = 3;
protected $id = self::QUARTZ_BLOCK;
public function __construct($meta = 0){
@ -38,10 +43,10 @@ class Quartz extends Solid{
public function getName(){
static $names = [
0 => "Quartz Block",
1 => "Chiseled Quartz Block",
2 => "Quartz Pillar",
3 => "Quartz Pillar",
self::QUARTZ_NORMAL => "Quartz Block",
self::QUARTZ_CHISELED => "Chiseled Quartz Block",
self::QUARTZ_PILLAR => "Quartz Pillar",
self::QUARTZ_PILLAR2 => "Quartz Pillar",
];
return $names[$this->meta & 0x03];
}
@ -51,7 +56,7 @@ class Quartz extends Solid{
}
public function getDrops(Item $item){
if($item->isPickaxe() >= 1){
if($item->isPickaxe() >= Tool::TIER_WOODEN){
return [
[Item::QUARTZ_BLOCK, $this->meta & 0x03, 1],
];

View File

@ -45,7 +45,7 @@ class Redstone extends Solid{
}
public function getDrops(Item $item){
if($item->isPickaxe() >= 1){
if($item->isPickaxe() >= Tool::TIER_WOODEN){
return [
[Item::REDSTONE_BLOCK, 0, 1],
];

View File

@ -58,7 +58,7 @@ class RedstoneOre extends Solid{
}
public function getDrops(Item $item){
if($item->isPickaxe() >= 2){
if($item->isPickaxe() >= Tool::TIER_GOLD){
return [
[Item::REDSTONE_DUST, 0, mt_rand(4, 5)],
];

View File

@ -26,6 +26,10 @@ use pocketmine\item\Tool;
class Sandstone extends Solid{
const NORMAL = 0;
const CHISELED = 1;
const SMOOTH = 2;
protected $id = self::SANDSTONE;
public function __construct($meta = 0){
@ -38,9 +42,9 @@ class Sandstone extends Solid{
public function getName(){
static $names = [
0 => "Sandstone",
1 => "Chiseled Sandstone",
2 => "Smooth Sandstone",
self::NORMAL => "Sandstone",
self::CHISELED => "Chiseled Sandstone",
self::SMOOTH => "Smooth Sandstone",
3 => "",
];
return $names[$this->meta & 0x03];
@ -51,7 +55,7 @@ class Sandstone extends Solid{
}
public function getDrops(Item $item){
if($item->isPickaxe() >= 1){
if($item->isPickaxe() >= Tool::TIER_WOODEN){
return [
[Item::SANDSTONE, $this->meta & 0x03, 1],
];

View File

@ -88,7 +88,7 @@ class SignPost extends Transparent{
}
public function onBreak(Item $item){
$this->getLevel()->setBlock($this, new Air(), true, true, true);
$this->getLevel()->setBlock($this, new Air(), true, true);
return true;
}

View File

@ -27,6 +27,14 @@ use pocketmine\math\AxisAlignedBB;
use pocketmine\Player;
class Slab extends Transparent{
const STONE = 0;
const SANDSTONE = 1;
const WOODEN = 2;
const COBBLESTONE = 3;
const BRICK = 4;
const STONE_BRICK = 5;
const QUARTZ = 6;
const NETHER_BRICK = 7;
protected $id = self::SLAB;
@ -40,14 +48,14 @@ class Slab extends Transparent{
public function getName(){
static $names = [
0 => "Stone",
1 => "Sandstone",
2 => "Wooden",
3 => "Cobblestone",
4 => "Brick",
5 => "Stone Brick",
6 => "Quartz",
7 => "",
self::STONE => "Stone",
self::SANDSTONE => "Sandstone",
self::WOODEN => "Wooden",
self::COBBLESTONE => "Cobblestone",
self::BRICK => "Brick",
self::STONE_BRICK => "Stone Brick",
self::QUARTZ => "Quartz",
self::NETHER_BRICK => "Nether Brick",
];
return (($this->meta & 0x08) > 0 ? "Upper " : "") . $names[$this->meta & 0x07] . " Slab";
}
@ -125,7 +133,7 @@ class Slab extends Transparent{
}
public function getDrops(Item $item){
if($item->isPickaxe() >= 1){
if($item->isPickaxe() >= Tool::TIER_WOODEN){
return [
[$this->id, $this->meta & 0x07, 1],
];

View File

@ -21,7 +21,7 @@
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\Tool;
class StainedClay extends Solid{

View File

@ -143,7 +143,7 @@ abstract class Stair extends Transparent{
}
public function getDrops(Item $item){
if($item->isPickaxe() >= 1){
if($item->isPickaxe() >= Tool::TIER_WOODEN){
return [
[$this->getId(), 0, 1],
];

View File

@ -37,7 +37,6 @@ class Stone extends Solid{
public function __construct($meta = 0){
$this->meta = $meta;
}
public function getHardness(){

View File

@ -25,6 +25,10 @@ use pocketmine\item\Item;
use pocketmine\item\Tool;
class StoneBricks extends Solid{
const NORMAL = 0;
const MOSSY = 1;
const CRACKED = 2;
const CHISELED = 3;
protected $id = self::STONE_BRICKS;
@ -42,16 +46,16 @@ class StoneBricks extends Solid{
public function getName(){
static $names = [
0 => "Stone Bricks",
1 => "Mossy Stone Bricks",
2 => "Cracked Stone Bricks",
3 => "Chiseled Stone Bricks",
self::NORMAL => "Stone Bricks",
self::MOSSY => "Mossy Stone Bricks",
self::CRACKED => "Cracked Stone Bricks",
self::CHISELED => "Chiseled Stone Bricks",
];
return $names[$this->meta & 0x03];
}
public function getDrops(Item $item){
if($item->isPickaxe() >= 1){
if($item->isPickaxe() >= Tool::TIER_WOODEN){
return [
[Item::STONE_BRICKS, $this->meta & 0x03, 1],
];

View File

@ -27,6 +27,8 @@ use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Vector3;
class StoneWall extends Transparent{
const NONE_MOSSY_WALL = 0;
const MOSSY_WALL = 1;
protected $id = self::STONE_WALL;

View File

@ -55,7 +55,7 @@ class Stonecutter extends Solid{
}
public function getDrops(Item $item){
if($item->isPickaxe() >= 1){
if($item->isPickaxe() >= Tool::TIER_WOODEN){
return [
[Item::STONECUTTER, 0, 1],
];

View File

@ -0,0 +1,181 @@
<?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\item\Item;
use pocketmine\item\Tool;
use pocketmine\math\AxisAlignedBB;
use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\Compound;
use pocketmine\nbt\tag\Enum;
use pocketmine\nbt\tag\Int;
use pocketmine\nbt\tag\String;
use pocketmine\Player;
use pocketmine\tile\Chest as TileChest;
use pocketmine\tile\Tile;
class TrappedChest extends Transparent{
protected $id = self::CHEST;
public function __construct($meta = 0){
$this->meta = $meta;
}
public function canBeActivated(){
return true;
}
public function getHardness(){
return 2.5;
}
public function getName(){
return "Trapped Chest";
}
public function getToolType(){
return Tool::TYPE_AXE;
}
protected function recalculateBoundingBox(){
return new AxisAlignedBB(
$this->x + 0.0625,
$this->y,
$this->z + 0.0625,
$this->x + 0.9375,
$this->y + 0.9475,
$this->z + 0.9375
);
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$faces = [
0 => 4,
1 => 2,
2 => 5,
3 => 3,
];
$chest = null;
$this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0];
for($side = 2; $side <= 5; ++$side){
if(($this->meta === 4 or $this->meta === 5) and ($side === 4 or $side === 5)){
continue;
}elseif(($this->meta === 3 or $this->meta === 2) and ($side === 2 or $side === 3)){
continue;
}
$c = $this->getSide($side);
if($c instanceof Chest and $c->getDamage() === $this->meta){
$tile = $this->getLevel()->getTile($c);
if($tile instanceof TileChest and !$tile->isPaired()){
$chest = $tile;
break;
}
}
}
$this->getLevel()->setBlock($block, $this, true, true);
$nbt = new Compound("", [
new Enum("Items", []),
new String("id", Tile::CHEST),
new Int("x", $this->x),
new Int("y", $this->y),
new Int("z", $this->z)
]);
$nbt->Items->setTagType(NBT::TAG_Compound);
if($item->hasCustomName()){
$nbt->CustomName = new String("CustomName", $item->getCustomName());
}
if($item->hasCustomBlockData()){
foreach($item->getCustomBlockData() as $key => $v){
$nbt->{$key} = $v;
}
}
$tile = Tile::createTile("Chest", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
if($chest instanceof TileChest and $tile instanceof TileChest){
$chest->pairWith($tile);
$tile->pairWith($chest);
}
return true;
}
public function onBreak(Item $item){
$t = $this->getLevel()->getTile($this);
if($t instanceof TileChest){
$t->unpair();
}
$this->getLevel()->setBlock($this, new Air(), true, true);
return true;
}
public function onActivate(Item $item, Player $player = null){
if($player instanceof Player){
$top = $this->getSide(1);
if($top->isTransparent() !== true){
return true;
}
$t = $this->getLevel()->getTile($this);
$chest = null;
if($t instanceof TileChest){
$chest = $t;
}else{
$nbt = new Compound("", [
new Enum("Items", []),
new String("id", Tile::CHEST),
new Int("x", $this->x),
new Int("y", $this->y),
new Int("z", $this->z)
]);
$nbt->Items->setTagType(NBT::TAG_Compound);
$chest = Tile::createTile("Chest", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
}
if(isset($chest->namedtag->Lock) and $chest->namedtag->Lock instanceof String){
if($chest->namedtag->Lock->getValue() !== $item->getCustomName()){
return true;
}
}
if($player->isCreative()){
return true;
}
$player->addWindow($chest->getInventory());
}
return true;
}
public function getDrops(Item $item){
return [
[$this->id, 0, 1],
];
}
}

View File

@ -22,6 +22,8 @@
namespace pocketmine\block;
use pocketmine\level\Level;
class WallSign extends SignPost{
protected $id = self::WALL_SIGN;
@ -31,6 +33,20 @@ class WallSign extends SignPost{
}
public function onUpdate($type){
$faces = [
2 => 3,
3 => 2,
4 => 5,
5 => 4,
];
if($type === Level::BLOCK_UPDATE_NORMAL){
if(isset($faces[$this->meta])) {
if ($this->getSide($faces[$this->meta])->getId() === self::AIR) {
$this->getLevel()->useBreakOn($this);
}
return Level::BLOCK_UPDATE_NORMAL;
}
}
return false;
}
}

View File

@ -21,9 +21,9 @@
namespace pocketmine\block;
use pocketmine\entity\Entity;
use pocketmine\item\Item;
use pocketmine\item\Tool;
use pocketmine\level\Level;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Vector3;