PocketMine-MP  1.4 - API 1.10.0
 All Classes Namespaces Functions Variables Pages
item/Painting.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 
22 namespace pocketmine\item;
23 
27 
28 
29 class Painting extends Item{
30  public function __construct($meta = 0, $count = 1){
31  parent::__construct(self::PAINTING, 0, $count, "Painting");
32  }
33 
34  public function canBeActivated(){
35  return true;
36  }
37 
38  public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
39  if($target->isTransparent() === false and $face > 1 and $block->isSolid() === false){
40  $faces = [
41  2 => 1,
42  3 => 3,
43  4 => 0,
44  5 => 2,
45 
46  ];
47  $motives = [
48  // Motive Width Height
49  ["Kebab", 1, 1],
50  ["Aztec", 1, 1],
51  ["Alban", 1, 1],
52  ["Aztec2", 1, 1],
53  ["Bomb", 1, 1],
54  ["Plant", 1, 1],
55  ["Wasteland", 1, 1],
56  ["Wanderer", 1, 2],
57  ["Graham", 1, 2],
58  ["Pool", 2, 1],
59  ["Courbet", 2, 1],
60  ["Sunset", 2, 1],
61  ["Sea", 2, 1],
62  ["Creebet", 2, 1],
63  ["Match", 2, 2],
64  ["Bust", 2, 2],
65  ["Stage", 2, 2],
66  ["Void", 2, 2],
67  ["SkullAndRoses", 2, 2],
68  //array("Wither", 2, 2),
69  ["Fighters", 4, 2],
70  ["Skeleton", 4, 3],
71  ["DonkeyKong", 4, 3],
72  ["Pointer", 4, 4],
73  ["Pigscene", 4, 4],
74  ["Flaming Skull", 4, 4],
75  ];
76  $motive = $motives[mt_rand(0, count($motives) - 1)];
77  $data = [
78  "x" => $target->x,
79  "y" => $target->y,
80  "z" => $target->z,
81  "yaw" => $faces[$face] * 90,
82  "Motive" => $motive[0],
83  ];
84  //TODO
85  //$e = $server->api->entity->add($level, ENTITY_OBJECT, OBJECT_PAINTING, $data);
86  //$e->spawnToAll();
87  /*if(($player->gamemode & 0x01) === 0x00){
88  $player->removeItem(Item::get($this->getId(), $this->getDamage(), 1));
89  }*/
90 
91  return true;
92  }
93 
94  return false;
95  }
96 
97 }