1
0

Changed Signiture of OnDestroyedByPlayer

This commit is contained in:
Tycho 2014-02-01 06:01:13 -08:00
parent c6304b2b4f
commit cf3b4ec226
12 changed files with 27 additions and 16 deletions

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
#include "BlockHandler.h" #include "BlockHandler.h"
#include "Chunk.h"

View File

@ -3,7 +3,7 @@
#include "BlockHandler.h" #include "BlockHandler.h"
#include "../Entities/Player.h" #include "../Entities/Player.h"
#include "Chunk.h"

View File

@ -5,6 +5,7 @@
#include "../World.h" #include "../World.h"
#include "../Root.h" #include "../Root.h"
#include "../Bindings/PluginManager.h" #include "../Bindings/PluginManager.h"
#include "../Chunk.h"
#include "BlockBed.h" #include "BlockBed.h"
#include "BlockBrewingStand.h" #include "BlockBrewingStand.h"
#include "BlockButton.h" #include "BlockButton.h"
@ -276,7 +277,7 @@ void cBlockHandler::OnPlacedByPlayer(cChunkInterface & a_ChunkInterface, cWorldI
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)
{ {
} }

View File

@ -3,7 +3,6 @@
#include "../Defines.h" #include "../Defines.h"
#include "../Item.h" #include "../Item.h"
#include "../Chunk.h"
#include "WorldInterface.h" #include "WorldInterface.h"
#include "ChunkInterface.h" #include "ChunkInterface.h"
@ -13,6 +12,7 @@
// fwd: // fwd:
class cPlayer; class cPlayer;
class cChunk;
@ -51,7 +51,7 @@ public:
); );
/// Called before the player has destroyed a block /// Called before the player has destroyed a block
virtual void OnDestroyedByPlayer(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ); virtual void OnDestroyedByPlayer(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ);
/// Called before a block gets destroyed / replaced with air /// Called before a block gets destroyed / replaced with air
virtual void OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ); virtual void OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ);

View File

