mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 18:32:55 +00:00
Added Block Properties
This commit is contained in:
65
src/classes/material/block/plant/Sapling.php
Normal file
65
src/classes/material/block/plant/Sapling.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
|
||||
-
|
||||
/ \
|
||||
/ \
|
||||
/ PocketMine \
|
||||
/ MP \
|
||||
|\ @shoghicp /|
|
||||
|. \ / .|
|
||||
| .. \ / .. |
|
||||
| .. | .. |
|
||||
| .. | .. |
|
||||
\ | /
|
||||
\ | /
|
||||
\ | /
|
||||
\ | /
|
||||
|
||||
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.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
class SaplingBlock extends TransparentBlock{
|
||||
const OAK = 0;
|
||||
const SPRUCE = 1;
|
||||
const BIRCH = 2;
|
||||
const BURN_TIME = 5;
|
||||
|
||||
public function __construct($type = Sapling::OAK){
|
||||
parent::__construct(SAPLING, $type, "Sapling");
|
||||
$this->isActivable = true;
|
||||
$this->isFlowable = true;
|
||||
$names = array(
|
||||
0 => "Oak Sapling",
|
||||
1 => "Spruce Sapling",
|
||||
2 => "Birch Sapling",
|
||||
);
|
||||
$this->name = $names[$this->type & 0x03];
|
||||
}
|
||||
|
||||
public function onActivate(LevelAPI $level, Item $item, Player $player){
|
||||
TreeObject::growTree($level, $this);
|
||||
}
|
||||
|
||||
public function onUpdate(LevelAPI $level, $type){
|
||||
if($this->inWorld !== true){
|
||||
return false;
|
||||
}
|
||||
if($type === BLOCK_UPDATE_RANDOM and mt_rand(0,2) === 0){ //Growth
|
||||
if(($this->meta & 0x08) === 0x08){
|
||||
TreeObject::growTree($level, $this);
|
||||
}else{
|
||||
$this->meta |= 0x08;
|
||||
$this->level->setBlock($this->x, $this->y, $this->z, $this->id, $this->meta);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user