PocketMine-MP 5.23.3 git-f7687af337d001ddbcc47b8e773f014a33faa662
Loading...
Searching...
No Matches
Lava.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
34
35class Lava extends Liquid{
36
37 public function getLightLevel() : int{
38 return 15;
39 }
40
41 public function getBucketFillSound() : Sound{
42 return new BucketFillLavaSound();
43 }
44
45 public function getBucketEmptySound() : Sound{
46 return new BucketEmptyLavaSound();
47 }
48
49 public function tickRate() : int{
50 return 30;
51 }
52
53 public function getFlowDecayPerBlock() : int{
54 return 2; //TODO: this is 1 in the nether
55 }
56
60 private function getAdjacentBlocksExceptDown() : \Generator{
61 foreach(Facing::ALL as $side){
62 if($side === Facing::DOWN){
63 continue;
64 }
65 yield $this->getSide($side);
66 }
67 }
68
69 protected function checkForHarden() : bool{
70 if($this->falling){
71 return false;
72 }
73 foreach($this->getAdjacentBlocksExceptDown() as $colliding){
74 if($colliding instanceof Water){
75 if($this->decay === 0){
76 $this->liquidCollide($colliding, VanillaBlocks::OBSIDIAN());
77 return true;
78 }elseif($this->decay <= 4){
79 $this->liquidCollide($colliding, VanillaBlocks::COBBLESTONE());
80 return true;
81 }
82 }
83 }
84
85 if($this->getSide(Facing::DOWN)->getTypeId() === BlockTypeIds::SOUL_SOIL){
86 foreach($this->getAdjacentBlocksExceptDown() as $colliding){
87 if($colliding->getTypeId() === BlockTypeIds::BLUE_ICE){
88 $this->liquidCollide($colliding, VanillaBlocks::BASALT());
89 return true;
90 }
91 }
92 }
93
94 return false;
95 }
96
97 protected function flowIntoBlock(Block $block, int $newFlowDecay, bool $falling) : void{
98 if($block instanceof Water){
99 $block->liquidCollide($this, VanillaBlocks::STONE());
100 }else{
101 parent::flowIntoBlock($block, $newFlowDecay, $falling);
102 }
103 }
104
105 public function onEntityInside(Entity $entity) : bool{
106 $ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_LAVA, 4);
107 $entity->attack($ev);
108
109 //in java burns entities for 15 seconds - seems to be a parity issue in bedrock
110 $ev = new EntityCombustByBlockEvent($this, $entity, 8);
111 $ev->call();
112 if(!$ev->isCancelled()){
113 $entity->setOnFire($ev->getDuration());
114 }
115
116 $entity->resetFallDistance();
117 return true;
118 }
119}
onEntityInside(Entity $entity)
Definition Lava.php:105