Muqsit / InvMenu

A PocketMine-MP virion to create and manage virtual inventories!
https://poggit.pmmp.io/ci/Muqsit/InvMenu/~
GNU General Public License v3.0
200 stars 75 forks source link

1.20.10 broke something #216

Closed dadodasyra closed 1 year ago

dadodasyra commented 1 year ago

Seems like nothing is happening, the chest pops out put not the UI..

alvin0319 commented 1 year ago
if(!$sender instanceof Player) return;
            $pk = UpdateBlockPacket::create(
                BlockPosition::fromVector3($pos = $sender->getPosition()->add(0, 5, 0)),
                TypeConverter::getInstance()->getBlockTranslator()->internalIdToNetworkId(VanillaBlocks::CHEST()->getStateId()),
                UpdateBlockPacket::FLAG_NETWORK,
                UpdateBlockPacket::DATA_LAYER_NORMAL
            );
            $sender->getNetworkSession()->sendDataPacket($pk);
            $sender->getNetworkSession()->sendDataPacket(
                UpdateBlockPacket::create(
                    BlockPosition::fromVector3($pos->add(1, 0, 0)),
                    TypeConverter::getInstance()->getBlockTranslator()->internalIdToNetworkId(VanillaBlocks::CHEST()->getStateId()),
                    UpdateBlockPacket::FLAG_NETWORK,
                    UpdateBlockPacket::DATA_LAYER_NORMAL
                )
            );
            $sender->getNetworkSession()->sendDataPacket(
                BlockActorDataPacket::create(
                    BlockPosition::fromVector3($pos),
                    new CacheableNbt(CompoundTag::create()
                        ->setString(Tile::TAG_ID, "Chest")
                        ->setInt(Tile::TAG_X, $pos->getFloorX())
                        ->setInt(Tile::TAG_Y, $pos->getFloorY())
                        ->setInt(Tile::TAG_Z, $pos->getFloorZ())
                        ->setString(Chest::TAG_CUSTOM_NAME, "TEST")
                        ->setInt(Chest::TAG_PAIRX, $pos->getFloorX() + 1)
                        ->setInt(Chest::TAG_PAIRZ, $pos->getFloorZ())
                    )
                )
            );
            $sender->getNetworkSession()->sendDataPacket(
                BlockActorDataPacket::create(
                    BlockPosition::fromVector3($pos->add(1, 0, 0)),
                    new CacheableNbt(CompoundTag::create()
                        ->setString(Tile::TAG_ID, "Chest")
                        ->setInt(Tile::TAG_X, $pos->getFloorX() + 1)
                        ->setInt(Tile::TAG_Y, $pos->getFloorY())
                        ->setInt(Tile::TAG_Z, $pos->getFloorZ())
                        ->setString(Chest::TAG_CUSTOM_NAME, "TEST")
                        ->setInt(Chest::TAG_PAIRX, $pos->getFloorX())
                        ->setInt(Chest::TAG_PAIRZ, $pos->getFloorZ())
                    )
                )
            );
            $this->getScheduler()->scheduleDelayedTask(new ClosureTask(function() use ($sender, $pos) : void{
                $sender->getNetworkSession()->sendDataPacket(
                    ContainerOpenPacket::blockInv(
                        1,
                        WindowTypes::CONTAINER,
                        BlockPosition::fromVector3($pos),
                    )
                );
            }), 10);
            $sender->sendMessage("Complete");

From what I can tell is that this code works. Looks like we need to add a delay for container opening?

dadodasyra commented 1 year ago

@alvin0319 Can you confirm this is not related to my code and your InvMenu is broken too ?

dadodasyra commented 1 year ago

I don't really understand what could have break since I found no server software changing anything about UIs..

dries-c commented 1 year ago

We're experiencing the same issue. However I've no clue what causes it yet

supercrafter333 commented 1 year ago

If I try to open a InvMenu, I can open it one time. If I try to open it a second time (no matter what contents or name the invmenu-inventory have), it doesn't work - no inventory is opening. If I try to open my own player-inventory, everything works fine.

I think the InvMenu-inventory wasn't closed the right way. Maybe we have to show what the code for closing the inventory do.

I also tried to use debug-messages but that wasn't helpful.

aabstractt commented 1 year ago

image The issue is the timestamp, InvMenu store the timestamp without long value and MCPE sent the packet with long (many 0)

supercrafter333 commented 1 year ago

image The issue is the timestamp, InvMenu store the timestamp with an long value and MCPE sent the packet without long

Any idea how to fix?

aabstractt commented 1 year ago

image

This is the quickfix on the PlayerNetwork method notify

Muqsit commented 1 year ago

Seems like there was a change in behavior of NetworkStackLatencyPacket in Bedrock Edition v1.20.10. This protocol change may be impacting PlayStation users as well, however I do not have access to one at the moment to test it.

Thank you for the details and analysis @alvin0319 @supercrafter333 @aabstractt.