PocketMine-MP 5.33.2 git-1133d49c924b4358c79d44eeb97dcbf56cb4d1eb
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;
40use function assert;
41
42final class LavaCauldron extends FillableCauldron{
43
44 public function writeStateToWorld() : void{
45 parent::writeStateToWorld();
46 $tile = $this->position->getWorld()->getTile($this->position);
47 assert($tile instanceof TileCauldron);
48
49 $tile->setCustomWaterColor(null);
50 $tile->setPotionItem(null);
51 }
52
53 public function getLightLevel() : int{
54 return 15;
55 }
56
57 public function getFillSound() : Sound{
58 return new CauldronFillLavaSound();
59 }
60
61 public function getEmptySound() : Sound{
62 return new CauldronEmptyLavaSound();
63 }
64
65 public function onInteract(Item $item, Facing $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{
66 match($item->getTypeId()){
67 ItemTypeIds::BUCKET => $this->removeFillLevels(self::MAX_FILL_LEVEL, $item, VanillaItems::LAVA_BUCKET(), $returnedItems),
68 ItemTypeIds::POWDER_SNOW_BUCKET, ItemTypeIds::WATER_BUCKET => $this->mix($item, VanillaItems::BUCKET(), $returnedItems),
69 ItemTypeIds::LINGERING_POTION, ItemTypeIds::POTION, ItemTypeIds::SPLASH_POTION => $this->mix($item, VanillaItems::GLASS_BOTTLE(), $returnedItems),
70 default => null
71 };
72 return true;
73 }
74
75 public function hasEntityCollision() : bool{ return true; }
76
77 public function onEntityInside(Entity $entity) : bool{
78 $ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_LAVA, 4);
79 $entity->attack($ev);
80
81 $ev = new EntityCombustByBlockEvent($this, $entity, 8);
82 $ev->call();
83 if(!$ev->isCancelled()){
84 $entity->setOnFire($ev->getDuration());
85 }
86
87 return true;
88 }
89}
onInteract(Item $item, Facing $face, Vector3 $clickVector, ?Player $player=null, array &$returnedItems=[])