diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 5a05a67eb..35cd9fdde 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -2785,7 +2785,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ break; //TODO case PlayerActionPacket::ACTION_CONTINUE_BREAK: $block = $this->level->getBlock($pos); - $this->level->broadcastLevelEvent($pos, LevelEventPacket::EVENT_PARTICLE_PUNCH_BLOCK, BlockFactory::toStaticRuntimeId($block->getId(), $block->getDamage()) | ($packet->face << 24)); + $this->level->broadcastLevelEvent($pos, LevelEventPacket::EVENT_PARTICLE_PUNCH_BLOCK, $block->getRuntimeId() | ($packet->face << 24)); //TODO: destroy-progress level event break; case PlayerActionPacket::ACTION_START_SWIMMING: diff --git a/src/pocketmine/block/Block.php b/src/pocketmine/block/Block.php index 42d77663b..6c3d5ffec 100644 --- a/src/pocketmine/block/Block.php +++ b/src/pocketmine/block/Block.php @@ -109,6 +109,14 @@ class Block extends Position implements BlockIds, Metadatable{ return $this->itemId ?? $this->getId(); } + /** + * @internal + * @return int + */ + public function getRuntimeId() : int{ + return BlockFactory::toStaticRuntimeId($this->getId(), $this->getDamage()); + } + /** * @return int */ diff --git a/src/pocketmine/entity/object/FallingBlock.php b/src/pocketmine/entity/object/FallingBlock.php index a2dfa4ad4..73ab3824e 100644 --- a/src/pocketmine/entity/object/FallingBlock.php +++ b/src/pocketmine/entity/object/FallingBlock.php @@ -71,7 +71,7 @@ class FallingBlock extends Entity{ $this->block = BlockFactory::get($blockId, $damage); - $this->propertyManager->setInt(self::DATA_VARIANT, BlockFactory::toStaticRuntimeId($this->block->getId(), $this->block->getDamage())); + $this->propertyManager->setInt(self::DATA_VARIANT, $this->block->getRuntimeId()); } public function canCollideWith(Entity $entity) : bool{ diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index bf173d576..934c240c5 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -872,16 +872,12 @@ class Level implements ChunkManager, Metadatable{ $pk->z = $b->z; if($b instanceof Block){ - $blockId = $b->getId(); - $blockData = $b->getDamage(); + $pk->blockRuntimeId = $b->getRuntimeId(); }else{ $fullBlock = $this->getFullBlock($b->x, $b->y, $b->z); - $blockId = $fullBlock >> 4; - $blockData = $fullBlock & 0xf; + $pk->blockRuntimeId = BlockFactory::toStaticRuntimeId($fullBlock >> 4, $fullBlock & 0xf); } - $pk->blockRuntimeId = BlockFactory::toStaticRuntimeId($blockId, $blockData); - $pk->flags = $first ? $flags : UpdateBlockPacket::FLAG_NONE; $packets[] = $pk; @@ -898,16 +894,12 @@ class Level implements ChunkManager, Metadatable{ $pk->z = $b->z; if($b instanceof Block){ - $blockId = $b->getId(); - $blockData = $b->getDamage(); + $pk->blockRuntimeId = $b->getRuntimeId(); }else{ $fullBlock = $this->getFullBlock($b->x, $b->y, $b->z); - $blockId = $fullBlock >> 4; - $blockData = $fullBlock & 0xf; + $pk->blockRuntimeId = BlockFactory::toStaticRuntimeId($fullBlock >> 4, $fullBlock & 0xf); } - $pk->blockRuntimeId = BlockFactory::toStaticRuntimeId($blockId, $blockData); - $pk->flags = $flags; $packets[] = $pk; @@ -1864,7 +1856,7 @@ class Level implements ChunkManager, Metadatable{ } if($playSound){ - $this->broadcastLevelSoundEvent($hand, LevelSoundEventPacket::SOUND_PLACE, 1, BlockFactory::toStaticRuntimeId($hand->getId(), $hand->getDamage())); + $this->broadcastLevelSoundEvent($hand, LevelSoundEventPacket::SOUND_PLACE, 1, $hand->getRuntimeId()); } $item->pop(); diff --git a/src/pocketmine/level/particle/DestroyBlockParticle.php b/src/pocketmine/level/particle/DestroyBlockParticle.php index 203163e63..3bec46f60 100644 --- a/src/pocketmine/level/particle/DestroyBlockParticle.php +++ b/src/pocketmine/level/particle/DestroyBlockParticle.php @@ -24,7 +24,6 @@ declare(strict_types=1); namespace pocketmine\level\particle; use pocketmine\block\Block; -use pocketmine\block\BlockFactory; use pocketmine\math\Vector3; use pocketmine\network\mcpe\protocol\LevelEventPacket; @@ -35,7 +34,7 @@ class DestroyBlockParticle extends Particle{ public function __construct(Vector3 $pos, Block $b){ parent::__construct($pos->x, $pos->y, $pos->z); - $this->data = BlockFactory::toStaticRuntimeId($b->getId(), $b->getDamage()); + $this->data = $b->getRuntimeId(); } public function encode(){ diff --git a/src/pocketmine/level/particle/TerrainParticle.php b/src/pocketmine/level/particle/TerrainParticle.php index 6864b63f9..8295f3d1d 100644 --- a/src/pocketmine/level/particle/TerrainParticle.php +++ b/src/pocketmine/level/particle/TerrainParticle.php @@ -24,11 +24,10 @@ declare(strict_types=1); namespace pocketmine\level\particle; use pocketmine\block\Block; -use pocketmine\block\BlockFactory; use pocketmine\math\Vector3; class TerrainParticle extends GenericParticle{ public function __construct(Vector3 $pos, Block $b){ - parent::__construct($pos, Particle::TYPE_TERRAIN, BlockFactory::toStaticRuntimeId($b->getId(), $b->getDamage())); + parent::__construct($pos, Particle::TYPE_TERRAIN, $b->getRuntimeId()); } }