Fixed Item drop delay

This commit is contained in:
Shoghi Cervantes 2014-09-08 07:40:19 +02:00
parent d8c492de4a
commit 0a4e0e3228
2 changed files with 3 additions and 3 deletions

View File

@ -1903,7 +1903,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
$this->inventory->setItemInHand(Item::get(Item::AIR, 0, 1)); $this->inventory->setItemInHand(Item::get(Item::AIR, 0, 1));
$motion = $this->getDirectionVector()->multiply(0.4); $motion = $this->getDirectionVector()->multiply(0.4);
$this->getLevel()->dropItem($this->add(0, 1.3, 0), $item, $motion); $this->getLevel()->dropItem($this->add(0, 1.3, 0), $item, $motion, 40);
if($this->inAction === true){ if($this->inAction === true){
$this->inAction = false; $this->inAction = false;

View File

@ -925,7 +925,7 @@ class Level implements ChunkManager, Metadatable{
* @param Item $item * @param Item $item
* @param Vector3 $motion * @param Vector3 $motion
*/ */
public function dropItem(Vector3 $source, Item $item, Vector3 $motion = null){ public function dropItem(Vector3 $source, Item $item, Vector3 $motion = null, $delay = 10){
$motion = $motion === null ? new Vector3(lcg_value() * 0.2 - 0.1, 0.2, lcg_value() * 0.2 - 0.1) : $motion; $motion = $motion === null ? new Vector3(lcg_value() * 0.2 - 0.1, 0.2, lcg_value() * 0.2 - 0.1) : $motion;
if($item->getID() !== Item::AIR and $item->getCount() > 0){ if($item->getID() !== Item::AIR and $item->getCount() > 0){
$itemEntity = new DroppedItem($this->getChunkAt($source->getX() >> 4, $source->getZ() >> 4), new Compound("", [ $itemEntity = new DroppedItem($this->getChunkAt($source->getX() >> 4, $source->getZ() >> 4), new Compound("", [
@ -950,7 +950,7 @@ class Level implements ChunkManager, Metadatable{
"Damage" => new Short("Damage", $item->getDamage()), "Damage" => new Short("Damage", $item->getDamage()),
"Count" => new Byte("Count", $item->getCount()) "Count" => new Byte("Count", $item->getCount())
]), ]),
"PickupDelay" => new Short("PickupDelay", 50) "PickupDelay" => new Short("PickupDelay", $delay)
])); ]));
$itemEntity->spawnToAll(); $itemEntity->spawnToAll();