mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 12:18:46 +00:00
parent
d8c90be5b8
commit
a6d1cc27ec
@ -40,6 +40,9 @@ use pocketmine\math\Math;
|
|||||||
use pocketmine\math\Vector3;
|
use pocketmine\math\Vector3;
|
||||||
use pocketmine\network\mcpe\protocol\ExplodePacket;
|
use pocketmine\network\mcpe\protocol\ExplodePacket;
|
||||||
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
|
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
|
||||||
|
use pocketmine\tile\Chest;
|
||||||
|
use pocketmine\tile\Container;
|
||||||
|
use pocketmine\tile\Tile;
|
||||||
|
|
||||||
class Explosion{
|
class Explosion{
|
||||||
|
|
||||||
@ -196,9 +199,11 @@ class Explosion{
|
|||||||
$air = ItemFactory::get(Item::AIR);
|
$air = ItemFactory::get(Item::AIR);
|
||||||
|
|
||||||
foreach($this->affectedBlocks as $block){
|
foreach($this->affectedBlocks as $block){
|
||||||
|
$yieldDrops = false;
|
||||||
|
|
||||||
if($block instanceof TNT){
|
if($block instanceof TNT){
|
||||||
$block->ignite(mt_rand(10, 30));
|
$block->ignite(mt_rand(10, 30));
|
||||||
}elseif(mt_rand(0, 100) < $yield){
|
}elseif($yieldDrops = (mt_rand(0, 100) < $yield)){
|
||||||
foreach($block->getDrops($air) as $drop){
|
foreach($block->getDrops($air) as $drop){
|
||||||
$this->level->dropItem($block->add(0.5, 0.5, 0.5), $drop);
|
$this->level->dropItem($block->add(0.5, 0.5, 0.5), $drop);
|
||||||
}
|
}
|
||||||
@ -206,6 +211,24 @@ class Explosion{
|
|||||||
|
|
||||||
$this->level->setBlockIdAt($block->x, $block->y, $block->z, 0);
|
$this->level->setBlockIdAt($block->x, $block->y, $block->z, 0);
|
||||||
|
|
||||||
|
$t = $this->level->getTile($block);
|
||||||
|
if($t instanceof Tile){
|
||||||
|
if($yieldDrops and $t instanceof Container){
|
||||||
|
if($t instanceof Chest){
|
||||||
|
$t->unpair();
|
||||||
|
}
|
||||||
|
|
||||||
|
$dropPos = $t->asVector3()->add(0.5, 0.5, 0.5);
|
||||||
|
foreach($t->getInventory()->getContents() as $drop){
|
||||||
|
if(!$drop->isNull()){
|
||||||
|
$this->level->dropItem($dropPos, $drop);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$t->close();
|
||||||
|
}
|
||||||
|
|
||||||
$pos = new Vector3($block->x, $block->y, $block->z);
|
$pos = new Vector3($block->x, $block->y, $block->z);
|
||||||
|
|
||||||
for($side = 0; $side <= 5; $side++){
|
for($side = 0; $side <= 5; $side++){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user