mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-16 18:59:00 +00:00
Added some extra tile entities, fake enchanting table
This commit is contained in:
parent
cba9ff393c
commit
d1bfb304cb
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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 [];
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
96
src/pocketmine/block/EnchantingTable.php
Normal file
96
src/pocketmine/block/EnchantingTable.php
Normal file
@ -0,0 +1,96 @@
|
||||
<?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\NBT;
|
||||
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)
|
||||
]);
|
||||
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 [];
|
||||
}
|
||||
}
|
||||
}
|
47
src/pocketmine/inventory/EnchantInventory.php
Normal file
47
src/pocketmine/inventory/EnchantInventory.php
Normal 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\inventory;
|
||||
|
||||
use pocketmine\level\Position;
|
||||
use pocketmine\Player;
|
||||
|
||||
class EnchantInventory extends ContainerInventory{
|
||||
public function __construct(Position $pos){
|
||||
parent::__construct(new FakeBlockMenu($this, $pos), InventoryType::get(InventoryType::ENCHANT_TABLE));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return FakeBlockMenu
|
||||
*/
|
||||
public function getHolder(){
|
||||
return $this->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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
38
src/pocketmine/tile/EnchantTable.php
Normal file
38
src/pocketmine/tile/EnchantTable.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?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\tile;
|
||||
|
||||
use pocketmine\nbt\tag\Compound;
|
||||
use pocketmine\nbt\tag\Int;
|
||||
use pocketmine\nbt\tag\String;
|
||||
|
||||
class EnchantTable extends Spawnable{
|
||||
|
||||
public function getSpawnCompound(){
|
||||
return new Compound("", [
|
||||
new String("id", Tile::ENCHANT_TABLE),
|
||||
new Int("x", (int) $this->x),
|
||||
new Int("y", (int) $this->y),
|
||||
new Int("z", (int) $this->z)
|
||||
]);
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user