mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 09:56:06 +00:00
Start deglobalizing TypeConverter
there's a bunch of places we can't reach with this right now: - particles - sounds - tile NBT - entity metadata - crafting data cache - chunk encoding - world block update encoding this is a work in progress, but ultimately we want to get rid of these singletons entirely.
This commit is contained in:
@ -443,7 +443,7 @@ class InGamePacketHandler extends PacketHandler{
|
||||
if($sourceSlotItem->getCount() < $droppedCount){
|
||||
return false;
|
||||
}
|
||||
$serverItemStack = TypeConverter::getInstance()->coreItemStackToNet($sourceSlotItem);
|
||||
$serverItemStack = $this->session->getTypeConverter()->coreItemStackToNet($sourceSlotItem);
|
||||
//because the client doesn't tell us the expected itemstack ID, we have to deep-compare our known
|
||||
//itemstack info with the one the client sent. This is costly, but we don't have any other option :(
|
||||
if(!$serverItemStack->equals($clientItemStack)){
|
||||
@ -776,7 +776,7 @@ class InGamePacketHandler extends PacketHandler{
|
||||
}
|
||||
|
||||
public function handleSetPlayerGameType(SetPlayerGameTypePacket $packet) : bool{
|
||||
$gameMode = TypeConverter::getInstance()->protocolGameModeToCore($packet->gamemode);
|
||||
$gameMode = $this->session->getTypeConverter()->protocolGameModeToCore($packet->gamemode);
|
||||
if($gameMode === null || !$gameMode->equals($this->player->getGamemode())){
|
||||
//Set this back to default. TODO: handle this properly
|
||||
$this->session->syncGameMode($this->player->getGamemode(), true);
|
||||
|
@ -65,11 +65,13 @@ class PreSpawnPacketHandler extends PacketHandler{
|
||||
$location = $this->player->getLocation();
|
||||
$world = $location->getWorld();
|
||||
|
||||
$typeConverter = $this->session->getTypeConverter();
|
||||
|
||||
$this->session->getLogger()->debug("Preparing StartGamePacket");
|
||||
$levelSettings = new LevelSettings();
|
||||
$levelSettings->seed = -1;
|
||||
$levelSettings->spawnSettings = new SpawnSettings(SpawnSettings::BIOME_TYPE_DEFAULT, "", DimensionIds::OVERWORLD); //TODO: implement this properly
|
||||
$levelSettings->worldGamemode = TypeConverter::getInstance()->coreGameModeToProtocol($this->server->getGamemode());
|
||||
$levelSettings->worldGamemode = $typeConverter->coreGameModeToProtocol($this->server->getGamemode());
|
||||
$levelSettings->difficulty = $world->getDifficulty();
|
||||
$levelSettings->spawnPosition = BlockPosition::fromVector3($world->getSpawnLocation());
|
||||
$levelSettings->hasAchievementsDisabled = true;
|
||||
@ -86,7 +88,7 @@ class PreSpawnPacketHandler extends PacketHandler{
|
||||
$this->session->sendDataPacket(StartGamePacket::create(
|
||||
$this->player->getId(),
|
||||
$this->player->getId(),
|
||||
TypeConverter::getInstance()->coreGameModeToProtocol($this->player->getGamemode()),
|
||||
$typeConverter->coreGameModeToProtocol($this->player->getGamemode()),
|
||||
$this->player->getOffsetPosition($location),
|
||||
$location->pitch,
|
||||
$location->yaw,
|
||||
@ -107,7 +109,7 @@ class PreSpawnPacketHandler extends PacketHandler{
|
||||
false,
|
||||
[],
|
||||
0,
|
||||
TypeConverter::getInstance()->getItemTypeDictionary()->getEntries(),
|
||||
$typeConverter->getItemTypeDictionary()->getEntries(),
|
||||
));
|
||||
|
||||
$this->session->getLogger()->debug("Sending actor identifiers");
|
||||
|
Reference in New Issue
Block a user