Skip to content

Commit

Permalink
Merged from official repo
Browse files Browse the repository at this point in the history
  • Loading branch information
PeratX committed Feb 18, 2016
1 parent 7218c4f commit 15534da
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
6 changes: 5 additions & 1 deletion src/pocketmine/Player.php
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,10 @@ public function isSleeping() : bool{
return $this->sleeping !== null;
}

public function getInAirTicks(){
return $this->inAirTicks;
}

protected function switchLevel(Level $targetLevel){
$oldLevel = $this->level;
if(parent::switchLevel($targetLevel)){
Expand Down Expand Up @@ -3364,7 +3368,7 @@ public function handleDataPacket(DataPacket $packet){
break;
}

$this->server->getPluginManager()->callEvent($ev = new CraftItemEvent($ingredients, $recipe));
$this->server->getPluginManager()->callEvent($ev = new CraftItemEvent($this, $ingredients, $recipe));

if($ev->isCancelled()){
$this->inventory->sendContents($this);
Expand Down
21 changes: 14 additions & 7 deletions src/pocketmine/event/inventory/CraftItemEvent.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

/**
*
* ____ _ _ __ __ _ __ __ ____
Expand All @@ -18,27 +17,30 @@
*
*
*/

namespace pocketmine\event\inventory;

use pocketmine\event\Cancellable;
use pocketmine\event\Event;
use pocketmine\inventory\Recipe;
use pocketmine\item\Item;
use pocketmine\Player;

class CraftItemEvent extends Event implements Cancellable{
public static $handlerList = null;

/** @var Item[] */
private $input = [];
/** @var Recipe */
private $recipe;
/** @var \pocketmine\Player */
private $player;

/**
* @param Item[] $input
* @param Recipe $recipe
* @param \pocketmine\Player $player
* @param Item[] $input
* @param Recipe $recipe
*/
public function __construct(array $input, Recipe $recipe){
public function __construct(Player $player, array $input, Recipe $recipe){
$this->player = $player;
$this->input = $input;
$this->recipe = $recipe;
}
Expand All @@ -51,7 +53,6 @@ public function getInput(){
foreach($items as $i => $item){
$items[$i] = clone $item;
}

return $items;
}

Expand All @@ -62,4 +63,10 @@ public function getRecipe(){
return $this->recipe;
}

/**
* @return \pocketmine\Player
*/
public function getPlayer(){
return $this->player;
}
}
11 changes: 9 additions & 2 deletions src/pocketmine/event/player/PlayerDeathEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ class PlayerDeathEvent extends EntityDeathEvent{
private $keepExperience = false;

/**
* @param Player $entity
* @param Item[] $drops
* @param Player $entity
* @param Item[] $drops
* @param string|TextContainer $deathMessage
*/
public function __construct(Player $entity, array $drops, $deathMessage){
Expand All @@ -51,6 +51,13 @@ public function getEntity(){
return $this->entity;
}

/**
* @return Player
*/
public function getPlayer(){
return $this->entity;
}

/**
* @return TextContainer|string
*/
Expand Down

0 comments on commit 15534da

Please sign in to comment.