1
0
cuberite-2a/src/Blocks/BlockBookShelf.h
mathiascode e6cc792cef Prevent bookshelf pickup crash
If no tool was involved in the creation of a bookshelf pickup (e.g. explosion), the server would crash due to a missing nullptr check. Removed the IsTool check completely, since we don't use it elsewhere, and vanilla doesn't do such checks either.
2020-04-24 19:39:22 +03:00

27 lines
490 B
C++

#pragma once
#include "BlockHandler.h"
class cBlockBookShelfHandler :
public cBlockHandler
{
public:
cBlockBookShelfHandler(BLOCKTYPE a_BlockType) :
cBlockHandler(a_BlockType)
{
}
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) override
{
if (ToolHasSilkTouch(a_Tool))
{
return cItem(m_BlockType, 1);
}
return cItem(E_ITEM_BOOK, 3);
}
};