1
0
Fork 0

Pumpkin and JackOLantern support

Fixes #99
This commit is contained in:
Tiger Wang 2013-09-10 22:09:31 +01:00
parent f300ed54e5
commit 3d7813fdb2
2 changed files with 65 additions and 0 deletions

View File

@ -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);

View File

@ -0,0 +1,62 @@
#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() - 180);
return true;
}
inline static NIBBLETYPE PlayerYawToMetaData(double a_Yaw)
{
ASSERT((a_Yaw >= -180) && (a_Yaw < 180));
a_Yaw += 360 + 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;
}
}
} ;