-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Items that have contents now drops them on destroy #4768
base: minor-next
Are you sure you want to change the base?
Items that have contents now drops them on destroy #4768
Conversation
Items should also scatter in different directions. Is it provided? |
That's a topic for a different issue. Player deaths should also have the same behaviour but don't. |
Will it be in the next next-minor? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to have some kind of API like Item::getContainedItems()
instead of making bogus assumptions about NBT.
Yeah, especially when the bundle gets implemented. It could’ve a different NBT compared to chests/shulker boxes. |
I think a general implementation in |
Now `ItemEntity` uses `Item::getContainedItems()` to drop the contained items
Need to be update with the upstream |
# Conflicts: # src/item/Item.php
Found 3 issues that are outside the scope of this PR:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks OK apart from a couple of minor nits
Introduction
Currently when you destroy an item with contents (ex: shulker box) it doesn’t drop them.
Changes
API changes
Added the following methods in
Item
:Item->getContainedItems()
: Returns the contents of such item, ex: shulker boxes, chests, brewing stands, hoppers, etc.Item->setContainedItems()
: Sets the contents of the item.Added the following method in
ContainerTrait
:ContainerTrait->copyContentsFromItem()
: Copied the citem contents into the block entity's inventory.Added the following helper class:
pocketmine\block\tile\util\ContainerHelper
Added the following trait:
pocketmine\block\util\ContainerTrait
Behavioural changes
Any item that has contents in it will now drop them once destroyed. This can include bundles once implemented.
Tests
z90lh0.mp4