diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index a59460f32..81c280481 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -2087,7 +2087,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade switch($packet->action){ case 0: //Start break - if($pos->distanceSquared($this) > 10000){ + if($this->lastBreak !== PHP_INT_MAX or $pos->distanceSquared($this) > 10000){ break; } $target = $this->level->getBlock($pos); @@ -2099,6 +2099,9 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade } $this->lastBreak = microtime(true); break; + case 1: //Abort! + $this->lastBreak = PHP_INT_MAX; + break; case 5: //Shot arrow if($this->startAction > -1 and $this->getDataFlag(self::DATA_FLAGS, self::DATA_FLAG_ACTION)){ if($this->inventory->getItemInHand()->getId() === Item::BOW) { diff --git a/src/pocketmine/block/Block.php b/src/pocketmine/block/Block.php index 28eae50c2..833eab7cb 100644 --- a/src/pocketmine/block/Block.php +++ b/src/pocketmine/block/Block.php @@ -796,6 +796,10 @@ class Block extends Position implements Metadatable{ $base *= 3.33; } + if($item->isSword()){ + $base *= 0.5; + } + return $base; } diff --git a/src/pocketmine/item/Tool.php b/src/pocketmine/item/Tool.php index 7d858de70..cc3121025 100644 --- a/src/pocketmine/item/Tool.php +++ b/src/pocketmine/item/Tool.php @@ -60,7 +60,19 @@ abstract class Tool extends Item{ return true; } - if($this->isHoe()){ + if($object instanceof Block){ + if( + $object->getToolType() === Tool::TYPE_PICKAXE and $this->isPickaxe() or + $object->getToolType() === Tool::TYPE_SHOVEL and $this->isShovel() or + $object->getToolType() === Tool::TYPE_AXE and $this->isAxe() or + $object->getToolType() === Tool::TYPE_SWORD and $this->isSword() or + $object->getToolType() === Tool::TYPE_SHEARS and $this->isShears() + ){ + $this->meta++; + }elseif(!$this->isShears() and $object->getBreakTime($this) > 0){ + $this->meta += 2; + } + }elseif($this->isHoe()){ if(($object instanceof Block) and ($object->getId() === self::GRASS or $object->getId() === self::DIRT)){ $this->meta++; } @@ -108,7 +120,7 @@ abstract class Tool extends Item{ public function isUnbreakable(){ $tag = $this->getNamedTagEntry("Unbreakable"); - return $tag instanceof Byte and $tag->getValue() > 0; + return $tag !== null and $tag->getValue() > 0; } public function isPickaxe(){ diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index 135530c5b..d7e24ecc8 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -1527,7 +1527,12 @@ class Level implements ChunkManager, Metadatable{ return false; } - $breakTime = $player->isCreative() ? 0.15 : $target->getBreakTime($item); + $breakTime = $target->getBreakTime($item); + + if($player->isCreative() and $breakTime > 0.15){ + $breakTime = 0.15; + } + if($player->hasEffect(Effect::SWIFTNESS)){ $breakTime *= 1 - (0.2 * ($player->getEffect(Effect::SWIFTNESS)->getAmplifier() + 1)); } @@ -1542,7 +1547,7 @@ class Level implements ChunkManager, Metadatable{ return false; } - $player->lastBreak = PHP_INT_MAX; + $player->lastBreak = microtime(true); $drops = $ev->getDrops();