Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 8 additions & 0 deletions src/block/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -982,4 +982,12 @@ public function calculateIntercept(Vector3 $pos1, Vector3 $pos2) : ?RayTraceResu

return $currentHit;
}

/**
* Return items dropped by the block when it is broken by a player in gamemode creative
* @return Item[]
*/
public function getCreativeDrops() : array{
return [];
}
}
13 changes: 13 additions & 0 deletions src/block/ShulkerBox.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use pocketmine\math\Vector3;
use pocketmine\player\Player;
use pocketmine\world\BlockTransaction;
use function count;

class ShulkerBox extends Opaque{
use AnyFacingTrait;
Expand Down Expand Up @@ -115,4 +116,16 @@ public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player
public function getSupportType(int $facing) : SupportType{
return SupportType::NONE;
}

public function getCreativeDrops() : array{
$shulker = $this->position->getWorld()->getTile($this->position);
if($shulker instanceof TileShulkerBox){
if(count($shulker->getInventory()->getContents()) > 0){
$drop = $this->asItem();
$this->addDataFromTile($shulker, $drop);
return [$drop];
}
}
return [];
}
}
36 changes: 36 additions & 0 deletions src/event/attribute/Listener.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/

declare(strict_types=1);

namespace pocketmine\event\attribute;

use Attribute;
use pocketmine\event\EventPriority;

#[Attribute(Attribute::TARGET_METHOD)]
class Listener{
public function __construct(
public ?string $event = null,
public int $priority = EventPriority::NORMAL,
public bool $ignoreCancelled = false
){ }
}
31 changes: 31 additions & 0 deletions src/event/attribute/NotHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/

declare(strict_types=1);

namespace pocketmine\event\attribute;

use Attribute;

#[Attribute(Attribute::TARGET_METHOD)]
class NotHandler{

}
3 changes: 2 additions & 1 deletion src/world/World.php
Original file line number Diff line number Diff line change
Expand Up @@ -2053,9 +2053,10 @@ public function useBreakOn(Vector3 $vector, Item &$item = null, ?Player $player
$item = VanillaItems::AIR();
}

$drops = [];
if($player === null || $player->hasFiniteResources()){
$drops = array_merge(...array_map(fn(Block $block) => $block->getDrops($item), $affectedBlocks));
}else{
$drops = array_merge(...array_map(fn(Block $block) => $block->getCreativeDrops(), $affectedBlocks));
}

$xpDrop = 0;
Expand Down