mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-15 18:29:46 +00:00
Sounds!
This commit is contained in:
parent
a2b3e48b45
commit
b42424eb22
@ -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;
|
||||
|
@ -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();
|
||||
|
||||
|
30
src/pocketmine/level/sound/BatSound.php
Normal file
30
src/pocketmine/level/sound/BatSound.php
Normal 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);
|
||||
}
|
||||
}
|
30
src/pocketmine/level/sound/ClickSound.php
Normal file
30
src/pocketmine/level/sound/ClickSound.php
Normal 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);
|
||||
}
|
||||
}
|
30
src/pocketmine/level/sound/DoorSound.php
Normal file
30
src/pocketmine/level/sound/DoorSound.php
Normal 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);
|
||||
}
|
||||
}
|
30
src/pocketmine/level/sound/FizzSound.php
Normal file
30
src/pocketmine/level/sound/FizzSound.php
Normal 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);
|
||||
}
|
||||
}
|
58
src/pocketmine/level/sound/GenericSound.php
Normal file
58
src/pocketmine/level/sound/GenericSound.php
Normal 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;
|
||||
}
|
||||
|
||||
}
|
30
src/pocketmine/level/sound/LaunchSound.php
Normal file
30
src/pocketmine/level/sound/LaunchSound.php
Normal 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);
|
||||
}
|
||||
}
|
30
src/pocketmine/level/sound/PopSound.php
Normal file
30
src/pocketmine/level/sound/PopSound.php
Normal 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);
|
||||
}
|
||||
}
|
34
src/pocketmine/level/sound/Sound.php
Normal file
34
src/pocketmine/level/sound/Sound.php
Normal 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();
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user