mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 02:42:58 +00:00
Added a hack to allow tiles to trigger client-side render updates on blocks without actually changing the block
Bedrock block entity updates don't directly trigger block rendering updates. This is a problem when the block entity data affects the block's appearance directly (e.g. cauldron water colour, flower pot contents), because it means changing them won't directly result in a client-side render update. This hack allows tiles to spoof block updates without actually changing the server-side block, keeping the internals and API clean of random shitbox workarounds. fixes #5174 fixes #4944
This commit is contained in:
@ -23,7 +23,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block\tile;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\nbt\tag\ByteTag;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\nbt\tag\IntTag;
|
||||
use pocketmine\nbt\tag\StringTag;
|
||||
use pocketmine\network\mcpe\protocol\types\CacheableNbt;
|
||||
use function get_class;
|
||||
|
||||
@ -49,6 +53,22 @@ abstract class Spawnable extends Tile{
|
||||
$this->spawnCompoundCache = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Bedrock client won't re-render a block if the block's state properties didn't change. This is a problem when
|
||||
* the tile may affect the block's appearance. For example, a cauldron's liquid changes colour based on the dye
|
||||
* inside.
|
||||
*
|
||||
* This is worked around in vanilla by modifying one of the block's state properties to a different value, and then
|
||||
* changing it back again. Since we don't want to litter core implementation with hacks like this, we brush it under
|
||||
* the rug into Tile.
|
||||
*
|
||||
* @return ByteTag[]|IntTag[]|StringTag[]
|
||||
* @phpstan-return array<string, IntTag|StringTag|ByteTag>
|
||||
*/
|
||||
public function getRenderUpdateBugWorkaroundStateProperties(Block $block) : array{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns encoded NBT (varint, little-endian) used to spawn this tile to clients. Uses cache where possible,
|
||||
* populates cache if it is null.
|
||||
|
Reference in New Issue
Block a user