mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 04:17:07 +00:00
World: do not apply fake state properties from tile if the block doesn't expect this tile type
This was causing a variety of crashes due to incorrect tiles, presumably from PM3 worlds.
This commit is contained in:
parent
7dd3a70d2e
commit
8fa5c7cdab
@ -1102,19 +1102,22 @@ class World implements ChunkManager{
|
||||
$blockPosition = BlockPosition::fromVector3($b);
|
||||
|
||||
$tile = $this->getTileAt($b->x, $b->y, $b->z);
|
||||
if($tile instanceof Spawnable && count($fakeStateProperties = $tile->getRenderUpdateBugWorkaroundStateProperties($fullBlock)) > 0){
|
||||
$originalStateData = $blockTranslator->internalIdToNetworkStateData($fullBlock->getStateId());
|
||||
$fakeStateData = new BlockStateData(
|
||||
$originalStateData->getName(),
|
||||
array_merge($originalStateData->getStates(), $fakeStateProperties),
|
||||
$originalStateData->getVersion()
|
||||
);
|
||||
$packets[] = UpdateBlockPacket::create(
|
||||
$blockPosition,
|
||||
$blockTranslator->getBlockStateDictionary()->lookupStateIdFromData($fakeStateData) ?? throw new AssumptionFailedError("Unmapped fake blockstate data: " . $fakeStateData->toNbt()),
|
||||
UpdateBlockPacket::FLAG_NETWORK,
|
||||
UpdateBlockPacket::DATA_LAYER_NORMAL
|
||||
);
|
||||
if($tile instanceof Spawnable){
|
||||
$expectedClass = $fullBlock->getIdInfo()->getTileClass();
|
||||
if($expectedClass !== null && $tile instanceof $expectedClass && count($fakeStateProperties = $tile->getRenderUpdateBugWorkaroundStateProperties($fullBlock)) > 0){
|
||||
$originalStateData = $blockTranslator->internalIdToNetworkStateData($fullBlock->getStateId());
|
||||
$fakeStateData = new BlockStateData(
|
||||
$originalStateData->getName(),
|
||||
array_merge($originalStateData->getStates(), $fakeStateProperties),
|
||||
$originalStateData->getVersion()
|
||||
);
|
||||
$packets[] = UpdateBlockPacket::create(
|
||||
$blockPosition,
|
||||
$blockTranslator->getBlockStateDictionary()->lookupStateIdFromData($fakeStateData) ?? throw new AssumptionFailedError("Unmapped fake blockstate data: " . $fakeStateData->toNbt()),
|
||||
UpdateBlockPacket::FLAG_NETWORK,
|
||||
UpdateBlockPacket::DATA_LAYER_NORMAL
|
||||
);
|
||||
}
|
||||
}
|
||||
$packets[] = UpdateBlockPacket::create(
|
||||
$blockPosition,
|
||||
|
Loading…
x
Reference in New Issue
Block a user