This commit is contained in:
Shoghi Cervantes 2015-03-20 16:42:50 +01:00
parent a2b3e48b45
commit b42424eb22
10 changed files with 292 additions and 11 deletions

View File

@ -166,7 +166,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
protected $forceMovement = null;
protected $connected = true;
protected $ip;
protected $removeFormat = false;
protected $removeFormat = true;
protected $port;
protected $username;
protected $iusername;
@ -2397,9 +2397,6 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
* @param string $message
*/
public function sendMessage($message){
if($this->removeFormat !== false){
$message = TextFormat::clean($message);
}
$mes = explode("\n", $message);
foreach($mes as $m){
if($m !== ""){
@ -2412,13 +2409,6 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
}
public function sendTranslation($message, array $parameters = []){
if($this->removeFormat !== false){
$message = TextFormat::clean($message);
foreach($parameters as $k => $v){
$parameters[$k] = TextFormat::clean($v);
}
}
$pk = new TextPacket();
$pk->type = TextPacket::TYPE_TRANSLATION;
$pk->message = $message;

View File

@ -97,6 +97,7 @@ use pocketmine\utils\Random;
use pocketmine\utils\ReversePriorityQueue;
use pocketmine\utils\TextFormat;
use pocketmine\level\particle\Particle;
use pocketmine\level\sound\Sound;
use pocketmine\level\particle\DestroyBlockParticle;
#include <rules/Level.h>
@ -368,6 +369,24 @@ class Level implements ChunkManager, Metadatable{
$this->temporalPosition = null;
}
public function addSound(Sound $sound, array $players = null){
$pk = $sound->encode();
if($players === null){
$players = $this->getUsingChunk($sound->x >> 4, $sound->z >> 4);
}
if($pk !== null){
if(!is_array($pk)){
Server::broadcastPacket($players, $pk);
}else{
foreach($pk as $p){
Server::broadcastPacket($players, $p);
}
}
}
}
public function addParticle(Particle $particle, array $players = null){
$pk = $particle->encode();

View File

@ -0,0 +1,30 @@
<?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\level\sound;
use pocketmine\math\Vector3;
class BatSound extends GenericSound{
public function __construct(Vector3 $pos, $pitch = 0){
parent::__construct($pos, 1015, $pitch);
}
}

View File

@ -0,0 +1,30 @@
<?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\level\sound;
use pocketmine\math\Vector3;
class ClickSound extends GenericSound{
public function __construct(Vector3 $pos, $pitch = 0){
parent::__construct($pos, 1000, $pitch);
}
}

View File

@ -0,0 +1,30 @@
<?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\level\sound;
use pocketmine\math\Vector3;
class DoorSound extends GenericSound{
public function __construct(Vector3 $pos, $pitch = 0){
parent::__construct($pos, 1003, $pitch);
}
}

View File

@ -0,0 +1,30 @@
<?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\level\sound;
use pocketmine\math\Vector3;
class FizzSound extends GenericSound{
public function __construct(Vector3 $pos, $pitch = 0){
parent::__construct($pos, 1004, $pitch);
}
}

View File

@ -0,0 +1,58 @@
<?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\level\sound;
use pocketmine\math\Vector3;
use pocketmine\network\protocol\LevelEventPacket;
class GenericSound extends Sound{
public function __construct(Vector3 $pos, $id, $pitch = 0){
parent::__construct($pos->x, $pos->y, $pos->z);
$this->id = (int) $id;
$this->pitch = (float) $pitch * 1000;
}
protected $pitch = 0;
protected $id;
public function getPitch(){
return $this->pitch / 1000;
}
public function setPitch($pitch){
$this->pitch = (float) $pitch * 1000;
}
public function encode(){
$pk = new LevelEventPacket;
$pk->evid = $this->id;
$pk->x = $this->x;
$pk->y = $this->y;
$pk->z = $this->z;
$pk->data = (int) $this->pitch;
return $pk;
}
}

View File

@ -0,0 +1,30 @@
<?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\level\sound;
use pocketmine\math\Vector3;
class LaunchSound extends GenericSound{
public function __construct(Vector3 $pos, $pitch = 0){
parent::__construct($pos, 1002, $pitch);
}
}

View File

@ -0,0 +1,30 @@
<?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\level\sound;
use pocketmine\math\Vector3;
class PopSound extends GenericSound{
public function __construct(Vector3 $pos, $pitch = 0){
parent::__construct($pos, 1001, $pitch);
}
}

View File

@ -0,0 +1,34 @@
<?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\level\sound;
use pocketmine\math\Vector3;
use pocketmine\network\protocol\DataPacket;
abstract class Sound extends Vector3{
/**
* @return DataPacket|DataPacket[]
*/
abstract public function encode();
}