diff options
author | Alexander Harkness <me@bearbin.net> | 2020-04-02 14:42:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-02 14:42:15 +0200 |
commit | cdc452916e3ec7e61f4a1ad822666192593b4b08 (patch) | |
tree | fcf35adfb6f907b7c2cd4388facc551cfe6c684a /src/Blocks/BlockCauldron.h | |
parent | Tweak attack ranges (diff) | |
download | cuberite-cdc452916e3ec7e61f4a1ad822666192593b4b08.tar cuberite-cdc452916e3ec7e61f4a1ad822666192593b4b08.tar.gz cuberite-cdc452916e3ec7e61f4a1ad822666192593b4b08.tar.bz2 cuberite-cdc452916e3ec7e61f4a1ad822666192593b4b08.tar.lz cuberite-cdc452916e3ec7e61f4a1ad822666192593b4b08.tar.xz cuberite-cdc452916e3ec7e61f4a1ad822666192593b4b08.tar.zst cuberite-cdc452916e3ec7e61f4a1ad822666192593b4b08.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Blocks/BlockCauldron.h | 40 |
1 files changed, 35 insertions, 5 deletions
diff --git a/src/Blocks/BlockCauldron.h b/src/Blocks/BlockCauldron.h index 5b45b2828..d6ef721ad 100644 --- a/src/Blocks/BlockCauldron.h +++ b/src/Blocks/BlockCauldron.h @@ -27,17 +27,31 @@ public: virtual bool OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override { NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta({a_BlockX, a_BlockY, a_BlockZ}); - switch (a_Player.GetEquippedItem().m_ItemType) + auto EquippedItem = a_Player.GetEquippedItem(); + switch (EquippedItem.m_ItemType) { + case E_ITEM_BUCKET: + { + if (Meta == 3) + { + a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, 0); + // 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; + } case E_ITEM_WATER_BUCKET: { if (Meta < 3) { a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, 3); + // Give empty bucket back when the gamemode is not creative: if (!a_Player.IsGameModeCreative()) { - a_Player.GetInventory().RemoveOneEquippedItem(); - a_Player.GetInventory().AddItem(cItem(E_ITEM_BUCKET)); + a_Player.ReplaceOneEquippedItemTossRest(cItem(E_ITEM_BUCKET)); } } break; @@ -47,11 +61,27 @@ public: if (Meta > 0) { a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, --Meta); - a_Player.GetInventory().RemoveOneEquippedItem(); - a_Player.GetInventory().AddItem(cItem(E_ITEM_POTION)); + // Give new potion when the gamemode is not creative: + if (!a_Player.IsGameModeCreative()) + { + a_Player.ReplaceOneEquippedItemTossRest(cItem(E_ITEM_POTION)); + } } break; } + case E_ITEM_POTION: + { + // Refill cauldron with water bottles. + if ((Meta < 3) && (EquippedItem.m_ItemDamage == 0)) + { + a_ChunkInterface.SetBlockMeta(Vector3i(a_BlockX, a_BlockY, a_BlockZ), ++Meta); + // Give empty bottle when the gamemode is not creative: + if (!a_Player.IsGameModeCreative()) + { + a_Player.ReplaceOneEquippedItemTossRest(cItem(E_ITEM_GLASS_BOTTLE)); + } + } + } } return true; } |