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 | |
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 '')
-rw-r--r-- | MCServer/crafting.txt | 2 | ||||
-rw-r--r-- | src/Items/ItemEmptyMap.h | 46 | ||||
-rw-r--r-- | src/Items/ItemHandler.cpp | 2 | ||||
-rw-r--r-- | src/Map.cpp | 8 |
4 files changed, 53 insertions, 5 deletions
diff --git a/MCServer/crafting.txt b/MCServer/crafting.txt index fe9a465d0..92abe24cb 100644 --- a/MCServer/crafting.txt +++ b/MCServer/crafting.txt @@ -156,7 +156,7 @@ Lighter = IronIngot, 1:1 | Flint, 2:2 Lighter = IronIngot, 2:1 | Flint, 1:2 Bucket = IronIngot, 1:1, 2:2, 3:1 Compass = IronIngot, 2:1, 1:2, 3:2, 2:3 | RedstoneDust, 2:2 -Map = Paper, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3 | Compass, 2:2 +EmptyMap = Paper, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1, 3:2, 3:3 | Compass, 2:2 Watch = GoldIngot, 2:1, 1:2, 3:2, 2:3 | RedstoneDust, 2:2 FishingRod = Stick, 1:3, 2:2, 3:1 | String, 3:2, 3:3 FishingRod = Stick, 3:3, 2:2, 1:1 | String, 1:2, 1:3 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; + } +} ; diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index 19913ab24..755766d64 100644 --- a/src/Items/ItemHandler.cpp +++ b/src/Items/ItemHandler.cpp @@ -18,6 +18,7 @@ #include "ItemComparator.h" #include "ItemDoor.h" #include "ItemDye.h" +#include "ItemEmptyMap.h" #include "ItemFishingRod.h" #include "ItemFlowerPot.h" #include "ItemFood.h" @@ -100,6 +101,7 @@ cItemHandler *cItemHandler::CreateItemHandler(int a_ItemType) case E_ITEM_COMPARATOR: return new cItemComparatorHandler(a_ItemType); case E_ITEM_DYE: return new cItemDyeHandler(a_ItemType); case E_ITEM_EGG: return new cItemEggHandler(); + case E_ITEM_EMPTY_MAP: return new cItemEmptyMapHandler(); case E_ITEM_ENDER_PEARL: return new cItemEnderPearlHandler(); case E_ITEM_FIREWORK_ROCKET: return new cItemFireworkHandler(); case E_ITEM_FISHING_ROD: return new cItemFishingRodHandler(a_ItemType); diff --git a/src/Map.cpp b/src/Map.cpp index 4acd9512c..497cc9659 100644 --- a/src/Map.cpp +++ b/src/Map.cpp @@ -15,8 +15,8 @@ cMap::cMap(unsigned int a_ID, cWorld * a_World) : m_ID(a_ID) - , m_Width(128) - , m_Height(128) + , m_Width(cChunkDef::Width * 8) + , m_Height(cChunkDef::Width * 8) , m_Scale(3) , m_CenterX(0) , m_CenterZ(0) @@ -31,8 +31,8 @@ cMap::cMap(unsigned int a_ID, cWorld * a_World) cMap::cMap(unsigned int a_ID, int a_CenterX, int a_CenterZ, cWorld * a_World, unsigned int a_Scale) : m_ID(a_ID) - , m_Width(128) - , m_Height(128) + , m_Width(cChunkDef::Width * 8) + , m_Height(cChunkDef::Width * 8) , m_Scale(a_Scale) , m_CenterX(a_CenterX) , m_CenterZ(a_CenterZ) |