PocketMine-MP 5.32.2 git-237b304ef9858756b018e44e8f298093f66f823b
Loading...
Searching...
No Matches
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;
30use pocketmine\block\utils\SupportType;
36
37class EnderChest extends Transparent implements HorizontalFacing{
38 use FacesOppositePlacingPlayerTrait;
39
40 public function getLightLevel() : int{
41 return 7;
42 }
43
44 protected function recalculateCollisionBoxes() : array{
45 //these are slightly bigger than in PC
46 return [AxisAlignedBB::one()->contract(0.025, 0, 0.025)->trim(Facing::UP, 0.05)];
47 }
48
49 public function getSupportType(int $facing) : SupportType{
50 return SupportType::NONE;
51 }
52
53 public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{
54 if($player instanceof Player){
55 $enderChest = $this->position->getWorld()->getTile($this->position);
56 if($enderChest instanceof TileEnderChest && $this->getSide(Facing::UP)->isTransparent()){
57 $enderChest->setViewerCount($enderChest->getViewerCount() + 1);
58 $player->setCurrentWindow(new EnderChestInventory($this->position, $player->getEnderInventory()));
59 }
60 }
61
62 return true;
63 }
64
65 public function getDropsForCompatibleTool(Item $item) : array{
66 return [
67 VanillaBlocks::OBSIDIAN()->asItem()->setCount(8)
68 ];
69 }
70
71 public function isAffectedBySilkTouch() : bool{
72 return true;
73 }
74}
getDropsForCompatibleTool(Item $item)
onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player=null, array &$returnedItems=[])