mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-01 07:39:57 +00:00
RuntimeBlockMapping: avoid keeping two copies of the same blockstate data in memory
This commit is contained in:
parent
14933a731b
commit
2ba51567d8
@ -66,8 +66,11 @@ final class RuntimeBlockMapping{
|
|||||||
private BlockStateDictionary $blockStateDictionary,
|
private BlockStateDictionary $blockStateDictionary,
|
||||||
private BlockStateSerializer $blockStateSerializer
|
private BlockStateSerializer $blockStateSerializer
|
||||||
){
|
){
|
||||||
$this->fallbackStateData = new BlockStateData(BlockTypeNames::INFO_UPDATE, [], BlockStateData::CURRENT_VERSION);
|
$this->fallbackStateId = $this->blockStateDictionary->lookupStateIdFromData(
|
||||||
$this->fallbackStateId = $this->blockStateDictionary->lookupStateIdFromData($this->fallbackStateData) ?? throw new AssumptionFailedError(BlockTypeNames::INFO_UPDATE . " should always exist");
|
new BlockStateData(BlockTypeNames::INFO_UPDATE, [], BlockStateData::CURRENT_VERSION)
|
||||||
|
) ?? throw new AssumptionFailedError(BlockTypeNames::INFO_UPDATE . " should always exist");
|
||||||
|
//lookup the state data from the dictionary to avoid keeping two copies of the same data around
|
||||||
|
$this->fallbackStateData = $this->blockStateDictionary->getDataFromStateId($this->fallbackStateId) ?? throw new AssumptionFailedError("We just looked up this state data, so it must exist");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function toRuntimeId(int $internalStateId) : int{
|
public function toRuntimeId(int $internalStateId) : int{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user