From 228075851c4e03ee6bf393b47073d842ee5e4d30 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Pueyo Date: Mon, 20 May 2013 16:38:41 +0200 Subject: [PATCH] Correct Ice drop --- src/API/BlockAPI.php | 4 +++- src/material/block/DoorBlock.php | 25 ++++++++++++------------- src/material/block/solid/Ice.php | 5 +++++ 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/API/BlockAPI.php b/src/API/BlockAPI.php index 07f1a060e..a264a0848 100644 --- a/src/API/BlockAPI.php +++ b/src/API/BlockAPI.php @@ -273,7 +273,9 @@ class BlockAPI{ if($this->server->api->dhandle("player.block.break", array("player" => $player, "target" => $target, "item" => $item)) !== false){ $drops = $target->getDrops($item, $player); - $target->onBreak($item, $player); + if($target->onBreak($item, $player) === false){ + return $this->cancelAction($target, $player); + } }else{ return $this->cancelAction($target, $player); } diff --git a/src/material/block/DoorBlock.php b/src/material/block/DoorBlock.php index c98a9f354..4c86f27c9 100644 --- a/src/material/block/DoorBlock.php +++ b/src/material/block/DoorBlock.php @@ -60,20 +60,19 @@ class DoorBlock extends TransparentBlock{ } public function onBreak(Item $item, Player $player){ - if(($this->meta & 0x08) === 0x08){ - $down = $this->getSide(0); - if($down->getID() === $this->id){ - $this->level->setBlock($down, new AirBlock()); - } - }else{ - $up = $this->getSide(1); - if($up->getID() === $this->id){ - $this->level->setBlock($up, new AirBlock()); - } + if(($this->meta & 0x08) === 0x08){ + $down = $this->getSide(0); + if($down->getID() === $this->id){ + $this->level->setBlock($down, new AirBlock()); } - $this->level->setBlock($this, new AirBlock()); - return true; - return false; + }else{ + $up = $this->getSide(1); + if($up->getID() === $this->id){ + $this->level->setBlock($up, new AirBlock()); + } + } + $this->level->setBlock($this, new AirBlock()); + return true; } public function onActivate(Item $item, Player $player){ diff --git a/src/material/block/solid/Ice.php b/src/material/block/solid/Ice.php index 8daae7e3c..5227b039b 100644 --- a/src/material/block/solid/Ice.php +++ b/src/material/block/solid/Ice.php @@ -30,6 +30,11 @@ class IceBlock extends TransparentBlock{ parent::__construct(ICE, 0, "Ice"); } + public function onBreak(Item $item, Player $player){ + $this->level->setBlock($this, new WaterBlock()); + return true; + } + public function getBreakTime(Item $item, Player $player){ if(($player->gamemode & 0x01) === 0x01){ return 0.20;