Пример #1
0
 public function onCommand(CommandSender $sender, Command $command, $label, array $args)
 {
     switch (strtolower($command->getName())) {
         case "sit":
             if (!$sender instanceof Player) {
                 $sender->sendMessage("ゲーム内で実行して下さい。");
                 break;
             }
             if ($sender->isSleeping()) {
                 //対策...
                 $sender->stopSleep();
             }
             $this->closeOldChair($sender);
             $x = $sender->getX();
             $y = $sender->getY();
             $z = $sender->getZ();
             if ($sender->getLevel()->getBlock($sender->getSide(Vector3::SIDE_DOWN)) instanceof Stair) {
                 $x = (int) $x + 0.5;
                 $y = (int) $y - 1 + 0.2;
                 $z = (int) $z + 0.5;
             } else {
                 $y -= 0.2;
                 //$y = ((int) $y) - 0.25;
             }
             $entity = Entity::createEntity("Chair", $sender->chunk, new Compound("", ["Pos" => new Enum("Pos", [new Double("", $x), new Double("", $y), new Double("", $z)]), "Motion" => new Enum("Motion", [new Double("", 0), new Double("", 0), new Double("", 0)]), "Rotation" => new Enum("Rotation", [new Float("", 0), new Float("", 0)])]));
             $entity->spawnToAll();
             $entity->sitEntity($sender);
             $sender->sendTip("ジャンプすることで立ち上がれます");
             $this->usedChairs[$sender->getName()] = $entity;
             break;
     }
     return true;
 }