diff options
author | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2013-09-18 23:20:08 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2013-09-18 23:20:08 +0200 |
commit | 198ac1892ca0751551206ca25164bc691386914b (patch) | |
tree | d69d08c269a7eaf78dd8917e309f0d75d4accf3d /source | |
parent | Added moar mobs! (diff) | |
download | cuberite-198ac1892ca0751551206ca25164bc691386914b.tar cuberite-198ac1892ca0751551206ca25164bc691386914b.tar.gz cuberite-198ac1892ca0751551206ca25164bc691386914b.tar.bz2 cuberite-198ac1892ca0751551206ca25164bc691386914b.tar.lz cuberite-198ac1892ca0751551206ca25164bc691386914b.tar.xz cuberite-198ac1892ca0751551206ca25164bc691386914b.tar.zst cuberite-198ac1892ca0751551206ca25164bc691386914b.zip |
Diffstat (limited to '')
-rw-r--r-- | source/Blocks/BlockHandler.cpp | 18 | ||||
-rw-r--r-- | source/Entities/Pickup.cpp | 4 | ||||
-rw-r--r-- | source/Entities/Pickup.h | 2 | ||||
-rw-r--r-- | source/World.cpp | 15 |
4 files changed, 16 insertions, 23 deletions
diff --git a/source/Blocks/BlockHandler.cpp b/source/Blocks/BlockHandler.cpp index 43330befa..7d896f1b6 100644 --- a/source/Blocks/BlockHandler.cpp +++ b/source/Blocks/BlockHandler.cpp @@ -358,13 +358,17 @@ void cBlockHandler::DropBlock(cWorld * a_World, cEntity * a_Digger, int a_BlockX if (!Pickups.empty()) { - // Add random offset to the spawn position: - // Commented out until bug with pickups not spawning properly is fixed, see World.cpp - /* - 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); - */ + MTRand r1; + + // Mid-block position first + int MicroX = (int)(floor(a_BlockX) * 32) + 16; + int MicroY = (int)(floor(a_BlockY) * 32) + 16; + int MicroZ = (int)(floor(a_BlockZ) * 32) + 16; + + // Add random offset second + MicroX = (int)(a_BlockX * 32) + (r1.randInt(16) + r1.randInt(16) - 16); + MicroY = (int)(a_BlockY * 32) + (r1.randInt(16) + r1.randInt(16) - 16); + MicroZ = (int)(a_BlockZ * 32) + (r1.randInt(16) + r1.randInt(16) - 16); a_World->SpawnItemPickups(Pickups, a_BlockX, a_BlockY, a_BlockZ); } diff --git a/source/Entities/Pickup.cpp b/source/Entities/Pickup.cpp index db7be8b04..79a3a6274 100644 --- a/source/Entities/Pickup.cpp +++ b/source/Entities/Pickup.cpp @@ -24,8 +24,8 @@ -cPickup::cPickup(int a_MicroPosX, int a_MicroPosY, int a_MicroPosZ, const cItem & a_Item, float a_SpeedX /* = 0.f */, float a_SpeedY /* = 0.f */, float a_SpeedZ /* = 0.f */) - : cEntity(etPickup, (((double)(a_MicroPosX)) / 32) + 0.1 /*Accomodate player vomiting*/, ((double)(a_MicroPosY)) / 32, ((double)(a_MicroPosZ)) / 32, 0.2, 0.2) +cPickup::cPickup(double a_MicroPosX, double a_MicroPosY, double a_MicroPosZ, const cItem & a_Item, float a_SpeedX /* = 0.f */, float a_SpeedY /* = 0.f */, float a_SpeedZ /* = 0.f */) + : cEntity(etPickup, (double)(a_MicroPosX), (double)(a_MicroPosY), (double)(a_MicroPosZ), 0.2, 0.2) , m_Timer( 0.f ) , m_Item(a_Item) , m_bCollected( false ) diff --git a/source/Entities/Pickup.h b/source/Entities/Pickup.h index af6eaf3bb..e35914684 100644 --- a/source/Entities/Pickup.h +++ b/source/Entities/Pickup.h @@ -24,7 +24,7 @@ class cPickup : public: CLASS_PROTODEF(cPickup); - cPickup(int a_MicroPosX, int a_MicroPosY, int a_MicroPosZ, const cItem & a_Item, float a_SpeedX = 0.f, float a_SpeedY = 0.f, float a_SpeedZ = 0.f); // tolua_export + cPickup(double a_MicroPosX, double a_MicroPosY, double a_MicroPosZ, const cItem & a_Item, float a_SpeedX = 0.f, float a_SpeedY = 0.f, float a_SpeedZ = 0.f); // tolua_export cItem & GetItem(void) {return m_Item; } // tolua_export const cItem & GetItem(void) const {return m_Item; } diff --git a/source/World.cpp b/source/World.cpp index 6ec3825cf..606ef0787 100644 --- a/source/World.cpp +++ b/source/World.cpp @@ -1522,14 +1522,9 @@ void cWorld::SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double float SpeedX = (float)(a_FlyAwaySpeed * (r1.randInt(1000) - 500)); float SpeedY = 1; float SpeedZ = (float)(a_FlyAwaySpeed * (r1.randInt(1000) - 500)); - - // Pickup doesn't spawn on client without a mid block position. Perhaps the doubles are causing issues? - int MicroX = (int)(floor(a_BlockX) * 32) + 16; - int MicroY = (int)(floor(a_BlockY) * 32) + 16; - int MicroZ = (int)(floor(a_BlockZ) * 32) + 16; cPickup * Pickup = new cPickup( - MicroX, MicroY, MicroZ, + a_BlockX, a_BlockY, a_BlockZ, *itr, SpeedX, SpeedY, SpeedZ ); Pickup->Initialize(this); @@ -1542,16 +1537,10 @@ 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) { - MTRand r1; for (cItems::const_iterator itr = a_Pickups.begin(); itr != a_Pickups.end(); ++itr) { - // Pickup doesn't spawn on client without a mid block position. Perhaps the doubles are causing issues? - int MicroX = (int)(floor(a_BlockX) * 32) + 16; - int MicroY = (int)(floor(a_BlockY) * 32) + 16; - int MicroZ = (int)(floor(a_BlockZ) * 32) + 16; - cPickup * Pickup = new cPickup( - MicroX, MicroY, MicroZ, + a_BlockX, a_BlockY, a_BlockZ, *itr, (float)a_SpeedX, (float)a_SpeedY, (float)a_SpeedZ ); Pickup->Initialize(this); |