diff --git a/src/block/Block.php b/src/block/Block.php index 873be4e9e..097b85fb4 100644 --- a/src/block/Block.php +++ b/src/block/Block.php @@ -38,7 +38,6 @@ use pocketmine\math\Facing; use pocketmine\math\RayTraceResult; use pocketmine\math\Vector3; use pocketmine\nbt\tag\CompoundTag; -use pocketmine\network\mcpe\convert\RuntimeBlockMapping; use pocketmine\player\Player; use pocketmine\world\BlockTransaction; use pocketmine\world\Position; @@ -105,13 +104,6 @@ class Block{ return ItemFactory::getInstance()->get($this->idInfo->getItemId(), $this->idInfo->getVariant()); } - /** - * @internal - */ - public function getRuntimeId() : int{ - return RuntimeBlockMapping::getInstance()->toRuntimeId($this->getId(), $this->getMeta()); - } - public function getMeta() : int{ $stateMeta = $this->writeStateToMeta(); assert(($stateMeta & ~$this->getStateBitmask()) === 0); diff --git a/src/entity/object/FallingBlock.php b/src/entity/object/FallingBlock.php index 4b955fc7a..69e43b800 100644 --- a/src/entity/object/FallingBlock.php +++ b/src/entity/object/FallingBlock.php @@ -34,6 +34,7 @@ use pocketmine\math\Vector3; use pocketmine\nbt\tag\ByteTag; use pocketmine\nbt\tag\CompoundTag; use pocketmine\nbt\tag\IntTag; +use pocketmine\network\mcpe\convert\RuntimeBlockMapping; use pocketmine\network\mcpe\protocol\types\entity\EntityIds; use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataCollection; use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataProperties; @@ -146,7 +147,7 @@ class FallingBlock extends Entity{ protected function syncNetworkData(EntityMetadataCollection $properties) : void{ parent::syncNetworkData($properties); - $properties->setInt(EntityMetadataProperties::VARIANT, $this->block->getRuntimeId()); + $properties->setInt(EntityMetadataProperties::VARIANT, RuntimeBlockMapping::getInstance()->toRuntimeId($this->block->getId(), $this->block->getMeta())); } public function getOffsetPosition(Vector3 $vector3) : Vector3{ diff --git a/src/world/World.php b/src/world/World.php index bd1c6530b..66892f095 100644 --- a/src/world/World.php +++ b/src/world/World.php @@ -52,6 +52,7 @@ use pocketmine\item\ItemUseResult; use pocketmine\item\LegacyStringToItemParser; use pocketmine\math\AxisAlignedBB; use pocketmine\math\Vector3; +use pocketmine\network\mcpe\convert\RuntimeBlockMapping; use pocketmine\network\mcpe\protocol\BlockActorDataPacket; use pocketmine\network\mcpe\protocol\ClientboundPacket; use pocketmine\network\mcpe\protocol\UpdateBlockPacket; @@ -829,7 +830,7 @@ class World implements ChunkManager{ } $fullBlock = $this->getBlockAt($b->x, $b->y, $b->z); - $packets[] = UpdateBlockPacket::create($b->x, $b->y, $b->z, $fullBlock->getRuntimeId()); + $packets[] = UpdateBlockPacket::create($b->x, $b->y, $b->z, RuntimeBlockMapping::getInstance()->toRuntimeId($fullBlock->getId(), $fullBlock->getMeta())); $tile = $this->getTileAt($b->x, $b->y, $b->z); if($tile instanceof Spawnable){ diff --git a/src/world/particle/BlockPunchParticle.php b/src/world/particle/BlockPunchParticle.php index 11d23bcf6..a932099a6 100644 --- a/src/world/particle/BlockPunchParticle.php +++ b/src/world/particle/BlockPunchParticle.php @@ -25,6 +25,7 @@ namespace pocketmine\world\particle; use pocketmine\block\Block; use pocketmine\math\Vector3; +use pocketmine\network\mcpe\convert\RuntimeBlockMapping; use pocketmine\network\mcpe\protocol\LevelEventPacket; /** @@ -43,6 +44,6 @@ class BlockPunchParticle implements Particle{ } public function encode(Vector3 $pos){ - return LevelEventPacket::create(LevelEventPacket::EVENT_PARTICLE_PUNCH_BLOCK, $this->block->getRuntimeId() | ($this->face << 24), $pos); + return LevelEventPacket::create(LevelEventPacket::EVENT_PARTICLE_PUNCH_BLOCK, RuntimeBlockMapping::getInstance()->toRuntimeId($this->block->getId(), $this->block->getMeta()) | ($this->face << 24), $pos); } } diff --git a/src/world/particle/DestroyBlockParticle.php b/src/world/particle/DestroyBlockParticle.php index 3039fbe40..0d4d96274 100644 --- a/src/world/particle/DestroyBlockParticle.php +++ b/src/world/particle/DestroyBlockParticle.php @@ -25,6 +25,7 @@ namespace pocketmine\world\particle; use pocketmine\block\Block; use pocketmine\math\Vector3; +use pocketmine\network\mcpe\convert\RuntimeBlockMapping; use pocketmine\network\mcpe\protocol\LevelEventPacket; class DestroyBlockParticle implements Particle{ @@ -37,6 +38,6 @@ class DestroyBlockParticle implements Particle{ } public function encode(Vector3 $pos){ - return LevelEventPacket::create(LevelEventPacket::EVENT_PARTICLE_DESTROY, $this->block->getRuntimeId(), $pos); + return LevelEventPacket::create(LevelEventPacket::EVENT_PARTICLE_DESTROY, RuntimeBlockMapping::getInstance()->toRuntimeId($this->block->getId(), $this->block->getMeta()), $pos); } } diff --git a/src/world/particle/TerrainParticle.php b/src/world/particle/TerrainParticle.php index 997c2e76b..e96ad680b 100644 --- a/src/world/particle/TerrainParticle.php +++ b/src/world/particle/TerrainParticle.php @@ -25,6 +25,7 @@ namespace pocketmine\world\particle; use pocketmine\block\Block; use pocketmine\math\Vector3; +use pocketmine\network\mcpe\convert\RuntimeBlockMapping; use pocketmine\network\mcpe\protocol\LevelEventPacket; use pocketmine\network\mcpe\protocol\types\ParticleIds; @@ -37,6 +38,6 @@ class TerrainParticle implements Particle{ } public function encode(Vector3 $pos){ - return LevelEventPacket::standardParticle(ParticleIds::TERRAIN, $this->block->getRuntimeId(), $pos); + return LevelEventPacket::standardParticle(ParticleIds::TERRAIN, RuntimeBlockMapping::getInstance()->toRuntimeId($this->block->getId(), $this->block->getMeta()), $pos); } } diff --git a/src/world/sound/BlockBreakSound.php b/src/world/sound/BlockBreakSound.php index 8beed8cd7..4d5e6a76e 100644 --- a/src/world/sound/BlockBreakSound.php +++ b/src/world/sound/BlockBreakSound.php @@ -25,6 +25,7 @@ namespace pocketmine\world\sound; use pocketmine\block\Block; use pocketmine\math\Vector3; +use pocketmine\network\mcpe\convert\RuntimeBlockMapping; use pocketmine\network\mcpe\protocol\LevelSoundEventPacket; class BlockBreakSound implements Sound{ @@ -37,6 +38,6 @@ class BlockBreakSound implements Sound{ } public function encode(?Vector3 $pos){ - return LevelSoundEventPacket::create(LevelSoundEventPacket::SOUND_BREAK, $pos, $this->block->getRuntimeId()); + return LevelSoundEventPacket::create(LevelSoundEventPacket::SOUND_BREAK, $pos, RuntimeBlockMapping::getInstance()->toRuntimeId($this->block->getId(), $this->block->getMeta())); } } diff --git a/src/world/sound/BlockPlaceSound.php b/src/world/sound/BlockPlaceSound.php index ae8e2e277..d6d9eef29 100644 --- a/src/world/sound/BlockPlaceSound.php +++ b/src/world/sound/BlockPlaceSound.php @@ -25,6 +25,7 @@ namespace pocketmine\world\sound; use pocketmine\block\Block; use pocketmine\math\Vector3; +use pocketmine\network\mcpe\convert\RuntimeBlockMapping; use pocketmine\network\mcpe\protocol\LevelSoundEventPacket; class BlockPlaceSound implements Sound{ @@ -37,6 +38,6 @@ class BlockPlaceSound implements Sound{ } public function encode(?Vector3 $pos){ - return LevelSoundEventPacket::create(LevelSoundEventPacket::SOUND_PLACE, $pos, $this->block->getRuntimeId()); + return LevelSoundEventPacket::create(LevelSoundEventPacket::SOUND_PLACE, $pos, RuntimeBlockMapping::getInstance()->toRuntimeId($this->block->getId(), $this->block->getMeta())); } } diff --git a/src/world/sound/BlockPunchSound.php b/src/world/sound/BlockPunchSound.php index 75b23e02c..ef9930285 100644 --- a/src/world/sound/BlockPunchSound.php +++ b/src/world/sound/BlockPunchSound.php @@ -25,6 +25,7 @@ namespace pocketmine\world\sound; use pocketmine\block\Block; use pocketmine\math\Vector3; +use pocketmine\network\mcpe\convert\RuntimeBlockMapping; use pocketmine\network\mcpe\protocol\LevelSoundEventPacket; /** @@ -43,7 +44,7 @@ class BlockPunchSound implements Sound{ return LevelSoundEventPacket::create( LevelSoundEventPacket::SOUND_HIT, $pos, - $this->block->getRuntimeId() + RuntimeBlockMapping::getInstance()->toRuntimeId($this->block->getId(), $this->block->getMeta()) ); } } diff --git a/src/world/sound/EntityLandSound.php b/src/world/sound/EntityLandSound.php index 113c89d9b..53b2d033b 100644 --- a/src/world/sound/EntityLandSound.php +++ b/src/world/sound/EntityLandSound.php @@ -26,6 +26,7 @@ namespace pocketmine\world\sound; use pocketmine\block\Block; use pocketmine\entity\Entity; use pocketmine\math\Vector3; +use pocketmine\network\mcpe\convert\RuntimeBlockMapping; use pocketmine\network\mcpe\protocol\LevelSoundEventPacket; /** @@ -47,7 +48,7 @@ class EntityLandSound implements Sound{ return LevelSoundEventPacket::create( LevelSoundEventPacket::SOUND_LAND, $pos, - $this->blockLandedOn->getRuntimeId(), + RuntimeBlockMapping::getInstance()->toRuntimeId($this->blockLandedOn->getId(), $this->blockLandedOn->getMeta()), $this->entity::getNetworkTypeId() //TODO: does isBaby have any relevance here? );