1
0
Fork 0

EmptyMap item handler

This commit is contained in:
andrew 2014-02-14 17:38:22 +02:00
parent 5b92b877bc
commit c7fb000858
4 changed files with 53 additions and 5 deletions

View File

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

46
src/Items/ItemEmptyMap.h Normal file
View File

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

View File

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

View File

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