PocketMine-MP 5.18.1 git-9381fc4172e5dce4cada1cb356050c8a2ab57b94
EnderChest.php
1<?php
2
3/*
4 *
5 * ____ _ _ __ __ _ __ __ ____
6 * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
7 * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
8 * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
9 * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
10 *
11 * This program is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * @author PocketMine Team
17 * @link http://www.pocketmine.net/
18 *
19 *
20 */
21
22declare(strict_types=1);
23
24namespace pocketmine\block;
25
27use pocketmine\block\tile\EnderChest as TileEnderChest;
28use pocketmine\block\utils\FacesOppositePlacingPlayerTrait;
29use pocketmine\block\utils\SupportType;
35
36class EnderChest extends Transparent{
37 use FacesOppositePlacingPlayerTrait;
38
39 public function getLightLevel() : int{
40 return 7;
41 }
42
46 protected function recalculateCollisionBoxes() : array{
47 //these are slightly bigger than in PC
48 return [AxisAlignedBB::one()->contract(0.025, 0, 0.025)->trim(Facing::UP, 0.05)];
49 }
50
51 public function getSupportType(int $facing) : SupportType{
52 return SupportType::NONE;
53 }
54
55 public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{
56 if($player instanceof Player){
57 $enderChest = $this->position->getWorld()->getTile($this->position);
58 if($enderChest instanceof TileEnderChest && $this->getSide(Facing::UP)->isTransparent()){
59 $enderChest->setViewerCount($enderChest->getViewerCount() + 1);
60 $player->setCurrentWindow(new EnderChestInventory($this->position, $player->getEnderInventory()));
61 }
62 }
63
64 return true;
65 }
66
67 public function getDropsForCompatibleTool(Item $item) : array{
68 return [
69 VanillaBlocks::OBSIDIAN()->asItem()->setCount(8)
70 ];
71 }
72
73 public function isAffectedBySilkTouch() : bool{
74 return true;
75 }
76}
getDropsForCompatibleTool(Item $item)
Definition: EnderChest.php:67
onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player=null, array &$returnedItems=[])
Definition: EnderChest.php:55