mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-12 12:55:21 +00:00
Limit blockitem metadata hack to just blockitems
for some reason putting NBT on some items makes the creative inventory go haywire. Sadly, we currently need this hack, so I limit it to only stuff which actually needs it (blockitems). closes #4159
This commit is contained in:
parent
b94bbf6f5e
commit
3c8eb29d4e
@ -310,8 +310,15 @@ class NetworkBinaryStream extends BinaryStream{
|
|||||||
|
|
||||||
$writeExtraCrapInTheMiddle($this);
|
$writeExtraCrapInTheMiddle($this);
|
||||||
|
|
||||||
$block = $item->getBlock();
|
$blockRuntimeId = 0;
|
||||||
$this->putVarInt($block->getId() === BlockIds::AIR ? 0 : RuntimeBlockMapping::toStaticRuntimeId($block->getId(), $block->getDamage()));
|
$isBlockItem = $item->getId() < 256;
|
||||||
|
if($isBlockItem){
|
||||||
|
$block = $item->getBlock();
|
||||||
|
if($block->getId() !== BlockIds::AIR){
|
||||||
|
$blockRuntimeId = RuntimeBlockMapping::toStaticRuntimeId($block->getId(), $block->getDamage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->putVarInt($blockRuntimeId);
|
||||||
|
|
||||||
$nbt = null;
|
$nbt = null;
|
||||||
if($item->hasCompoundTag()){
|
if($item->hasCompoundTag()){
|
||||||
@ -328,7 +335,7 @@ class NetworkBinaryStream extends BinaryStream{
|
|||||||
$nbt = new CompoundTag();
|
$nbt = new CompoundTag();
|
||||||
}
|
}
|
||||||
$nbt->setInt(self::DAMAGE_TAG, $coreData);
|
$nbt->setInt(self::DAMAGE_TAG, $coreData);
|
||||||
}elseif($block->getId() !== BlockIds::AIR && $coreData !== 0){
|
}elseif($isBlockItem && $coreData !== 0){
|
||||||
//TODO HACK: This foul-smelling code ensures that we can correctly deserialize an item when the
|
//TODO HACK: This foul-smelling code ensures that we can correctly deserialize an item when the
|
||||||
//client sends it back to us, because as of 1.16.220, blockitems quietly discard their metadata
|
//client sends it back to us, because as of 1.16.220, blockitems quietly discard their metadata
|
||||||
//client-side. Aside from being very annoying, this also breaks various server-side behaviours.
|
//client-side. Aside from being very annoying, this also breaks various server-side behaviours.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user