mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 02:42:58 +00:00
Coarse is now a state of Dirt, instead of a separate block
This commit is contained in:
@ -31,10 +31,36 @@ use pocketmine\player\Player;
|
||||
|
||||
class Dirt extends Opaque{
|
||||
|
||||
protected bool $coarse = false;
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->coarse = ($stateMeta & BlockLegacyMetadata::DIRT_FLAG_COARSE) !== 0;
|
||||
}
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return $this->coarse ? BlockLegacyMetadata::DIRT_FLAG_COARSE : 0;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1;
|
||||
}
|
||||
|
||||
public function getNonPersistentStateBitmask() : int{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function isCoarse() : bool{ return $this->coarse; }
|
||||
|
||||
/** @return $this */
|
||||
public function setCoarse(bool $coarse) : self{
|
||||
$this->coarse = $coarse;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if($face === Facing::UP and $item instanceof Hoe){
|
||||
$item->applyDamage(1);
|
||||
$this->pos->getWorld()->setBlock($this->pos, VanillaBlocks::FARMLAND());
|
||||
$this->pos->getWorld()->setBlock($this->pos, $this->coarse ? VanillaBlocks::DIRT() : VanillaBlocks::FARMLAND());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user