From 30483d53129968178cf0ce2a31e75a411ac35d2f Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Sun, 25 Aug 2013 20:40:25 +0200 Subject: [PATCH] Added Shears check and drops [gh#749,750] --- src/material/Item.php | 4 ++++ src/material/block/solid/Leaves.php | 14 +++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/material/Item.php b/src/material/Item.php index e18c36578..44a378795 100644 --- a/src/material/Item.php +++ b/src/material/Item.php @@ -261,6 +261,10 @@ class Item{ return false; } } + + public function isShears(){ + return ($this->id === SHEARS); + } final public function __toString(){ return "Item ". $this->name ." (".$this->id.":".$this->meta.")"; diff --git a/src/material/block/solid/Leaves.php b/src/material/block/solid/Leaves.php index 0f8fbb0c0..8c20e6b5b 100644 --- a/src/material/block/solid/Leaves.php +++ b/src/material/block/solid/Leaves.php @@ -141,11 +141,15 @@ class LeavesBlock extends TransparentBlock{ public function getDrops(Item $item, Player $player){ $drops = array(); - if(mt_rand(1,20) === 1){ //Saplings - $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); + if($item->isShears()){ + $drops[] = array(LEAVES, $this->meta & 0x03, 1); + }else{ + if(mt_rand(1,20) === 1){ //Saplings + $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; }