From 24efa6f8645c2f310997c212907fb4e591d0afec Mon Sep 17 00:00:00 2001 From: "lapayo94@gmail.com" Date: Thu, 22 Dec 2011 21:36:24 +0000 Subject: =?UTF-8?q?Digging=20leaves=20with=20shears=20now=20drops=20leaves?= =?UTF-8?q?=20Falling=20Sand=20now=20notifies=20water=20around=20Implement?= =?UTF-8?q?ed=20Function=20to=20get=20the=20relative=20chunk=20position=20?= =?UTF-8?q?in=20the=20total=20position=20(cChunk::PositionToWorldPosition)?= =?UTF-8?q?=20Pistons=20don=C2=B4t=20drop=20water=20and=20lava=20items=20a?= =?UTF-8?q?nymore=20when=20stopping=20water/lava=20implemented=20Getter=20?= =?UTF-8?q?for=20lava=20and=20water=20simulator=20IsBlockWater=20and=20IsB?= =?UTF-8?q?lockLava=20function=20in=20Defines.h?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://mc-server.googlecode.com/svn/trunk@97 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- items.ini | 1 + source/Defines.h | 7 ++++++- source/cChunk.cpp | 35 +++++++++++++++++++++++++++++++---- source/cChunk.h | 2 ++ source/cClientHandle.cpp | 3 ++- source/cPickup.cpp | 2 ++ source/cWorld.cpp | 10 +++++----- source/cWorld.h | 4 ++++ 8 files changed, 53 insertions(+), 11 deletions(-) diff --git a/items.ini b/items.ini index 393c5ef77..acc5b68df 100644 --- a/items.ini +++ b/items.ini @@ -209,5 +209,6 @@ lightdust=348 rawfish=349 fish=349 cookedfish=350 +shears=359 goldrecord=2256 greenrecord=2257 \ No newline at end of file diff --git a/source/Defines.h b/source/Defines.h index 6d86da825..838eb1340 100644 --- a/source/Defines.h +++ b/source/Defines.h @@ -46,11 +46,16 @@ inline bool IsValidItem( int a_ItemID ) //tolua_export return IsValidBlock( a_ItemID ); } //tolua_export -inline bool IsBlockWater (char a_BlockID) +inline bool IsBlockWater(char a_BlockID) { return (a_BlockID == E_BLOCK_WATER || a_BlockID == E_BLOCK_STATIONARY_WATER); } +inline bool IsBlockLava(char a_BlockID) +{ + return (a_BlockID == E_BLOCK_LAVA || a_BlockID == E_BLOCK_STATIONARY_LAVA); +} + inline void AddDirection( int & a_X, char & a_Y, int & a_Z, char a_Direction, bool a_bInverse = false ) //tolua_export {//tolua_export if( !a_bInverse ) diff --git a/source/cChunk.cpp b/source/cChunk.cpp index b2cd443f8..0fe192c0b 100644 --- a/source/cChunk.cpp +++ b/source/cChunk.cpp @@ -5,8 +5,12 @@ #include // for mkdir #include #endif + + #include "cChunk.h" #include "cWorld.h" +#include "cWaterSimulator.h" +#include "cLavaSimulator.h" #include "cClientHandle.h" #include "cServer.h" #include "zlib.h" @@ -249,7 +253,13 @@ void cChunk::Tick(float a_Dt) { if( GetBlock( X, Y-1, Z ) == E_BLOCK_AIR ) { - SetBlock( X, Y, Z, 0, 0 ); + SetBlock( X, Y, Z, E_BLOCK_AIR, 0 ); + + int wX, wY, wZ; + PositionToWorldPosition(X, Y, Z, wX, wY, wZ); + + m_World->GetWaterSimulator()->WakeUp( wX, wY, wZ ); + m_World->GetLavaSimulator()->WakeUp( wX, wY, wZ ); if (isRedstone) { cRedstone Redstone(m_World); Redstone.ChangeRedstone( (X+m_PosX*16), (Y+m_PosY*16), (Z+m_PosZ*16), false ); @@ -291,7 +301,7 @@ void cChunk::Tick(float a_Dt) AddDirection( XX, YY, ZZ, Dir, true ); if( m_World->GetBlock( XX, YY, ZZ ) == E_BLOCK_AIR ) { - SetBlock( X, Y, Z, 0, 0 ); + SetBlock( X, Y, Z, E_BLOCK_AIR, 0 ); cPickup* Pickup = new cPickup( (X+m_PosX*16) * 32 + 16, (Y+m_PosY*128) * 32 + 16, (Z+m_PosZ*16) * 32 + 16, cItem( (ENUM_ITEM_ID)BlockID, 1 ) ); Pickup->Initialize( m_World ); } @@ -305,10 +315,19 @@ void cChunk::Tick(float a_Dt) case E_BLOCK_SAND: { char BottomBlock = GetBlock( X, Y-1, Z ); - if( BottomBlock == E_BLOCK_AIR || BottomBlock == E_BLOCK_WATER || BottomBlock == E_BLOCK_STATIONARY_WATER || BottomBlock == E_BLOCK_LAVA || BottomBlock == E_BLOCK_STATIONARY_LAVA ) + if( BottomBlock == E_BLOCK_AIR || IsBlockWater(BottomBlock) || IsBlockLava(BottomBlock) ) { - SetBlock( X, Y, Z, 0, 0 ); + SetBlock( X, Y, Z, E_BLOCK_AIR, 0 ); SetBlock( X, Y-1, Z, BlockID, 0 ); + + int wX, wY, wZ; + + PositionToWorldPosition(X, Y, Z, wX, wY, wZ); + + m_World->GetWaterSimulator()->WakeUp( wX, wY, wZ ); + m_World->GetLavaSimulator()->WakeUp( wX, wY, wZ ); + m_World->GetWaterSimulator()->WakeUp( wX, wY - 1, wZ ); + m_World->GetLavaSimulator()->WakeUp( wX, wY - 1, wZ ); } } break; @@ -1448,3 +1467,11 @@ void cChunk::RemoveTickBlockEntity( cFurnaceEntity* a_Entity ) { m_pState->m_TickBlockEntities.remove( a_Entity ); } + + +void cChunk::PositionToWorldPosition(int a_ChunkX, int a_ChunkY, int a_ChunkZ, int & a_X, int & a_Y, int & a_Z) +{ + a_Y = a_ChunkY; + a_X = m_PosX * 16 + a_ChunkX; + a_Z = m_PosZ * 16 + a_ChunkZ; +} \ No newline at end of file diff --git a/source/cChunk.h b/source/cChunk.h index c8db5f69c..9e117bb94 100644 --- a/source/cChunk.h +++ b/source/cChunk.h @@ -77,6 +77,8 @@ public: void SetLight(char* a_Buffer, int a_BlockIdx, char a_Light); void SetLight(char* a_Buffer, int x, int y, int z, char light); + void PositionToWorldPosition(int a_ChunkX, int a_ChunkY, int a_ChunkZ, int & a_X, int & a_Y, int & a_Z); + void AddTickBlockEntity( cFurnaceEntity* a_Entity ); //{ // m_TickBlockEntities.remove( a_Entity ); diff --git a/source/cClientHandle.cpp b/source/cClientHandle.cpp index a1e24c576..b8de73467 100644 --- a/source/cClientHandle.cpp +++ b/source/cClientHandle.cpp @@ -503,7 +503,7 @@ void cClientHandle::HandlePacket( cPacket* a_Packet ) m_Player->SetLastBlockActionCnt(LastActionCnt+1); if (LastActionCnt > 3) { //kick if more than 3 interactions per .1 seconds LOGWARN("Player %s tried to interact with a block too quickly! (could indicate bot) Was Kicked.", GetUsername() ); - //To many false-positives :s for example on a minimal server lagg :s should be re checked + //TODO Too many false-positives :s for example on a minimal server lagg :s should be re checked Kick("You're a baaaaaad boy!"); break; } @@ -524,6 +524,7 @@ void cClientHandle::HandlePacket( cPacket* a_Packet ) char OldBlock = World->GetBlock(PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ); char MetaData = World->GetBlockMeta(PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ); bool bBroken = (PacketData->m_Status == 0x02) || g_BlockOneHitDig[(int)OldBlock] || ( (PacketData->m_Status == 0x00) && (m_Player->GetGameMode() == 1) ); + if(bBroken == false) bBroken = (m_Player->GetInventory().GetEquippedItem().m_ItemID == E_ITEM_SHEARS && OldBlock == E_BLOCK_LEAVES); cItem PickupItem; if( bBroken && !(m_Player->GetGameMode() == 1) ) // broken diff --git a/source/cPickup.cpp b/source/cPickup.cpp index 7c4a546ec..db409c637 100644 --- a/source/cPickup.cpp +++ b/source/cPickup.cpp @@ -217,6 +217,8 @@ void cPickup::HandlePhysics(float a_Dt) *m_Pos += *m_Speed*a_Dt; } } + + } bool cPickup::CollectedBy( cPlayer* a_Dest ) diff --git a/source/cWorld.cpp b/source/cWorld.cpp index 65c35535b..b1a0d1813 100644 --- a/source/cWorld.cpp +++ b/source/cWorld.cpp @@ -255,10 +255,10 @@ cWorld::cWorld( const char* a_WorldName ) // Blocks that breaks when pushed by piston g_BlockPistonBreakable[ E_BLOCK_AIR ] = true; - g_BlockPistonBreakable[ E_BLOCK_STATIONARY_WATER ] = true; - g_BlockPistonBreakable[ E_BLOCK_WATER ] = true; - g_BlockPistonBreakable[ E_BLOCK_STATIONARY_LAVA ] = true; - g_BlockPistonBreakable[ E_BLOCK_LAVA ] = true; + g_BlockPistonBreakable[ E_BLOCK_STATIONARY_WATER ] = false; //This gave pistons the ability to drop water :D + g_BlockPistonBreakable[ E_BLOCK_WATER ] = false; + g_BlockPistonBreakable[ E_BLOCK_STATIONARY_LAVA ] = false; + g_BlockPistonBreakable[ E_BLOCK_LAVA ] = false; g_BlockPistonBreakable[ E_BLOCK_BED ] = true; g_BlockPistonBreakable[ E_BLOCK_COBWEB ] = true; g_BlockPistonBreakable[ E_BLOCK_TALL_GRASS ] = true; @@ -709,7 +709,7 @@ bool cWorld::DigBlock( int a_X, int a_Y, int a_Z, cItem & a_PickupItem ) cChunk* DestChunk = GetChunk( ChunkX, ChunkY, ChunkZ ); if(DestChunk) { - DestChunk->SetBlock(PosX, PosY, PosZ, 0, 0 ); + DestChunk->SetBlock(PosX, PosY, PosZ, E_BLOCK_AIR, 0 ); m_WaterSimulator->WakeUp( a_X, a_Y, a_Z ); m_LavaSimulator->WakeUp( a_X, a_Y, a_Z ); diff --git a/source/cWorld.h b/source/cWorld.h index 7278fa0a4..6e407f656 100644 --- a/source/cWorld.h +++ b/source/cWorld.h @@ -81,6 +81,10 @@ public: const double & GetSpawnY(); //tolua_export const double & GetSpawnZ() { return m_SpawnZ; } //tolua_export + cWaterSimulator *GetWaterSimulator() { return m_WaterSimulator; } + cLavaSimulator *GetLavaSimulator() { return m_LavaSimulator; } + + cBlockEntity* GetBlockEntity( int a_X, int a_Y, int a_Z ); //tolua_export void GrowTree( int a_X, int a_Y, int a_Z ); //tolua_export -- cgit v1.2.3