diff --git a/src/pocketmine/Server.php b/src/pocketmine/Server.php index 9975a8937..38075cfc6 100644 --- a/src/pocketmine/Server.php +++ b/src/pocketmine/Server.php @@ -101,6 +101,7 @@ use pocketmine\scheduler\FileWriteTask; use pocketmine\scheduler\SendUsageTask; use pocketmine\scheduler\ServerScheduler; use pocketmine\tile\Chest; +use pocketmine\tile\EnchantTable; use pocketmine\tile\Furnace; use pocketmine\tile\Sign; use pocketmine\tile\Tile; @@ -2572,6 +2573,7 @@ class Server{ Tile::registerTile(Chest::class); Tile::registerTile(Furnace::class); Tile::registerTile(Sign::class); + Tile::registerTile(EnchantTable::class); } } diff --git a/src/pocketmine/block/Anvil.php b/src/pocketmine/block/Anvil.php index 3560bb99c..4c3114bd4 100644 --- a/src/pocketmine/block/Anvil.php +++ b/src/pocketmine/block/Anvil.php @@ -24,15 +24,7 @@ namespace pocketmine\block; use pocketmine\inventory\AnvilInventory; 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 Anvil extends Fallable{ @@ -79,8 +71,12 @@ class Anvil extends Fallable{ } public function getDrops(Item $item){ - return [ - [$this->id, 0, 1], //TODO break level - ]; + if($item->isPickaxe() >= 1){ + return [ + [$this->id, 0, 1], //TODO break level + ]; + }else{ + return []; + } } } \ No newline at end of file diff --git a/src/pocketmine/block/Block.php b/src/pocketmine/block/Block.php index 4d3bfda3c..b694fff54 100644 --- a/src/pocketmine/block/Block.php +++ b/src/pocketmine/block/Block.php @@ -185,6 +185,10 @@ class Block extends Position implements Metadatable{ const NETHER_BRICKS_STAIRS = 114; + const ENCHANTING_TABLE = 116; + const ENCHANT_TABLE = 116; + const ENCHANTMENT_TABLE = 116; + const END_PORTAL_FRAME = 120; const END_STONE = 121; @@ -413,6 +417,8 @@ class Block extends Position implements Metadatable{ self::$list[self::NETHER_BRICKS_STAIRS] = NetherBrickStairs::class; + self::$list[self::ENCHANTING_TABLE] = EnchantingTable::class; + self::$list[self::END_PORTAL_FRAME] = EndPortalFrame::class; self::$list[self::END_STONE] = EndStone::class; self::$list[self::SANDSTONE_STAIRS] = SandstoneStairs::class; diff --git a/src/pocketmine/block/EnchantingTable.php b/src/pocketmine/block/EnchantingTable.php new file mode 100644 index 000000000..b9ede2372 --- /dev/null +++ b/src/pocketmine/block/EnchantingTable.php @@ -0,0 +1,96 @@ +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) + ]); + 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){ + if($player->isCreative()){ + return true; + } + + $player->addWindow(new EnchantInventory($this)); + } + + return true; + } + + public function getDrops(Item $item){ + if($item->isPickaxe() >= 1){ + return [ + [$this->id, 0, 1], + ]; + }else{ + return []; + } + } +} \ No newline at end of file diff --git a/src/pocketmine/inventory/EnchantInventory.php b/src/pocketmine/inventory/EnchantInventory.php new file mode 100644 index 000000000..39f21b570 --- /dev/null +++ b/src/pocketmine/inventory/EnchantInventory.php @@ -0,0 +1,47 @@ +holder; + } + + public function onClose(Player $who){ + parent::onClose($who); + + for($i = 0; $i < 2; ++$i){ + $this->getHolder()->getLevel()->dropItem($this->getHolder()->add(0.5, 0.5, 0.5), $this->getItem($i)); + $this->clear($i); + } + } +} \ No newline at end of file diff --git a/src/pocketmine/inventory/InventoryType.php b/src/pocketmine/inventory/InventoryType.php index 7fd05d5a9..046a6464f 100644 --- a/src/pocketmine/inventory/InventoryType.php +++ b/src/pocketmine/inventory/InventoryType.php @@ -63,7 +63,7 @@ class InventoryType{ static::$default[static::CRAFTING] = new InventoryType(5, "Crafting", 1); //4 CRAFTING slots, 1 RESULT static::$default[static::WORKBENCH] = new InventoryType(10, "Crafting", 1); //9 CRAFTING slots, 1 RESULT static::$default[static::STONECUTTER] = new InventoryType(10, "Crafting", 1); //9 CRAFTING slots, 1 RESULT - static::$default[static::ENCHANT_TABLE] = new InventoryType(1, "Enchant", 4); //1 INPUT/OUTPUT + static::$default[static::ENCHANT_TABLE] = new InventoryType(2, "Enchant", 4); //1 INPUT/OUTPUT, 1 LAPIS static::$default[static::BREWING_STAND] = new InventoryType(4, "Brewing", 5); //1 INPUT, 3 POTION static::$default[static::ANVIL] = new InventoryType(3, "Anvil", 6); //2 INPUT, 1 OUTPUT } diff --git a/src/pocketmine/item/Item.php b/src/pocketmine/item/Item.php index 8bac60688..b51b2abfb 100644 --- a/src/pocketmine/item/Item.php +++ b/src/pocketmine/item/Item.php @@ -209,6 +209,10 @@ class Item{ const NETHER_BRICKS_STAIRS = 114; + const ENCHANTING_TABLE = 116; + const ENCHANT_TABLE = 116; + const ENCHANTMENT_TABLE = 116; + const END_PORTAL = 120; const END_STONE = 121; diff --git a/src/pocketmine/tile/EnchantTable.php b/src/pocketmine/tile/EnchantTable.php new file mode 100644 index 000000000..1a9fa9cc5 --- /dev/null +++ b/src/pocketmine/tile/EnchantTable.php @@ -0,0 +1,38 @@ +x), + new Int("y", (int) $this->y), + new Int("z", (int) $this->z) + ]); + } +} diff --git a/src/pocketmine/tile/Tile.php b/src/pocketmine/tile/Tile.php index 32252094e..d3ad814f1 100644 --- a/src/pocketmine/tile/Tile.php +++ b/src/pocketmine/tile/Tile.php @@ -39,6 +39,11 @@ abstract class Tile extends Position{ const SIGN = "Sign"; const CHEST = "Chest"; const FURNACE = "Furnace"; + const FLOWER_POT = "FlowerPot"; + const MOB_SPAWNER = "MobSpawner"; + const SKULL = "Skull"; + const BREWING_STAND = "Cauldron"; + const ENCHANT_TABLE = "EnchantTable"; public static $tileCount = 1;