1
0

Refactored GetPlacementBlockTypeMeta

This commit is contained in:
Tycho 2014-01-26 07:06:25 -08:00
parent bed2ee22e8
commit a13d009a30
7 changed files with 12 additions and 11 deletions

View File

@ -2,7 +2,6 @@
#pragma once #pragma once
#include "BlockEntity.h" #include "BlockEntity.h"
#include "../World.h"
#include "../BlockArea.h" #include "../BlockArea.h"
#include "../Entities/Player.h" #include "../Entities/Player.h"

View File

@ -18,11 +18,11 @@ public:
} }
virtual void OnUse(cWorld * a_World, cWorldInterface * a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override virtual void OnUse(cChunkInterface * a_ChunkInterface, cWorldInterface * a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override
{ {
NIBBLETYPE Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); NIBBLETYPE Meta = a_ChunkInterface->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
Meta ^= 0x04; // Toggle 3rd (addition/subtraction) bit with XOR Meta ^= 0x04; // Toggle 3rd (addition/subtraction) bit with XOR
a_World->SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta); a_ChunkInterface->SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta);
} }
@ -46,7 +46,7 @@ public:
virtual bool GetPlacementBlockTypeMeta( virtual bool GetPlacementBlockTypeMeta(
cWorld * a_World, cPlayer * a_Player, cChunkInterface * a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ, int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta

View File

@ -244,7 +244,7 @@ cBlockHandler::cBlockHandler(BLOCKTYPE a_BlockType)
bool cBlockHandler::GetPlacementBlockTypeMeta( bool cBlockHandler::GetPlacementBlockTypeMeta(
cWorld * a_World, cPlayer * a_Player, cChunkInterface * a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ, int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta

View File

@ -33,7 +33,7 @@ public:
Called by cItemHandler::GetPlacementBlockTypeMeta() if the item is a block Called by cItemHandler::GetPlacementBlockTypeMeta() if the item is a block
*/ */
virtual bool GetPlacementBlockTypeMeta( virtual bool GetPlacementBlockTypeMeta(
cWorld * a_World, cPlayer * a_Player, cChunkInterface * a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ, int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta

View File

@ -2,7 +2,6 @@
#pragma once #pragma once
#include "BlockEntity.h" #include "BlockEntity.h"
#include "../World.h"

View File

@ -31,12 +31,14 @@ public:
) override ) override
{ {
a_BlockType = (m_ItemType == E_ITEM_WOODEN_DOOR) ? E_BLOCK_WOODEN_DOOR : E_BLOCK_IRON_DOOR; a_BlockType = (m_ItemType == E_ITEM_WOODEN_DOOR) ? E_BLOCK_WOODEN_DOOR : E_BLOCK_IRON_DOOR;
return BlockHandler(a_BlockType)->GetPlacementBlockTypeMeta( cChunkInterface ChunkInterface(a_World->GetChunkMap());
a_World, a_Player, bool Meta = BlockHandler(a_BlockType)->GetPlacementBlockTypeMeta(
&ChunkInterface, a_Player,
a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace,
a_CursorX, a_CursorY, a_CursorZ, a_CursorX, a_CursorY, a_CursorZ,
a_BlockType, a_BlockMeta a_BlockType, a_BlockMeta
); );
return Meta;
} }
} ; } ;

View File

@ -465,8 +465,9 @@ bool cItemHandler::GetPlacementBlockTypeMeta(
} }
cBlockHandler * BlockH = BlockHandler(m_ItemType); cBlockHandler * BlockH = BlockHandler(m_ItemType);
cChunkInterface ChunkInterface(a_World->GetChunkMap());
return BlockH->GetPlacementBlockTypeMeta( return BlockH->GetPlacementBlockTypeMeta(
a_World, a_Player, &ChunkInterface, a_Player,
a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace,
a_CursorX, a_CursorY, a_CursorZ, a_CursorX, a_CursorY, a_CursorZ,
a_BlockType, a_BlockMeta a_BlockType, a_BlockMeta