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

Items that have contents now drops them on destroy #4768

Open
wants to merge 21 commits into
base: minor-next
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
ce9a2b9
Items that have contents now drops them on death
JavierLeon9966 Jan 24, 2022
027e8e1
Merge branch 'stable' into item-drop-contents
dktapps Sep 28, 2022
4b918aa
Added `Item::getContainedItems()` and `Item::setContainedItems()`
JavierLeon9966 Oct 3, 2022
1168d47
Fixed syntax error
JavierLeon9966 Oct 3, 2022
135781c
Fixed CS
JavierLeon9966 Oct 3, 2022
1ab9e4b
Merge branch 'next-minor' into item-drop-contents
JavierLeon9966 Oct 3, 2022
f1701a5
Merge remote-tracking branch 'origin/minor-next' into item-drop-contents
JavierLeon9966 Aug 22, 2024
ee86b51
Fixed items not preserving their slot positions
JavierLeon9966 Aug 23, 2024
28ae2d7
Extracted item contents serialization code
JavierLeon9966 Aug 23, 2024
bbbaf7e
Fixed PHPStan error
JavierLeon9966 Aug 23, 2024
d9fcbc7
Fix CS
JavierLeon9966 Aug 23, 2024
8d9e14d
Fix CS (again)
JavierLeon9966 Aug 23, 2024
6d47810
Make chiseled bookshelves use their own items serialization
JavierLeon9966 Aug 24, 2024
9628fbf
Include more item containers to be dropped upon destroy
JavierLeon9966 Aug 24, 2024
90d2432
Fix CS
JavierLeon9966 Aug 24, 2024
074cf27
Fix CS
JavierLeon9966 Aug 24, 2024
b0f1347
Merge remote-tracking branch 'fork/item-drop-contents' into item-drop…
JavierLeon9966 Aug 24, 2024
039105f
Renamed "util" folder to "utils" for consistency
JavierLeon9966 Aug 24, 2024
1582f95
Merge branch 'minor-next' into item-drop-contents
dktapps Nov 15, 2024
1ba57de
Clone the contained items before setting them
JavierLeon9966 Nov 29, 2024
d3e45f7
Merge branch 'minor-next' into item-drop-contents
JavierLeon9966 Nov 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/entity/object/ItemEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

namespace pocketmine\entity\object;

use pocketmine\block\tile\Container;
use pocketmine\entity\Entity;
use pocketmine\entity\EntitySizeInfo;
use pocketmine\entity\Location;
Expand All @@ -32,6 +33,7 @@
use pocketmine\item\Item;
use pocketmine\math\Vector3;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\ListTag;
use pocketmine\network\mcpe\convert\TypeConverter;
use pocketmine\network\mcpe\protocol\AddItemActorPacket;
use pocketmine\network\mcpe\protocol\types\entity\EntityIds;
Expand Down Expand Up @@ -255,4 +257,13 @@ public function onCollideWithPlayer(Player $player) : void{
}
$this->flagForDespawn();
}

protected function onDeath() : void{
if(($inventoryTag = $this->item->getNamedTag()->getTag(Container::TAG_ITEMS)) instanceof ListTag){
/** @var CompoundTag $itemNBT */
foreach($inventoryTag as $itemNBT){
$this->getWorld()->dropItem($this->location, Item::nbtDeserialize($itemNBT));
}
}
}
}