diff --git a/src/block/Ice.php b/src/block/Ice.php index c1156fffa..f41426ead 100644 --- a/src/block/Ice.php +++ b/src/block/Ice.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace pocketmine\block; +use pocketmine\event\block\BlockMeltEvent; use pocketmine\item\enchantment\VanillaEnchantments; use pocketmine\item\Item; use pocketmine\player\Player; @@ -51,7 +52,11 @@ class Ice extends Transparent{ public function onRandomTick() : void{ if($this->position->getWorld()->getHighestAdjacentBlockLight($this->position->x, $this->position->y, $this->position->z) >= 12){ - $this->position->getWorld()->useBreakOn($this->position); + $ev = new BlockMeltEvent($this, VanillaBlocks::WATER()); + $ev->call(); + if(!$ev->isCancelled()){ + $this->position->getWorld()->setBlock($this->position, $ev->getNewState()); + } } } diff --git a/src/block/SnowLayer.php b/src/block/SnowLayer.php index c901e9d0c..4bea77df5 100644 --- a/src/block/SnowLayer.php +++ b/src/block/SnowLayer.php @@ -26,6 +26,7 @@ namespace pocketmine\block; use pocketmine\block\utils\BlockDataSerializer; use pocketmine\block\utils\Fallable; use pocketmine\block\utils\FallableTrait; +use pocketmine\event\block\BlockMeltEvent; use pocketmine\item\Item; use pocketmine\item\VanillaItems; use pocketmine\math\AxisAlignedBB; @@ -100,7 +101,11 @@ class SnowLayer extends Flowable implements Fallable{ public function onRandomTick() : void{ if($this->position->getWorld()->getBlockLightAt($this->position->x, $this->position->y, $this->position->z) >= 12){ - $this->position->getWorld()->setBlock($this->position, VanillaBlocks::AIR(), false); + $ev = new BlockMeltEvent($this, VanillaBlocks::AIR()); + $ev->call(); + if(!$ev->isCancelled()){ + $this->position->getWorld()->setBlock($this->position, $ev->getNewState()); + } } } diff --git a/src/event/block/BlockMeltEvent.php b/src/event/block/BlockMeltEvent.php new file mode 100644 index 000000000..a3b2f8fc7 --- /dev/null +++ b/src/event/block/BlockMeltEvent.php @@ -0,0 +1,31 @@ +