Merge branch 'master' into mcpe-1.2

This commit is contained in:
Dylan K. Taylor 2017-08-28 18:02:09 +01:00
commit b5d2402c9b
20 changed files with 53 additions and 63 deletions

View File

@ -1694,7 +1694,10 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
if($this->spawned){
$this->processMovement($tickDiff);
Timings::$timerEntityBaseTick->startTiming();
$this->entityBaseTick($tickDiff);
Timings::$timerEntityBaseTick->stopTiming();
if(!$this->isSpectator() and $this->isAlive()){
$this->checkNearEntities($tickDiff);

View File

@ -375,7 +375,11 @@ class BlockFactory{
}
try{
$block = clone self::$fullList[($id << 4) | $meta];
if(self::$fullList !== null){
$block = clone self::$fullList[($id << 4) | $meta];
}else{
$block = new UnknownBlock($id, $meta);
}
}catch(\RuntimeException $e){
throw new \InvalidArgumentException("Block ID $id is out of bounds");
}

View File

@ -43,7 +43,7 @@ class Dandelion extends Flowable{
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $facePos, Player $player = null) : bool{
$down = $this->getSide(Vector3::SIDE_DOWN);
if($down->getId() === 2 or $down->getId() === 3 or $down->getId() === 60){
if($down->getId() === Block::GRASS or $down->getId() === Block::DIRT or $down->getId() === Block::FARMLAND){
$this->getLevel()->setBlock($blockReplace, $this, true, true);
return true;

View File

@ -86,11 +86,11 @@ class VersionCommand extends VanillaCommand{
$desc = $plugin->getDescription();
$sender->sendMessage(TextFormat::DARK_GREEN . $desc->getName() . TextFormat::WHITE . " version " . TextFormat::DARK_GREEN . $desc->getVersion());
if($desc->getDescription() != null){
if($desc->getDescription() !== ""){
$sender->sendMessage($desc->getDescription());
}
if($desc->getWebsite() != null){
if($desc->getWebsite() !== ""){
$sender->sendMessage("Website: " . $desc->getWebsite());
}

View File

@ -26,7 +26,7 @@ namespace pocketmine\item;
abstract class Armor extends Item{
public function getMaxStackSize(){
public function getMaxStackSize() : int{
return 1;
}
}

View File

@ -32,7 +32,7 @@ class Bed extends Item{
parent::__construct(self::BED, $meta, "Bed");
}
public function getMaxStackSize(){
public function getMaxStackSize() : int{
return 1;
}
}

View File

@ -29,7 +29,7 @@ class BeetrootSoup extends Food{
parent::__construct(self::BEETROOT_SOUP, $meta, "Beetroot Soup");
}
public function getMaxStackSize(){
public function getMaxStackSize() : int{
return 1;
}

View File

@ -51,6 +51,7 @@ class Bow extends Tool{
public function onReleaseUsing(Player $player) : bool{
if($player->isSurvival() and !$player->getInventory()->contains(ItemFactory::get(Item::ARROW, 0, 1))){
$player->getInventory()->sendContents($player);
return false;
}
$nbt = new CompoundTag("", [

View File

@ -37,7 +37,7 @@ class Bucket extends Item{
parent::__construct(self::BUCKET, $meta, "Bucket");
}
public function getMaxStackSize(){
public function getMaxStackSize() : int{
return 1;
}

View File

@ -32,7 +32,7 @@ class Cake extends Item{
parent::__construct(self::CAKE, $meta, "Cake");
}
public function getMaxStackSize(){
public function getMaxStackSize() : int{
return 1;
}
}

View File

@ -32,7 +32,7 @@ class IronDoor extends Item{
parent::__construct(self::IRON_DOOR, $meta, "Iron Door");
}
public function getMaxStackSize(){
public function getMaxStackSize() : int{
return 1;
}
}

View File

@ -738,7 +738,7 @@ class Item implements ItemIds, \JsonSerializable{
* Returns the highest amount of this item which will fit into one inventory slot.
* @return int
*/
public function getMaxStackSize(){
public function getMaxStackSize() : int{
return 64;
}

View File

@ -28,7 +28,7 @@ class MushroomStew extends Food{
parent::__construct(self::MUSHROOM_STEW, $meta, "Mushroom Stew");
}
public function getMaxStackSize(){
public function getMaxStackSize() : int{
return 1;
}

View File

@ -32,7 +32,7 @@ class Sign extends Item{
parent::__construct(self::SIGN, $meta, "Sign");
}
public function getMaxStackSize(){
public function getMaxStackSize() : int{
return 16;
}
}

View File

@ -29,7 +29,7 @@ class Snowball extends Item{
parent::__construct(self::SNOWBALL, $meta, "Snowball");
}
public function getMaxStackSize(){
public function getMaxStackSize() : int{
return 16;
}

View File

@ -40,7 +40,7 @@ abstract class Tool extends Item{
const TYPE_AXE = 4;
const TYPE_SHEARS = 5;
public function getMaxStackSize(){
public function getMaxStackSize() : int{
return 1;
}

View File

@ -32,7 +32,7 @@ class WoodenDoor extends Item{
parent::__construct(self::WOODEN_DOOR, $meta, "Wooden Door");
}
public function getMaxStackSize(){
public function getMaxStackSize() : int{
return 1;
}
}

View File

@ -407,49 +407,31 @@ class Level implements ChunkManager, Metadatable{
public function addSound(Sound $sound, array $players = null){
$pk = $sound->encode();
if(!is_array($pk)){
$pk = [$pk];
}
if($players === null){
if($pk !== null){
if(!is_array($pk)){
$this->addChunkPacket($sound->x >> 4, $sound->z >> 4, $pk);
}else{
foreach($pk as $e){
$this->addChunkPacket($sound->x >> 4, $sound->z >> 4, $e);
}
}
foreach($pk as $e){
$this->addChunkPacket($sound->x >> 4, $sound->z >> 4, $e);
}
}else{
if($pk !== null){
if(!is_array($pk)){
$this->server->broadcastPacket($players, $pk);
}else{
$this->server->batchPackets($players, $pk, false);
}
}
$this->server->batchPackets($players, $pk, false);
}
}
public function addParticle(Particle $particle, array $players = null){
$pk = $particle->encode();
if(!is_array($pk)){
$pk = [$pk];
}
if($players === null){
if($pk !== null){
if(!is_array($pk)){
$this->addChunkPacket($particle->x >> 4, $particle->z >> 4, $pk);
}else{
foreach($pk as $e){
$this->addChunkPacket($particle->x >> 4, $particle->z >> 4, $e);
}
}
foreach($pk as $e){
$this->addChunkPacket($particle->x >> 4, $particle->z >> 4, $e);
}
}else{
if($pk !== null){
if(!is_array($pk)){
$this->server->broadcastPacket($players, $pk);
}else{
$this->server->batchPackets($players, $pk, false);
}
}
$this->server->batchPackets($players, $pk, false);
}
}
@ -1637,10 +1619,8 @@ class Level implements ChunkManager, Metadatable{
}
$above = $this->getBlock(new Vector3($target->x, $target->y + 1, $target->z));
if($above !== null){
if($above->getId() === Item::FIRE){
$this->setBlock($above, BlockFactory::get(Block::AIR), true);
}
if($above->getId() === Item::FIRE){
$this->setBlock($above, BlockFactory::get(Block::AIR), true);
}
if($createParticles){

View File

@ -101,9 +101,9 @@ class BanList{
*/
public function addBan(string $target, string $reason = null, \DateTime $expires = null, string $source = null) : BanEntry{
$entry = new BanEntry($target);
$entry->setSource($source != null ? $source : $entry->getSource());
$entry->setSource($source ?? $entry->getSource());
$entry->setExpires($expires);
$entry->setReason($reason != null ? $reason : $entry->getReason());
$entry->setReason($reason ?? $entry->getReason());
$this->list[$entry->getName()] = $entry;
$this->save();

View File

@ -31,11 +31,7 @@ use pocketmine\Player;
abstract class Spawnable extends Tile{
public function spawnTo(Player $player){
if($this->closed){
return false;
}
public function createSpawnPacket() : BlockEntityDataPacket{
$nbt = new NBT(NBT::LITTLE_ENDIAN);
$nbt->setData($this->getSpawnCompound());
$pk = new BlockEntityDataPacket();
@ -43,7 +39,16 @@ abstract class Spawnable extends Tile{
$pk->y = $this->y;
$pk->z = $this->z;
$pk->namedtag = $nbt->write(true);
$player->dataPacket($pk);
return $pk;
}
public function spawnTo(Player $player){
if($this->closed){
return false;
}
$player->dataPacket($this->createSpawnPacket());
return true;
}
@ -58,11 +63,8 @@ abstract class Spawnable extends Tile{
return;
}
foreach($this->getLevel()->getChunkPlayers($this->chunk->getX(), $this->chunk->getZ()) as $player){
if($player->spawned === true){
$this->spawnTo($player);
}
}
$pk = $this->createSpawnPacket();
$this->level->addChunkPacket($this->chunk->getX(), $this->chunk->getZ(), $pk);
}
protected function onChanged(){