mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-13 09:19:42 +00:00
RuntimeBlockMapping: these IDs are not static any more
This commit is contained in:
parent
e3dec95b75
commit
6b037d6a4c
@ -111,7 +111,7 @@ class Block{
|
|||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
public function getRuntimeId() : int{
|
public function getRuntimeId() : int{
|
||||||
return RuntimeBlockMapping::getInstance()->toStaticRuntimeId($this->getId(), $this->getMeta());
|
return RuntimeBlockMapping::getInstance()->toRuntimeId($this->getId(), $this->getMeta());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMeta() : int{
|
public function getMeta() : int{
|
||||||
|
@ -127,7 +127,7 @@ final class RuntimeBlockMapping{
|
|||||||
return $table;
|
return $table;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function toStaticRuntimeId(int $id, int $meta = 0) : int{
|
public function toRuntimeId(int $id, int $meta = 0) : int{
|
||||||
/*
|
/*
|
||||||
* try id+meta first
|
* try id+meta first
|
||||||
* if not found, try id+0 (strip meta)
|
* if not found, try id+0 (strip meta)
|
||||||
@ -139,7 +139,7 @@ final class RuntimeBlockMapping{
|
|||||||
/**
|
/**
|
||||||
* @return int[] [id, meta]
|
* @return int[] [id, meta]
|
||||||
*/
|
*/
|
||||||
public function fromStaticRuntimeId(int $runtimeId) : array{
|
public function fromRuntimeId(int $runtimeId) : array{
|
||||||
$v = $this->runtimeToLegacyMap[$runtimeId];
|
$v = $this->runtimeToLegacyMap[$runtimeId];
|
||||||
return [$v >> 4, $v & 0xf];
|
return [$v >> 4, $v & 0xf];
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ final class ChunkSerializer{
|
|||||||
//zigzag and just shift directly.
|
//zigzag and just shift directly.
|
||||||
$stream->putUnsignedVarInt(count($palette) << 1); //yes, this is intentionally zigzag
|
$stream->putUnsignedVarInt(count($palette) << 1); //yes, this is intentionally zigzag
|
||||||
foreach($palette as $p){
|
foreach($palette as $p){
|
||||||
$stream->putUnsignedVarInt($blockMapper->toStaticRuntimeId($p >> 4, $p & 0xf) << 1);
|
$stream->putUnsignedVarInt($blockMapper->toRuntimeId($p >> 4, $p & 0xf) << 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user