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:
Dylan K. Taylor
2023-05-06 17:47:09 +01:00
parent 7cdf6b0946
commit e0a6ec0c24
9 changed files with 50 additions and 26 deletions

View File

@ -182,6 +182,7 @@ class NetworkSession{
private PacketBroadcaster $broadcaster,
private EntityEventBroadcaster $entityEventBroadcaster,
private Compressor $compressor,
private TypeConverter $typeConverter,
private string $ip,
private int $port
){
@ -538,6 +539,8 @@ class NetworkSession{
return $this->compressor;
}
public function getTypeConverter() : TypeConverter{ return $this->typeConverter; }
public function queueCompressed(CompressBatchPromise $payload, bool $immediate = false) : void{
Timings::$playerNetworkSend->startTiming();
try{
@ -887,7 +890,7 @@ class NetworkSession{
}
public function syncGameMode(GameMode $mode, bool $isRollback = false) : void{
$this->sendDataPacket(SetPlayerGameTypePacket::create(TypeConverter::getInstance()->coreGameModeToProtocol($mode)));
$this->sendDataPacket(SetPlayerGameTypePacket::create($this->typeConverter->coreGameModeToProtocol($mode)));
if($this->player !== null){
$this->syncAbilities($this->player);
$this->syncAdventureSettings(); //TODO: we might be able to do this with the abilities packet alone