2014-12-24 01:20:17 -05:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "ItemHandler.h"
|
2020-04-03 02:57:01 -04:00
|
|
|
#include "../BlockInfo.h"
|
2014-12-24 01:20:17 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class cItemBigFlowerHandler:
|
|
|
|
public cItemHandler
|
|
|
|
{
|
2020-04-13 12:38:06 -04:00
|
|
|
using Super = cItemHandler;
|
2014-12-24 01:20:17 -05:00
|
|
|
|
|
|
|
public:
|
2020-04-13 12:38:06 -04:00
|
|
|
|
2020-04-21 16:19:22 -04:00
|
|
|
cItemBigFlowerHandler():
|
2020-04-13 12:38:06 -04:00
|
|
|
Super(E_BLOCK_BIG_FLOWER)
|
2014-12-24 01:20:17 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-04-21 16:19:22 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
2021-05-05 09:25:10 -04:00
|
|
|
virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) override
|
2014-12-24 01:20:17 -05:00
|
|
|
{
|
2021-05-05 09:25:10 -04:00
|
|
|
// Needs at least two free blocks to build in:
|
|
|
|
if (a_PlacePosition.y >= (cChunkDef::Height - 1))
|
2014-12-24 01:20:17 -05:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-05-05 09:25:10 -04:00
|
|
|
const auto & World = *a_Player.GetWorld();
|
|
|
|
const auto TopPos = a_PlacePosition.addedY(1);
|
2017-07-07 10:37:53 -04:00
|
|
|
BLOCKTYPE TopType;
|
|
|
|
NIBBLETYPE TopMeta;
|
2021-05-05 09:25:10 -04:00
|
|
|
World.GetBlockTypeMeta(TopPos, TopType, TopMeta);
|
2017-07-07 10:37:53 -04:00
|
|
|
|
2021-05-05 09:25:10 -04:00
|
|
|
if (!cBlockHandler::For(TopType).DoesIgnoreBuildCollision(World, a_HeldItem, TopPos, TopMeta, a_ClickedBlockFace, false))
|
2017-07-07 10:37:53 -04:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-05-05 09:25:10 -04:00
|
|
|
return a_Player.PlaceBlocks(
|
|
|
|
{
|
|
|
|
{ a_PlacePosition, E_BLOCK_BIG_FLOWER, static_cast<NIBBLETYPE>(a_HeldItem.m_ItemDamage & 0x07) },
|
|
|
|
{ TopPos, E_BLOCK_BIG_FLOWER, E_META_BIG_FLOWER_TOP }
|
|
|
|
});
|
2014-12-24 01:20:17 -05:00
|
|
|
}
|
|
|
|
};
|