Added ItemSpawnEvent

This commit is contained in:
Shoghi Cervantes 2014-10-08 16:53:13 +02:00
parent c750a204e6
commit 4a3163b4c8
2 changed files with 52 additions and 0 deletions

View File

@ -24,6 +24,7 @@ namespace pocketmine\entity;
use pocketmine\event\entity\EntityDamageEvent;
use pocketmine\event\entity\EntityRegainHealthEvent;
use pocketmine\event\entity\ItemDespawnEvent;
use pocketmine\event\entity\ItemSpawnEvent;
use pocketmine\item\Item;
use pocketmine\math\Vector3;
use pocketmine\nbt\tag\Byte;
@ -67,6 +68,9 @@ class DroppedItem extends Entity{
$this->thrower = $this->namedtag["Thrower"];
}
$this->item = Item::get($this->namedtag->Item["id"], $this->namedtag->Item["Damage"], $this->namedtag->Item["Count"]);
$this->server->getPluginManager()->callEvent(new ItemSpawnEvent($this));
}
public function onUpdate(){

View File

@ -0,0 +1,48 @@
<?php
/**
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine\event\entity;
use pocketmine\block\Block;
use pocketmine\entity\DroppedItem;
use pocketmine\entity\Entity;
use pocketmine\event\Cancellable;
use pocketmine\level\Position;
class ItemSpawnEvent extends EntityEvent{
public static $handlerList = null;
/**
* @param DroppedItem $item
*/
public function __construct(DroppedItem $item){
$this->entity = $item;
}
/**
* @return DroppedItem
*/
public function getEntity(){
return $this->entity;
}
}