From c52f299e724bf893944553ac3aeedf7bf0a58241 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 2 Jan 2022 11:56:36 +0000 Subject: Handlers: update item and block handlers (#5371) + Resend blocks when server rejects placement because in a block * Fix chest handler not invoked, fixes #5367 * Fix comparator handler not invoked * Update some naming --- src/Blocks/BlockEnderChest.h | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/Blocks/BlockEnderChest.h (limited to 'src/Blocks/BlockEnderChest.h') diff --git a/src/Blocks/BlockEnderChest.h b/src/Blocks/BlockEnderChest.h new file mode 100644 index 000000000..2e0da0f17 --- /dev/null +++ b/src/Blocks/BlockEnderChest.h @@ -0,0 +1,40 @@ + +#pragma once + +#include "Mixins.h" + + + + +class cBlockEnderChestHandler final : + public cYawRotator +{ + using Super = cYawRotator; + +public: + + using Super::Super; + +private: + + virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override + { + // Only drop something when mined with a pickaxe: + if ( + (a_Tool != nullptr) && + ItemCategory::IsPickaxe(a_Tool->m_ItemType) + ) + { + // Only drop self when mined with a silk-touch pickaxe: + if (a_Tool->m_Enchantments.GetLevel(cEnchantments::enchSilkTouch) > 0) + { + return cItem(E_BLOCK_ENDER_CHEST); + } + + return cItem(E_BLOCK_OBSIDIAN, 8); + } + + return {}; + } + +}; -- cgit v1.2.3