Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for entity inventories #144

Closed
inxomnyaa opened this issue May 31, 2021 · 2 comments
Closed

Add support for entity inventories #144

inxomnyaa opened this issue May 31, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@inxomnyaa
Copy link
Contributor

inxomnyaa commented May 31, 2021

As talked about on Discord

The following "prevents" it since https://github.com/Muqsit/InvMenu/blob/4.0/src/muqsit/invmenu/inventory/InvMenuInventory.php implements a block inventory:

https://github.com/Muqsit/InvMenu/blob/4.0/src/muqsit/invmenu/InvMenu.php#L150

@Muqsit
Copy link
Owner

Muqsit commented Feb 20, 2023

Since v4.5.0, it is possible to register entity inventories by using the InvMenuTypeBuilders::ACTOR_FIXED() builder (see ActorInvMenuTypeBuilderTrait to modify metadata properties of the actor-backed inventory).

// make InvMenu::create(InvMenu::TYPE_CHEST) create a minecart with chest inventory:
InvMenuHandler::getTypeRegistry()->register(InvMenu::TYPE_CHEST, InvMenuTypeBuilders::ACTOR_FIXED()
	->setActorIdentifier(EntityIds::CHEST_MINECART)
	->setNetworkWindowType(WindowTypes::CONTAINER)
	->setSize(27)
->build());

Actor/entity-backed inventories offer several advantages over block-backed inventories:

  1. Since they are entities, they can be completely invisible. The library doesn't need to spawn the inventory outside the player's FOV.
  2. Players cannot abuse menus to "levitate" in the air by standing on a fake chest block.
  3. IIRC entity-backed inventories do not automatically close when a player moves out of range (although this does not seem to be the case for the minecart with chest menu registered above).

However, replacing block-backed inventories with entity-backed inventories increases the maintenance cost of this library. From BedrockProtocol's commit history, AddActorPacket underwent changes during 1.19.10, 1.19.20, and 1.19.40 (most recent change was 4 months ago). In contrast, BlockActorDataPacket's property list has remained unchanged for more than a year (in fact, the last change was a property being renamed).

@inxomnyaa
Copy link
Contributor Author

inxomnyaa commented Feb 20, 2023

Players cannot abuse menus to "levitate" in the air by standing on a fake chest block.

@dries-c This might be interesting for @NetherGamesMC

As for the maintenance cost, i am surprised they still change stuff around. Depending on the scale of changes and my spare time i might be able to coauthor some updates in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants