mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-12 16:59:44 +00:00
RuntimeBlockMapping::toRuntimeId() now accepts a single integer instead of id/meta
the expectation is that eventually this will receive arbitrary internal runtime IDs instead of static id/meta, and RuntimeBlockMapping doesn't really care about this crap anyway.
This commit is contained in:
parent
42b184c113
commit
5661d0496f
@ -147,7 +147,7 @@ class FallingBlock extends Entity{
|
||||
protected function syncNetworkData(EntityMetadataCollection $properties) : void{
|
||||
parent::syncNetworkData($properties);
|
||||
|
||||
$properties->setInt(EntityMetadataProperties::VARIANT, RuntimeBlockMapping::getInstance()->toRuntimeId($this->block->getId(), $this->block->getMeta()));
|
||||
$properties->setInt(EntityMetadataProperties::VARIANT, RuntimeBlockMapping::getInstance()->toRuntimeId($this->block->getFullId()));
|
||||
}
|
||||
|
||||
public function getOffsetPosition(Vector3 $vector3) : Vector3{
|
||||
|
@ -135,21 +135,15 @@ final class RuntimeBlockMapping{
|
||||
return $table;
|
||||
}
|
||||
|
||||
public function toRuntimeId(int $id, int $meta = 0) : int{
|
||||
/*
|
||||
* try id+meta first
|
||||
* if not found, try id+0 (strip meta)
|
||||
* if still not found, return update! block
|
||||
*/
|
||||
return $this->legacyToRuntimeMap[($id << 4) | $meta] ?? $this->legacyToRuntimeMap[$id << 4] ?? $this->legacyToRuntimeMap[BlockLegacyIds::INFO_UPDATE << 4];
|
||||
public function toRuntimeId(int $internalStateId) : int{
|
||||
return $this->legacyToRuntimeMap[$internalStateId] ?? $this->legacyToRuntimeMap[BlockLegacyIds::INFO_UPDATE << 4];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int[] [id, meta]
|
||||
* @return int
|
||||
*/
|
||||
public function fromRuntimeId(int $runtimeId) : array{
|
||||
$v = $this->runtimeToLegacyMap[$runtimeId];
|
||||
return [$v >> 4, $v & 0xf];
|
||||
public function fromRuntimeId(int $runtimeId) : int{
|
||||
return $this->runtimeToLegacyMap[$runtimeId];
|
||||
}
|
||||
|
||||
private function registerMapping(int $staticRuntimeId, int $legacyId, int $legacyMeta) : void{
|
||||
|
@ -71,7 +71,7 @@ final class ChunkSerializer{
|
||||
//zigzag and just shift directly.
|
||||
$stream->putUnsignedVarInt(count($palette) << 1); //yes, this is intentionally zigzag
|
||||
foreach($palette as $p){
|
||||
$stream->put(Binary::writeUnsignedVarInt($blockMapper->toRuntimeId($p >> 4, $p & 0xf) << 1));
|
||||
$stream->put(Binary::writeUnsignedVarInt($blockMapper->toRuntimeId($p) << 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -829,7 +829,7 @@ class World implements ChunkManager{
|
||||
}
|
||||
|
||||
$fullBlock = $this->getBlockAt($b->x, $b->y, $b->z);
|
||||
$packets[] = UpdateBlockPacket::create($b->x, $b->y, $b->z, RuntimeBlockMapping::getInstance()->toRuntimeId($fullBlock->getId(), $fullBlock->getMeta()));
|
||||
$packets[] = UpdateBlockPacket::create($b->x, $b->y, $b->z, RuntimeBlockMapping::getInstance()->toRuntimeId($fullBlock->getFullId()));
|
||||
|
||||
$tile = $this->getTileAt($b->x, $b->y, $b->z);
|
||||
if($tile instanceof Spawnable){
|
||||
|
@ -44,6 +44,6 @@ class BlockPunchParticle implements Particle{
|
||||
}
|
||||
|
||||
public function encode(Vector3 $pos){
|
||||
return LevelEventPacket::create(LevelEventPacket::EVENT_PARTICLE_PUNCH_BLOCK, RuntimeBlockMapping::getInstance()->toRuntimeId($this->block->getId(), $this->block->getMeta()) | ($this->face << 24), $pos);
|
||||
return LevelEventPacket::create(LevelEventPacket::EVENT_PARTICLE_PUNCH_BLOCK, RuntimeBlockMapping::getInstance()->toRuntimeId($this->block->getFullId()) | ($this->face << 24), $pos);
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,6 @@ class DestroyBlockParticle implements Particle{
|
||||
}
|
||||
|
||||
public function encode(Vector3 $pos){
|
||||
return LevelEventPacket::create(LevelEventPacket::EVENT_PARTICLE_DESTROY, RuntimeBlockMapping::getInstance()->toRuntimeId($this->block->getId(), $this->block->getMeta()), $pos);
|
||||
return LevelEventPacket::create(LevelEventPacket::EVENT_PARTICLE_DESTROY, RuntimeBlockMapping::getInstance()->toRuntimeId($this->block->getFullId()), $pos);
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,6 @@ class TerrainParticle implements Particle{
|
||||
}
|
||||
|
||||
public function encode(Vector3 $pos){
|
||||
return LevelEventPacket::standardParticle(ParticleIds::TERRAIN, RuntimeBlockMapping::getInstance()->toRuntimeId($this->block->getId(), $this->block->getMeta()), $pos);
|
||||
return LevelEventPacket::standardParticle(ParticleIds::TERRAIN, RuntimeBlockMapping::getInstance()->toRuntimeId($this->block->getFullId()), $pos);
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,6 @@ class BlockBreakSound implements Sound{
|
||||
}
|
||||
|
||||
public function encode(?Vector3 $pos){
|
||||
return LevelSoundEventPacket::create(LevelSoundEventPacket::SOUND_BREAK, $pos, RuntimeBlockMapping::getInstance()->toRuntimeId($this->block->getId(), $this->block->getMeta()));
|
||||
return LevelSoundEventPacket::create(LevelSoundEventPacket::SOUND_BREAK, $pos, RuntimeBlockMapping::getInstance()->toRuntimeId($this->block->getFullId()));
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,6 @@ class BlockPlaceSound implements Sound{
|
||||
}
|
||||
|
||||
public function encode(?Vector3 $pos){
|
||||
return LevelSoundEventPacket::create(LevelSoundEventPacket::SOUND_PLACE, $pos, RuntimeBlockMapping::getInstance()->toRuntimeId($this->block->getId(), $this->block->getMeta()));
|
||||
return LevelSoundEventPacket::create(LevelSoundEventPacket::SOUND_PLACE, $pos, RuntimeBlockMapping::getInstance()->toRuntimeId($this->block->getFullId()));
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ class BlockPunchSound implements Sound{
|
||||
return LevelSoundEventPacket::create(
|
||||
LevelSoundEventPacket::SOUND_HIT,
|
||||
$pos,
|
||||
RuntimeBlockMapping::getInstance()->toRuntimeId($this->block->getId(), $this->block->getMeta())
|
||||
RuntimeBlockMapping::getInstance()->toRuntimeId($this->block->getFullId())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ class EntityLandSound implements Sound{
|
||||
return LevelSoundEventPacket::create(
|
||||
LevelSoundEventPacket::SOUND_LAND,
|
||||
$pos,
|
||||
RuntimeBlockMapping::getInstance()->toRuntimeId($this->blockLandedOn->getId(), $this->blockLandedOn->getMeta()),
|
||||
RuntimeBlockMapping::getInstance()->toRuntimeId($this->blockLandedOn->getFullId()),
|
||||
$this->entity::getNetworkTypeId()
|
||||
//TODO: does isBaby have any relevance here?
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user