mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 08:17:34 +00:00
Merge branch 'stable' into next-minor
This commit is contained in:
commit
8c0d441a13
@ -1397,7 +1397,7 @@ class Server{
|
||||
Network::$BATCH_THRESHOLD = -1;
|
||||
}
|
||||
|
||||
$this->networkCompressionLevel = $this->getProperty("network.compression-level", 7);
|
||||
$this->networkCompressionLevel = (int) $this->getProperty("network.compression-level", 7);
|
||||
if($this->networkCompressionLevel < 1 or $this->networkCompressionLevel > 9){
|
||||
$this->logger->warning("Invalid network compression level $this->networkCompressionLevel set, setting to default 7");
|
||||
$this->networkCompressionLevel = 7;
|
||||
|
@ -23,6 +23,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\ItemFactory;
|
||||
use pocketmine\item\ItemIds;
|
||||
use function mt_rand;
|
||||
|
||||
class CocoaBlock extends Transparent{
|
||||
|
||||
protected $id = self::COCOA_BLOCK;
|
||||
@ -48,4 +53,14 @@ class CocoaBlock extends Transparent{
|
||||
public function isAffectedBySilkTouch() : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [
|
||||
ItemFactory::get(ItemIds::DYE, 3, ($this->meta >> 2) === 2 ? mt_rand(2, 3) : 1)
|
||||
];
|
||||
}
|
||||
|
||||
public function getPickedItem() : Item{
|
||||
return ItemFactory::get(ItemIds::DYE, 3);
|
||||
}
|
||||
}
|
||||
|
@ -1931,7 +1931,12 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
|
||||
}
|
||||
|
||||
public function spawnTo(Player $player) : void{
|
||||
if(!isset($this->hasSpawned[$player->getLoaderId()]) and $this->chunk !== null and isset($player->usedChunks[Level::chunkHash($this->chunk->getX(), $this->chunk->getZ())])){
|
||||
if(
|
||||
!isset($this->hasSpawned[$player->getLoaderId()]) and
|
||||
$this->chunk !== null and
|
||||
isset($player->usedChunks[$chunkHash = Level::chunkHash($this->chunk->getX(), $this->chunk->getZ())]) and
|
||||
$player->usedChunks[$chunkHash] === true
|
||||
){
|
||||
$this->hasSpawned[$player->getLoaderId()] = $player;
|
||||
|
||||
$this->sendSpawnPacket($player);
|
||||
|
@ -1909,7 +1909,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
|
||||
if($player !== null){
|
||||
$ev = new BlockPlaceEvent($player, $hand, $blockReplace, $blockClicked, $item);
|
||||
if($this->checkSpawnProtection($player, $blockClicked)){
|
||||
if($this->checkSpawnProtection($player, $blockReplace)){
|
||||
$ev->setCancelled();
|
||||
}
|
||||
|
||||
|
@ -34,17 +34,26 @@ abstract class LightUpdate{
|
||||
/** @var ChunkManager */
|
||||
protected $level;
|
||||
|
||||
/** @var int[][] blockhash => [x, y, z, new light level] */
|
||||
/**
|
||||
* @var int[][] blockhash => [x, y, z, new light level]
|
||||
* @phpstan-var array<int, array{int, int, int, int}>
|
||||
*/
|
||||
protected $updateNodes = [];
|
||||
|
||||
/** @var \SplQueue */
|
||||
protected $spreadQueue;
|
||||
/** @var bool[] */
|
||||
/**
|
||||
* @var true[]
|
||||
* @phpstan-var array<int, true>
|
||||
*/
|
||||
protected $spreadVisited = [];
|
||||
|
||||
/** @var \SplQueue */
|
||||
protected $removalQueue;
|
||||
/** @var bool[] */
|
||||
/**
|
||||
* @var true[]
|
||||
* @phpstan-var array<int, true>
|
||||
*/
|
||||
protected $removalVisited = [];
|
||||
/** @var SubChunkIteratorManager */
|
||||
protected $subChunkHandler;
|
||||
|
@ -28,6 +28,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\protocol\types\DeviceOS;
|
||||
use pocketmine\network\mcpe\protocol\types\EntityLink;
|
||||
use pocketmine\utils\UUID;
|
||||
use function count;
|
||||
@ -84,7 +85,7 @@ class AddPlayerPacket extends DataPacket{
|
||||
/** @var string */
|
||||
public $deviceId = ""; //TODO: fill player's device ID (???)
|
||||
/** @var int */
|
||||
public $buildPlatform = -1;
|
||||
public $buildPlatform = DeviceOS::UNKNOWN;
|
||||
|
||||
protected function decodePayload(){
|
||||
$this->uuid = $this->getUUID();
|
||||
|
44
src/pocketmine/network/mcpe/protocol/types/DeviceOS.php
Normal file
44
src/pocketmine/network/mcpe/protocol/types/DeviceOS.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol\types;
|
||||
|
||||
final class DeviceOS{
|
||||
|
||||
public const UNKNOWN = -1;
|
||||
public const ANDROID = 1;
|
||||
public const IOS = 2;
|
||||
public const OSX = 3;
|
||||
public const AMAZON = 4;
|
||||
public const GEAR_VR = 5;
|
||||
public const HOLOLENS = 6;
|
||||
public const WINDOWS_10 = 7;
|
||||
public const WIN32 = 8;
|
||||
public const DEDICATED = 9;
|
||||
public const TVOS = 10;
|
||||
public const PLAYSTATION = 11;
|
||||
public const NINTENDO = 12;
|
||||
public const XBOX = 13;
|
||||
public const WINDOWS_PHONE = 14;
|
||||
|
||||
}
|
@ -40,7 +40,7 @@ class PlayerListEntry{
|
||||
/** @var string */
|
||||
public $platformChatId = "";
|
||||
/** @var int */
|
||||
public $buildPlatform = -1;
|
||||
public $buildPlatform = DeviceOS::UNKNOWN;
|
||||
/** @var bool */
|
||||
public $isTeacher = false;
|
||||
/** @var bool */
|
||||
|
@ -49,11 +49,11 @@ class SkinImage{
|
||||
public static function fromLegacy(string $data) : SkinImage{
|
||||
switch(strlen($data)){
|
||||
case 64 * 32 * 4:
|
||||
return new self(64, 32, $data);
|
||||
return new self(32, 64, $data);
|
||||
case 64 * 64 * 4:
|
||||
return new self(64, 64, $data);
|
||||
case 128 * 64 * 4:
|
||||
return new self(128, 64, $data);
|
||||
return new self(64, 128, $data);
|
||||
case 128 * 128 * 4:
|
||||
return new self(128, 128, $data);
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ class PermissionManager{
|
||||
$this->defaultPerms[$permission->getName()] = $permission;
|
||||
$this->dirtyPermissibles(false);
|
||||
}
|
||||
Timings::$permissionDefaultTimer->startTiming();
|
||||
Timings::$permissionDefaultTimer->stopTiming();
|
||||
}
|
||||
|
||||
private function dirtyPermissibles(bool $op) : void{
|
||||
|
@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
namespace pocketmine\resourcepacks;
|
||||
|
||||
use Ahc\Json\Comment as CommentedJsonDecoder;
|
||||
use function assert;
|
||||
use function count;
|
||||
use function fclose;
|
||||
use function feof;
|
||||
@ -35,6 +36,8 @@ use function fseek;
|
||||
use function gettype;
|
||||
use function hash_file;
|
||||
use function implode;
|
||||
use function preg_match;
|
||||
use function strlen;
|
||||
|
||||
class ZippedResourcePack implements ResourcePack{
|
||||
|
||||
@ -85,7 +88,22 @@ class ZippedResourcePack implements ResourcePack{
|
||||
}
|
||||
|
||||
if(($manifestData = $archive->getFromName("manifest.json")) === false){
|
||||
if($archive->locateName("pack_manifest.json") !== false){
|
||||
$manifestPath = null;
|
||||
$manifestIdx = null;
|
||||
for($i = 0; $i < $archive->numFiles; ++$i){
|
||||
$name = $archive->getNameIndex($i);
|
||||
if(
|
||||
($manifestPath === null or strlen($name) < strlen($manifestPath)) and
|
||||
preg_match('#.*/manifest.json$#', $name) === 1
|
||||
){
|
||||
$manifestPath = $name;
|
||||
$manifestIdx = $i;
|
||||
}
|
||||
}
|
||||
if($manifestIdx !== null){
|
||||
$manifestData = $archive->getFromIndex($manifestIdx);
|
||||
assert($manifestData !== false);
|
||||
}elseif($archive->locateName("pack_manifest.json") !== false){
|
||||
throw new ResourcePackException("Unsupported old pack format");
|
||||
}else{
|
||||
throw new ResourcePackException("manifest.json not found in the archive root");
|
||||
|
@ -36,7 +36,7 @@ class TaskScheduler{
|
||||
/** @var bool */
|
||||
private $enabled = true;
|
||||
|
||||
/** @var ReversePriorityQueue<Task> */
|
||||
/** @var ReversePriorityQueue<TaskHandler> */
|
||||
protected $queue;
|
||||
|
||||
/** @var TaskHandler[] */
|
||||
|
Loading…
x
Reference in New Issue
Block a user