commit
85804d085d
@ -41,6 +41,7 @@
|
||||
#include "BlockNote.h"
|
||||
#include "BlockOre.h"
|
||||
#include "BlockPiston.h"
|
||||
#include "BlockPumpkin.h"
|
||||
#include "BlockRail.h"
|
||||
#include "BlockRedstone.h"
|
||||
#include "BlockRedstoneRepeater.h"
|
||||
@ -153,6 +154,8 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
|
||||
case E_BLOCK_PISTON: return new cBlockPistonHandler (a_BlockType);
|
||||
case E_BLOCK_PISTON_EXTENSION: return new cBlockPistonHeadHandler ();
|
||||
case E_BLOCK_PLANKS: return new cBlockWoodHandler (a_BlockType);
|
||||
case E_BLOCK_PUMPKIN: return new cBlockPumpkinHandler (a_BlockType);
|
||||
case E_BLOCK_JACK_O_LANTERN: return new cBlockPumpkinHandler (a_BlockType);
|
||||
case E_BLOCK_PUMPKIN_STEM: return new cBlockStemsHandler (a_BlockType);
|
||||
case E_BLOCK_QUARTZ_STAIR: return new cBlockStairsHandler (a_BlockType);
|
||||
case E_BLOCK_RAIL: return new cBlockRailHandler (a_BlockType);
|
||||
|
60
source/Blocks/BlockPumpkin.h
Normal file
60
source/Blocks/BlockPumpkin.h
Normal file
@ -0,0 +1,60 @@
|
||||
#pragma once
|
||||
|
||||
#include "BlockHandler.h"
|
||||
|
||||
|
||||
|
||||
|
||||
class cBlockPumpkinHandler :
|
||||
public cBlockHandler
|
||||
{
|
||||
public:
|
||||
cBlockPumpkinHandler(BLOCKTYPE a_BlockType)
|
||||
: cBlockHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
virtual bool GetPlacementBlockTypeMeta(
|
||||
cWorld * a_World, cPlayer * a_Player,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace,
|
||||
int a_CursorX, int a_CursorY, int a_CursorZ,
|
||||
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
|
||||
) override
|
||||
{
|
||||
a_BlockType = m_BlockType;
|
||||
a_BlockMeta = PlayerYawToMetaData(a_Player->GetRotation());
|
||||
return true;
|
||||
}
|
||||
|
||||
inline static NIBBLETYPE PlayerYawToMetaData(double a_Yaw)
|
||||
{
|
||||
ASSERT((a_Yaw >= -180) && (a_Yaw < 180));
|
||||
|
||||
a_Yaw += 180 + 45;
|
||||
if (a_Yaw > 360)
|
||||
{
|
||||
a_Yaw -= 360;
|
||||
}
|
||||
if ((a_Yaw >= 0) && (a_Yaw < 90))
|
||||
{
|
||||
return 0x0;
|
||||
}
|
||||
else if ((a_Yaw >= 180) && (a_Yaw < 270))
|
||||
{
|
||||
return 0x2;
|
||||
}
|
||||
else if ((a_Yaw >= 90) && (a_Yaw < 180))
|
||||
{
|
||||
return 0x1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0x3;
|
||||
}
|
||||
}
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
|
@ -55,6 +55,7 @@ cEntity::cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, d
|
||||
, m_TicksSinceLastBurnDamage(0)
|
||||
, m_TicksSinceLastLavaDamage(0)
|
||||
, m_TicksSinceLastFireDamage(0)
|
||||
, m_TicksSinceLastVoidDamage(0)
|
||||
, m_TicksLeftBurning(0)
|
||||
, m_WaterSpeed(0, 0, 0)
|
||||
, m_Width(a_Width)
|
||||
@ -505,6 +506,11 @@ void cEntity::Tick(float a_Dt, cChunk & a_Chunk)
|
||||
{
|
||||
TickBurning(a_Chunk);
|
||||
}
|
||||
if ((a_Chunk.IsValid()) && (GetPosY() < -46))
|
||||
{
|
||||
TickInVoid(a_Chunk);
|
||||
}
|
||||
else { m_TicksSinceLastVoidDamage = 0; }
|
||||
}
|
||||
|
||||
|
||||
@ -524,8 +530,15 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
|
||||
if ((BlockY >= cChunkDef::Height) || (BlockY < 0))
|
||||
{
|
||||
// Outside of the world
|
||||
// TODO: Current speed should still be added to the entity position
|
||||
// Otherwise TNT explosions in the void will still effect the bottommost layers of the world
|
||||
|
||||
cChunk * NextChunk = a_Chunk.GetNeighborChunk(BlockX, BlockZ);
|
||||
// See if we can commit our changes. If not, we will discard them.
|
||||
if (NextChunk != NULL)
|
||||
{
|
||||
SetSpeed(NextSpeed);
|
||||
NextPos += (NextSpeed * a_Dt);
|
||||
SetPosition(NextPos);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -829,6 +842,23 @@ void cEntity::TickBurning(cChunk & a_Chunk)
|
||||
|
||||
|
||||
|
||||
void cEntity::TickInVoid(cChunk & a_Chunk)
|
||||
{
|
||||
if (m_TicksSinceLastVoidDamage == 20)
|
||||
{
|
||||
TakeDamage(dtInVoid, NULL, 2, 0);
|
||||
m_TicksSinceLastVoidDamage = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_TicksSinceLastVoidDamage++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// Called when the entity starts burning
|
||||
void cEntity::OnStartedBurning(void)
|
||||
{
|
||||
|
@ -268,6 +268,9 @@ public:
|
||||
/// Updates the state related to this entity being on fire
|
||||
virtual void TickBurning(cChunk & a_Chunk);
|
||||
|
||||
/// Handles when the entity is in the void
|
||||
virtual void TickInVoid(cChunk & a_Chunk);
|
||||
|
||||
/// Called when the entity starts burning
|
||||
virtual void OnStartedBurning(void);
|
||||
|
||||
@ -390,6 +393,9 @@ protected:
|
||||
/// Time, in ticks, until the entity extinguishes its fire
|
||||
int m_TicksLeftBurning;
|
||||
|
||||
/// Time, in ticks, since the last damage dealt by the void. Reset to zero when moving out of the void.
|
||||
int m_TicksSinceLastVoidDamage;
|
||||
|
||||
virtual void Destroyed(void) {} // Called after the entity has been destroyed
|
||||
|
||||
void SetWorld(cWorld * a_World) { m_World = a_World; }
|
||||
|
@ -610,11 +610,14 @@ void cPlayer::SetSprint(bool a_IsSprinting)
|
||||
|
||||
void cPlayer::DoTakeDamage(TakeDamageInfo & a_TDI)
|
||||
{
|
||||
if (m_GameMode == eGameMode_Creative)
|
||||
if (a_TDI.DamageType != dtInVoid)
|
||||
{
|
||||
if (IsGameModeCreative())
|
||||
{
|
||||
// No damage / health in creative mode
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
super::DoTakeDamage(a_TDI);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user