diff options
author | andrew <xdotftw@gmail.com> | 2014-02-14 16:38:22 +0100 |
---|---|---|
committer | andrew <xdotftw@gmail.com> | 2014-02-14 16:38:22 +0100 |
commit | c7fb00085854ed76b8b8945968de0505b8fbe8a2 (patch) | |
tree | cc8305ba5910e7b681e6c8c8df79f5ee0579bece /src/Items/ItemEmptyMap.h | |
parent | Send map when selected (diff) | |
download | cuberite-c7fb00085854ed76b8b8945968de0505b8fbe8a2.tar cuberite-c7fb00085854ed76b8b8945968de0505b8fbe8a2.tar.gz cuberite-c7fb00085854ed76b8b8945968de0505b8fbe8a2.tar.bz2 cuberite-c7fb00085854ed76b8b8945968de0505b8fbe8a2.tar.lz cuberite-c7fb00085854ed76b8b8945968de0505b8fbe8a2.tar.xz cuberite-c7fb00085854ed76b8b8945968de0505b8fbe8a2.tar.zst cuberite-c7fb00085854ed76b8b8945968de0505b8fbe8a2.zip |
Diffstat (limited to 'src/Items/ItemEmptyMap.h')
-rw-r--r-- | src/Items/ItemEmptyMap.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/Items/ItemEmptyMap.h b/src/Items/ItemEmptyMap.h new file mode 100644 index 000000000..5516033a0 --- /dev/null +++ b/src/Items/ItemEmptyMap.h @@ -0,0 +1,46 @@ + +// ItemEmptyMap.h + + + + + +#pragma once + +#include "../Entities/Entity.h" +#include "../Item.h" + + + + + +class cItemEmptyMapHandler : + public cItemHandler +{ + typedef cItemHandler super; + +public: + cItemEmptyMapHandler() : + super(E_ITEM_EMPTY_MAP) + { + } + + virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Dir) override + { + UNUSED(a_Item); + UNUSED(a_BlockX); + UNUSED(a_BlockZ); + UNUSED(a_Dir); + + // The map center is fixed at the central point of the 8x8 block of chunks you are standing in when you right-click it. + + const int RegionWidth = cChunkDef::Width * 8; + + int CenterX = round(a_Player->GetPosX() / (float) RegionWidth) * RegionWidth; + int CenterZ = round(a_Player->GetPosZ() / (float) RegionWidth) * RegionWidth; + + a_World->CreateMap(CenterX, CenterZ, 0); + + return true; + } +} ; |