2013-07-29 07:13:03 -04:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "BlockHandler.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class cBlockCauldronHandler :
|
2020-03-23 16:07:08 -04:00
|
|
|
public cBlockHandler
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
2020-04-13 12:38:06 -04:00
|
|
|
using Super = cBlockHandler;
|
2019-10-16 04:06:34 -04:00
|
|
|
|
2013-07-29 07:13:03 -04:00
|
|
|
public:
|
|
|
|
|
2019-10-16 04:06:34 -04:00
|
|
|
cBlockCauldronHandler(BLOCKTYPE a_BlockType):
|
2020-04-13 12:38:06 -04:00
|
|
|
Super(a_BlockType)
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-04-17 05:36:37 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-03-23 16:07:08 -04:00
|
|
|
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) override
|
|
|
|
{
|
|
|
|
return cItem(E_ITEM_CAULDRON, 1, 0);
|
|
|
|
}
|
|
|
|
|
2020-04-17 05:36:37 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-04-21 16:19:22 -04:00
|
|
|
virtual bool OnUse(
|
|
|
|
cChunkInterface & a_ChunkInterface,
|
|
|
|
cWorldInterface & a_WorldInterface,
|
|
|
|
cPlayer & a_Player,
|
|
|
|
const Vector3i a_BlockPos,
|
|
|
|
eBlockFace a_BlockFace,
|
|
|
|
const Vector3i a_CursorPos
|
|
|
|
) override
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
2020-04-21 16:19:22 -04:00
|
|
|
NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockPos);
|
2020-04-02 08:42:15 -04:00
|
|
|
auto EquippedItem = a_Player.GetEquippedItem();
|
|
|
|
switch (EquippedItem.m_ItemType)
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
2020-04-02 08:42:15 -04:00
|
|
|
case E_ITEM_BUCKET:
|
|
|
|
{
|
|
|
|
if (Meta == 3)
|
|
|
|
{
|
2020-04-21 16:19:22 -04:00
|
|
|
a_ChunkInterface.SetBlockMeta(a_BlockPos, 0);
|
2020-04-02 08:42:15 -04:00
|
|
|
// Give new bucket, filled with fluid when the gamemode is not creative:
|
|
|
|
if (!a_Player.IsGameModeCreative())
|
|
|
|
{
|
|
|
|
a_Player.ReplaceOneEquippedItemTossRest(cItem(E_ITEM_WATER_BUCKET));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2013-07-29 07:13:03 -04:00
|
|
|
case E_ITEM_WATER_BUCKET:
|
|
|
|
{
|
2014-02-20 11:45:18 -05:00
|
|
|
if (Meta < 3)
|
|
|
|
{
|
2020-04-21 16:19:22 -04:00
|
|
|
a_ChunkInterface.SetBlockMeta(a_BlockPos, 3);
|
2020-04-02 08:42:15 -04:00
|
|
|
// Give empty bucket back when the gamemode is not creative:
|
2017-07-31 16:17:52 -04:00
|
|
|
if (!a_Player.IsGameModeCreative())
|
2014-02-20 14:58:23 -05:00
|
|
|
{
|
2020-04-02 08:42:15 -04:00
|
|
|
a_Player.ReplaceOneEquippedItemTossRest(cItem(E_ITEM_BUCKET));
|
2014-02-20 14:58:23 -05:00
|
|
|
}
|
2014-02-20 11:45:18 -05:00
|
|
|
}
|
2013-07-29 07:13:03 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case E_ITEM_GLASS_BOTTLE:
|
|
|
|
{
|
2014-02-20 11:45:18 -05:00
|
|
|
if (Meta > 0)
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
2020-04-21 16:19:22 -04:00
|
|
|
a_ChunkInterface.SetBlockMeta(a_BlockPos, --Meta);
|
2020-04-02 08:42:15 -04:00
|
|
|
// Give new potion when the gamemode is not creative:
|
|
|
|
if (!a_Player.IsGameModeCreative())
|
|
|
|
{
|
|
|
|
a_Player.ReplaceOneEquippedItemTossRest(cItem(E_ITEM_POTION));
|
|
|
|
}
|
2013-07-29 07:13:03 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2020-04-02 08:42:15 -04:00
|
|
|
case E_ITEM_POTION:
|
|
|
|
{
|
|
|
|
// Refill cauldron with water bottles.
|
|
|
|
if ((Meta < 3) && (EquippedItem.m_ItemDamage == 0))
|
|
|
|
{
|
2020-04-21 16:19:22 -04:00
|
|
|
a_ChunkInterface.SetBlockMeta(Vector3i(a_BlockPos), ++Meta);
|
|
|
|
// Give back an empty bottle when the gamemode is not creative:
|
2020-04-02 08:42:15 -04:00
|
|
|
if (!a_Player.IsGameModeCreative())
|
|
|
|
{
|
|
|
|
a_Player.ReplaceOneEquippedItemTossRest(cItem(E_ITEM_GLASS_BOTTLE));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-07-29 07:13:03 -04:00
|
|
|
}
|
2015-12-01 17:12:44 -05:00
|
|
|
return true;
|
2013-07-29 07:13:03 -04:00
|
|
|
}
|
|
|
|
|
2020-04-17 05:36:37 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-07-29 07:13:03 -04:00
|
|
|
virtual bool IsUseable() override
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2014-05-29 11:58:40 -04:00
|
|
|
|
2020-04-17 05:36:37 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
virtual void OnUpdate(
|
|
|
|
cChunkInterface & a_ChunkInterface,
|
|
|
|
cWorldInterface & a_WorldInterface,
|
|
|
|
cBlockPluginInterface & a_PluginInterface,
|
|
|
|
cChunk & a_Chunk,
|
|
|
|
const Vector3i a_RelPos
|
|
|
|
) override
|
2014-05-29 11:58:40 -04:00
|
|
|
{
|
2020-04-17 05:36:37 -04:00
|
|
|
auto WorldPos = a_Chunk.RelativeToAbsolute(a_RelPos);
|
|
|
|
if (!a_WorldInterface.IsWeatherWetAtXYZ(WorldPos.addedY(1)))
|
2014-05-29 11:58:40 -04:00
|
|
|
{
|
2014-06-14 05:14:04 -04:00
|
|
|
// It's not raining at our current location or we do not have a direct view of the sky
|
2014-05-29 11:58:40 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-04-17 05:36:37 -04:00
|
|
|
auto Meta = a_Chunk.GetMeta(a_RelPos);
|
2014-05-29 11:58:40 -04:00
|
|
|
if (Meta < 3)
|
|
|
|
{
|
2020-04-17 05:36:37 -04:00
|
|
|
a_Chunk.SetMeta(a_RelPos, Meta + 1);
|
2014-05-29 11:58:40 -04:00
|
|
|
}
|
|
|
|
}
|
2015-06-30 10:50:15 -04:00
|
|
|
|
2020-04-17 05:36:37 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-06-30 10:50:15 -04:00
|
|
|
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
|
|
|
|
{
|
|
|
|
UNUSED(a_Meta);
|
|
|
|
return 21;
|
|
|
|
}
|
2013-07-29 07:13:03 -04:00
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|