22declare(strict_types=1);
35use
function array_rand;
42 return ItemUseResult::NONE;
49 $currentTotalDimension = $motive->getHeight() + $motive->getWidth();
50 if($currentTotalDimension < $totalDimension){
54 if(
Painting::canFit($player->getWorld(), $blockReplace->getPosition(), $face,
true, $motive)){
55 if($currentTotalDimension > $totalDimension){
56 $totalDimension = $currentTotalDimension;
69 if(count($motives) === 0){
70 return ItemUseResult::NONE;
74 $motive = $motives[array_rand($motives)];
76 $replacePos = $blockReplace->getPosition();
77 $clickedPos = $blockClicked->getPosition();
79 $entity =
new Painting(
Location::fromObject($replacePos, $replacePos->getWorld()), $clickedPos, $face, $motive);
81 $entity->spawnToAll();
83 $player->getWorld()->addSound($replacePos->add(0.5, 0.5, 0.5),
new PaintingPlaceSound());
84 return ItemUseResult::SUCCESS;
static fromObject(Vector3 $pos, ?World $world, float $yaw=0.0, float $pitch=0.0)
static canFit(World $world, Vector3 $blockIn, int $facing, bool $checkOverlap, PaintingMotive $motive)
onInteractBlock(Player $player, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, array &$returnedItems)