2013-07-29 07:13:03 -04:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "ItemHandler.h"
|
|
|
|
#include "../World.h"
|
2014-07-17 20:19:30 -04:00
|
|
|
#include "../Blocks/BlockSignPost.h"
|
|
|
|
#include "../Blocks/BlockWallSign.h"
|
2016-11-18 14:00:04 -05:00
|
|
|
#include "../ClientHandle.h"
|
2013-07-29 07:13:03 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class cItemSignHandler :
|
|
|
|
public cItemHandler
|
|
|
|
{
|
2014-12-24 01:20:17 -05:00
|
|
|
typedef cItemHandler super;
|
2013-07-29 07:13:03 -04:00
|
|
|
public:
|
|
|
|
cItemSignHandler(int a_ItemType) :
|
2014-12-24 01:20:17 -05:00
|
|
|
super(a_ItemType)
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-12-24 01:20:17 -05:00
|
|
|
virtual bool OnPlayerPlace(
|
|
|
|
cWorld & a_World, cPlayer & a_Player, const cItem & a_EquippedItem,
|
|
|
|
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
|
|
|
int a_CursorX, int a_CursorY, int a_CursorZ
|
2015-05-23 07:56:08 -04:00
|
|
|
) override
|
2014-12-24 01:20:17 -05:00
|
|
|
{
|
2016-12-01 09:20:03 -05:00
|
|
|
// Check if placing on something ignoring build collision to edit the correct sign later on:
|
|
|
|
BLOCKTYPE ClickedBlock;
|
|
|
|
NIBBLETYPE ClickedBlockMeta;
|
|
|
|
a_World.GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, ClickedBlock, ClickedBlockMeta);
|
2017-07-07 10:37:53 -04:00
|
|
|
cChunkInterface ChunkInterface(a_World.GetChunkMap());
|
|
|
|
bool isReplacingClickedBlock = BlockHandler(ClickedBlock)->DoesIgnoreBuildCollision(ChunkInterface, { a_BlockX, a_BlockY, a_BlockZ }, a_Player, ClickedBlockMeta);
|
2016-12-01 09:20:03 -05:00
|
|
|
|
2014-12-24 01:20:17 -05:00
|
|
|
// If the regular placement doesn't work, do no further processing:
|
|
|
|
if (!super::OnPlayerPlace(a_World, a_Player, a_EquippedItem, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-12-01 09:20:03 -05:00
|
|
|
// Use isReplacingClickedBlock to make sure we will edit the right sign:
|
|
|
|
if (!isReplacingClickedBlock)
|
|
|
|
{
|
|
|
|
AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
|
|
|
|
}
|
|
|
|
|
2014-12-24 01:20:17 -05:00
|
|
|
// After successfully placing the sign, open the sign editor for the player:
|
|
|
|
a_Player.GetClientHandle()->SendEditSign(a_BlockX, a_BlockY, a_BlockZ);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-29 07:13:03 -04:00
|
|
|
virtual bool IsPlaceable(void) override
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-02-05 16:45:45 -05:00
|
|
|
|
2013-07-29 07:13:03 -04:00
|
|
|
virtual bool GetPlacementBlockTypeMeta(
|
|
|
|
cWorld * a_World, cPlayer * a_Player,
|
2014-07-17 16:50:58 -04:00
|
|
|
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
2013-07-29 07:13:03 -04:00
|
|
|
int a_CursorX, int a_CursorY, int a_CursorZ,
|
|
|
|
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
|
|
|
|
) override
|
|
|
|
{
|
|
|
|
if (a_BlockFace == BLOCK_FACE_TOP)
|
|
|
|
{
|
2014-07-17 20:19:30 -04:00
|
|
|
a_BlockMeta = cBlockSignPostHandler::RotationToMetaData(a_Player->GetYaw());
|
2013-07-29 07:13:03 -04:00
|
|
|
a_BlockType = E_BLOCK_SIGN_POST;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-07-17 20:19:30 -04:00
|
|
|
a_BlockMeta = cBlockWallSignHandler::DirectionToMetaData(a_BlockFace);
|
2013-07-29 07:13:03 -04:00
|
|
|
a_BlockType = E_BLOCK_WALLSIGN;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|