mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-01 17:53:41 +00:00
this also changes the name of the class property 'pos' to 'position' as well as Block->getPosOffset() to Block->getPositionOffset()
66 lines
1.8 KiB
PHP
66 lines
1.8 KiB
PHP
<?php
|
|
|
|
/*
|
|
*
|
|
* ____ _ _ __ __ _ __ __ ____
|
|
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
|
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
|
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* @author PocketMine Team
|
|
* @link http://www.pocketmine.net/
|
|
*
|
|
*
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace pocketmine\block;
|
|
|
|
use pocketmine\item\enchantment\VanillaEnchantments;
|
|
use pocketmine\item\Item;
|
|
use pocketmine\player\Player;
|
|
|
|
class Ice extends Transparent{
|
|
|
|
public function getLightFilter() : int{
|
|
return 2;
|
|
}
|
|
|
|
public function getFrictionFactor() : float{
|
|
return 0.98;
|
|
}
|
|
|
|
public function onBreak(Item $item, ?Player $player = null) : bool{
|
|
if(($player === null or $player->isSurvival()) and !$item->hasEnchantment(VanillaEnchantments::SILK_TOUCH())){
|
|
$this->position->getWorld()->setBlock($this->position, VanillaBlocks::WATER());
|
|
return true;
|
|
}
|
|
return parent::onBreak($item, $player);
|
|
}
|
|
|
|
public function ticksRandomly() : bool{
|
|
return true;
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|
|
|
|
public function getDropsForCompatibleTool(Item $item) : array{
|
|
return [];
|
|
}
|
|
|
|
public function isAffectedBySilkTouch() : bool{
|
|
return true;
|
|
}
|
|
}
|