Skip to content

Commit

Permalink
Pickup spawn improvements (#4525)
Browse files Browse the repository at this point in the history
Pickups are now thrown around when spawned, like in vanilla. Pickups also bail out of the collision detection checks while being created, to prevent them from blasting too far off in e.g. cobblestone generators.
  • Loading branch information
mathiascode committed Mar 23, 2020
1 parent 41e0948 commit 7700116
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Entities/Entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@ void cEntity::HandlePhysics(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
}
}
}
else if (!(IsMinecart() || IsTNT()))
else if (!(IsMinecart() || IsTNT() || (IsPickup() && (m_TicksAlive < 15))))
{
// Push out entity.
BLOCKTYPE GotBlock;
Expand Down
8 changes: 4 additions & 4 deletions src/World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1974,9 +1974,9 @@ void cWorld::SpawnItemPickups(const cItems & a_Pickups, Vector3d a_Pos, double a
continue;
}

float SpeedX = static_cast<float>(a_FlyAwaySpeed * Random.RandInt(-5, 5));
float SpeedY = static_cast<float>(a_FlyAwaySpeed * Random.RandInt(50));
float SpeedZ = static_cast<float>(a_FlyAwaySpeed * Random.RandInt(-5, 5));
float SpeedX = static_cast<float>(a_FlyAwaySpeed * Random.RandInt(-10, 10));
float SpeedY = static_cast<float>(a_FlyAwaySpeed * Random.RandInt(40, 50));
float SpeedZ = static_cast<float>(a_FlyAwaySpeed * Random.RandInt(-10, 10));

auto Pickup = cpp14::make_unique<cPickup>(a_Pos, *itr, a_IsPlayerCreated, Vector3f{SpeedX, SpeedY, SpeedZ});
auto PickupPtr = Pickup.get();
Expand Down Expand Up @@ -2226,7 +2226,7 @@ bool cWorld::DropBlockAsPickups(Vector3i a_BlockPos, const cEntity * a_Digger, c
{
return false;
}
SpawnItemPickups(pickups, Vector3d(0.5, 0.5, 0.5) + a_BlockPos);
SpawnItemPickups(pickups, Vector3d(0.5, 0.5, 0.5) + a_BlockPos, 10);
return true;
}

Expand Down

0 comments on commit 7700116

Please sign in to comment.