summaryrefslogtreecommitdiffstats
path: root/source/cPlayer.cpp
diff options
context:
space:
mode:
authoradmin@omencraft.com <admin@omencraft.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2011-11-06 10:23:20 +0100
committeradmin@omencraft.com <admin@omencraft.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2011-11-06 10:23:20 +0100
commit36f7084e3fb4193676b14f302d0f961f2102e4ba (patch)
treeb2e7d7c7d1854dbe484605b4054e707c0bd09cef /source/cPlayer.cpp
parentFinished most of piston class. Pistons should work when a redstone current with wire is lit up or extinguished near them but don't yet. There'sa bug to kill. (diff)
downloadcuberite-36f7084e3fb4193676b14f302d0f961f2102e4ba.tar
cuberite-36f7084e3fb4193676b14f302d0f961f2102e4ba.tar.gz
cuberite-36f7084e3fb4193676b14f302d0f961f2102e4ba.tar.bz2
cuberite-36f7084e3fb4193676b14f302d0f961f2102e4ba.tar.lz
cuberite-36f7084e3fb4193676b14f302d0f961f2102e4ba.tar.xz
cuberite-36f7084e3fb4193676b14f302d0f961f2102e4ba.tar.zst
cuberite-36f7084e3fb4193676b14f302d0f961f2102e4ba.zip
Diffstat (limited to '')
-rw-r--r--source/cPlayer.cpp46
1 files changed, 28 insertions, 18 deletions
diff --git a/source/cPlayer.cpp b/source/cPlayer.cpp
index 85eec3e2d..62098eb0b 100644
--- a/source/cPlayer.cpp
+++ b/source/cPlayer.cpp
@@ -40,7 +40,7 @@
#include <sys/types.h>
#define sprintf_s(dst, size, format, ...) sprintf(dst, format, __VA_ARGS__ )
#endif
-
+#define float2int(x) ((x)<0 ? ((int)(x))-1 : (int)(x))
extern std::vector< std::string > StringSplit( std::string str, std::string delim);
CLASS_DEFINITION( cPlayer, cPawn );
@@ -81,7 +81,7 @@ cPlayer::cPlayer(cClientHandle* a_Client, const char* a_PlayerName)
m_TimeLastTeleportPacket = cWorld::GetTime();
m_TimeLastPickupCheck = cWorld::GetTime();
-
+
m_pState->PlayerName = a_PlayerName;
m_bDirtyPosition = true; // So chunks are streamed to player at spawn
@@ -104,6 +104,7 @@ cPlayer::~cPlayer(void)
{
SaveToDisk();
m_ClientHandle = 0;
+
CloseWindow();
if( m_Inventory )
{
@@ -149,6 +150,7 @@ void cPlayer::Tick(float a_Dt)
InChunk->Broadcast( EntityLook, m_ClientHandle );
m_bDirtyOrientation = false;
}
+
if(m_bDirtyPosition )
{
cRoot::Get()->GetPluginManager()->CallHook( cPluginManager::E_PLUGIN_PLAYER_MOVE, 1, this );
@@ -229,22 +231,21 @@ void cPlayer::Tick(float a_Dt)
void cPlayer::InStateBurning(float a_Dt) {
m_FireDamageInterval += a_Dt;
- char block = GetWorld()->GetBlock( (int)m_Pos->x, (int)m_Pos->y, (int)m_Pos->z );
- char bblock = GetWorld()->GetBlock( (int)m_Pos->x, (int)m_Pos->y -1, (int)m_Pos->z );
- if(m_FireDamageInterval > 1000) {
+ char block = GetWorld()->GetBlock( float2int(m_Pos->x), float2int(m_Pos->y), float2int(m_Pos->z) );
+ char bblock = GetWorld()->GetBlock( float2int(m_Pos->x), float2int(m_Pos->y)+1, float2int(m_Pos->z) );
+ if(m_FireDamageInterval > 800) {
m_FireDamageInterval = 0;
- int rem = rand()%3 + 1; //Burn most of the time
- if(rem >= 2) {
- //printf("OUCH burning!!!\n");
- TakeDamage(1, this);
- }
+
m_BurnPeriod++;
if(block == E_BLOCK_LAVA || block == E_BLOCK_STATIONARY_LAVA || block == E_BLOCK_FIRE
- || bblock == E_BLOCK_LAVA || bblock == E_BLOCK_STATIONARY_LAVA || bblock == E_BLOCK_FIRE)
+ || bblock == E_BLOCK_LAVA || bblock == E_BLOCK_STATIONARY_LAVA || bblock == E_BLOCK_FIRE) {
m_BurnPeriod = 0;
-
- if(m_BurnPeriod > 5) {
+ TakeDamage(6, this);
+ }else{
+ TakeDamage(1, this);
+ }
+ if(m_BurnPeriod > 7) {
cChunk* InChunk = GetWorld()->GetChunkUnreliable( m_ChunkX, m_ChunkY, m_ChunkZ );
e_EPMetaState = NORMAL;
@@ -261,14 +262,22 @@ void cPlayer::InStateBurning(float a_Dt) {
//----Change Entity MetaData
void cPlayer::CheckMetaDataBurn() {
- char block = GetWorld()->GetBlock( (int)m_Pos->x, (int)m_Pos->y, (int)m_Pos->z );
- char bblock = GetWorld()->GetBlock( (int)m_Pos->x, (int)m_Pos->y -1, (int)m_Pos->z );
- if(m_bBurnable && e_EPMetaState != BURNING && (block == E_BLOCK_LAVA || block == E_BLOCK_STATIONARY_LAVA || block == E_BLOCK_FIRE
+ char block = GetWorld()->GetBlock( float2int(m_Pos->x), float2int(m_Pos->y), float2int(m_Pos->z) );
+ char bblock = GetWorld()->GetBlock( float2int(m_Pos->x), float2int(m_Pos->y)+1, float2int(m_Pos->z) );
+ if(e_EPMetaState == BURNING && (block == E_BLOCK_WATER || block == E_BLOCK_STATIONARY_WATER
+ || bblock == E_BLOCK_WATER || bblock == E_BLOCK_STATIONARY_WATER)) {
+ cChunk* InChunk = GetWorld()->GetChunkUnreliable( m_ChunkX, m_ChunkY, m_ChunkZ );
+ if(!InChunk)
+ return;
+ e_EPMetaState = NORMAL;
+ cPacket_Metadata md(NORMAL,GetUniqueID());
+ InChunk->Broadcast(md);
+ }else if(m_bBurnable && e_EPMetaState != BURNING && (block == E_BLOCK_LAVA || block == E_BLOCK_STATIONARY_LAVA || block == E_BLOCK_FIRE
|| bblock == E_BLOCK_LAVA || bblock == E_BLOCK_STATIONARY_LAVA || bblock == E_BLOCK_FIRE)) {
cChunk* InChunk = GetWorld()->GetChunkUnreliable( m_ChunkX, m_ChunkY, m_ChunkZ );
if(!InChunk)
return;
- printf("I should burn");
+ printf("I should burn\n");
e_EPMetaState = BURNING;
cPacket_Metadata md(BURNING,GetUniqueID());
InChunk->Broadcast(md);
@@ -282,7 +291,7 @@ void cPlayer::SetTouchGround( bool a_bTouchGround )
if( !m_bTouchGround )
{
cWorld* World = GetWorld();
- char BlockID = World->GetBlock( (int)m_Pos->x, (int)m_Pos->y, (int)m_Pos->z );
+ char BlockID = World->GetBlock( float2int(m_Pos->x), float2int(m_Pos->y), float2int(m_Pos->z) );
if( BlockID != E_BLOCK_AIR )
{
m_bTouchGround = true;
@@ -371,6 +380,7 @@ void cPlayer::Respawn()
//Packet.m_CreativeMode = (char)GetWorld()->GetGameMode();
Packet.m_CreativeMode = (char)m_GameMode; //Set GameMode packet based on Player's GameMode;
//Send Packet
+ e_EPMetaState = NORMAL;
m_ClientHandle->Send( Packet );
TeleportTo( GetWorld()->GetSpawnX(), GetWorld()->GetSpawnY(), GetWorld()->GetSpawnZ() );
SetVisible( true );