@ -80,19 +80,19 @@ cBlockPistonHeadHandler::cBlockPistonHeadHandler(void) :
void cBlockPistonHeadHandler::OnDestroyedByPlayer(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) void cBlockPistonHeadHandler::OnDestroyedByPlayer(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
{ {
NIBBLETYPE OldMeta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); NIBBLETYPE OldMeta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
int newX = a_BlockX; int newX = a_BlockX;
int newY = a_BlockY; int newY = a_BlockY;
int newZ = a_BlockZ; int newZ = a_BlockZ;
AddPistonDir(newX, newY, newZ, OldMeta & ~(8), -1); AddPistonDir(newX, newY, newZ, OldMeta & ~(8), -1);
BLOCKTYPE Block = a_World->GetBlock(newX, newY, newZ); BLOCKTYPE Block = a_ChunkInterface.GetBlock(newX, newY, newZ);
if ((Block == E_BLOCK_STICKY_PISTON) || (Block == E_BLOCK_PISTON)) if ((Block == E_BLOCK_STICKY_PISTON) || (Block == E_BLOCK_PISTON))
{ {
a_World->DigBlock(newX, newY, newZ); a_ChunkInterface.DigBlock(a_WorldInterface, newX, newY, newZ);
if (a_Player->IsGameModeCreative()) if (a_Player->IsGameModeCreative())
{ {
return; // No pickups if creative return; // No pickups if creative
@ -100,7 +100,7 @@ void cBlockPistonHeadHandler::OnDestroyedByPlayer(cWorld * a_World, cPlayer * a_
cItems Pickups; cItems Pickups;
Pickups.push_back(cItem(Block, 1)); Pickups.push_back(cItem(Block, 1));
a_World->SpawnItemPickups(Pickups, a_BlockX + 0.5, a_BlockY + 0.5, a_BlockZ + 0.5); a_WorldInterface.SpawnItemPickups(Pickups, a_BlockX + 0.5, a_BlockY + 0.5, a_BlockZ + 0.5);
} }
} }

View File

@ -35,7 +35,7 @@ class cBlockPistonHeadHandler :
public: public:
cBlockPistonHeadHandler(void); cBlockPistonHeadHandler(void);
virtual void OnDestroyedByPlayer(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) override; virtual void OnDestroyedByPlayer(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) override;
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{ {

View File

@ -2,6 +2,7 @@
#pragma once #pragma once
#include "BlockHandler.h" #include "BlockHandler.h"
#include "Chunk.h"

View File

@ -2,8 +2,8 @@
#pragma once #pragma once
#include "BlockHandler.h" #include "BlockHandler.h"
#include "../World.h"
#include "../Entities/Player.h" #include "../Entities/Player.h"
#include "Chunk.h"

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
#include "BlockHandler.h" #include "BlockHandler.h"
#include "../World.h" #include "../Chunk.h"

View File

@ -3,6 +3,9 @@
#include "../ChunkMap.h" #include "../ChunkMap.h"
#include "../ForEachChunkProvider.h" #include "../ForEachChunkProvider.h"
#include "WorldInterface.h"
class cBlockHandler;
class cChunkInterface : public cForEachChunkProvider class cChunkInterface : public cForEachChunkProvider
{ {
@ -69,6 +72,8 @@ public:
return m_ChunkMap->WriteBlockArea(a_Area, a_MinBlockX, a_MinBlockY, a_MinBlockZ, a_DataTypes); return m_ChunkMap->WriteBlockArea(a_Area, a_MinBlockX, a_MinBlockY, a_MinBlockZ, a_DataTypes);
} }
bool DigBlock(cWorldInterface & a_WorldInterface, int a_X, int a_Y, int a_Z);
private: private:
cChunkMap * m_ChunkMap; cChunkMap * m_ChunkMap;
}; };

View File

@ -2,6 +2,9 @@
#pragma once #pragma once
#include "BroadcastInterface.h" #include "BroadcastInterface.h"
#include "../Mobs/Monster.h"
class cItems;
class cWorldInterface class cWorldInterface
{ {

View File

@ -832,8 +832,8 @@ void cClientHandle::HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_Blo
cWorld * World = m_Player->GetWorld(); cWorld * World = m_Player->GetWorld();
ItemHandler->OnBlockDestroyed(World, m_Player, m_Player->GetEquippedItem(), a_BlockX, a_BlockY, a_BlockZ); ItemHandler->OnBlockDestroyed(World, m_Player, m_Player->GetEquippedItem(), a_BlockX, a_BlockY, a_BlockZ);
// The ItemHandler is also responsible for spawning the pickups // The ItemHandler is also responsible for spawning the pickups
cChunkInterface ChunkInterface(World->GetChunkMap());
BlockHandler(a_OldBlock)->OnDestroyedByPlayer(World, m_Player, a_BlockX, a_BlockY, a_BlockZ); BlockHandler(a_OldBlock)->OnDestroyedByPlayer(ChunkInterface,*World, m_Player, a_BlockX, a_BlockY, a_BlockZ);
World->BroadcastSoundParticleEffect(2001, a_BlockX, a_BlockY, a_BlockZ, a_OldBlock, this); World->BroadcastSoundParticleEffect(2001, a_BlockX, a_BlockY, a_BlockZ, a_OldBlock, this);
World->DigBlock(a_BlockX, a_BlockY, a_BlockZ); World->DigBlock(a_BlockX, a_BlockY, a_BlockZ);
@ -1002,7 +1002,8 @@ void cClientHandle::HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, c
BlockHandler(ClickedBlock)->DoesIgnoreBuildCollision(m_Player, ClickedBlockMeta) BlockHandler(ClickedBlock)->DoesIgnoreBuildCollision(m_Player, ClickedBlockMeta)
) )
{ {
BlockHandler(ClickedBlock)->OnDestroyedByPlayer(World, m_Player, a_BlockX, a_BlockY, a_BlockZ); cChunkInterface ChunkInterface(World->GetChunkMap());
BlockHandler(ClickedBlock)->OnDestroyedByPlayer(ChunkInterface, *World, m_Player, a_BlockX, a_BlockY, a_BlockZ);
} }
else else
{ {