-
Notifications
You must be signed in to change notification settings - Fork 75
Frequently Asked Questions
Setting actual blocks and tiles to the world opens room for several loopholes, especially when using InvMenu to implement a menu-driven GUI (such as a shop GUI).
-
Setting actual blocks and tiles to the world overwrites existing blocks and tiles.
This causes an issue where a manually-placed container in the world (such as a chest or a furnace placed by a player) gets deleted while the menu is in use. -
Other players can view the block and interact with the tile.
It simply doesn't seem right to make the menu's container block and tile visible or interactable by players that aren't viewing the inventory. -
The container could be broken.
Players would be able to break the InvMenu container by hand, or through other means such as causing an explosion. In case of a shop GUI where valuable items such as diamonds are displayed in the container's inventory, a player would have to simply break the chest to win free diamonds. -
It interferes with other mechanisms.
Pistons would be able to move the chest block. Hoppers could suck items from the menu despite the InvMenu instance being in a read-only state.
While one could argue some of these reasons could be addressed by handling a set of events, that is simply not enough. Since InvMenu instances exist purely in memory (as opposed to having their states persist by storing on disk), InvMenu wouldn't be able to remember whether a chest block is of an InvMenu type between server restarts. In a more practical scenario, when the server fails to shut down gracefully (more precisely, when a chunk in a world fails to save gracefully), it may result in an InvMenu container exist in an invalid state in the world, which may lead to unexpected consequences.
For this reason, InvMenu broadcasts the block and tile updates over the network, without sharing information with pocketmine worlds. This ensures other mechanisms wouldn't be able to interfere with the menu's inventory, greatly reducing the many possible cases that would've had to be accounted for.