mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 08:17:34 +00:00
Block: get rid of getRuntimeId()
the runtime ID mapping should be non-global in case of multiple protocols.
This commit is contained in:
parent
ad99dc5884
commit
909f3f39de
@ -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);
|
||||
|
@ -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{
|
||||
|
@ -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){
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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()));
|
||||
}
|
||||
}
|
||||
|
@ -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()));
|
||||
}
|
||||
}
|
||||
|
@ -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())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -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?
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user