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