Added Shears check and drops [gh#749,750]

This commit is contained in:
Shoghi Cervantes 2013-08-25 20:40:25 +02:00
parent 02a8a3e881
commit 30483d5312
2 changed files with 13 additions and 5 deletions

View File

@ -261,6 +261,10 @@ class Item{
return false; return false;
} }
} }
public function isShears(){
return ($this->id === SHEARS);
}
final public function __toString(){ final public function __toString(){
return "Item ". $this->name ." (".$this->id.":".$this->meta.")"; return "Item ". $this->name ." (".$this->id.":".$this->meta.")";

View File

@ -141,11 +141,15 @@ class LeavesBlock extends TransparentBlock{
public function getDrops(Item $item, Player $player){ public function getDrops(Item $item, Player $player){
$drops = array(); $drops = array();
if(mt_rand(1,20) === 1){ //Saplings if($item->isShears()){
$drops[] = array(SAPLING, $this->meta & 0x03, 1); $drops[] = array(LEAVES, $this->meta & 0x03, 1);
} }else{
if(($this->meta & 0x03) === LeavesBlock::OAK and mt_rand(1,200) === 1){ //Apples if(mt_rand(1,20) === 1){ //Saplings
$drops[] = array(APPLE, 0, 1); $drops[] = array(SAPLING, $this->meta & 0x03, 1);
}
if(($this->meta & 0x03) === LeavesBlock::OAK and mt_rand(1,200) === 1){ //Apples
$drops[] = array(APPLE, 0, 1);
}
} }
return $drops; return $drops;
} }