Fixed dropped items going too fast

This commit is contained in:
Shoghi Cervantes 2014-09-01 23:37:31 +02:00
parent acf7eb1ce9
commit e94ddcabe0
2 changed files with 6 additions and 6 deletions

View File

@ -1903,9 +1903,9 @@ 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(10); $motion = $this->getDirectionVector()->multiply(0.4);
$this->getLevel()->dropItem($this->add(0, 1, 0), $item, $motion); $this->getLevel()->dropItem($this->add(0, 1.3, 0), $item, $motion);
if($this->inAction === true){ if($this->inAction === true){
$this->inAction = false; $this->inAction = false;

View File

@ -924,7 +924,7 @@ class Level implements ChunkManager, Metadatable{
* @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){
$motion = $motion === null ? new Vector3(0, 0, 0) : $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("", [
"Pos" => new Enum("Pos", [ "Pos" => new Enum("Pos", [
@ -934,9 +934,9 @@ class Level implements ChunkManager, Metadatable{
]), ]),
//TODO: add random motion with physics //TODO: add random motion with physics
"Motion" => new Enum("Motion", [ "Motion" => new Enum("Motion", [
new Double("", $motion->x + (lcg_value() * 0.2 - 0.1)), new Double("", $motion->x),
new Double("", $motion->y + 0.2), new Double("", $motion->y),
new Double("", $motion->z + (lcg_value() * 0.2 - 0.1)) new Double("", $motion->z)
]), ]),
"Rotation" => new Enum("Rotation", [ "Rotation" => new Enum("Rotation", [
new Float("", lcg_value() * 360), new Float("", lcg_value() * 360),