1
0
cuberite-2a/src/Blocks/BlockSeaLantern.h
KingCol13 b6b7fb1a65
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.
2020-09-20 18:06:28 +00:00

37 lines
742 B
C++

#pragma once
#include "BlockHandler.h"
class cBlockSeaLanternHandler :
public cBlockHandler
{
using Super = cBlockHandler;
public:
using Super::Super;
private:
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
{
// 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<char>(2, 3 + ToolFortuneLevel(a_Tool));
// cap the dropnum to the max amount of 5
DropNum = std::min<unsigned int>(DropNum, 5);
// Reset meta to 0
return cItem(E_ITEM_PRISMARINE_CRYSTALS, DropNum, 0);
}
}
} ;