From b6b7fb1a6549ba0c92c5db141af6f6f9bc1d3038 Mon Sep 17 00:00:00 2001 From: KingCol13 <48412633+KingCol13@users.noreply.github.com> Date: Sun, 20 Sep 2020 19:06:28 +0100 Subject: Implement fortune for ores, glowstone and sea lanterns (#4897) * Implemented fortune for ores, glowstone and sea lanterns (but nothing organic or flint). * Cleanup printf * Stopped playing golf, gave the Camels a FirstHump and moved the FortuneDropMult comment. Thanks for the review :). * Got rid of FortuneDropMult and replaced with Peter's massive optimization/simplification. * Fixed default lapis max droprate (8 -> 9). * Clamp max drops for non-redstone ores to 10. * Comment justifying the clamp. --- src/Blocks/BlockSeaLantern.h | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/Blocks/BlockSeaLantern.h') diff --git a/src/Blocks/BlockSeaLantern.h b/src/Blocks/BlockSeaLantern.h index c24476e0b..1fab10a11 100644 --- a/src/Blocks/BlockSeaLantern.h +++ b/src/Blocks/BlockSeaLantern.h @@ -6,7 +6,6 @@ - class cBlockSeaLanternHandler : public cBlockHandler { @@ -20,8 +19,18 @@ private: virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override { - // Reset meta to 0 - // TODO: Handle the Fortune enchantment - return cItem(E_ITEM_PRISMARINE_CRYSTALS, GetRandomProvider().RandInt(2, 3), 0); + // Drop self only when using silk-touch: + if (ToolHasSilkTouch(a_Tool)) + { + return cItem(E_BLOCK_SEA_LANTERN, 1, 0); + } + else + { + unsigned int DropNum = GetRandomProvider().RandInt(2, 3 + ToolFortuneLevel(a_Tool)); + // cap the dropnum to the max amount of 5 + DropNum = std::min(DropNum, 5); + // Reset meta to 0 + return cItem(E_ITEM_PRISMARINE_CRYSTALS, DropNum, 0); + } } } ; -- cgit v1.2.3