ContainerTrait: improve performance of block destroy hook

this was creating useless vector3s for every iteration, as well as repeatedly invoking Position->getWorld() for no reason.
This commit is contained in:
Dylan K. Taylor 2022-07-20 20:39:37 +01:00
parent dbc0b9634b
commit 24e72ec109
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -96,8 +96,10 @@ trait ContainerTrait{
$inv = $this->getRealInventory();
$pos = $this->getPosition();
$world = $pos->getWorld();
$dropPos = $pos->add(0.5, 0.5, 0.5);
foreach($inv->getContents() as $k => $item){
$pos->getWorld()->dropItem($pos->add(0.5, 0.5, 0.5), $item);
$world->dropItem($dropPos, $item);
}
$inv->clearAll();
}