PocketMine-MP 5.21.2 git-a6534ecbbbcf369264567d27e5ed70f7f5be9816
Loading...
Searching...
No Matches
LavaCauldron.php
1<?php
2
3/*
4 *
5 * ____ _ _ __ __ _ __ __ ____
6 * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
7 * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
8 * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
9 * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
10 *
11 * This program is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * @author PocketMine Team
17 * @link http://www.pocketmine.net/
18 *
19 *
20 */
21
22declare(strict_types=1);
23
24namespace pocketmine\block;
25
26use pocketmine\block\tile\Cauldron as TileCauldron;
39use function assert;
40
41final class LavaCauldron extends FillableCauldron{
42
43 public function writeStateToWorld() : void{
44 parent::writeStateToWorld();
45 $tile = $this->position->getWorld()->getTile($this->position);
46 assert($tile instanceof TileCauldron);
47
48 $tile->setCustomWaterColor(null);
49 $tile->setPotionItem(null);
50 }
51
52 public function getLightLevel() : int{
53 return 15;
54 }
55
56 public function getFillSound() : Sound{
57 return new CauldronFillLavaSound();
58 }
59
60 public function getEmptySound() : Sound{
61 return new CauldronEmptyLavaSound();
62 }
63
64 public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{
65 match($item->getTypeId()){
66 ItemTypeIds::BUCKET => $this->removeFillLevels(self::MAX_FILL_LEVEL, $item, VanillaItems::LAVA_BUCKET(), $returnedItems),
67 ItemTypeIds::POWDER_SNOW_BUCKET, ItemTypeIds::WATER_BUCKET => $this->mix($item, VanillaItems::BUCKET(), $returnedItems),
68 ItemTypeIds::LINGERING_POTION, ItemTypeIds::POTION, ItemTypeIds::SPLASH_POTION => $this->mix($item, VanillaItems::GLASS_BOTTLE(), $returnedItems),
69 default => null
70 };
71 return true;
72 }
73
74 public function hasEntityCollision() : bool{ return true; }
75
76 public function onEntityInside(Entity $entity) : bool{
77 $ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_LAVA, 4);
78 $entity->attack($ev);
79
80 $ev = new EntityCombustByBlockEvent($this, $entity, 8);
81 $ev->call();
82 if(!$ev->isCancelled()){
83 $entity->setOnFire($ev->getDuration());
84 }
85
86 return true;
87 }
88}
onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player=null, array &$returnedItems=[])