summaryrefslogtreecommitdiffstats
path: root/src/Blocks/BlockHandler.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-02-02 16:25:30 +0100
committerMattes D <github@xoft.cz>2014-02-02 16:25:30 +0100
commit3cfd9ce269f695e27c9f62cbd95b7a3b60963581 (patch)
treeca1faaae5c7d0fbd756f4cee56f61500ba0a12ed /src/Blocks/BlockHandler.cpp
parentFixed #620 (diff)
parentAdded missing files (diff)
downloadcuberite-3cfd9ce269f695e27c9f62cbd95b7a3b60963581.tar
cuberite-3cfd9ce269f695e27c9f62cbd95b7a3b60963581.tar.gz
cuberite-3cfd9ce269f695e27c9f62cbd95b7a3b60963581.tar.bz2
cuberite-3cfd9ce269f695e27c9f62cbd95b7a3b60963581.tar.lz
cuberite-3cfd9ce269f695e27c9f62cbd95b7a3b60963581.tar.xz
cuberite-3cfd9ce269f695e27c9f62cbd95b7a3b60963581.tar.zst
cuberite-3cfd9ce269f695e27c9f62cbd95b7a3b60963581.zip
Diffstat (limited to 'src/Blocks/BlockHandler.cpp')
-rw-r--r--src/Blocks/BlockHandler.cpp63
1 files changed, 32 insertions, 31 deletions
diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp
index b9c0887ce..3f69ba1c1 100644
--- a/src/Blocks/BlockHandler.cpp
+++ b/src/Blocks/BlockHandler.cpp
@@ -5,6 +5,7 @@
#include "../World.h"
#include "../Root.h"
#include "../Bindings/PluginManager.h"
+#include "../Chunk.h"
#include "BlockBed.h"
#include "BlockBrewingStand.h"
#include "BlockButton.h"
@@ -244,7 +245,7 @@ cBlockHandler::cBlockHandler(BLOCKTYPE a_BlockType)
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_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
@@ -260,7 +261,7 @@ bool cBlockHandler::GetPlacementBlockTypeMeta(
-void cBlockHandler::OnUpdate(cChunk & a_Chunk, int a_BlockX, int a_BlockY, int a_BlockZ)
+void cBlockHandler::OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_BlockX, int a_BlockY, int a_BlockZ)
{
}
@@ -268,7 +269,7 @@ void cBlockHandler::OnUpdate(cChunk & a_Chunk, int a_BlockX, int a_BlockY, int a
-void cBlockHandler::OnPlacedByPlayer(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
+void cBlockHandler::OnPlacedByPlayer(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, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
}
@@ -276,7 +277,7 @@ void cBlockHandler::OnPlacedByPlayer(cWorld * a_World, cPlayer * a_Player, int a
-void cBlockHandler::OnDestroyedByPlayer(cWorld *a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
+void cBlockHandler::OnDestroyedByPlayer(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
{
}
@@ -284,41 +285,41 @@ void cBlockHandler::OnDestroyedByPlayer(cWorld *a_World, cPlayer * a_Player, int
-void cBlockHandler::OnPlaced(cWorld *a_World, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
+void cBlockHandler::OnPlaced(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
// Notify the neighbors
- NeighborChanged(a_World, a_BlockX - 1, a_BlockY, a_BlockZ);
- NeighborChanged(a_World, a_BlockX + 1, a_BlockY, a_BlockZ);
- NeighborChanged(a_World, a_BlockX, a_BlockY - 1, a_BlockZ);
- NeighborChanged(a_World, a_BlockX, a_BlockY + 1, a_BlockZ);
- NeighborChanged(a_World, a_BlockX, a_BlockY, a_BlockZ - 1);
- NeighborChanged(a_World, a_BlockX, a_BlockY, a_BlockZ + 1);
+ NeighborChanged(a_ChunkInterface, a_BlockX - 1, a_BlockY, a_BlockZ);
+ NeighborChanged(a_ChunkInterface, a_BlockX + 1, a_BlockY, a_BlockZ);
+ NeighborChanged(a_ChunkInterface, a_BlockX, a_BlockY - 1, a_BlockZ);
+ NeighborChanged(a_ChunkInterface, a_BlockX, a_BlockY + 1, a_BlockZ);
+ NeighborChanged(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ - 1);
+ NeighborChanged(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ + 1);
}
-void cBlockHandler::OnDestroyed(cWorld *a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
+void cBlockHandler::OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ)
{
// Notify the neighbors
- NeighborChanged(a_World, a_BlockX - 1, a_BlockY, a_BlockZ);
- NeighborChanged(a_World, a_BlockX + 1, a_BlockY, a_BlockZ);
- NeighborChanged(a_World, a_BlockX, a_BlockY - 1, a_BlockZ);
- NeighborChanged(a_World, a_BlockX, a_BlockY + 1, a_BlockZ);
- NeighborChanged(a_World, a_BlockX, a_BlockY, a_BlockZ - 1);
- NeighborChanged(a_World, a_BlockX, a_BlockY, a_BlockZ + 1);
+ NeighborChanged(a_ChunkInterface, a_BlockX - 1, a_BlockY, a_BlockZ);
+ NeighborChanged(a_ChunkInterface, a_BlockX + 1, a_BlockY, a_BlockZ);
+ NeighborChanged(a_ChunkInterface, a_BlockX, a_BlockY - 1, a_BlockZ);
+ NeighborChanged(a_ChunkInterface, a_BlockX, a_BlockY + 1, a_BlockZ);
+ NeighborChanged(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ - 1);
+ NeighborChanged(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ + 1);
}
-void cBlockHandler::NeighborChanged(cWorld *a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
+void cBlockHandler::NeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ)
{
if ((a_BlockY >= 0) && (a_BlockY < cChunkDef::Height))
{
- GetBlockHandler(a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ))->OnNeighborChanged(a_World, a_BlockX, a_BlockY, a_BlockZ);
+ GetBlockHandler(a_ChunkInterface.GetBlock(a_BlockX, a_BlockY, a_BlockZ))->OnNeighborChanged(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ);
}
}
@@ -326,7 +327,7 @@ void cBlockHandler::NeighborChanged(cWorld *a_World, int a_BlockX, int a_BlockY,
-void cBlockHandler::OnNeighborChanged(cWorld *a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
+void cBlockHandler::OnNeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ)
{
}
@@ -334,7 +335,7 @@ void cBlockHandler::OnNeighborChanged(cWorld *a_World, int a_BlockX, int a_Block
-void cBlockHandler::OnDigging(cWorld *a_World, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
+void cBlockHandler::OnDigging(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
{
}
@@ -342,7 +343,7 @@ void cBlockHandler::OnDigging(cWorld *a_World, cPlayer *a_Player, int a_BlockX,
-void cBlockHandler::OnUse(cWorld *a_World, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ)
+void cBlockHandler::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)
{
}
@@ -360,14 +361,14 @@ void cBlockHandler::ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta)
-void cBlockHandler::DropBlock(cWorld * a_World, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ)
+void cBlockHandler::DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ)
{
cItems Pickups;
- NIBBLETYPE Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
+ NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
ConvertToPickups(Pickups, Meta);
// Allow plugins to modify the pickups:
- cRoot::Get()->GetPluginManager()->CallHookBlockToPickups(a_World, a_Digger, a_BlockX, a_BlockY, a_BlockZ, m_BlockType, Meta, Pickups);
+ a_BlockPluginInterface.CallHookBlockToPickups(a_Digger, a_BlockX, a_BlockY, a_BlockZ, m_BlockType, Meta, Pickups);
if (!Pickups.empty())
{
@@ -383,7 +384,7 @@ void cBlockHandler::DropBlock(cWorld * a_World, cEntity * a_Digger, int a_BlockX
MicroX += r1.rand(1) - 0.5;
MicroZ += r1.rand(1) - 0.5;
- a_World->SpawnItemPickups(Pickups, MicroX, MicroY, MicroZ);
+ a_WorldInterface.SpawnItemPickups(Pickups, MicroX, MicroY, MicroZ);
}
}
@@ -400,7 +401,7 @@ const char * cBlockHandler::GetStepSound()
-bool cBlockHandler::CanBeAt(int a_BlockX, int a_BlockY, int a_BlockZ, const cChunk & a_Chunk)
+bool cBlockHandler::CanBeAt(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ, const cChunk & a_Chunk)
{
return true;
}
@@ -445,15 +446,15 @@ bool cBlockHandler::DoesDropOnUnsuitable(void)
-void cBlockHandler::Check(int a_RelX, int a_RelY, int a_RelZ, cChunk & a_Chunk)
+void cBlockHandler::Check(cChunkInterface & a_ChunkInterface, cBlockPluginInterface & a_PluginInterface, int a_RelX, int a_RelY, int a_RelZ, cChunk & a_Chunk)
{
- if (!CanBeAt(a_RelX, a_RelY, a_RelZ, a_Chunk))
+ if (!CanBeAt(a_ChunkInterface, a_RelX, a_RelY, a_RelZ, a_Chunk))
{
if (DoesDropOnUnsuitable())
{
int BlockX = a_RelX + a_Chunk.GetPosX() * cChunkDef::Width;
int BlockZ = a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width;
- DropBlock(a_Chunk.GetWorld(), NULL, BlockX, a_RelY, BlockZ);
+ DropBlock(a_ChunkInterface, *a_Chunk.GetWorld(), a_PluginInterface, NULL, BlockX, a_RelY, BlockZ);
}
a_Chunk.SetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_AIR, 0);