6 #include "../Simulator/FluidSimulator.h" 7 #include "../Blocks/BlockHandler.h" 8 #include "../LineBlockTracer.h" 9 #include "../Blocks/ChunkInterface.h" 29 int a_BlockX,
int a_BlockY,
int a_BlockZ,
eBlockFace a_BlockFace
39 ASSERT(!
"Unhandled ItemType");
90 if ((BlockPos.
x - a_Player->
GetPosX() > 5) || (BlockPos.
z - a_Player->
GetPosZ() > 5))
107 LOG(
"Clicked with an empty bucket, but cannot remove one from the inventory? WTF?");
108 ASSERT(!
"Inventory bucket mismatch");
152 if ((BlockPos.
x - a_Player->
GetPosX() > 5) || (BlockPos.
z - a_Player->
GetPosZ() > 5))
162 LOG(
"Clicked with a full bucket, but cannot remove one from the inventory? WTF?");
163 ASSERT(!
"Inventory bucket mismatch");
182 a_PluginInterface.
CallHookPlayerBrokenBlock(*a_Player, BlockPos.
x, BlockPos.
y, BlockPos.
z, EntryFace, CurrentBlockType, CurrentBlockMeta);
186 return a_Player->
PlaceBlock(BlockPos.
x, BlockPos.
y, BlockPos.
z, a_FluidBlock, 0);
196 public cBlockTracer::cCallbacks
208 virtual bool OnNextBlock(
int a_BlockX,
int a_BlockY,
int a_BlockZ,
BLOCKTYPE a_BlockType,
NIBBLETYPE a_BlockMeta,
eBlockFace a_EntryFace)
override 212 if (a_BlockMeta != 0)
216 m_HasHitFluid =
true;
217 m_Pos.
Set(a_BlockX, a_BlockY, a_BlockZ);
228 Tracer.
Trace(Start.x, Start.y, Start.z, End.x, End.y, End.z);
230 if (!Callbacks.m_HasHitFluid)
236 a_BlockPos = Callbacks.m_Pos;
245 public cBlockTracer::cCallbacks
253 virtual bool OnNextBlock(
int a_CBBlockX,
int a_CBBlockY,
int a_CBBlockZ,
BLOCKTYPE a_CBBlockType,
NIBBLETYPE a_CBBlockMeta,
eBlockFace a_CBEntryFace)
override 257 m_ReplacedBlockType = a_CBBlockType;
258 m_ReplacedBlockMeta = a_CBBlockMeta;
259 m_EntryFace =
static_cast<eBlockFace>(a_CBEntryFace);
264 m_Pos.
Set(a_CBBlockX, a_CBBlockY, a_CBBlockZ);
278 if (!Tracer.
Trace(Start.x, Start.y, Start.z, End.x, End.y, End.z))
280 a_BlockPos = Callbacks.m_Pos;
281 a_BlockType = Callbacks.m_ReplacedBlockType;
282 a_BlockMeta = Callbacks.m_ReplacedBlockMeta;
283 a_BlockFace = Callbacks.m_EntryFace;
double GetPosX(void) const
BLOCKTYPE GetBlock(Vector3i a_BlockPos)
Returns the block type at the specified position.
bool IsBlockWater(BLOCKTYPE a_BlockType)
unsigned char BLOCKTYPE
The datatype used by blockdata.
bool RemoveOneEquippedItem(void)
Removes one item out of the currently equipped item stack, returns true if successful, false if empty-handed.
bool ScoopUpFluid(cWorld *a_World, cPlayer *a_Player, const cItem &a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace)
bool GetBlockFromTrace(cWorld *a_World, cPlayer *a_Player, Vector3i &a_BlockPos)
virtual bool OnItemUse(cWorld *a_World, cPlayer *a_Player, cBlockPluginInterface &a_PluginInterface, const cItem &a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) override
Called when the player tries to use the item (right mouse button).
void Set(T a_x, T a_y, T a_z)
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
bool PlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
Calls the block-placement hook and places the block in the world, unless refused by the hook...
bool DropBlockAsPickups(Vector3i a_BlockPos, const cEntity *a_Digger=nullptr, const cItem *a_Tool=nullptr)
Digs the specified block, and spawns the appropriate pickups for it.
NIBBLETYPE GetBlockMeta(Vector3i a_BlockPos)
Returns the block meta at the specified position.
bool GetPlacementCoordsFromTrace(cWorld *a_World, cPlayer *a_Player, Vector3i &a_BlockPos, BLOCKTYPE &a_BlockType, NIBBLETYPE &a_BlockMeta, eBlockFace &a_BlockFace)
static bool CanWashAway(BLOCKTYPE a_BlockType)
This interface is used to decouple block handlers from the cPluginManager dependency through cWorld...
bool IsBlockLiquid(BLOCKTYPE a_BlockType)
bool IsGameModeAdventure(void) const
Returns true if the player is in Adventure mode, either explicitly, or by inheriting from current wor...
void AddFaceDirection(int &a_BlockX, int &a_BlockY, int &a_BlockZ, eBlockFace a_BlockFace, bool a_bInverse=false)
Vector3d GetLookVector(void) const
virtual bool CallHookPlayerBrokenBlock(cPlayer &a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)=0
int AddItem(const cItem &a_ItemStack, bool a_AllowNewStacks=true)
Adds as many items out of a_ItemStack as can fit.
cItemBucketHandler(int a_ItemType)
eBlockFace
Block face constants, used in PlayerDigging and PlayerBlockPlacement packets and bbox collision calc...
bool Trace(double a_StartX, double a_StartY, double a_StartZ, double a_EndX, double a_EndY, double a_EndZ)
Traces one line between Start and End; returns true if the entire line was traced (until OnNoMoreHits...
void TossPickup(const cItem &a_Item)
tosses a pickup newly created from a_Item
virtual bool CallHookPlayerBreakingBlock(cPlayer &a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)=0
void LOG(const char *a_Format, fmt::ArgList a_ArgList)
Vector3d GetEyePosition(void) const
double GetPosZ(void) const
bool IsGameModeCreative(void) const
Returns true if the player is in Creative mode, either explicitly, or by inheriting from current worl...
bool PlaceFluid(cWorld *a_World, cPlayer *a_Player, cBlockPluginInterface &a_PluginInterface, const cItem &a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, BLOCKTYPE a_FluidBlock)
cInventory & GetInventory(void)
bool IsBlockLava(BLOCKTYPE a_BlockType)