mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-03 16:49:53 +00:00
TypeConverter: avoid repeated calls to getId() and getMeta()
This commit is contained in:
parent
6102740ee3
commit
a77fc8109f
@ -143,7 +143,9 @@ class TypeConverter{
|
|||||||
$nbt = clone $nbt;
|
$nbt = clone $nbt;
|
||||||
}
|
}
|
||||||
|
|
||||||
$idMeta = ItemTranslator::getInstance()->toNetworkIdQuiet($itemStack->getId(), $itemStack->getMeta());
|
$internalId = $itemStack->getId();
|
||||||
|
$internalMeta = $itemStack->getMeta();
|
||||||
|
$idMeta = ItemTranslator::getInstance()->toNetworkIdQuiet($internalId, $internalMeta);
|
||||||
if($idMeta === null){
|
if($idMeta === null){
|
||||||
//Display unmapped items as INFO_UPDATE, but stick something in their NBT to make sure they don't stack with
|
//Display unmapped items as INFO_UPDATE, but stick something in their NBT to make sure they don't stack with
|
||||||
//other unmapped items.
|
//other unmapped items.
|
||||||
@ -151,8 +153,8 @@ class TypeConverter{
|
|||||||
if($nbt === null){
|
if($nbt === null){
|
||||||
$nbt = new CompoundTag();
|
$nbt = new CompoundTag();
|
||||||
}
|
}
|
||||||
$nbt->setInt(self::PM_ID_TAG, $itemStack->getId());
|
$nbt->setInt(self::PM_ID_TAG, $internalId);
|
||||||
$nbt->setInt(self::PM_META_TAG, $itemStack->getMeta());
|
$nbt->setInt(self::PM_META_TAG, $internalMeta);
|
||||||
}else{
|
}else{
|
||||||
[$id, $meta] = $idMeta;
|
[$id, $meta] = $idMeta;
|
||||||
|
|
||||||
@ -171,7 +173,7 @@ class TypeConverter{
|
|||||||
}
|
}
|
||||||
|
|
||||||
$blockRuntimeId = 0;
|
$blockRuntimeId = 0;
|
||||||
if($itemStack->getId() < 256){
|
if($internalId < 256){
|
||||||
$block = $itemStack->getBlock();
|
$block = $itemStack->getBlock();
|
||||||
if($block->getId() !== BlockLegacyIds::AIR){
|
if($block->getId() !== BlockLegacyIds::AIR){
|
||||||
$blockRuntimeId = RuntimeBlockMapping::getInstance()->toRuntimeId($block->getFullId());
|
$blockRuntimeId = RuntimeBlockMapping::getInstance()->toRuntimeId($block->getFullId());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user