diff options
author | lapayo94@gmail.com <lapayo94@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2011-12-22 22:36:24 +0100 |
---|---|---|
committer | lapayo94@gmail.com <lapayo94@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2011-12-22 22:36:24 +0100 |
commit | 24efa6f8645c2f310997c212907fb4e591d0afec (patch) | |
tree | ff6d43fb6a9af7838b0dc41908f895f71d9aef5c | |
parent | Fixes: (diff) | |
download | cuberite-24efa6f8645c2f310997c212907fb4e591d0afec.tar cuberite-24efa6f8645c2f310997c212907fb4e591d0afec.tar.gz cuberite-24efa6f8645c2f310997c212907fb4e591d0afec.tar.bz2 cuberite-24efa6f8645c2f310997c212907fb4e591d0afec.tar.lz cuberite-24efa6f8645c2f310997c212907fb4e591d0afec.tar.xz cuberite-24efa6f8645c2f310997c212907fb4e591d0afec.tar.zst cuberite-24efa6f8645c2f310997c212907fb4e591d0afec.zip |
-rw-r--r-- | items.ini | 1 | ||||
-rw-r--r-- | source/Defines.h | 7 | ||||
-rw-r--r-- | source/cChunk.cpp | 35 | ||||
-rw-r--r-- | source/cChunk.h | 2 | ||||
-rw-r--r-- | source/cClientHandle.cpp | 3 | ||||
-rw-r--r-- | source/cPickup.cpp | 2 | ||||
-rw-r--r-- | source/cWorld.cpp | 10 | ||||
-rw-r--r-- | source/cWorld.h | 4 |
8 files changed, 53 insertions, 11 deletions
@@ -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 <sys/stat.h> // for mkdir
#include <sys/types.h>
#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
|