mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 12:18:46 +00:00
remove PM resource interaction from StartGamePacket
also lose the cache, because it's not very useful ...
This commit is contained in:
parent
218f32f5b8
commit
b4606a4cd0
40
src/data/bedrock/LegacyItemIdToStringIdMap.php
Normal file
40
src/data/bedrock/LegacyItemIdToStringIdMap.php
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<?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\data\bedrock;
|
||||||
|
|
||||||
|
use pocketmine\utils\AssumptionFailedError;
|
||||||
|
use pocketmine\utils\SingletonTrait;
|
||||||
|
use function file_get_contents;
|
||||||
|
use function is_array;
|
||||||
|
use function is_int;
|
||||||
|
use function is_string;
|
||||||
|
use function json_decode;
|
||||||
|
|
||||||
|
final class LegacyItemIdToStringIdMap extends LegacyToStringBidirectionalIdMap{
|
||||||
|
use SingletonTrait;
|
||||||
|
|
||||||
|
public function __construct(){
|
||||||
|
parent::__construct(\pocketmine\RESOURCE_PATH . 'vanilla/item_id_map.json');
|
||||||
|
}
|
||||||
|
}
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\network\mcpe\handler;
|
namespace pocketmine\network\mcpe\handler;
|
||||||
|
|
||||||
|
use pocketmine\data\bedrock\LegacyItemIdToStringIdMap;
|
||||||
use pocketmine\network\mcpe\convert\RuntimeBlockMapping;
|
use pocketmine\network\mcpe\convert\RuntimeBlockMapping;
|
||||||
use pocketmine\network\mcpe\NetworkSession;
|
use pocketmine\network\mcpe\NetworkSession;
|
||||||
use pocketmine\network\mcpe\protocol\RequestChunkRadiusPacket;
|
use pocketmine\network\mcpe\protocol\RequestChunkRadiusPacket;
|
||||||
@ -78,7 +79,7 @@ class PreSpawnPacketHandler extends PacketHandler{
|
|||||||
$pk->levelId = "";
|
$pk->levelId = "";
|
||||||
$pk->worldName = $this->server->getMotd();
|
$pk->worldName = $this->server->getMotd();
|
||||||
$pk->blockTable = RuntimeBlockMapping::getInstance()->getStartGamePaletteCache();
|
$pk->blockTable = RuntimeBlockMapping::getInstance()->getStartGamePaletteCache();
|
||||||
|
$pk->itemTable = LegacyItemIdToStringIdMap::getInstance()->getStringToLegacyMap(); //TODO: check if this is actually needed
|
||||||
$this->session->sendDataPacket($pk);
|
$this->session->sendDataPacket($pk);
|
||||||
|
|
||||||
$this->session->sendDataPacket(StaticPacketCache::getInstance()->getAvailableActorIdentifiers());
|
$this->session->sendDataPacket(StaticPacketCache::getInstance()->getAvailableActorIdentifiers());
|
||||||
|
@ -38,9 +38,6 @@ use const pocketmine\RESOURCE_PATH;
|
|||||||
class StartGamePacket extends DataPacket implements ClientboundPacket{
|
class StartGamePacket extends DataPacket implements ClientboundPacket{
|
||||||
public const NETWORK_ID = ProtocolInfo::START_GAME_PACKET;
|
public const NETWORK_ID = ProtocolInfo::START_GAME_PACKET;
|
||||||
|
|
||||||
/** @var string|null */
|
|
||||||
private static $itemTableCache = null;
|
|
||||||
|
|
||||||
/** @var int */
|
/** @var int */
|
||||||
public $entityUniqueId;
|
public $entityUniqueId;
|
||||||
/** @var int */
|
/** @var int */
|
||||||
@ -155,10 +152,10 @@ class StartGamePacket extends DataPacket implements ClientboundPacket{
|
|||||||
*/
|
*/
|
||||||
public $blockTable;
|
public $blockTable;
|
||||||
/**
|
/**
|
||||||
* @var int[]|null string (name) => int16 (legacyID)
|
* @var int[] string (name) => int16 (legacyID)
|
||||||
* @phpstan-var array<string, int>|null
|
* @phpstan-var array<string, int>
|
||||||
*/
|
*/
|
||||||
public $itemTable = null;
|
public $itemTable = [];
|
||||||
|
|
||||||
protected function decodePayload(NetworkBinaryStream $in) : void{
|
protected function decodePayload(NetworkBinaryStream $in) : void{
|
||||||
$this->entityUniqueId = $in->getEntityUniqueId();
|
$this->entityUniqueId = $in->getEntityUniqueId();
|
||||||
@ -285,14 +282,7 @@ class StartGamePacket extends DataPacket implements ClientboundPacket{
|
|||||||
|
|
||||||
$out->put($this->blockTable->getEncodedNbt());
|
$out->put($this->blockTable->getEncodedNbt());
|
||||||
|
|
||||||
if($this->itemTable === null){
|
|
||||||
if(self::$itemTableCache === null){
|
|
||||||
self::$itemTableCache = self::serializeItemTable(json_decode(file_get_contents(RESOURCE_PATH . '/vanilla/item_id_map.json'), true));
|
|
||||||
}
|
|
||||||
$out->put(self::$itemTableCache);
|
|
||||||
}else{
|
|
||||||
$out->put(self::serializeItemTable($this->itemTable));
|
$out->put(self::serializeItemTable($this->itemTable));
|
||||||
}
|
|
||||||
|
|
||||||
$out->putString($this->multiplayerCorrelationId);
|
$out->putString($this->multiplayerCorrelationId);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user