summaryrefslogtreecommitdiffstats
path: root/source/World.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-05-12 23:00:21 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-05-12 23:00:21 +0200
commit59eb31229105fda3cd4165cf091f83eaf3c26a5c (patch)
tree5c6e591d2df3fb7c9a69bb5cf772014e348dfdfe /source/World.cpp
parentNoise3D: cleanup (diff)
downloadcuberite-59eb31229105fda3cd4165cf091f83eaf3c26a5c.tar
cuberite-59eb31229105fda3cd4165cf091f83eaf3c26a5c.tar.gz
cuberite-59eb31229105fda3cd4165cf091f83eaf3c26a5c.tar.bz2
cuberite-59eb31229105fda3cd4165cf091f83eaf3c26a5c.tar.lz
cuberite-59eb31229105fda3cd4165cf091f83eaf3c26a5c.tar.xz
cuberite-59eb31229105fda3cd4165cf091f83eaf3c26a5c.tar.zst
cuberite-59eb31229105fda3cd4165cf091f83eaf3c26a5c.zip
Diffstat (limited to 'source/World.cpp')
-rw-r--r--source/World.cpp34
1 files changed, 25 insertions, 9 deletions
diff --git a/source/World.cpp b/source/World.cpp
index 0c33ddcaf..ea4950551 100644
--- a/source/World.cpp
+++ b/source/World.cpp
@@ -1209,14 +1209,22 @@ void cWorld::SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double
float SpeedY = (float)(a_FlyAwaySpeed * r1.randInt(1000));
float SpeedZ = (float)(a_FlyAwaySpeed * (r1.randInt(1000) - 500));
+ // Add random offset to the spawn position:
+ int MicroX = (int)(a_BlockX * 32) + (r1.randInt(16) + r1.randInt(16) - 16);
+ int MicroY = (int)(a_BlockY * 32) + (r1.randInt(16) + r1.randInt(16) - 16);
+ int MicroZ = (int)(a_BlockZ * 32) + (r1.randInt(16) + r1.randInt(16) - 16);
+
// TODO 2013_05_12 _X: Because spawning pickups with nonzero speed causes them to bug (FS #338),
// I decided to temporarily reset the speed to zero to fix it, until we have proper pickup physics
SpeedX = SpeedY = SpeedZ = 0;
+ // TODO 2013_05_12 _X: It seems that pickups bug out even with zero speed, trying mid-block position:
+ MicroX = (int)(floor(a_BlockX) * 32) + 16;
+ MicroY = (int)(floor(a_BlockY) * 32) + 16;
+ MicroZ = (int)(floor(a_BlockZ) * 32) + 16;
+
cPickup * Pickup = new cPickup(
- (int)(a_BlockX * 32) + (r1.randInt(16) + r1.randInt(16) - 16),
- (int)(a_BlockY * 32) + (r1.randInt(16) + r1.randInt(16) - 16),
- (int)(a_BlockZ * 32) + (r1.randInt(16) + r1.randInt(16) - 16),
+ MicroX, MicroY, MicroZ,
*itr, SpeedX, SpeedY, SpeedZ
);
Pickup->Initialize(this);
@@ -1229,17 +1237,25 @@ void cWorld::SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double
void cWorld::SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_SpeedX, double a_SpeedY, double a_SpeedZ)
{
+ // TODO 2013_05_12 _X: Because spawning pickups with nonzero speed causes them to bug (FS #338),
+ // I decided to temporarily reset the speed to zero to fix it, until we have proper pickup physics
+ a_SpeedX = a_SpeedY = a_SpeedZ = 0;
+
MTRand r1;
for (cItems::const_iterator itr = a_Pickups.begin(); itr != a_Pickups.end(); ++itr)
{
- // TODO 2013_05_12 _X: Because spawning pickups with nonzero speed causes them to bug (FS #338),
- // I decided to temporarily reset the speed to zero to fix it, until we have proper pickup physics
- a_SpeedX = a_SpeedY = a_SpeedZ = 0;
+ // Add random offset to the spawn position:
+ int MicroX = (int)(a_BlockX * 32) + (r1.randInt(16) + r1.randInt(16) - 16);
+ int MicroY = (int)(a_BlockY * 32) + (r1.randInt(16) + r1.randInt(16) - 16);
+ int MicroZ = (int)(a_BlockZ * 32) + (r1.randInt(16) + r1.randInt(16) - 16);
+
+ // TODO 2013_05_12 _X: It seems that pickups bug out even with zero speed, trying mid-block position:
+ MicroX = (int)(floor(a_BlockX) * 32) + 16;
+ MicroY = (int)(floor(a_BlockY) * 32) + 16;
+ MicroZ = (int)(floor(a_BlockZ) * 32) + 16;
cPickup * Pickup = new cPickup(
- (int)(a_BlockX * 32) + r1.randInt(16) + r1.randInt(16),
- (int)(a_BlockY * 32) + r1.randInt(16) + r1.randInt(16),
- (int)(a_BlockZ * 32) + r1.randInt(16) + r1.randInt(16),
+ MicroX, MicroY, MicroZ,
*itr, (float)a_SpeedX, (float)a_SpeedY, (float)a_SpeedZ
);
Pickup->Initialize(this);