From 3ff57559e36d3254c64e334fbe3bdd47398fe16f Mon Sep 17 00:00:00 2001 From: x12xx12x <44411062+12xx12@users.noreply.github.com> Date: Thu, 2 Dec 2021 00:31:10 +0100 Subject: ItemHandler initialisation is a constant expression (#5344) * Transition to non-pointer item handler * That is my destructor - I decide when I leave this world * I declare your destruction private and you final --- src/Blocks/BlockCauldron.h | 2 +- src/Blocks/BlockMobSpawner.h | 4 +- src/Blocks/BlockOre.h | 2 +- src/Chunk.cpp | 2 +- src/ClientHandle.cpp | 32 +- src/Entities/Entity.cpp | 2 +- src/Entities/Player.cpp | 14 +- src/Inventory.cpp | 7 +- src/Item.cpp | 8 +- src/Item.h | 2 +- src/ItemGrid.cpp | 7 +- src/Items/CMakeLists.txt | 1 + src/Items/ItemAnvil.h | 4 +- src/Items/ItemArmor.h | 11 +- src/Items/ItemAxe.h | 11 +- src/Items/ItemBanner.h | 11 +- src/Items/ItemBed.h | 11 +- src/Items/ItemBigFlower.h | 13 +- src/Items/ItemBoat.h | 9 +- src/Items/ItemBottle.h | 11 +- src/Items/ItemBow.h | 11 +- src/Items/ItemBucket.h | 14 +- src/Items/ItemButton.h | 4 +- src/Items/ItemChest.h | 9 +- src/Items/ItemChorusFruit.h | 8 +- src/Items/ItemCloth.h | 4 +- src/Items/ItemComparator.h | 6 +- src/Items/ItemCookedFish.h | 8 +- src/Items/ItemDefaultItem.h | 9 + src/Items/ItemDoor.h | 8 +- src/Items/ItemDropSpenser.h | 4 +- src/Items/ItemDye.h | 9 +- src/Items/ItemEmptyMap.h | 9 +- src/Items/ItemEnchantingTable.h | 6 +- src/Items/ItemEndCrystal.h | 6 +- src/Items/ItemEndPortalFrame.h | 4 +- src/Items/ItemEnderchest.h | 4 +- src/Items/ItemEyeOfEnder.h | 8 +- src/Items/ItemFenceGate.h | 4 +- src/Items/ItemFishingRod.h | 15 +- src/Items/ItemFood.h | 17 +- src/Items/ItemFoodSeeds.h | 10 +- src/Items/ItemFurnace.h | 4 +- src/Items/ItemGlazedTerracotta.h | 4 +- src/Items/ItemGoldenApple.h | 8 +- src/Items/ItemHandler.cpp | 1316 +++++++++++++++++++++++--------- src/Items/ItemHandler.h | 65 +- src/Items/ItemHoe.h | 11 +- src/Items/ItemHopper.h | 4 +- src/Items/ItemItemFrame.h | 9 +- src/Items/ItemJackOLantern.h | 4 +- src/Items/ItemLadder.h | 4 +- src/Items/ItemLeaves.h | 9 +- src/Items/ItemLever.h | 4 +- src/Items/ItemLighter.h | 9 +- src/Items/ItemLilypad.h | 8 +- src/Items/ItemMap.h | 9 +- src/Items/ItemMilk.h | 11 +- src/Items/ItemMinecart.h | 9 +- src/Items/ItemMobHead.h | 21 +- src/Items/ItemNetherWart.h | 11 +- src/Items/ItemObserver.h | 4 +- src/Items/ItemPainting.h | 9 +- src/Items/ItemPickaxe.h | 14 +- src/Items/ItemPiston.h | 4 +- src/Items/ItemPlanks.h | 4 +- src/Items/ItemPoisonousPotato.h | 8 +- src/Items/ItemPotion.h | 13 +- src/Items/ItemPumpkin.h | 10 +- src/Items/ItemQuartz.h | 4 +- src/Items/ItemRail.h | 4 +- src/Items/ItemRawChicken.h | 8 +- src/Items/ItemRawFish.h | 10 +- src/Items/ItemRedstoneDust.h | 11 +- src/Items/ItemRedstoneRepeater.h | 11 +- src/Items/ItemRottenFlesh.h | 8 +- src/Items/ItemSapling.h | 9 +- src/Items/ItemSeeds.h | 14 +- src/Items/ItemShears.h | 24 +- src/Items/ItemShovel.h | 15 +- src/Items/ItemSideways.h | 4 +- src/Items/ItemSign.h | 6 +- src/Items/ItemSlab.h | 4 +- src/Items/ItemSnow.h | 4 +- src/Items/ItemSoup.h | 6 +- src/Items/ItemSpawnEgg.h | 13 +- src/Items/ItemSpiderEye.h | 8 +- src/Items/ItemStairs.h | 4 +- src/Items/ItemSword.h | 16 +- src/Items/ItemThrowable.h | 39 +- src/Items/ItemTorch.h | 4 +- src/Items/ItemTrapdoor.h | 4 +- src/Items/ItemTripwireHook.h | 4 +- src/Items/ItemVine.h | 4 +- src/Items/SimplePlaceableItemHandler.h | 8 +- src/Mobs/Monster.cpp | 2 +- src/Mobs/Wolf.cpp | 2 +- src/Root.cpp | 2 - src/UI/SlotArea.cpp | 23 +- src/UI/Window.cpp | 2 +- 100 files changed, 1340 insertions(+), 864 deletions(-) create mode 100644 src/Items/ItemDefaultItem.h diff --git a/src/Blocks/BlockCauldron.h b/src/Blocks/BlockCauldron.h index 80f95164f..cbd17a849 100644 --- a/src/Blocks/BlockCauldron.h +++ b/src/Blocks/BlockCauldron.h @@ -146,7 +146,7 @@ private: } } - if (!ItemHandler(EquippedItem.m_ItemType)->IsPlaceable()) + if (!EquippedItem.GetHandler().IsPlaceable()) { // Item not placeable in the first place, our work is done: return true; diff --git a/src/Blocks/BlockMobSpawner.h b/src/Blocks/BlockMobSpawner.h index da5bd84c4..b4981abe9 100644 --- a/src/Blocks/BlockMobSpawner.h +++ b/src/Blocks/BlockMobSpawner.h @@ -71,8 +71,8 @@ private: } const auto Player = static_cast(a_Digger); - auto Handler = Player->GetEquippedItem().GetHandler(); - if (!Player->IsGameModeSurvival() || !Handler->CanHarvestBlock(E_BLOCK_MOB_SPAWNER)) + auto & Handler = Player->GetEquippedItem().GetHandler(); + if (!Player->IsGameModeSurvival() || !Handler.CanHarvestBlock(E_BLOCK_MOB_SPAWNER)) { return; } diff --git a/src/Blocks/BlockOre.h b/src/Blocks/BlockOre.h index 3bd193ee3..c2526e16c 100644 --- a/src/Blocks/BlockOre.h +++ b/src/Blocks/BlockOre.h @@ -94,7 +94,7 @@ private: return; } - if (!ItemHandler(Player->GetEquippedItem().m_ItemType)->CanHarvestBlock(m_BlockType)) + if (!Player->GetEquippedItem().GetHandler().CanHarvestBlock(m_BlockType)) { return; } diff --git a/src/Chunk.cpp b/src/Chunk.cpp index fac2d37ee..462323308 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -985,7 +985,7 @@ cItems cChunk::PickupsFromBlock(Vector3i a_RelPos, const cEntity * a_Digger, con cItems Pickups; const auto BlockEntity = GetBlockEntityRel(a_RelPos); - if ((a_Tool == nullptr) || a_Tool->GetHandler()->CanHarvestBlock(BlockType)) + if ((a_Tool == nullptr) || a_Tool->GetHandler().CanHarvestBlock(BlockType)) { Pickups = cBlockHandler::For(BlockType).ConvertToPickups(BlockMeta, a_Tool); diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index a42212002..1d9b8e2a6 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1164,8 +1164,8 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB case DIG_STATUS_SHOOT_EAT: { - cItemHandler * ItemHandler = cItemHandler::GetItemHandler(m_Player->GetEquippedItem()); - if (ItemHandler->IsFood() || ItemHandler->IsDrinkable(m_Player->GetEquippedItem().m_ItemDamage)) + auto & ItemHandler = m_Player->GetEquippedItem().GetHandler(); + if (ItemHandler.IsFood() || ItemHandler.IsDrinkable(m_Player->GetEquippedItem().m_ItemDamage)) { m_Player->AbortEating(); return; @@ -1180,9 +1180,12 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB // When bow is in off-hand / shield slot if (m_Player->GetInventory().GetShieldSlot().m_ItemType == E_ITEM_BOW) { - ItemHandler = cItemHandler::GetItemHandler(m_Player->GetInventory().GetShieldSlot()); + m_Player->GetInventory().GetShieldSlot().GetHandler().OnItemShoot(m_Player, {a_BlockX, a_BlockY, a_BlockZ}, a_BlockFace); + } + else + { + ItemHandler.OnItemShoot(m_Player, {a_BlockX, a_BlockY, a_BlockZ}, a_BlockFace); } - ItemHandler->OnItemShoot(m_Player, {a_BlockX, a_BlockY, a_BlockZ}, a_BlockFace); } return; } @@ -1319,8 +1322,7 @@ void cClientHandle::HandleBlockDigStarted(int a_BlockX, int a_BlockY, int a_Bloc cChunkInterface ChunkInterface(World->GetChunkMap()); cBlockHandler::For(DiggingBlock).OnDigging(ChunkInterface, *World, *m_Player, {a_BlockX, a_BlockY, a_BlockZ}); - cItemHandler * ItemHandler = cItemHandler::GetItemHandler(m_Player->GetEquippedItem()); - ItemHandler->OnDiggingBlock(World, m_Player, m_Player->GetEquippedItem(), {a_BlockX, a_BlockY, a_BlockZ}, a_BlockFace); + m_Player->GetEquippedItem().GetHandler().OnDiggingBlock(World, m_Player, m_Player->GetEquippedItem(), {a_BlockX, a_BlockY, a_BlockZ}, a_BlockFace); } @@ -1452,7 +1454,7 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e // TODO: We are still consuming the items in main hand. Remove this override when the off-hand consumption is handled correctly. a_UsedMainHand = true; const cItem & HeldItem = a_UsedMainHand ? m_Player->GetEquippedItem() : m_Player->GetInventory().GetShieldSlot(); - cItemHandler * ItemHandler = cItemHandler::GetItemHandler(HeldItem.m_ItemType); + auto & ItemHandler = HeldItem.GetHandler(); // TODO: This distance should be calculated from the point that the cursor pointing at, instead of the center of the block // Distance from the block's center to the player's eye height @@ -1480,7 +1482,7 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e World->GetBlockTypeMeta(ClickedBlockPos, BlockType, BlockMeta); const auto & BlockHandler = cBlockHandler::For(BlockType); - bool Placeable = ItemHandler->IsPlaceable() && !m_Player->IsGameModeAdventure() && !m_Player->IsGameModeSpectator(); + bool Placeable = ItemHandler.IsPlaceable() && !m_Player->IsGameModeAdventure() && !m_Player->IsGameModeSpectator(); bool BlockUsable = BlockHandler.IsUseable() && (!m_Player->IsGameModeSpectator() || cBlockInfo::IsUseableBySpectator(BlockType)); if (BlockUsable && !(m_Player->IsCrouched() && !HeldItem.IsEmpty())) @@ -1499,7 +1501,7 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e if (Placeable) { // Place a block: - ItemHandler->OnPlayerPlace(*m_Player, HeldItem, {a_BlockX, a_BlockY, a_BlockZ}, a_BlockFace, {a_CursorX, a_CursorY, a_CursorZ}); + ItemHandler.OnPlayerPlace(*m_Player, HeldItem, {a_BlockX, a_BlockY, a_BlockZ}, a_BlockFace, {a_CursorX, a_CursorY, a_CursorZ}); } return; @@ -1516,7 +1518,7 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e } // Place a block: - ItemHandler->OnPlayerPlace(*m_Player, HeldItem, {a_BlockX, a_BlockY, a_BlockZ}, a_BlockFace, {a_CursorX, a_CursorY, a_CursorZ}); + ItemHandler.OnPlayerPlace(*m_Player, HeldItem, {a_BlockX, a_BlockY, a_BlockZ}, a_BlockFace, {a_CursorX, a_CursorY, a_CursorZ}); return; } else if (!PlgMgr->CallHookPlayerUsingItem(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ)) @@ -1525,7 +1527,7 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e // Use an item in hand with a target block. cBlockInServerPluginInterface PluginInterface(*World); - ItemHandler->OnItemUse(World, m_Player, PluginInterface, HeldItem, {a_BlockX, a_BlockY, a_BlockZ}, a_BlockFace); + ItemHandler.OnItemUse(World, m_Player, PluginInterface, HeldItem, {a_BlockX, a_BlockY, a_BlockZ}, a_BlockFace); PlgMgr->CallHookPlayerUsedItem(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ); return; } @@ -1854,7 +1856,7 @@ void cClientHandle::HandleUseItem(bool a_UsedMainHand) // TODO: We are still consuming the items in main hand. Remove this override when the off-hand consumption is handled correctly. a_UsedMainHand = true; const cItem & HeldItem = a_UsedMainHand ? m_Player->GetEquippedItem() : m_Player->GetInventory().GetShieldSlot(); - cItemHandler * ItemHandler = cItemHandler::GetItemHandler(HeldItem.m_ItemType); + auto & ItemHandler = HeldItem.GetHandler(); cWorld * World = m_Player->GetWorld(); cPluginManager * PlgMgr = cRoot::Get()->GetPluginManager(); @@ -1872,10 +1874,10 @@ void cClientHandle::HandleUseItem(bool a_UsedMainHand) return; } - if (ItemHandler->IsFood() || ItemHandler->IsDrinkable(HeldItem.m_ItemDamage)) + if (ItemHandler.IsFood() || ItemHandler.IsDrinkable(HeldItem.m_ItemDamage)) { if ( - ItemHandler->IsFood() && + ItemHandler.IsFood() && (m_Player->IsSatiated() || m_Player->IsGameModeCreative()) && // Only non-creative or hungry players can eat (HeldItem.m_ItemType != E_ITEM_GOLDEN_APPLE) && // Golden apple is a special case, it is used instead of eaten (HeldItem.m_ItemType != E_ITEM_CHORUS_FRUIT) // Chorus fruit is a special case, it is used instead of eaten @@ -1896,7 +1898,7 @@ void cClientHandle::HandleUseItem(bool a_UsedMainHand) { // All plugins agree with using the item cBlockInServerPluginInterface PluginInterface(*World); - ItemHandler->OnItemUse(World, m_Player, PluginInterface, HeldItem, {-1, 255, -1}, BLOCK_FACE_NONE); + ItemHandler.OnItemUse(World, m_Player, PluginInterface, HeldItem, {-1, 255, -1}, BLOCK_FACE_NONE); PlgMgr->CallHookPlayerUsedItem(*m_Player, -1, 255, -1, BLOCK_FACE_NONE, 0, 0, 0); } } diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index bf4b9372c..0bb8b97bc 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -406,7 +406,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI) { cPlayer * Player = static_cast(a_TDI.Attacker); - Player->GetEquippedItem().GetHandler()->OnEntityAttack(Player, this); + Player->GetEquippedItem().GetHandler().OnEntityAttack(Player, this); // Whether an enchantment boosted this attack's damage. bool MagicalCriticalHit = false; diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index e1caef7f9..1d3bad306 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -525,12 +525,12 @@ void cPlayer::FinishEating(void) // consume the item: cItem Item(GetEquippedItem()); Item.m_ItemCount = 1; - cItemHandler * ItemHandler = cItemHandler::GetItemHandler(Item.m_ItemType); - if (!ItemHandler->EatItem(this, &Item)) + auto & ItemHandler = Item.GetHandler(); + if (!ItemHandler.EatItem(this, &Item)) { return; } - ItemHandler->OnFoodEaten(m_World, this, &Item); + ItemHandler.OnFoodEaten(m_World, this, &Item); } @@ -2035,7 +2035,7 @@ void cPlayer::UseEquippedItem(cItemHandler::eDurabilityLostAction a_Action) cItem Item = GetEquippedItem(); // Get base damage for action type: - short Dmg = cItemHandler::GetItemHandler(Item)->GetDurabilityLossByAction(a_Action); + short Dmg = Item.GetHandler().GetDurabilityLossByAction(a_Action); UseEquippedItem(Dmg); } @@ -2613,10 +2613,10 @@ float cPlayer::GetDigSpeed(BLOCKTYPE a_Block) // Based on: https://minecraft.gamepedia.com/Breaking#Speed // Get the base speed multiplier of the equipped tool for the mined block - float MiningSpeed = GetEquippedItem().GetHandler()->GetBlockBreakingStrength(a_Block); + float MiningSpeed = GetEquippedItem().GetHandler().GetBlockBreakingStrength(a_Block); // If we can harvest the block then we can apply material and enchantment bonuses - if (GetEquippedItem().GetHandler()->CanHarvestBlock(a_Block)) + if (GetEquippedItem().GetHandler().CanHarvestBlock(a_Block)) { if (MiningSpeed > 1.0f) // If the base multiplier for this block is greater than 1, now we can check enchantments { @@ -2683,7 +2683,7 @@ float cPlayer::GetMiningProgressPerTick(BLOCKTYPE a_Block) return 1; } - const bool CanHarvest = GetEquippedItem().GetHandler()->CanHarvestBlock(a_Block); + const bool CanHarvest = GetEquippedItem().GetHandler().CanHarvestBlock(a_Block); const float BlockHardness = cBlockInfo::GetHardness(a_Block) * (CanHarvest ? 1.5f : 5.0f); ASSERT(BlockHardness > 0); // Can't divide by 0 or less, IsOneHitDig should have returned true diff --git a/src/Inventory.cpp b/src/Inventory.cpp index 6509dfe5d..2fdd1c25f 100644 --- a/src/Inventory.cpp +++ b/src/Inventory.cpp @@ -78,7 +78,7 @@ int cInventory::HowManyCanFit(const cItem & a_ItemStack, int a_BeginSlotNum, int } char NumLeft = a_ItemStack.m_ItemCount; - int MaxStack = ItemHandler(a_ItemStack.m_ItemType)->GetMaxStackSize(); + int MaxStack = a_ItemStack.GetMaxStackSize(); for (int i = a_BeginSlotNum; i <= a_EndSlotNum; i++) { const cItem & Slot = GetSlot(i); @@ -260,8 +260,7 @@ int cInventory::ReplaceOneEquippedItem(const cItem & a_Item, bool a_TryOtherSlot cItem ItemsToAdd = a_Item; if (EquippedItem.IsEqual(ItemsToAdd)) { - cItemHandler Handler(ItemsToAdd.m_ItemType); - auto AmountToAdd = std::min(static_cast(Handler.GetMaxStackSize() - EquippedItem.m_ItemCount), ItemsToAdd.m_ItemCount); + auto AmountToAdd = std::min(static_cast(ItemsToAdd.GetMaxStackSize() - EquippedItem.m_ItemCount), ItemsToAdd.m_ItemCount); EquippedItem.m_ItemCount += AmountToAdd; SetEquippedItem(EquippedItem); @@ -689,7 +688,7 @@ void cInventory::UpdateItems(void) const cItem & Slot = GetEquippedItem(); if (!Slot.IsEmpty()) { - ItemHandler(Slot.m_ItemType)->OnUpdate(m_Owner.GetWorld(), &m_Owner, Slot); + Slot.GetHandler().OnUpdate(m_Owner.GetWorld(), &m_Owner, Slot); } } diff --git a/src/Item.cpp b/src/Item.cpp index ba2a8db90..198912aa4 100644 --- a/src/Item.cpp +++ b/src/Item.cpp @@ -197,7 +197,7 @@ bool cItem::DamageItem(short a_Amount) bool cItem::IsFullStack(void) const { - return (m_ItemCount >= ItemHandler(m_ItemType)->GetMaxStackSize()); + return (m_ItemCount >= GetMaxStackSize()); } @@ -206,16 +206,16 @@ bool cItem::IsFullStack(void) const char cItem::GetMaxStackSize(void) const { - return ItemHandler(m_ItemType)->GetMaxStackSize(); + return cItemHandler::For(m_ItemType).GetMaxStackSize(); } -cItemHandler * cItem::GetHandler(void) const +const cItemHandler & cItem::GetHandler(void) const { - return ItemHandler(m_ItemType); + return cItemHandler::For(m_ItemType); } diff --git a/src/Item.h b/src/Item.h index 6d20da7cd..a3379ebdc 100644 --- a/src/Item.h +++ b/src/Item.h @@ -124,7 +124,7 @@ public: // tolua_end /** Returns the cItemHandler responsible for this item type */ - cItemHandler * GetHandler(void) const; + const cItemHandler & GetHandler(void) const; /** Saves the item data into JSON representation */ void GetJson(Json::Value & a_OutValue) const; diff --git a/src/ItemGrid.cpp b/src/ItemGrid.cpp index a4cf41a14..4ffd51b97 100644 --- a/src/ItemGrid.cpp +++ b/src/ItemGrid.cpp @@ -246,7 +246,7 @@ void cItemGrid::Clear(void) int cItemGrid::HowManyCanFit(const cItem & a_ItemStack, bool a_AllowNewStacks) { int NumLeft = a_ItemStack.m_ItemCount; - int MaxStack = ItemHandler(a_ItemStack.m_ItemType)->GetMaxStackSize(); + int MaxStack = a_ItemStack.GetMaxStackSize(); if (!m_Slots.IsStorageAllocated()) { @@ -491,10 +491,9 @@ int cItemGrid::ChangeSlotCount(int a_SlotNum, int a_AddToCount) m_Slots[a_SlotNum].m_ItemCount += a_AddToCount; - cItemHandler * Handler = cItemHandler::GetItemHandler(m_Slots[a_SlotNum].m_ItemType); - if (m_Slots[a_SlotNum].m_ItemCount > Handler->GetMaxStackSize()) + if (m_Slots[a_SlotNum].m_ItemCount > m_Slots[a_SlotNum].GetMaxStackSize()) { - m_Slots[a_SlotNum].m_ItemCount = Handler->GetMaxStackSize(); + m_Slots[a_SlotNum].m_ItemCount = m_Slots[a_SlotNum].GetMaxStackSize(); } TriggerListeners(a_SlotNum); diff --git a/src/Items/CMakeLists.txt b/src/Items/CMakeLists.txt index 0dc7f8365..1e3a05bd0 100644 --- a/src/Items/CMakeLists.txt +++ b/src/Items/CMakeLists.txt @@ -19,6 +19,7 @@ target_sources( ItemCloth.h ItemComparator.h ItemCookedFish.h + ItemDefaultItem.h ItemDoor.h ItemDropSpenser.h ItemDye.h diff --git a/src/Items/ItemAnvil.h b/src/Items/ItemAnvil.h index e52f28e65..3262c322c 100644 --- a/src/Items/ItemAnvil.h +++ b/src/Items/ItemAnvil.h @@ -8,7 +8,7 @@ -class cItemAnvilHandler : +class cItemAnvilHandler final : public cItemHandler { using Super = cItemHandler; @@ -19,7 +19,7 @@ public: private: - virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) override + virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const override { return a_Player.PlaceBlock( a_PlacePosition, diff --git a/src/Items/ItemArmor.h b/src/Items/ItemArmor.h index 3139c09f4..eb7e31c79 100644 --- a/src/Items/ItemArmor.h +++ b/src/Items/ItemArmor.h @@ -8,17 +8,14 @@ -class cItemArmorHandler: +class cItemArmorHandler final : public cItemHandler { using Super = cItemHandler; public: - cItemArmorHandler(int a_ItemType): - Super(a_ItemType) - { - } + using Super::Super; @@ -32,7 +29,7 @@ public: const cItem & a_HeldItem, const Vector3i a_ClickedBlockPos, eBlockFace a_ClickedBlockFace - ) override + ) const override { int SlotNum; if (ItemCategory::IsHelmet(a_HeldItem.m_ItemType)) @@ -71,7 +68,7 @@ public: - virtual bool CanRepairWithRawMaterial(short a_ItemType) override + virtual bool CanRepairWithRawMaterial(short a_ItemType) const override { switch (m_ItemType) { diff --git a/src/Items/ItemAxe.h b/src/Items/ItemAxe.h index cee41989d..3cd82fb73 100644 --- a/src/Items/ItemAxe.h +++ b/src/Items/ItemAxe.h @@ -8,21 +8,18 @@ -class cItemAxeHandler: +class cItemAxeHandler final : public cItemHandler { using Super = cItemHandler; public: - cItemAxeHandler(int a_ItemType): - Super(a_ItemType) - { - } + using Super::Super; - virtual short GetDurabilityLossByAction(eDurabilityLostAction a_Action) override + virtual short GetDurabilityLossByAction(eDurabilityLostAction a_Action) const override { switch (a_Action) { @@ -35,7 +32,7 @@ public: - virtual float GetBlockBreakingStrength(BLOCKTYPE a_Block) override + virtual float GetBlockBreakingStrength(BLOCKTYPE a_Block) const override { if (!IsBlockMaterialWood(a_Block) && !IsBlockMaterialPlants(a_Block) && !IsBlockMaterialVine(a_Block)) { diff --git a/src/Items/ItemBanner.h b/src/Items/ItemBanner.h index 2ebfca44a..a404af336 100644 --- a/src/Items/ItemBanner.h +++ b/src/Items/ItemBanner.h @@ -12,21 +12,18 @@ -class cItemBannerHandler: +class cItemBannerHandler final: public cItemHandler { using Super = cItemHandler; public: - cItemBannerHandler(int a_ItemType): - Super(a_ItemType) - { - } + using Super::Super; private: - virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) override + virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const override { // Cannot place a banner at "no face" and from the bottom: if ((a_ClickedBlockFace == BLOCK_FACE_NONE) || (a_ClickedBlockFace == BLOCK_FACE_BOTTOM)) @@ -54,7 +51,7 @@ private: - virtual bool IsPlaceable(void) override + virtual bool IsPlaceable(void) const override { return true; } diff --git a/src/Items/ItemBed.h b/src/Items/ItemBed.h index 7b8dde637..a2e254171 100644 --- a/src/Items/ItemBed.h +++ b/src/Items/ItemBed.h @@ -9,20 +9,17 @@ -class cItemBedHandler: +class cItemBedHandler final : public cItemHandler { using Super = cItemHandler; public: - cItemBedHandler(int a_ItemType): - Super(a_ItemType) - { - } + using Super::Super; - virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) override + virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const override { const auto BlockMeta = cBlockBedHandler::YawToMetaData(a_Player.GetYaw()); const auto HeadPosition = a_PlacePosition + cBlockBedHandler::MetaDataToDirection(BlockMeta); @@ -65,7 +62,7 @@ public: } - virtual bool IsPlaceable(void) override + virtual bool IsPlaceable(void) const override { return true; } diff --git a/src/Items/ItemBigFlower.h b/src/Items/ItemBigFlower.h index 12ebc2188..cbdecbed7 100644 --- a/src/Items/ItemBigFlower.h +++ b/src/Items/ItemBigFlower.h @@ -8,23 +8,16 @@ -class cItemBigFlowerHandler: +class cItemBigFlowerHandler final: public cItemHandler { using Super = cItemHandler; public: - cItemBigFlowerHandler(): - Super(E_BLOCK_BIG_FLOWER) - { - } - - - - + using Super::Super; - virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) override + virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const override { // Needs at least two free blocks to build in: if (a_PlacePosition.y >= (cChunkDef::Height - 1)) diff --git a/src/Items/ItemBoat.h b/src/Items/ItemBoat.h index d6e9ed7c3..51f2f8803 100644 --- a/src/Items/ItemBoat.h +++ b/src/Items/ItemBoat.h @@ -8,17 +8,14 @@ -class cItemBoatHandler: +class cItemBoatHandler final: public cItemHandler { using Super = cItemHandler; public: - cItemBoatHandler(int a_ItemType): - Super(a_ItemType) - { - } + using Super::Super; @@ -31,7 +28,7 @@ public: const cItem & a_HeldItem, const Vector3i a_ClickedBlockPos, eBlockFace a_ClickedBlockFace - ) override + ) const override { // Only allow placing blocks on top of blocks, or when not in range of dest block: if ((a_ClickedBlockFace != BLOCK_FACE_YM) && (a_ClickedBlockFace != BLOCK_FACE_NONE)) diff --git a/src/Items/ItemBottle.h b/src/Items/ItemBottle.h index 84950de29..a324eb101 100644 --- a/src/Items/ItemBottle.h +++ b/src/Items/ItemBottle.h @@ -9,17 +9,14 @@ -class cItemBottleHandler: +class cItemBottleHandler final: public cItemHandler { using Super = cItemHandler; public: - cItemBottleHandler(): - Super(E_ITEM_GLASS_BOTTLE) - { - } + using Super::Super; @@ -28,7 +25,7 @@ public: /** Searches for a water source block in the line of sight. Returns true and sets a_BlockPos if a water source block is found within line-of-sight. Returns false if not. */ - bool GetBlockFromTrace(cWorld * a_World, cPlayer * a_Player, Vector3i & a_BlockPos) + bool GetBlockFromTrace(cWorld * a_World, cPlayer * a_Player, Vector3i & a_BlockPos) const { class cCallbacks: public cBlockTracer::cCallbacks @@ -81,7 +78,7 @@ public: const cItem & a_HeldItem, const Vector3i a_ClickedBlockPos, eBlockFace a_ClickedBlockFace - ) override + ) const override { if (a_ClickedBlockFace != BLOCK_FACE_NONE) { diff --git a/src/Items/ItemBow.h b/src/Items/ItemBow.h index 636df5753..d1993c03c 100644 --- a/src/Items/ItemBow.h +++ b/src/Items/ItemBow.h @@ -8,17 +8,14 @@ -class cItemBowHandler: +class cItemBowHandler final: public cItemHandler { using Super = cItemHandler; public: - cItemBowHandler(void): - Super(E_ITEM_BOW) - { - } + using Super::Super; @@ -31,7 +28,7 @@ public: const cItem & a_HeldItem, const Vector3i a_ClickedBlockPos, eBlockFace a_ClickedBlockFace - ) override + ) const override { ASSERT(a_Player != nullptr); @@ -47,7 +44,7 @@ public: - virtual void OnItemShoot(cPlayer * a_Player, const Vector3i a_BlockPos, eBlockFace a_BlockFace) override + virtual void OnItemShoot(cPlayer * a_Player, const Vector3i a_BlockPos, eBlockFace a_BlockFace) const override { // Actual shot - produce the arrow with speed based on the number of ticks that the bow was charged UNUSED(a_BlockPos); diff --git a/src/Items/ItemBucket.h b/src/Items/ItemBucket.h index 6d7a33ccf..639661b24 100644 --- a/src/Items/ItemBucket.h +++ b/src/Items/ItemBucket.h @@ -13,14 +13,14 @@ -class cItemBucketHandler : +class cItemBucketHandler final : public cItemHandler { using Super = cItemHandler; public: - cItemBucketHandler(int a_ItemType): + constexpr cItemBucketHandler(int a_ItemType): Super(a_ItemType) { @@ -37,7 +37,7 @@ public: const cItem & a_HeldItem, const Vector3i a_ClickedBlockPos, eBlockFace a_ClickedBlockFace - ) override + ) const override { switch (m_ItemType) { @@ -56,7 +56,7 @@ public: - bool ScoopUpFluid(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, const Vector3i a_ClickedBlockPos, eBlockFace a_ClickedBlockFace) + bool ScoopUpFluid(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, const Vector3i a_ClickedBlockPos, eBlockFace a_ClickedBlockFace) const { // Players can't pick up fluid while in adventure mode. if (a_Player->IsGameModeAdventure()) @@ -127,7 +127,7 @@ public: bool PlaceFluid( cWorld * a_World, cPlayer * a_Player, cBlockPluginInterface & a_PluginInterface, const cItem & a_Item, const Vector3i a_BlockPos, eBlockFace a_BlockFace, BLOCKTYPE a_FluidBlock - ) + ) const { // Players can't place fluid while in adventure mode. if (a_Player->IsGameModeAdventure()) @@ -182,7 +182,7 @@ public: - bool GetBlockFromTrace(cWorld * a_World, cPlayer * a_Player, Vector3i & a_BlockPos) + bool GetBlockFromTrace(cWorld * a_World, cPlayer * a_Player, Vector3i & a_BlockPos) const { class cCallbacks : public cBlockTracer::cCallbacks @@ -233,7 +233,7 @@ public: - bool GetPlacementCoordsFromTrace(cWorld * a_World, cPlayer * a_Player, Vector3i & a_BlockPos, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta, eBlockFace & a_BlockFace) + bool GetPlacementCoordsFromTrace(cWorld * a_World, cPlayer * a_Player, Vector3i & a_BlockPos, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta, eBlockFace & a_BlockFace) const { class cCallbacks : public cBlockTracer::cCallbacks diff --git a/src/Items/ItemButton.h b/src/Items/ItemButton.h index 0f6e5c6f5..c106f393f 100644 --- a/src/Items/ItemButton.h +++ b/src/Items/ItemButton.h @@ -7,7 +7,7 @@ -class cItemButtonHandler : +class cItemButtonHandler final : public cItemHandler { using Super = cItemHandler; @@ -38,7 +38,7 @@ private: } - virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) override + virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const override { return a_Player.PlaceBlock(a_PlacePosition, static_cast(a_HeldItem.m_ItemType), BlockFaceToMetaData(a_ClickedBlockFace)); } diff --git a/src/Items/ItemChest.h b/src/Items/ItemChest.h index a714045ee..db5bd4493 100644 --- a/src/Items/ItemChest.h +++ b/src/Items/ItemChest.h @@ -8,23 +8,20 @@ -class cItemChestHandler: +class cItemChestHandler final : public cItemHandler { using Super = cItemHandler; public: - cItemChestHandler(int a_ItemType): - Super(a_ItemType) - { - } + using Super::Super; cItemChestHandler(const cItemChestHandler &) = delete; private: - virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) override + virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const override { // Check that there is at most one single neighbor of the same chest type: static const Vector3i CrossCoords[] = diff --git a/src/Items/ItemChorusFruit.h b/src/Items/ItemChorusFruit.h index 261088411..d60c2730f 100644 --- a/src/Items/ItemChorusFruit.h +++ b/src/Items/ItemChorusFruit.h @@ -8,19 +8,19 @@ -class cItemChorusFruitHandler: +class cItemChorusFruitHandler final: public cItemFoodHandler { using Super = cItemFoodHandler; public: - cItemChorusFruitHandler(): - Super(E_ITEM_CHORUS_FRUIT, FoodInfo(4, 2.4)) + constexpr cItemChorusFruitHandler(int a_ItemType) : + Super(a_ItemType, FoodInfo(4, 2.4)) { } - virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) override + virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) const override { cItemHandler::EatItem(a_Player, a_Item); diff --git a/src/Items/ItemCloth.h b/src/Items/ItemCloth.h index aca27a299..149bd642b 100644 --- a/src/Items/ItemCloth.h +++ b/src/Items/ItemCloth.h @@ -7,11 +7,11 @@ -class cItemClothHandler : +class cItemClothHandler final : public cItemHandler { public: - cItemClothHandler(int a_ItemType) + constexpr cItemClothHandler(int a_ItemType) : cItemHandler(a_ItemType) { diff --git a/src/Items/ItemComparator.h b/src/Items/ItemComparator.h index 681ce0b54..a8caa2431 100644 --- a/src/Items/ItemComparator.h +++ b/src/Items/ItemComparator.h @@ -8,7 +8,7 @@ -class cItemComparatorHandler: +class cItemComparatorHandler final: public cItemHandler { using Super = cItemHandler; @@ -24,7 +24,7 @@ public: - virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) override + virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const override { return a_Player.PlaceBlock(a_PlacePosition, E_BLOCK_INACTIVE_COMPARATOR, cBlockComparatorHandler::YawToMetaData(a_Player.GetYaw())); } @@ -33,7 +33,7 @@ public: - virtual bool IsPlaceable(void) override + virtual bool IsPlaceable(void) const override { return true; } diff --git a/src/Items/ItemCookedFish.h b/src/Items/ItemCookedFish.h index d0edc2d6a..32933e058 100644 --- a/src/Items/ItemCookedFish.h +++ b/src/Items/ItemCookedFish.h @@ -7,19 +7,19 @@ -class cItemCookedFishHandler: +class cItemCookedFishHandler final: public cItemFoodHandler { using Super = cItemFoodHandler; public: - cItemCookedFishHandler(): - Super(E_ITEM_COOKED_FISH, FoodInfo(0, 0)) + constexpr cItemCookedFishHandler(int a_ItemType): + Super(a_ItemType, FoodInfo(0, 0)) { } - virtual FoodInfo GetFoodInfo(const cItem * a_Item) override + virtual FoodInfo GetFoodInfo(const cItem * a_Item) const override { static const FoodInfo CookedFishInfos[] = { diff --git a/src/Items/ItemDefaultItem.h b/src/Items/ItemDefaultItem.h new file mode 100644 index 000000000..f455257aa --- /dev/null +++ b/src/Items/ItemDefaultItem.h @@ -0,0 +1,9 @@ + +#include "ItemHandler.h" + +class cDefaultItemHandler final : + public cItemHandler +{ +public: + using cItemHandler::cItemHandler; +}; diff --git a/src/Items/ItemDoor.h b/src/Items/ItemDoor.h index b85f018bc..6538a5bef 100644 --- a/src/Items/ItemDoor.h +++ b/src/Items/ItemDoor.h @@ -9,14 +9,14 @@ -class cItemDoorHandler: +class cItemDoorHandler final: public cItemHandler { using Super = cItemHandler; public: - cItemDoorHandler(int a_ItemType): + constexpr cItemDoorHandler(int a_ItemType): Super(a_ItemType) { @@ -25,7 +25,7 @@ public: - virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) override + virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const override { // Vanilla only allows door placement while clicking on the top face of the block below the door: if (a_ClickedBlockFace != BLOCK_FACE_TOP) @@ -109,7 +109,7 @@ public: - virtual bool IsPlaceable(void) override + virtual bool IsPlaceable(void) const override { return true; } diff --git a/src/Items/ItemDropSpenser.h b/src/Items/ItemDropSpenser.h index a06f67569..68f2cc137 100644 --- a/src/Items/ItemDropSpenser.h +++ b/src/Items/ItemDropSpenser.h @@ -8,7 +8,7 @@ -class cItemDropSpenserHandler : +class cItemDropSpenserHandler final : public cItemHandler { using Super = cItemHandler; @@ -19,7 +19,7 @@ public: private: - virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) override + virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const override { return a_Player.PlaceBlock(a_PlacePosition, static_cast(a_HeldItem.m_ItemType), cBlockDropSpenserHandler::DisplacementYawToMetaData(a_PlacePosition, a_Player.GetEyePosition(), a_Player.GetYaw())); } diff --git a/src/Items/ItemDye.h b/src/Items/ItemDye.h index 38cc2e4b2..5b0081b45 100644 --- a/src/Items/ItemDye.h +++ b/src/Items/ItemDye.h @@ -10,16 +10,13 @@ -class cItemDyeHandler : +class cItemDyeHandler final : public cItemHandler { using Super = cItemHandler; public: - cItemDyeHandler(int a_ItemType): - Super(a_ItemType) - { - } + using Super::Super; @@ -32,7 +29,7 @@ public: const cItem & a_HeldItem, const Vector3i a_ClickedBlockPos, eBlockFace a_ClickedBlockFace - ) override + ) const override { if ((a_HeldItem.m_ItemDamage == E_META_DYE_WHITE) && (a_ClickedBlockFace != BLOCK_FACE_NONE)) { diff --git a/src/Items/ItemEmptyMap.h b/src/Items/ItemEmptyMap.h index ac5053107..d06102fab 100644 --- a/src/Items/ItemEmptyMap.h +++ b/src/Items/ItemEmptyMap.h @@ -7,7 +7,7 @@ -class cItemEmptyMapHandler: +class cItemEmptyMapHandler final: public cItemHandler { using Super = cItemHandler; @@ -16,10 +16,7 @@ class cItemEmptyMapHandler: public: - cItemEmptyMapHandler(): - Super(E_ITEM_EMPTY_MAP) - { - } + using Super::Super; @@ -32,7 +29,7 @@ public: const cItem & a_HeldItem, const Vector3i a_ClickedBlockPos, eBlockFace a_ClickedBlockFace - ) override + ) const override { UNUSED(a_HeldItem); UNUSED(a_ClickedBlockFace); diff --git a/src/Items/ItemEnchantingTable.h b/src/Items/ItemEnchantingTable.h index 29a6eeef6..c89de2a34 100644 --- a/src/Items/ItemEnchantingTable.h +++ b/src/Items/ItemEnchantingTable.h @@ -9,7 +9,7 @@ -class cItemEnchantingTableHandler: +class cItemEnchantingTableHandler final: public cItemHandler { using Super = cItemHandler; @@ -20,7 +20,7 @@ public: private: - virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) override + virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const override { if (!Super::CommitPlacement(a_Player, a_HeldItem, a_PlacePosition, a_ClickedBlockFace, a_CursorPosition)) { @@ -44,7 +44,7 @@ private: } - virtual bool IsPlaceable(void) override + virtual bool IsPlaceable(void) const override { return true; } diff --git a/src/Items/ItemEndCrystal.h b/src/Items/ItemEndCrystal.h index b9b265b60..976bc83ec 100644 --- a/src/Items/ItemEndCrystal.h +++ b/src/Items/ItemEndCrystal.h @@ -9,14 +9,14 @@ -class cItemEndCrystalHandler : +class cItemEndCrystalHandler final : public cItemHandler { using Super = cItemHandler; public: - cItemEndCrystalHandler(int a_ItemType) : + constexpr cItemEndCrystalHandler(int a_ItemType) : Super(a_ItemType) { } @@ -26,7 +26,7 @@ public: cWorld * a_World, cPlayer * a_Player, cBlockPluginInterface & a_PluginInterface, const cItem & a_HeldItem, const Vector3i a_BlockPos, - eBlockFace a_ClickedBlockFace) override + eBlockFace a_ClickedBlockFace) const override { // Must click a valid block: if (a_ClickedBlockFace < 0) diff --git a/src/Items/ItemEndPortalFrame.h b/src/Items/ItemEndPortalFrame.h index 08bcdf9fa..4f4d8a81f 100644 --- a/src/Items/ItemEndPortalFrame.h +++ b/src/Items/ItemEndPortalFrame.h @@ -8,7 +8,7 @@ -class cItemEndPortalFrameHandler : +class cItemEndPortalFrameHandler final : public cItemHandler { using Super = cItemHandler; @@ -19,7 +19,7 @@ public: private: - virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) override + virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const override { return a_Player.PlaceBlock(a_PlacePosition, E_BLOCK_END_PORTAL_FRAME, cBlockEndPortalFrameHandler::YawToMetaData(a_Player.GetYaw())); } diff --git a/src/Items/ItemEnderchest.h b/src/Items/ItemEnderchest.h index 4feba1f13..bd8487b11 100644 --- a/src/Items/ItemEnderchest.h +++ b/src/Items/ItemEnderchest.h @@ -8,7 +8,7 @@ -class cItemEnderchestHandler : +class cItemEnderchestHandler final : public cItemHandler { using Super = cItemHandler; @@ -19,7 +19,7 @@ public: private: - virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) override + virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const override { return a_Player.PlaceBlock(a_PlacePosition, E_BLOCK_ENDER_CHEST, cBlockEnderchestHandler::YawToMetaData(a_Player.GetYaw())); } diff --git a/src/Items/ItemEyeOfEnder.h b/src/Items/ItemEyeOfEnder.h index 6a636cb12..fc6fac336 100644 --- a/src/Items/ItemEyeOfEnder.h +++ b/src/Items/ItemEyeOfEnder.h @@ -8,15 +8,15 @@ -class cItemEyeOfEnderHandler: +class cItemEyeOfEnderHandler final: public cItemThrowableHandler { using Super = cItemThrowableHandler; public: - cItemEyeOfEnderHandler(): - Super(E_ITEM_EYE_OF_ENDER, cProjectileEntity::pkSnowball, 30) + constexpr cItemEyeOfEnderHandler(int a_ItemType): + Super(a_ItemType, cProjectileEntity::pkSnowball, 30) { } @@ -28,7 +28,7 @@ public: cWorld * a_World, cPlayer * a_Player, cBlockPluginInterface & a_PluginInterface, const cItem & a_Item, const Vector3i a_ClickedBlockPos, eBlockFace a_ClickedBlockFace - ) override + ) const override { // Try to fill an End Portal Frame block: if (a_ClickedBlockFace != BLOCK_FACE_NONE) diff --git a/src/Items/ItemFenceGate.h b/src/Items/ItemFenceGate.h index cd06340b0..a3e02f5b1 100644 --- a/src/Items/ItemFenceGate.h +++ b/src/Items/ItemFenceGate.h @@ -8,7 +8,7 @@ -class cItemFenceGateHandler : +class cItemFenceGateHandler final : public cItemHandler { using Super = cItemHandler; @@ -19,7 +19,7 @@ public: private: - virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) override + virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const override { return a_Player.PlaceBlock(a_PlacePosition, static_cast(a_HeldItem.m_ItemType), cBlockFenceGateHandler::YawToMetaData(a_Player.GetYaw())); } diff --git a/src/Items/ItemFishingRod.h b/src/Items/ItemFishingRod.h index 909f892c3..840ff7d5c 100644 --- a/src/Items/ItemFishingRod.h +++ b/src/Items/ItemFishingRod.h @@ -49,17 +49,14 @@ protected: -class cItemFishingRodHandler: +class cItemFishingRodHandler final: public cItemHandler { using Super = cItemHandler; public: - cItemFishingRodHandler(int a_ItemType): - Super(a_ItemType) - { - } + using Super::Super; @@ -72,7 +69,7 @@ public: const cItem & a_HeldItem, const Vector3i a_ClickedBlockPos, eBlockFace a_ClickedBlockFace - ) override + ) const override { if (a_ClickedBlockFace != BLOCK_FACE_NONE) { @@ -108,7 +105,7 @@ public: /** Reels back the fishing line, reeling any attached mob, or creating fished loot, or just breaking the fishing rod. */ - void ReelIn(cWorld & a_World, cPlayer & a_Player) + void ReelIn(cWorld & a_World, cPlayer & a_Player) const { cFloaterCallback FloaterInfo; a_World.DoWithEntityByID(a_Player.GetFloaterID(), FloaterInfo); @@ -140,7 +137,7 @@ public: /** Reels back the entity, specified by the ID, and damages the fishing rod accordingly. */ - void ReelInEntity(cWorld & a_World, cPlayer & a_Player, UInt32 a_EntityID) + void ReelInEntity(cWorld & a_World, cPlayer & a_Player, UInt32 a_EntityID) const { auto PlayerPos = a_Player.GetPosition(); a_World.DoWithEntityByID(a_EntityID, [=](cEntity & a_Entity) @@ -157,7 +154,7 @@ public: - void ReelInLoot(cWorld & a_World, cPlayer & a_Player, const Vector3d a_FloaterBitePos) + void ReelInLoot(cWorld & a_World, cPlayer & a_Player, const Vector3d a_FloaterBitePos) const { auto LotSLevel = std::min(a_Player.GetEquippedItem().m_Enchantments.GetLevel(cEnchantments::enchLuckOfTheSea), 3u); diff --git a/src/Items/ItemFood.h b/src/Items/ItemFood.h index 29d733cab..7ec879b5d 100644 --- a/src/Items/ItemFood.h +++ b/src/Items/ItemFood.h @@ -14,25 +14,25 @@ class cItemFoodHandler: public: - cItemFoodHandler(int a_ItemType, FoodInfo a_FoodInfo): + constexpr cItemFoodHandler(int a_ItemType, FoodInfo a_FoodInfo): Super(a_ItemType), m_FoodInfo(a_FoodInfo) { } - virtual bool IsFood(void) override + virtual bool IsFood(void) const override { return true; } - virtual FoodInfo GetFoodInfo(const cItem * a_Item) override + virtual FoodInfo GetFoodInfo(const cItem * a_Item) const override { UNUSED(a_Item); return m_FoodInfo; } - virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) override + virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) const override { if (!Super::EatItem(a_Player, a_Item)) { @@ -50,8 +50,11 @@ public: protected: FoodInfo m_FoodInfo; + ~cItemFoodHandler() = default; }; - - - +class cItemSimpleFoodHandler final: + public cItemFoodHandler +{ + using cItemFoodHandler::cItemFoodHandler; +}; diff --git a/src/Items/ItemFoodSeeds.h b/src/Items/ItemFoodSeeds.h index 89d05287d..381bcc4eb 100644 --- a/src/Items/ItemFoodSeeds.h +++ b/src/Items/ItemFoodSeeds.h @@ -8,14 +8,14 @@ -class cItemFoodSeedsHandler: +class cItemFoodSeedsHandler final: public cItemSeedsHandler { using Super = cItemSeedsHandler; public: - cItemFoodSeedsHandler(int a_ItemType, FoodInfo a_FoodInfo): + constexpr cItemFoodSeedsHandler(int a_ItemType, FoodInfo a_FoodInfo): Super(a_ItemType), m_FoodInfo(a_FoodInfo) { @@ -23,18 +23,18 @@ public: } - virtual bool IsFood(void) override + virtual bool IsFood(void) const override { return true; } - virtual FoodInfo GetFoodInfo(const cItem * a_Item) override + virtual FoodInfo GetFoodInfo(const cItem * a_Item) const override { UNUSED(a_Item); return m_FoodInfo; } - virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) override + virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) const override { if (!Super::EatItem(a_Player, a_Item)) { diff --git a/src/Items/ItemFurnace.h b/src/Items/ItemFurnace.h index 24bcd5e06..48f725f4f 100644 --- a/src/Items/ItemFurnace.h +++ b/src/Items/ItemFurnace.h @@ -8,7 +8,7 @@ -class cItemFurnaceHandler : +class cItemFurnaceHandler final : public cItemHandler { using Super = cItemHandler; @@ -19,7 +19,7 @@ public: private: - virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) override + virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const override { return a_Player.PlaceBlock(a_PlacePosition, E_BLOCK_FURNACE, cBlockFurnaceHandler::YawToMetaData(a_Player.GetYaw())); } diff --git a/src/Items/ItemGlazedTerracotta.h b/src/Items/ItemGlazedTerracotta.h index d08d6308e..0ce74d5aa 100644 --- a/src/Items/ItemGlazedTerracotta.h +++ b/src/Items/ItemGlazedTerracotta.h @@ -8,7 +8,7 @@ -class cItemGlazedTerracottaHandler : +class cItemGlazedTerracottaHandler final : public cItemHandler { using Super = cItemHandler; @@ -19,7 +19,7 @@ public: private: - virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) override + virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const override { return a_Player.PlaceBlock(a_PlacePosition, static_cast(a_HeldItem.m_ItemType), cBlockGlazedTerracottaHandler::YawToMetaData(a_Player.GetYaw())); } diff --git a/src/Items/ItemGoldenApple.h b/src/Items/ItemGoldenApple.h index e01335dd4..25ed284e6 100644 --- a/src/Items/ItemGoldenApple.h +++ b/src/Items/ItemGoldenApple.h @@ -7,19 +7,19 @@ -class cItemGoldenAppleHandler: +class cItemGoldenAppleHandler final: public cItemFoodHandler { using Super = cItemFoodHandler; public: - cItemGoldenAppleHandler(): - Super(E_ITEM_GOLDEN_APPLE, FoodInfo(4, 9.6)) + constexpr cItemGoldenAppleHandler(int a_ItemType): + Super(a_ItemType, FoodInfo(4, 9.6)) { } - virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) override + virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) const override { cItemHandler::EatItem(a_Player, a_Item); diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index 63f950e26..c8994fada 100644 --- a/src/Items/ItemHandler.cpp +++ b/src/Items/ItemHandler.cpp @@ -24,6 +24,7 @@ #include "ItemCloth.h" #include "ItemComparator.h" #include "ItemCookedFish.h" +#include "ItemDefaultItem.h" #include "ItemDoor.h" #include "ItemDropSpenser.h" #include "ItemDye.h" @@ -95,363 +96,953 @@ -bool cItemHandler::m_HandlerInitialized = false; -cItemHandler * cItemHandler::m_ItemHandler[2268]; - - - - - -cItemHandler * cItemHandler::GetItemHandler(int a_ItemType) +namespace { - if ((a_ItemType < 0) || (static_cast(a_ItemType) >= ARRAYCOUNT(m_ItemHandler))) - { - // Either nothing (-1), or bad value, both cases should return the air handler - if (a_ItemType < -1) - { - ASSERT(!"Bad item type"); - } - a_ItemType = 0; - } - - if (!m_HandlerInitialized) - { - // We need to initialize - memset(m_ItemHandler, 0, sizeof(m_ItemHandler)); - m_HandlerInitialized = true; - } - if (m_ItemHandler[a_ItemType] == nullptr) - { - m_ItemHandler[a_ItemType] = CreateItemHandler(a_ItemType); - } - return m_ItemHandler[a_ItemType]; + constexpr cDefaultItemHandler Item11DiscHandler (E_ITEM_11_DISC); + constexpr cDefaultItemHandler Item13DiscHandler (E_ITEM_13_DISC); + constexpr cItemBoatHandler ItemAcaciaBoatHandler (E_ITEM_ACACIA_BOAT); + constexpr cDefaultItemHandler ItemAcaciaDoorBlockHandler (E_BLOCK_ACACIA_DOOR); + constexpr cItemDoorHandler ItemAcaciaDoorHandler (E_ITEM_ACACIA_DOOR); + constexpr cItemFenceGateHandler ItemAcaciaFenceGateHandler (E_BLOCK_ACACIA_FENCE_GATE); + constexpr cDefaultItemHandler ItemAcaciaFenceHandler (E_BLOCK_ACACIA_FENCE); + constexpr cItemStairsHandler ItemAcaciaStairsHandler (E_BLOCK_ACACIA_WOOD_STAIRS); + constexpr cItemRailHandler ItemActivatorRailHandler (E_BLOCK_ACTIVATOR_RAIL); + constexpr cDefaultItemHandler ItemActiveComparatorHandler (E_BLOCK_ACTIVE_COMPARATOR); + constexpr cDefaultItemHandler ItemAirHandler (E_BLOCK_AIR); + constexpr cItemAnvilHandler ItemAnvilHandler (E_BLOCK_ANVIL); + constexpr cItemSimpleFoodHandler ItemAppleHandler (E_ITEM_RED_APPLE, cItemHandler::FoodInfo(4, 2.4)); + constexpr cDefaultItemHandler ItemArmorStandHandler (E_ITEM_ARMOR_STAND); + constexpr cDefaultItemHandler ItemArrowHandler (E_ITEM_ARROW); + constexpr cItemSimpleFoodHandler ItemBakedPotatoHandler (E_ITEM_BAKED_POTATO, cItemHandler::FoodInfo(5, 6)); + constexpr cItemBannerHandler ItemBannerHandler (E_ITEM_BANNER); + constexpr cDefaultItemHandler ItemBarrierHandler (E_BLOCK_BARRIER); + constexpr cDefaultItemHandler ItemBeaconHandler (E_BLOCK_BEACON); + constexpr cItemBedHandler ItemBedBlockHandler (E_BLOCK_BED); + constexpr cItemBedHandler ItemBedHandler (E_ITEM_BED); + constexpr cDefaultItemHandler ItemBedrockHandler (E_BLOCK_BEDROCK); + constexpr cItemSimpleFoodHandler ItemBeetrootHandler (E_ITEM_BEETROOT, cItemHandler::FoodInfo(1, 1.2)); + constexpr cItemSimpleSeedsHandler ItemBeetrootSeedsHandler (E_ITEM_BEETROOT_SEEDS); + constexpr cItemSoupHandler ItemBeetrootSoupHandler (E_ITEM_BEETROOT_SOUP, cItemHandler::FoodInfo(6, 7.2)); + constexpr cDefaultItemHandler ItemBeetrootsBlockHandler (E_BLOCK_BEETROOTS); + constexpr cItemBigFlowerHandler ItemBigFlowerHandler (E_BLOCK_BIG_FLOWER); + constexpr cItemBoatHandler ItemBirchBoatHandler (E_ITEM_BIRCH_BOAT); + constexpr cItemDoorHandler ItemBirchDoorHandler (E_ITEM_BIRCH_DOOR); + constexpr cItemFenceGateHandler ItemBirchFenceGateHandler (E_BLOCK_BIRCH_FENCE_GATE); + constexpr cDefaultItemHandler ItemBirchFenceHandler (E_BLOCK_BIRCH_FENCE); + constexpr cItemStairsHandler ItemBirchStairsHandler (E_BLOCK_BIRCH_WOOD_STAIRS); + constexpr cItemGlazedTerracottaHandler ItemBlackGlazedTerracottaHandler (E_BLOCK_BLACK_GLAZED_TERRACOTTA); + constexpr cDefaultItemHandler ItemBlackShulkerBoxHandler (E_BLOCK_BLACK_SHULKER_BOX); + constexpr cDefaultItemHandler ItemBlazePowderHandler (E_ITEM_BLAZE_POWDER); + constexpr cDefaultItemHandler ItemBlazeRodHandler (E_ITEM_BLAZE_ROD); + constexpr cDefaultItemHandler ItemBlocksDiscHandler (E_ITEM_BLOCKS_DISC); + constexpr cItemGlazedTerracottaHandler ItemBlueGlazedTerracottaHandler (E_BLOCK_BLUE_GLAZED_TERRACOTTA); + constexpr cDefaultItemHandler ItemBlueShulkerBoxHandler (E_BLOCK_BLUE_SHULKER_BOX); + constexpr cDefaultItemHandler ItemBoneBlockHandler (E_BLOCK_BONE_BLOCK); + constexpr cDefaultItemHandler ItemBoneHandler (E_ITEM_BONE); + constexpr cDefaultItemHandler ItemBookAndQuillHandler (E_ITEM_BOOK_AND_QUILL); + constexpr cDefaultItemHandler ItemBookHandler (E_ITEM_BOOK); + constexpr cDefaultItemHandler ItemBookshelfHandler (E_BLOCK_BOOKCASE); + constexpr cItemBottleOEnchantingHandler ItemBottleOEnchantingHandler (E_ITEM_BOTTLE_O_ENCHANTING); + constexpr cItemBowHandler ItemBowHandler (E_ITEM_BOW); + constexpr cDefaultItemHandler ItemBowlHandler (E_ITEM_BOWL); + constexpr cItemSimpleFoodHandler ItemBreadHandler (E_ITEM_BREAD, cItemHandler::FoodInfo(5, 6)); + constexpr cDefaultItemHandler ItemBrewingStandBlockHandler (E_BLOCK_BREWING_STAND); + constexpr cSimplePlaceableItemHandler ItemBrewingStandHandler (E_ITEM_BREWING_STAND, E_BLOCK_BREWING_STAND); + constexpr cDefaultItemHandler ItemBrickHandler (E_ITEM_CLAY_BRICK); + constexpr cDefaultItemHandler ItemBricksHandler (E_BLOCK_BRICK); + constexpr cItemStairsHandler ItemBricksStairsHandler (E_BLOCK_BRICK_STAIRS); + constexpr cItemGlazedTerracottaHandler ItemBrownGlazedTerracottaHandler (E_BLOCK_BROWN_GLAZED_TERRACOTTA); + constexpr cDefaultItemHandler ItemBrownMushroomBlockHandler (E_BLOCK_BROWN_MUSHROOM); + constexpr cDefaultItemHandler ItemBrownShulkerBoxHandler (E_BLOCK_BROWN_SHULKER_BOX); + constexpr cItemBucketHandler ItemBucketHandler (E_ITEM_BUCKET); + constexpr cDefaultItemHandler ItemCactusHandler (E_BLOCK_CACTUS); + constexpr cDefaultItemHandler ItemCakeBlockHandler (E_BLOCK_CAKE); + constexpr cSimplePlaceableItemHandler ItemCakeHandler (E_ITEM_CAKE, E_BLOCK_CAKE); + constexpr cDefaultItemHandler ItemCarpetHandler (E_BLOCK_CARPET); + constexpr cItemFoodSeedsHandler ItemCarrotHandler (E_ITEM_CARROT, cItemHandler::FoodInfo(3, 6.6)); + constexpr cDefaultItemHandler ItemCarrotOnStickHandler (E_ITEM_CARROT_ON_STICK); + constexpr cDefaultItemHandler ItemCarrotsBlockHandler (E_BLOCK_CARROTS); + constexpr cDefaultItemHandler ItemCatDiscHandler (E_ITEM_CAT_DISC); + constexpr cDefaultItemHandler ItemCauldronBlockHandler (E_BLOCK_CAULDRON); + constexpr cSimplePlaceableItemHandler ItemCauldronHandler (E_ITEM_CAULDRON, E_BLOCK_CAULDRON);; + constexpr cItemArmorHandler ItemChainBootsHandler (E_ITEM_CHAIN_BOOTS); + constexpr cItemArmorHandler ItemChainChestplateHandler (E_ITEM_CHAIN_CHESTPLATE); + constexpr cDefaultItemHandler ItemChainCommandBlockHandler (E_BLOCK_CHAIN_COMMAND_BLOCK); + constexpr cItemArmorHandler ItemChainHelmetHandler (E_ITEM_CHAIN_HELMET); + constexpr cItemArmorHandler ItemChainLeggingsHandler (E_ITEM_CHAIN_LEGGINGS); + constexpr cDefaultItemHandler ItemChestBlockHandler (E_BLOCK_CHEST); + constexpr cItemMinecartHandler ItemChestMinecartHandler (E_ITEM_CHEST_MINECART); + constexpr cDefaultItemHandler ItemChirpDiscHandler (E_ITEM_CHIRP_DISC); + constexpr cDefaultItemHandler ItemChorusFlowerHandler (E_BLOCK_CHORUS_FLOWER); + constexpr cItemChorusFruitHandler ItemChorusFruitHandler (E_ITEM_CHORUS_FRUIT); + constexpr cDefaultItemHandler ItemChorusPlantHandler (E_BLOCK_CHORUS_PLANT); + constexpr cDefaultItemHandler ItemClayBlockHandler (E_BLOCK_CLAY); + constexpr cDefaultItemHandler ItemClayHandler (E_ITEM_CLAY); + constexpr cDefaultItemHandler ItemClockHandler (E_ITEM_CLOCK); + constexpr cDefaultItemHandler ItemCoalBlockHandler (E_BLOCK_BLOCK_OF_COAL); + constexpr cDefaultItemHandler ItemCoalHandler (E_ITEM_COAL); + constexpr cDefaultItemHandler ItemCoalOreHandler (E_BLOCK_COAL_ORE); + constexpr cDefaultItemHandler ItemCobblestoneHandler (E_BLOCK_COBBLESTONE); + constexpr cItemStairsHandler ItemCobblestoneStairsHandler (E_BLOCK_COBBLESTONE_STAIRS); + constexpr cDefaultItemHandler ItemCobblestoneWallHandler (E_BLOCK_COBBLESTONE_WALL); + constexpr cDefaultItemHandler ItemCobwebHandler (E_BLOCK_COBWEB); + constexpr cDefaultItemHandler ItemCocoaPodHandler (E_BLOCK_COCOA_POD); + constexpr cDefaultItemHandler ItemCommandBlockHandler (E_BLOCK_COMMAND_BLOCK); + constexpr cDefaultItemHandler ItemComparatorHandler (E_ITEM_COMPARATOR); + constexpr cDefaultItemHandler ItemCompassHandler (E_ITEM_COMPASS); + constexpr cDefaultItemHandler ItemConcreteBlockHandler (E_BLOCK_CONCRETE); + constexpr cDefaultItemHandler ItemConcretePowderHandler (E_BLOCK_CONCRETE_POWDER); + constexpr cItemSimpleFoodHandler ItemCookedBeefHandler (E_ITEM_STEAK, cItemHandler::FoodInfo(8, 12.8)); + constexpr cItemSimpleFoodHandler ItemCookedChickenHandler (E_ITEM_COOKED_CHICKEN, cItemHandler::FoodInfo(6, 7.2)); + constexpr cItemCookedFishHandler ItemCookedFishHandler (E_ITEM_COOKED_FISH); + constexpr cItemSimpleFoodHandler ItemCookedMuttonHandler (E_ITEM_COOKED_MUTTON, cItemHandler::FoodInfo(6, 9.6)); + constexpr cItemSimpleFoodHandler ItemCookedPorkchopHandler (E_ITEM_COOKED_PORKCHOP, cItemHandler::FoodInfo(8, 12.8)); + constexpr cItemSimpleFoodHandler ItemCookedRabbitHandler (E_ITEM_COOKED_RABBIT, cItemHandler::FoodInfo(5, 6)); + constexpr cItemSimpleFoodHandler ItemCookieHandler (E_ITEM_COOKIE, cItemHandler::FoodInfo(2, 0.5)); + constexpr cItemGlazedTerracottaHandler ItemCyanGlazedTerracottaHandler (E_BLOCK_CYAN_GLAZED_TERRACOTTA); + constexpr cDefaultItemHandler ItemCyanShulkerBoxHandler (E_BLOCK_CYAN_SHULKER_BOX); + constexpr cDefaultItemHandler ItemDandelionHandler (E_BLOCK_DANDELION); + constexpr cItemBoatHandler ItemDarkOakBoatHandler (E_ITEM_DARK_OAK_BOAT); + constexpr cDefaultItemHandler ItemDarkOakDoorBlockHandler (E_BLOCK_DARK_OAK_DOOR); + constexpr cItemDoorHandler ItemDarkOakDoorHandler (E_ITEM_DARK_OAK_DOOR); + constexpr cItemFenceGateHandler ItemDarkOakFenceGateHandler (E_BLOCK_DARK_OAK_FENCE_GATE); + constexpr cDefaultItemHandler ItemDarkOakFenceHandler (E_BLOCK_DARK_OAK_FENCE); + constexpr cItemStairsHandler ItemDarkOakStairsHandler (E_BLOCK_DARK_OAK_WOOD_STAIRS); + constexpr cDefaultItemHandler ItemDaylightSensorBlockHandler (E_BLOCK_DAYLIGHT_SENSOR); + constexpr cDefaultItemHandler ItemDeadBushHandler (E_BLOCK_DEAD_BUSH); + constexpr cItemRailHandler ItemDetectorRailHandler (E_BLOCK_DETECTOR_RAIL); + constexpr cItemAxeHandler ItemDiamondAxeHandler (E_ITEM_DIAMOND_AXE); + constexpr cDefaultItemHandler ItemDiamondBlockHandler (E_BLOCK_DIAMOND_BLOCK); + constexpr cItemArmorHandler ItemDiamondBootsHandler (E_ITEM_DIAMOND_BOOTS); + constexpr cItemArmorHandler ItemDiamondChestplateHandler (E_ITEM_DIAMOND_CHESTPLATE); + constexpr cDefaultItemHandler ItemDiamondHandler (E_ITEM_DIAMOND); + constexpr cItemArmorHandler ItemDiamondHelmetHandler (E_ITEM_DIAMOND_HELMET); + constexpr cItemHoeHandler ItemDiamondHoeHandler (E_ITEM_DIAMOND_HOE); + constexpr cDefaultItemHandler ItemDiamondHorseArmorHandler (E_ITEM_DIAMOND_HORSE_ARMOR); + constexpr cItemArmorHandler ItemDiamondLeggingsHandler (E_ITEM_DIAMOND_LEGGINGS); + constexpr cDefaultItemHandler ItemDiamondOreHandler (E_BLOCK_DIAMOND_ORE); + constexpr cItemPickaxeHandler ItemDiamondPickaxeHandler (E_ITEM_DIAMOND_PICKAXE); + constexpr cItemShovelHandler ItemDiamondShovelHandler (E_ITEM_DIAMOND_SHOVEL); + constexpr cItemSwordHandler ItemDiamondSwordHandler (E_ITEM_DIAMOND_SWORD); + constexpr cDefaultItemHandler ItemDirtHandler (E_BLOCK_DIRT); + constexpr cItemDropSpenserHandler ItemDispenserHandler (E_BLOCK_DISPENSER); + constexpr cDefaultItemHandler ItemBirchDoorBlockHandler (E_BLOCK_BIRCH_DOOR); + constexpr cDefaultItemHandler ItemDoubleOakSlabHandler (E_BLOCK_DOUBLE_WOODEN_SLAB); + constexpr cDefaultItemHandler ItemDoubleRedSandstoneSlabHandler (E_BLOCK_DOUBLE_RED_SANDSTONE_SLAB); + constexpr cDefaultItemHandler ItemDoubleStoneSlabHandler (E_BLOCK_DOUBLE_STONE_SLAB); + constexpr cDefaultItemHandler ItemDragonBreathHandler (E_ITEM_DRAGON_BREATH); + constexpr cDefaultItemHandler ItemDragonEggBlockHandler (E_BLOCK_DRAGON_EGG); + constexpr cItemDropSpenserHandler ItemDropperHandler (E_BLOCK_DROPPER); + constexpr cItemDyeHandler ItemDyeHandler (E_ITEM_DYE); + constexpr cItemEggHandler ItemEggHandler (E_ITEM_EGG); + constexpr cItemArmorHandler ItemElytraHandler (E_ITEM_ELYTRA); + constexpr cDefaultItemHandler ItemEmeraldBlockHandler (E_BLOCK_EMERALD_BLOCK); + constexpr cDefaultItemHandler ItemEmeraldHandler (E_ITEM_EMERALD); + constexpr cDefaultItemHandler ItemEmeraldOreHandler (E_BLOCK_EMERALD_ORE); + constexpr cItemEmptyMapHandler ItemEmptyMapHandler (E_ITEM_EMPTY_MAP); + constexpr cDefaultItemHandler ItemEnchantedBookHandler (E_ITEM_ENCHANTED_BOOK); + constexpr cItemEnchantingTableHandler ItemEnchantingTableHandler (E_BLOCK_ENCHANTMENT_TABLE); + constexpr cDefaultItemHandler ItemEndBricksHandler (E_BLOCK_END_BRICKS); + constexpr cItemEndCrystalHandler ItemEndCrystalHandler (E_ITEM_END_CRYSTAL); + constexpr cDefaultItemHandler ItemEndGatewayHandler (E_BLOCK_END_GATEWAY); + constexpr cDefaultItemHandler ItemEndPortalBlockHandler (E_BLOCK_END_PORTAL); + constexpr cItemEndPortalFrameHandler ItemEndPortalFrameHandler (E_BLOCK_END_PORTAL_FRAME); + constexpr cDefaultItemHandler ItemEndRodHandler (E_BLOCK_END_ROD); + constexpr cDefaultItemHandler ItemEndStoneBlockHandler (E_BLOCK_END_STONE); + constexpr cItemEnderPearlHandler ItemEnderPearlHandler (E_ITEM_ENDER_PEARL); + constexpr cItemEnderchestHandler ItemEnderchestHandler (E_BLOCK_ENDER_CHEST); + constexpr cItemEyeOfEnderHandler ItemEyeOfEnderHandler (E_ITEM_EYE_OF_ENDER); + constexpr cDefaultItemHandler ItemFarDiscHandler (E_ITEM_FAR_DISC); + constexpr cDefaultItemHandler ItemFarmlandHandler (E_BLOCK_FARMLAND); + constexpr cDefaultItemHandler ItemFeatherHandler (E_ITEM_FEATHER); + constexpr cDefaultItemHandler ItemOakFenceHandler (E_BLOCK_FENCE); + constexpr cDefaultItemHandler ItemFermentedSpiderEyeHandler (E_ITEM_FERMENTED_SPIDER_EYE); + constexpr cDefaultItemHandler ItemFireBlockHandler (E_BLOCK_FIRE); + constexpr cItemLighterHandler ItemFireChargeHandler (E_ITEM_FIRE_CHARGE); + constexpr cItemFireworkHandler ItemFireworkRocketHandler (E_ITEM_FIREWORK_ROCKET); + constexpr cDefaultItemHandler ItemFireworkStarHandler (E_ITEM_FIREWORK_STAR); + constexpr cItemFishingRodHandler ItemFishingRodHandler (E_ITEM_FISHING_ROD); + constexpr cItemLighterHandler ItemFlintAndSteelHandler (E_ITEM_FLINT_AND_STEEL); + constexpr cDefaultItemHandler ItemFlintHandler (E_ITEM_FLINT); + constexpr cDefaultItemHandler ItemFlowerPotBlockHandler (E_BLOCK_FLOWER_POT); + constexpr cSimplePlaceableItemHandler ItemFlowerPotHandler (E_ITEM_FLOWER_POT, E_BLOCK_FLOWER_POT); + constexpr cDefaultItemHandler ItemFrostedIceHandler (E_BLOCK_FROSTED_ICE); + constexpr cItemFurnaceHandler ItemFurnaceHandler (E_BLOCK_FURNACE); + constexpr cItemMinecartHandler ItemFurnaceMinecartHandler (E_ITEM_FURNACE_MINECART); + constexpr cDefaultItemHandler ItemGhastTearHandler (E_ITEM_GHAST_TEAR); + constexpr cItemBottleHandler ItemGlassBottleHandler (E_ITEM_GLASS_BOTTLE); + constexpr cDefaultItemHandler ItemGlassHandler (E_BLOCK_GLASS); + constexpr cDefaultItemHandler ItemGlassPaneBlockHandler (E_BLOCK_GLASS_PANE); + constexpr cDefaultItemHandler ItemGlisteringMelonHandler (E_ITEM_GLISTERING_MELON); + constexpr cDefaultItemHandler ItemGlowstoneBlockHandler (E_BLOCK_GLOWSTONE); + constexpr cDefaultItemHandler ItemGlowstoneDustHandler (E_ITEM_GLOWSTONE_DUST); + constexpr cDefaultItemHandler ItemGoldBlockHandler (E_BLOCK_GOLD_BLOCK); + constexpr cDefaultItemHandler ItemGoldHandler (E_ITEM_GOLD); + constexpr cDefaultItemHandler ItemGoldNuggetHandler (E_ITEM_GOLD_NUGGET); + constexpr cDefaultItemHandler ItemGoldOreHandler (E_BLOCK_GOLD_ORE); + constexpr cItemGoldenAppleHandler ItemGoldenAppleHandler (E_ITEM_GOLDEN_APPLE); + constexpr cItemAxeHandler ItemGoldenAxeHandler (E_ITEM_GOLD_AXE); + constexpr cItemArmorHandler ItemGoldenBootsHandler (E_ITEM_GOLD_BOOTS); + constexpr cItemSimpleFoodHandler ItemGoldenCarrotHandler (E_ITEM_GOLDEN_CARROT, cItemHandler::FoodInfo(6, 14.4)); + constexpr cItemArmorHandler ItemGoldenChestplateHandler (E_ITEM_GOLD_CHESTPLATE); + constexpr cItemArmorHandler ItemGoldenHelmetHandler (E_ITEM_GOLD_HELMET); + constexpr cItemHoeHandler ItemGoldenHoeHandler (E_ITEM_GOLD_HOE); + constexpr cDefaultItemHandler ItemGoldenHorseArmorHandler (E_ITEM_GOLD_HORSE_ARMOR); + constexpr cItemArmorHandler ItemGoldenLeggingsHandler (E_ITEM_GOLD_LEGGINGS); + constexpr cItemPickaxeHandler ItemGoldenPickaxeHandler (E_ITEM_GOLD_PICKAXE); + constexpr cItemShovelHandler ItemGoldenShovelHandler (E_ITEM_GOLD_SHOVEL); + constexpr cItemSwordHandler ItemGoldenSwordHandler (E_ITEM_GOLD_SWORD); + constexpr cDefaultItemHandler ItemGrassBlockHandler (E_BLOCK_GRASS); + constexpr cDefaultItemHandler ItemGrassPathHandler (E_BLOCK_GRASS_PATH); + constexpr cDefaultItemHandler ItemGravelHandler (E_BLOCK_GRAVEL); + constexpr cItemGlazedTerracottaHandler ItemGrayGlazedTerracottaHandler (E_BLOCK_GRAY_GLAZED_TERRACOTTA); + constexpr cDefaultItemHandler ItemGrayShulkerBoxHandler (E_BLOCK_GRAY_SHULKER_BOX); + constexpr cItemGlazedTerracottaHandler ItemGreenGlazedTerracottaHandler (E_BLOCK_GREEN_GLAZED_TERRACOTTA); + constexpr cDefaultItemHandler ItemGreenShulkerBoxHandler (E_BLOCK_GREEN_SHULKER_BOX); + constexpr cDefaultItemHandler ItemGunpowderHandler (E_ITEM_GUNPOWDER); + constexpr cDefaultItemHandler ItemHardenedClayHandler (E_BLOCK_HARDENED_CLAY); + constexpr cItemSidewaysHandler ItemHayBaleHandler (E_BLOCK_HAY_BALE); + constexpr cItemMobHeadHandler ItemHeadBlockHandler (E_BLOCK_HEAD); + constexpr cItemMobHeadHandler ItemHeadHandler (E_ITEM_HEAD); + constexpr cDefaultItemHandler ItemHeavyWeightedPressurePlateBlockHandler (E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE); + constexpr cItemHopperHandler ItemHopperHandler (E_BLOCK_HOPPER); + constexpr cDefaultItemHandler ItemHugeBrownMushroomBlockHandler (E_BLOCK_HUGE_BROWN_MUSHROOM); + constexpr cDefaultItemHandler ItemHugeRedMushroomBlockHandler (E_BLOCK_HUGE_RED_MUSHROOM); + constexpr cDefaultItemHandler ItemIceHandler (E_BLOCK_ICE); + constexpr cDefaultItemHandler ItemInactiveComparatorHandler (E_BLOCK_INACTIVE_COMPARATOR); + constexpr cDefaultItemHandler ItemInvertedDaylightSensorHandler (E_BLOCK_INVERTED_DAYLIGHT_SENSOR); + constexpr cItemAxeHandler ItemIronAxeHandler (E_ITEM_IRON_AXE); + constexpr cDefaultItemHandler ItemIronBarsBlockHandler (E_BLOCK_IRON_BARS); + constexpr cItemArmorHandler ItemIronBootsHandler (E_ITEM_IRON_BOOTS); + constexpr cItemArmorHandler ItemIronChestplateHandler (E_ITEM_IRON_CHESTPLATE); + constexpr cDefaultItemHandler ItemIronDoorBlockHandler (E_BLOCK_IRON_DOOR); + constexpr cItemDoorHandler ItemIronDoorHandler (E_ITEM_IRON_DOOR); + constexpr cDefaultItemHandler ItemIronHandler (E_ITEM_IRON); + constexpr cItemArmorHandler ItemIronHelmetHandler (E_ITEM_IRON_HELMET); + constexpr cItemHoeHandler ItemIronHoeHandler (E_ITEM_IRON_HOE); + constexpr cDefaultItemHandler ItemIronHorseArmorHandler (E_ITEM_IRON_HORSE_ARMOR); + constexpr cItemArmorHandler ItemIronLeggingsHandler (E_ITEM_IRON_LEGGINGS); + constexpr cDefaultItemHandler ItemIronNuggetHandler (E_ITEM_IRON_NUGGET); + constexpr cDefaultItemHandler ItemIronOreHandler (E_BLOCK_IRON_ORE); + constexpr cItemPickaxeHandler ItemIronPickaxeHandler (E_ITEM_IRON_PICKAXE); + constexpr cItemShovelHandler ItemIronShovelHandler (E_ITEM_IRON_SHOVEL); + constexpr cItemSwordHandler ItemIronSwordHandler (E_ITEM_IRON_SWORD); + constexpr cItemTrapdoorHandler ItemIronTrapdoorHandler (E_BLOCK_IRON_TRAPDOOR); + constexpr cDefaultItemHandler ItemIronBlockHandler (E_BLOCK_IRON_BLOCK); + constexpr cItemItemFrameHandler ItemItemFrameHandler (E_ITEM_ITEM_FRAME); + constexpr cItemJackOLanternHandler ItemJackOLanternHandler (E_BLOCK_JACK_O_LANTERN); + constexpr cDefaultItemHandler ItemJukeboxHandler (E_BLOCK_JUKEBOX); + constexpr cItemBoatHandler ItemJungleBoatHandler (E_ITEM_JUNGLE_BOAT); + constexpr cDefaultItemHandler ItemJungleDoorBlockHandler (E_BLOCK_JUNGLE_DOOR); + constexpr cItemDoorHandler ItemJungleDoorHandler (E_ITEM_JUNGLE_DOOR); + constexpr cItemFenceGateHandler ItemJungleFenceGateHandler (E_BLOCK_JUNGLE_FENCE_GATE); + constexpr cDefaultItemHandler ItemJungleFenceHandler (E_BLOCK_JUNGLE_FENCE); + constexpr cItemStairsHandler ItemJungleStairsHandler (E_BLOCK_JUNGLE_WOOD_STAIRS); + constexpr cItemLadderHandler ItemLadderHandler (E_BLOCK_LADDER); + constexpr cDefaultItemHandler ItemLapisBlockHandler (E_BLOCK_LAPIS_BLOCK); + constexpr cDefaultItemHandler ItemLapisOreHandler (E_BLOCK_LAPIS_ORE); + constexpr cItemBucketHandler ItemLavaBucketHandler (E_ITEM_LAVA_BUCKET); + constexpr cDefaultItemHandler ItemLavaHandler (E_BLOCK_LAVA); + constexpr cDefaultItemHandler ItemLeashHandler (E_ITEM_LEAD); + constexpr cItemArmorHandler ItemLeatherBootsHandler (E_ITEM_LEATHER_BOOTS); + constexpr cItemArmorHandler ItemLeatherCapHandler (E_ITEM_LEATHER_CAP); + constexpr cDefaultItemHandler ItemLeatherHandler (E_ITEM_LEATHER); + constexpr cItemArmorHandler ItemLeatherPantsHandler (E_ITEM_LEATHER_PANTS); + constexpr cItemArmorHandler ItemLeatherTunicHandler (E_ITEM_LEATHER_TUNIC); + constexpr cItemLeavesHandler ItemLeavesHandler (E_BLOCK_LEAVES); + constexpr cItemLeverHandler ItemLeverHandler (E_BLOCK_LEVER); + constexpr cItemGlazedTerracottaHandler ItemLightBlueGlazedTerracottaHandler (E_BLOCK_LIGHT_BLUE_GLAZED_TERRACOTTA); + constexpr cDefaultItemHandler ItemLightBlueShulkerBoxHandler (E_BLOCK_LIGHT_BLUE_SHULKER_BOX); + constexpr cItemGlazedTerracottaHandler ItemLightGrayGlazedTerracottaHandler (E_BLOCK_LIGHT_GRAY_GLAZED_TERRACOTTA); + constexpr cDefaultItemHandler ItemLightGrayShulkerBoxHandler (E_BLOCK_LIGHT_GRAY_SHULKER_BOX); + constexpr cDefaultItemHandler ItemLightWeightedPressurePlateBlockHandler (E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE); + constexpr cItemLilypadHandler ItemLilypadHandler (E_BLOCK_LILY_PAD); + constexpr cItemGlazedTerracottaHandler ItemLimeGlazedTerracottaHandler (E_BLOCK_LIME_GLAZED_TERRACOTTA); + constexpr cDefaultItemHandler ItemLimeShulkerBoxHandler (E_BLOCK_LIME_SHULKER_BOX); + constexpr cItemPotionHandler ItemLingeringPotionHandler (E_ITEM_LINGERING_POTION); + constexpr cDefaultItemHandler ItemLitFurnaceHandler (E_BLOCK_LIT_FURNACE); + constexpr cItemSidewaysHandler ItemLogHandler (E_BLOCK_LOG); + constexpr cItemGlazedTerracottaHandler ItemMagentaGlazedTerracottaHandler (E_BLOCK_MAGENTA_GLAZED_TERRACOTTA); + constexpr cDefaultItemHandler ItemMagentaShulkerBoxHandler (E_BLOCK_MAGENTA_SHULKER_BOX); + constexpr cDefaultItemHandler ItemMagmaBlockHandler (E_BLOCK_MAGMA); + constexpr cDefaultItemHandler ItemMagmaCreamHandler (E_ITEM_MAGMA_CREAM); + constexpr cDefaultItemHandler ItemMallDiscHandler (E_ITEM_MALL_DISC); + constexpr cItemMapHandler ItemMapHandler (E_ITEM_MAP); + constexpr cDefaultItemHandler ItemMellohiDiscHandler (E_ITEM_MELLOHI_DISC); + constexpr cDefaultItemHandler ItemMelonBlockHandler (E_BLOCK_MELON); + constexpr cItemSimpleSeedsHandler ItemMelonSeedsHandler (E_ITEM_MELON_SEEDS); + constexpr cItemSimpleFoodHandler ItemMelonSliceHandler (E_ITEM_MELON_SLICE, cItemHandler::FoodInfo(2, 1.2)); + constexpr cDefaultItemHandler ItemMelonStemHandler (E_BLOCK_MELON_STEM); + constexpr cItemMilkHandler ItemMilkHandler (E_ITEM_MILK); + constexpr cItemMinecartHandler ItemMinecartHandler (E_ITEM_MINECART); + constexpr cItemMinecartHandler ItemMinecartWithCommandBlockHandler (E_ITEM_MINECART_WITH_COMMAND_BLOCK); + constexpr cItemMinecartHandler ItemMinecartWithHopperHandler (E_ITEM_MINECART_WITH_HOPPER); + constexpr cItemMinecartHandler ItemMinecartWithTNTHandler (E_ITEM_MINECART_WITH_TNT); + constexpr cDefaultItemHandler ItemMobSpawnerBlockHandler (E_BLOCK_MOB_SPAWNER); + constexpr cDefaultItemHandler ItemMossyCobblestoneHandler (E_BLOCK_MOSSY_COBBLESTONE); + constexpr cItemSoupHandler ItemMushroomSoupHandler (E_ITEM_MUSHROOM_SOUP, cItemHandler::FoodInfo(6, 7.2)); + constexpr cDefaultItemHandler ItemMyceliumHandler (E_BLOCK_MYCELIUM); + constexpr cDefaultItemHandler ItemNameTagHandler (E_ITEM_NAME_TAG); + constexpr cDefaultItemHandler ItemNetherBrickBlockHandler (E_BLOCK_NETHER_BRICK); + constexpr cDefaultItemHandler ItemNetherBrickFenceBlockHandler (E_BLOCK_NETHER_BRICK_FENCE); + constexpr cDefaultItemHandler ItemNetherBrickHandler (E_ITEM_NETHER_BRICK); + constexpr cItemStairsHandler ItemNetherBrickStairsHandler (E_BLOCK_NETHER_BRICK_STAIRS); + constexpr cDefaultItemHandler ItemNetherPortalBlockHandler (E_BLOCK_NETHER_PORTAL); + constexpr cDefaultItemHandler ItemNetherQuartzHandler (E_ITEM_NETHER_QUARTZ); + constexpr cDefaultItemHandler ItemNetherQuartzOreHandler (E_BLOCK_NETHER_QUARTZ_ORE); + constexpr cDefaultItemHandler ItemNetherStarHandler (E_ITEM_NETHER_STAR); + constexpr cDefaultItemHandler ItemNetherWartBlockBlockHandler (E_BLOCK_NETHER_WART_BLOCK); + constexpr cDefaultItemHandler ItemNetherWartBlockHandler (E_BLOCK_NETHER_WART); + constexpr cItemNetherWartHandler ItemNetherWartHandler (E_ITEM_NETHER_WART); + constexpr cDefaultItemHandler ItemNetherrackHandler (E_BLOCK_NETHERRACK); + constexpr cItemLeavesHandler ItemNewLeavesHandler (E_BLOCK_NEW_LEAVES); + constexpr cItemSidewaysHandler ItemNewLogHandler (E_BLOCK_NEW_LOG); + constexpr cDefaultItemHandler ItemNoteBlockHandler (E_BLOCK_NOTE_BLOCK); + constexpr cItemBoatHandler ItemOakBoatHandler (E_ITEM_BOAT); + constexpr cItemButtonHandler ItemOakButtonHandler (E_BLOCK_WOODEN_BUTTON); + constexpr cDefaultItemHandler ItemOakDoorBlockHandler (E_BLOCK_OAK_DOOR); + constexpr cItemDoorHandler ItemOakDoorHandler (E_ITEM_WOODEN_DOOR); + constexpr cItemFenceGateHandler ItemOakFenceGateHandler (E_BLOCK_OAK_FENCE_GATE); + constexpr cItemSlabHandler ItemOakSlabHandler (E_BLOCK_WOODEN_SLAB); + constexpr cItemStairsHandler ItemOakStairsHandler (E_BLOCK_OAK_WOOD_STAIRS); + constexpr cItemTrapdoorHandler ItemOakTrapdoorHandler (E_BLOCK_TRAPDOOR); + constexpr cItemObserverHandler ItemObserverHandler (E_BLOCK_OBSERVER); + constexpr cDefaultItemHandler ItemObsidianHandler (E_BLOCK_OBSIDIAN); + constexpr cItemGlazedTerracottaHandler ItemOrangeGlazedTerracottaHandler (E_BLOCK_ORANGE_GLAZED_TERRACOTTA); + constexpr cDefaultItemHandler ItemOrangeShulkerBoxHandler (E_BLOCK_ORANGE_SHULKER_BOX); + constexpr cDefaultItemHandler ItemPackedIceHandler (E_BLOCK_PACKED_ICE); + constexpr cItemPaintingHandler ItemPaintingHandler (E_ITEM_PAINTING); + constexpr cDefaultItemHandler ItemPaperHandler (E_ITEM_PAPER); + constexpr cItemGlazedTerracottaHandler ItemPinkGlazedTerracottaHandler (E_BLOCK_PINK_GLAZED_TERRACOTTA); + constexpr cDefaultItemHandler ItemPinkShulkerBoxHandler (E_BLOCK_PINK_SHULKER_BOX); + constexpr cDefaultItemHandler ItemPistonExtensionHandler (E_BLOCK_PISTON_EXTENSION); + constexpr cItemPistonHandler ItemPistonHandler (E_BLOCK_PISTON); + constexpr cDefaultItemHandler ItemPistonMovedBlockHandler (E_BLOCK_PISTON_MOVED_BLOCK); + constexpr cItemPlanksHandler ItemPlanksHandler (E_BLOCK_PLANKS); + constexpr cItemPoisonousPotatoHandler ItemPoisonousPotatoHandler (E_ITEM_POISONOUS_POTATO); + constexpr cDefaultItemHandler ItemPoppedChorusFruitHandler (E_ITEM_POPPED_CHORUS_FRUIT); + constexpr cDefaultItemHandler ItemPoppyHandler (E_BLOCK_FLOWER); + constexpr cItemFoodSeedsHandler ItemPotatoHandler (E_ITEM_POTATO, cItemHandler::FoodInfo(1, 0.6)); + constexpr cDefaultItemHandler ItemPotatoesBlockHandler (E_BLOCK_POTATOES); + constexpr cItemPotionHandler ItemPotionHandler (E_ITEM_POTION); + constexpr cItemRailHandler ItemPoweredRailHandler (E_BLOCK_POWERED_RAIL); + constexpr cDefaultItemHandler ItemPrismarineBlockHandler (E_BLOCK_PRISMARINE_BLOCK); + constexpr cDefaultItemHandler ItemPrismarineCrystalsHandler (E_ITEM_PRISMARINE_CRYSTALS); + constexpr cDefaultItemHandler ItemPrismarineShardHandler (E_ITEM_PRISMARINE_SHARD); + constexpr cItemPumpkinHandler ItemPumpkinHandler (E_BLOCK_PUMPKIN); + constexpr cItemSimpleFoodHandler ItemPumpkinPieHandler (E_ITEM_PUMPKIN_PIE, cItemHandler::FoodInfo(8, 4.8)); + constexpr cItemSimpleSeedsHandler ItemPumpkinSeedsHandler (E_ITEM_PUMPKIN_SEEDS); + constexpr cDefaultItemHandler ItemPumpkinStemHandler (E_BLOCK_PUMPKIN_STEM); + constexpr cItemStairsHandler ItemPurpurStairsHandler (E_BLOCK_PURPUR_STAIRS); + constexpr cItemGlazedTerracottaHandler ItemPurpleGlazedTerracottaHandler (E_BLOCK_PURPLE_GLAZED_TERRACOTTA); + constexpr cDefaultItemHandler ItemPurpleShulkerBoxHandler (E_BLOCK_PURPLE_SHULKER_BOX); + constexpr cDefaultItemHandler ItemPurpurBlockHandler (E_BLOCK_PURPUR_BLOCK); + constexpr cDefaultItemHandler ItemPurpurDoubleSlabHandler (E_BLOCK_PURPUR_DOUBLE_SLAB); + constexpr cDefaultItemHandler ItemPurpurPillarHandler (E_BLOCK_PURPUR_PILLAR); + constexpr cItemSlabHandler ItemPurpurSlabHandler (E_BLOCK_PURPUR_SLAB); + constexpr cItemQuartzHandler ItemQuartzBlockHandler (E_BLOCK_QUARTZ_BLOCK); + constexpr cItemStairsHandler ItemQuartzStairsHandler (E_BLOCK_QUARTZ_STAIRS); + constexpr cDefaultItemHandler ItemRabbitHideHandler (E_ITEM_RABBIT_HIDE); + constexpr cItemSoupHandler ItemRabbitStewHandler (E_ITEM_RABBIT_STEW, cItemHandler::FoodInfo(10, 12)); + constexpr cDefaultItemHandler ItemRabbitsFootHandler (E_ITEM_RABBITS_FOOT); + constexpr cItemRailHandler ItemRailHandler (E_BLOCK_RAIL); + constexpr cItemSimpleFoodHandler ItemRawBeefHandler (E_ITEM_RAW_BEEF, cItemHandler::FoodInfo(3, 1.8)); + constexpr cItemRawChickenHandler ItemRawChickenHandler (E_ITEM_RAW_CHICKEN); + constexpr cItemRawFishHandler ItemRawFishHandler (E_ITEM_RAW_FISH); + constexpr cItemSimpleFoodHandler ItemRawMuttonHandler (E_ITEM_RAW_MUTTON, cItemHandler::FoodInfo(2, 1.2)); + constexpr cItemSimpleFoodHandler ItemRawPorkchopHandler (E_ITEM_RAW_PORKCHOP, cItemHandler::FoodInfo(3, 1.8)); + constexpr cItemSimpleFoodHandler ItemRawRabbitHandler (E_ITEM_RAW_RABBIT, cItemHandler::FoodInfo(3, 1.8)); + constexpr cItemGlazedTerracottaHandler ItemRedGlazedTerracottaHandler (E_BLOCK_RED_GLAZED_TERRACOTTA); + constexpr cDefaultItemHandler ItemRedMushroomBlockHandler (E_BLOCK_RED_MUSHROOM); + constexpr cDefaultItemHandler ItemRedNetherBricksHandler (E_BLOCK_RED_NETHER_BRICK); + constexpr cDefaultItemHandler ItemRedSandstoneHandler (E_BLOCK_RED_SANDSTONE); + constexpr cItemSlabHandler ItemRedSandstoneSlabHandler (E_BLOCK_RED_SANDSTONE_SLAB); + constexpr cItemStairsHandler ItemRedSandstoneStairsHandler (E_BLOCK_RED_SANDSTONE_STAIRS); + constexpr cDefaultItemHandler ItemRedShulkerBoxHandler (E_BLOCK_RED_SHULKER_BOX); + constexpr cDefaultItemHandler ItemRedstoneBlockHandler (E_BLOCK_BLOCK_OF_REDSTONE); + constexpr cItemRedstoneDustHandler ItemRedstoneDustHandler (E_ITEM_REDSTONE_DUST); + constexpr cDefaultItemHandler ItemRedstoneLampOffHandler (E_BLOCK_REDSTONE_LAMP_OFF); + constexpr cDefaultItemHandler ItemRedstoneLampOnHandler (E_BLOCK_REDSTONE_LAMP_ON); + constexpr cDefaultItemHandler ItemRedstoneOreHandler (E_BLOCK_REDSTONE_ORE); + constexpr cDefaultItemHandler ItemRedstoneOreGlowingHandler (E_BLOCK_REDSTONE_ORE_GLOWING); + constexpr cItemRedstoneRepeaterHandler ItemRedstoneRepeaterHandler (E_ITEM_REDSTONE_REPEATER); + constexpr cDefaultItemHandler ItemRedstoneRepeaterOffHandler (E_BLOCK_REDSTONE_REPEATER_OFF); + constexpr cDefaultItemHandler ItemRedstoneRepeaterOnHandler (E_BLOCK_REDSTONE_REPEATER_ON); + constexpr cItemTorchHandler ItemRedstoneTorchHandler (E_BLOCK_REDSTONE_TORCH_ON); + constexpr cDefaultItemHandler ItemRedstoneTorchOffBlockHandler (E_BLOCK_REDSTONE_TORCH_OFF); + constexpr cDefaultItemHandler ItemRedstoneWireHandler (E_BLOCK_REDSTONE_WIRE); + constexpr cDefaultItemHandler ItemRepeatingCommandBlockHandler (E_BLOCK_REPEATING_COMMAND_BLOCK); + constexpr cItemRottenFleshHandler ItemRottenFleshHandler (E_ITEM_ROTTEN_FLESH); + constexpr cDefaultItemHandler ItemSaddleHandler (E_ITEM_SADDLE); + constexpr cDefaultItemHandler ItemSandHandler (E_BLOCK_SAND); + constexpr cDefaultItemHandler ItemSandstoneHandler (E_BLOCK_SANDSTONE); + constexpr cItemStairsHandler ItemSandstoneStairsHandler (E_BLOCK_SANDSTONE_STAIRS); + constexpr cItemSaplingHandler ItemSaplingHandler (E_BLOCK_SAPLING); + constexpr cDefaultItemHandler ItemSeaLanternHandler (E_BLOCK_SEA_LANTERN); + constexpr cItemSimpleSeedsHandler ItemSeedsHandler (E_ITEM_SEEDS); + constexpr cItemShearsHandler ItemShearsHandler (E_ITEM_SHEARS); + constexpr cDefaultItemHandler ItemShieldHandler (E_ITEM_SHIELD); + constexpr cDefaultItemHandler ItemShulkerShellHandler (E_ITEM_SHULKER_SHELL); + constexpr cItemSignHandler ItemSignHandler (E_ITEM_SIGN); + constexpr cDefaultItemHandler ItemSignPostHandler (E_BLOCK_SIGN_POST); + constexpr cDefaultItemHandler ItemSilverfishEggBlockHandler (E_BLOCK_SILVERFISH_EGG); + constexpr cDefaultItemHandler ItemSlimeBlockHandler (E_BLOCK_SLIME_BLOCK); + constexpr cDefaultItemHandler ItemSlimeballHandler (E_ITEM_SLIMEBALL); + constexpr cDefaultItemHandler ItemSnowBlockHandler (E_BLOCK_SNOW_BLOCK); + constexpr cItemSnowHandler ItemSnowHandler (E_BLOCK_SNOW); + constexpr cItemSnowballHandler ItemSnowballHandler (E_ITEM_SNOWBALL); + constexpr cDefaultItemHandler ItemSoulsandHandler (E_BLOCK_SOULSAND); + constexpr cItemSpawnEggHandler ItemSpawnEggHandler (E_ITEM_SPAWN_EGG); + constexpr cItemSpiderEyeHandler ItemSpiderEyeHandler (E_ITEM_SPIDER_EYE); + constexpr cItemPotionHandler ItemSplashPotionHandler (E_ITEM_SPLASH_POTION); + constexpr cDefaultItemHandler ItemSpongeHandler (E_BLOCK_SPONGE); + constexpr cDefaultItemHandler ItemSpectralArrowHandler (E_ITEM_SPECTRAL_ARROW); + constexpr cItemBoatHandler ItemSpruceBoatHandler (E_ITEM_SPRUCE_BOAT); + constexpr cDefaultItemHandler ItemSpruceDoorBlockHandler (E_BLOCK_SPRUCE_DOOR); + constexpr cItemDoorHandler ItemSpruceDoorHandler (E_ITEM_SPRUCE_DOOR); + constexpr cItemFenceGateHandler ItemSpruceFenceGateHandler (E_BLOCK_SPRUCE_FENCE_GATE); + constexpr cDefaultItemHandler ItemSpruceFenceHandler (E_BLOCK_SPRUCE_FENCE); + constexpr cItemStairsHandler ItemSpruceStairsHandler (E_BLOCK_SPRUCE_WOOD_STAIRS); + constexpr cSimplePlaceableItemHandler ItemStringHandler (E_ITEM_STRING, E_BLOCK_TRIPWIRE); + constexpr cDefaultItemHandler ItemStainedGlassHandler (E_BLOCK_STAINED_GLASS); + constexpr cDefaultItemHandler ItemStainedGlassPaneHandler (E_BLOCK_STAINED_GLASS_PANE); + constexpr cDefaultItemHandler ItemStalDiscHandler (E_ITEM_STAL_DISC); + constexpr cDefaultItemHandler ItemStandingBannerHandler (E_BLOCK_STANDING_BANNER); + constexpr cDefaultItemHandler ItemStationaryLavaHandler (E_BLOCK_STATIONARY_LAVA); + constexpr cDefaultItemHandler ItemStationaryWaterHandler (E_BLOCK_STATIONARY_WATER); + constexpr cDefaultItemHandler ItemStickHandler (E_ITEM_STICK); + constexpr cItemPistonHandler ItemStickyPistonHandler (E_BLOCK_STICKY_PISTON); + constexpr cItemAxeHandler ItemStoneAxeHandler (E_ITEM_STONE_AXE); + constexpr cDefaultItemHandler ItemStoneBricksHandler (E_BLOCK_STONE_BRICKS); + constexpr cItemStairsHandler ItemStoneBrickStairsHandler (E_BLOCK_STONE_BRICK_STAIRS); + constexpr cItemButtonHandler ItemStoneButtonHandler (E_BLOCK_STONE_BUTTON); + constexpr cDefaultItemHandler ItemStoneHandler (E_BLOCK_STONE); + constexpr cItemHoeHandler ItemStoneHoeHandler (E_ITEM_STONE_HOE); + constexpr cItemPickaxeHandler ItemStonePickaxeHandler (E_ITEM_STONE_PICKAXE); + constexpr cDefaultItemHandler ItemStonePressurePlateBlockHandler (E_BLOCK_STONE_PRESSURE_PLATE); + constexpr cItemShovelHandler ItemStoneShovelHandler (E_ITEM_STONE_SHOVEL); + constexpr cItemSlabHandler ItemStoneSlabHandler (E_BLOCK_STONE_SLAB); + constexpr cItemSwordHandler ItemStoneSwordHandler (E_ITEM_STONE_SWORD); + constexpr cDefaultItemHandler ItemStradDiscHandler (E_ITEM_STRAD_DISC); + constexpr cDefaultItemHandler ItemStructureBlockHandler (E_BLOCK_STRUCTURE_BLOCK); + constexpr cDefaultItemHandler ItemStructureVoidHandler (E_BLOCK_STRUCTURE_VOID); + constexpr cSimplePlaceableItemHandler ItemSugarCaneHandler (E_BLOCK_SUGARCANE, E_BLOCK_SUGARCANE); + constexpr cDefaultItemHandler ItemSugarHandler (E_ITEM_SUGAR); + constexpr cSimplePlaceableItemHandler ItemSugarcaneHandler (E_ITEM_SUGARCANE, E_BLOCK_SUGARCANE); + constexpr cDefaultItemHandler ItemTNTBlockHandler (E_BLOCK_TNT); + constexpr cDefaultItemHandler ItemTallGrassHandler (E_BLOCK_TALL_GRASS); + constexpr cDefaultItemHandler ItemTerracottaHandler (E_BLOCK_TERRACOTTA); + constexpr cDefaultItemHandler ItemTippedArrowHandler (E_ITEM_TIPPED_ARROW); + constexpr cItemTorchHandler ItemTorchBlockHandler (E_BLOCK_TORCH); + constexpr cDefaultItemHandler ItemTotemOfUndyingHandler (E_ITEM_TOTEM_OF_UNDYING); + constexpr cItemChestHandler ItemTrappedChestHandler (E_BLOCK_TRAPPED_CHEST); + constexpr cDefaultItemHandler ItemTripwireHandler (E_BLOCK_TRIPWIRE); + constexpr cItemTripwireHookHandler ItemTripwireHookHandler (E_BLOCK_TRIPWIRE_HOOK); + constexpr cItemVineHandler ItemVineHandler (E_BLOCK_VINES); + constexpr cDefaultItemHandler ItemWaitDiscHandler (E_ITEM_WAIT_DISC); + constexpr cDefaultItemHandler ItemWallBannerHandler (E_BLOCK_WALL_BANNER); + constexpr cDefaultItemHandler ItemWallsignHandler (E_BLOCK_WALLSIGN); + constexpr cDefaultItemHandler ItemWardDiscHandler (E_ITEM_WARD_DISC); + constexpr cItemBucketHandler ItemWaterBucketHandler (E_ITEM_WATER_BUCKET); + constexpr cDefaultItemHandler ItemWaterHandler (E_BLOCK_WATER); + constexpr cDefaultItemHandler ItemWheatBlockHandler (E_BLOCK_WHEAT); + constexpr cDefaultItemHandler ItemWheatHandler (E_ITEM_WHEAT); + constexpr cItemGlazedTerracottaHandler ItemWhiteGlazedTerracottaHandler (E_BLOCK_WHITE_GLAZED_TERRACOTTA); + constexpr cDefaultItemHandler ItemWhiteShulkerBoxHandler (E_BLOCK_WHITE_SHULKER_BOX); + constexpr cItemAxeHandler ItemWoodenAxeHandler (E_ITEM_WOODEN_AXE); + constexpr cItemHoeHandler ItemWoodenHoeHandler (E_ITEM_WOODEN_HOE); + constexpr cItemPickaxeHandler ItemWoodenPickaxeHandler (E_ITEM_WOODEN_PICKAXE); + constexpr cDefaultItemHandler ItemWoodenPressurePlateBlockHandler (E_BLOCK_WOODEN_PRESSURE_PLATE); + constexpr cItemShovelHandler ItemWoodenShovelHandler (E_ITEM_WOODEN_SHOVEL); + constexpr cItemSwordHandler ItemWoodenSwordHandler (E_ITEM_WOODEN_SWORD); + constexpr cItemClothHandler ItemWoolHandler (E_BLOCK_WOOL); + constexpr cDefaultItemHandler ItemWorkbenchHandler (E_BLOCK_WORKBENCH); + constexpr cDefaultItemHandler ItemWrittenBookHandler (E_ITEM_WRITTEN_BOOK); + constexpr cItemGlazedTerracottaHandler ItemYellowGlazedTerracottaHandler (E_BLOCK_YELLOW_GLAZED_TERRACOTTA); + constexpr cDefaultItemHandler ItemYellowShulkerBoxHandler (E_BLOCK_YELLOW_SHULKER_BOX); } -cItemHandler * cItemHandler::CreateItemHandler(int a_ItemType) +const cItemHandler & cItemHandler::For(int a_ItemType) { switch (a_ItemType) { - default: return new cItemHandler(a_ItemType); - - // Single item per handler, alphabetically sorted: - case E_BLOCK_ACTIVATOR_RAIL: return new cItemRailHandler(a_ItemType); - case E_BLOCK_ANVIL: return new cItemAnvilHandler(a_ItemType); - case E_BLOCK_BIG_FLOWER: return new cItemBigFlowerHandler; - case E_BLOCK_CHEST: return new cItemChestHandler(a_ItemType); - case E_BLOCK_DETECTOR_RAIL: return new cItemRailHandler(a_ItemType); - case E_BLOCK_DISPENSER: return new cItemDropSpenserHandler(a_ItemType); - case E_BLOCK_DROPPER: return new cItemDropSpenserHandler(a_ItemType); - case E_BLOCK_ENCHANTMENT_TABLE: return new cItemEnchantingTableHandler(a_ItemType); - case E_BLOCK_ENDER_CHEST: return new cItemEnderchestHandler(a_ItemType); - case E_BLOCK_END_PORTAL_FRAME: return new cItemEndPortalFrameHandler(a_ItemType); - case E_BLOCK_FURNACE: return new cItemFurnaceHandler(a_ItemType); - case E_BLOCK_HAY_BALE: return new cItemSidewaysHandler(a_ItemType); - case E_BLOCK_HEAD: return new cItemMobHeadHandler(a_ItemType); - case E_BLOCK_HOPPER: return new cItemHopperHandler(a_ItemType); - case E_BLOCK_IRON_TRAPDOOR: return new cItemTrapdoorHandler(a_ItemType); - case E_BLOCK_JACK_O_LANTERN: return new cItemJackOLanternHandler(a_ItemType); - case E_BLOCK_LADDER: return new cItemLadderHandler(a_ItemType); - case E_BLOCK_LEAVES: return new cItemLeavesHandler(a_ItemType); - case E_BLOCK_LEVER: return new cItemLeverHandler(a_ItemType); - case E_BLOCK_LILY_PAD: return new cItemLilypadHandler(a_ItemType); - case E_BLOCK_LOG: return new cItemSidewaysHandler(a_ItemType); - case E_BLOCK_NEW_LEAVES: return new cItemLeavesHandler(a_ItemType); - case E_BLOCK_NEW_LOG: return new cItemSidewaysHandler(a_ItemType); - case E_BLOCK_OBSERVER: return new cItemObserverHandler(a_ItemType); - case E_BLOCK_PISTON: return new cItemPistonHandler(a_ItemType); - case E_BLOCK_PLANKS: return new cItemPlanksHandler(a_ItemType); - case E_BLOCK_POWERED_RAIL: return new cItemRailHandler(a_ItemType); - case E_BLOCK_PUMPKIN: return new cItemPumpkinHandler(a_ItemType); - case E_BLOCK_PURPUR_SLAB: return new cItemSlabHandler(a_ItemType); - case E_BLOCK_QUARTZ_BLOCK: return new cItemQuartzHandler(a_ItemType); - case E_BLOCK_RAIL: return new cItemRailHandler(a_ItemType); - case E_BLOCK_REDSTONE_TORCH_ON: return new cItemTorchHandler(a_ItemType); - case E_BLOCK_RED_SANDSTONE_SLAB: return new cItemSlabHandler(a_ItemType); - case E_BLOCK_SAPLING: return new cItemSaplingHandler(a_ItemType); - case E_BLOCK_SNOW: return new cItemSnowHandler(a_ItemType); - case E_BLOCK_STICKY_PISTON: return new cItemPistonHandler(a_ItemType); - case E_BLOCK_STONE_BUTTON: return new cItemButtonHandler(a_ItemType); - case E_BLOCK_STONE_SLAB: return new cItemSlabHandler(a_ItemType); - case E_BLOCK_TORCH: return new cItemTorchHandler(a_ItemType); - case E_BLOCK_TRAPDOOR: return new cItemTrapdoorHandler(a_ItemType); - case E_BLOCK_TRAPPED_CHEST: return new cItemChestHandler(a_ItemType); - case E_BLOCK_TRIPWIRE_HOOK: return new cItemTripwireHookHandler(a_ItemType); - case E_BLOCK_VINES: return new cItemVineHandler(a_ItemType); - case E_BLOCK_WOODEN_BUTTON: return new cItemButtonHandler(a_ItemType); - case E_BLOCK_WOODEN_SLAB: return new cItemSlabHandler(a_ItemType); - case E_BLOCK_WOOL: return new cItemClothHandler(a_ItemType); - case E_ITEM_BANNER: return new cItemBannerHandler(a_ItemType); - case E_ITEM_BED: return new cItemBedHandler(a_ItemType); - case E_ITEM_BOTTLE_O_ENCHANTING: return new cItemBottleOEnchantingHandler(); - case E_ITEM_BOW: return new cItemBowHandler(); - case E_ITEM_BREWING_STAND: return new cSimplePlaceableItemHandler(a_ItemType, E_BLOCK_BREWING_STAND); - case E_ITEM_CAKE: return new cSimplePlaceableItemHandler(a_ItemType, E_BLOCK_CAKE); - case E_ITEM_CAULDRON: return new cSimplePlaceableItemHandler(a_ItemType, E_BLOCK_CAULDRON); - case E_ITEM_COMPARATOR: return new cItemComparatorHandler(a_ItemType); - case E_ITEM_DYE: return new cItemDyeHandler(a_ItemType); - case E_ITEM_EGG: return new cItemEggHandler(); - case E_ITEM_EMPTY_MAP: return new cItemEmptyMapHandler(); - case E_ITEM_ENDER_PEARL: return new cItemEnderPearlHandler(); - case E_ITEM_END_CRYSTAL: return new cItemEndCrystalHandler(a_ItemType); - case E_ITEM_EYE_OF_ENDER: return new cItemEyeOfEnderHandler(); - case E_ITEM_FIREWORK_ROCKET: return new cItemFireworkHandler(); - case E_ITEM_FIRE_CHARGE: return new cItemLighterHandler(a_ItemType); - case E_ITEM_FISHING_ROD: return new cItemFishingRodHandler(a_ItemType); - case E_ITEM_FLINT_AND_STEEL: return new cItemLighterHandler(a_ItemType); - case E_ITEM_FLOWER_POT: return new cSimplePlaceableItemHandler(a_ItemType, E_BLOCK_FLOWER_POT); - case E_ITEM_GLASS_BOTTLE: return new cItemBottleHandler(); - case E_ITEM_HEAD: return new cItemMobHeadHandler(a_ItemType); - case E_ITEM_ITEM_FRAME: return new cItemItemFrameHandler(a_ItemType); - case E_ITEM_MAP: return new cItemMapHandler(); - case E_ITEM_MILK: return new cItemMilkHandler(); - case E_ITEM_NETHER_WART: return new cItemNetherWartHandler(a_ItemType); - case E_ITEM_PAINTING: return new cItemPaintingHandler(a_ItemType); - case E_ITEM_POTIONS: return new cItemPotionHandler(); - case E_ITEM_REDSTONE_DUST: return new cItemRedstoneDustHandler(a_ItemType); - case E_ITEM_REDSTONE_REPEATER: return new cItemRedstoneRepeaterHandler(a_ItemType); - case E_ITEM_SHEARS: return new cItemShearsHandler(a_ItemType); - case E_ITEM_SIGN: return new cItemSignHandler(a_ItemType); - case E_ITEM_SNOWBALL: return new cItemSnowballHandler(); - case E_ITEM_SPAWN_EGG: return new cItemSpawnEggHandler(a_ItemType); - case E_ITEM_STRING: return new cSimplePlaceableItemHandler(a_ItemType, E_BLOCK_TRIPWIRE); - case E_ITEM_SUGARCANE: return new cSimplePlaceableItemHandler(a_ItemType, E_BLOCK_SUGARCANE); - - case E_ITEM_WOODEN_HOE: - case E_ITEM_STONE_HOE: - case E_ITEM_IRON_HOE: - case E_ITEM_GOLD_HOE: - case E_ITEM_DIAMOND_HOE: - { - return new cItemHoeHandler(a_ItemType); - } - - case E_ITEM_WOODEN_PICKAXE: - case E_ITEM_STONE_PICKAXE: - case E_ITEM_IRON_PICKAXE: - case E_ITEM_GOLD_PICKAXE: - case E_ITEM_DIAMOND_PICKAXE: - { - return new cItemPickaxeHandler(a_ItemType); - } - - case E_ITEM_WOODEN_SHOVEL: - case E_ITEM_STONE_SHOVEL: - case E_ITEM_IRON_SHOVEL: - case E_ITEM_GOLD_SHOVEL: - case E_ITEM_DIAMOND_SHOVEL: - { - return new cItemShovelHandler(a_ItemType); - } - - case E_ITEM_WOODEN_AXE: - case E_ITEM_STONE_AXE: - case E_ITEM_IRON_AXE: - case E_ITEM_GOLD_AXE: - case E_ITEM_DIAMOND_AXE: - { - return new cItemAxeHandler(a_ItemType); - } - - case E_ITEM_WOODEN_SWORD: - case E_ITEM_STONE_SWORD: - case E_ITEM_IRON_SWORD: - case E_ITEM_GOLD_SWORD: - case E_ITEM_DIAMOND_SWORD: - { - return new cItemSwordHandler(a_ItemType); - } - - case E_ITEM_BUCKET: - case E_ITEM_WATER_BUCKET: - case E_ITEM_LAVA_BUCKET: - { - return new cItemBucketHandler(a_ItemType); - } - - case E_ITEM_BEETROOT_SEEDS: - case E_ITEM_MELON_SEEDS: - case E_ITEM_PUMPKIN_SEEDS: - case E_ITEM_SEEDS: - { - return new cItemSeedsHandler(a_ItemType); - } - - case E_ITEM_POTATO: return new cItemFoodSeedsHandler(a_ItemType, FoodInfo(1, 0.6)); - case E_ITEM_CARROT: return new cItemFoodSeedsHandler(a_ItemType, FoodInfo(3, 6.6)); - - case E_ITEM_ACACIA_DOOR: - case E_ITEM_BIRCH_DOOR: - case E_ITEM_DARK_OAK_DOOR: - case E_ITEM_JUNGLE_DOOR: - case E_ITEM_SPRUCE_DOOR: - case E_ITEM_IRON_DOOR: - case E_ITEM_WOODEN_DOOR: - { - return new cItemDoorHandler(a_ItemType); - } - - case E_ITEM_MINECART: - case E_ITEM_CHEST_MINECART: - case E_ITEM_FURNACE_MINECART: - case E_ITEM_MINECART_WITH_TNT: - case E_ITEM_MINECART_WITH_HOPPER: - { - return new cItemMinecartHandler(a_ItemType); - } - - case E_BLOCK_ACACIA_FENCE_GATE: - case E_BLOCK_BIRCH_FENCE_GATE: - case E_BLOCK_DARK_OAK_FENCE_GATE: - case E_BLOCK_JUNGLE_FENCE_GATE: - case E_BLOCK_OAK_FENCE_GATE: - case E_BLOCK_SPRUCE_FENCE_GATE: - { - return new cItemFenceGateHandler(a_ItemType); - } - - case E_BLOCK_ACACIA_WOOD_STAIRS: - case E_BLOCK_BIRCH_WOOD_STAIRS: - case E_BLOCK_BRICK_STAIRS: - case E_BLOCK_COBBLESTONE_STAIRS: - case E_BLOCK_DARK_OAK_WOOD_STAIRS: - case E_BLOCK_JUNGLE_WOOD_STAIRS: - case E_BLOCK_NETHER_BRICK_STAIRS: - case E_BLOCK_OAK_WOOD_STAIRS: - case E_BLOCK_PURPUR_STAIRS: - case E_BLOCK_QUARTZ_STAIRS: - case E_BLOCK_RED_SANDSTONE_STAIRS: - case E_BLOCK_SANDSTONE_STAIRS: - case E_BLOCK_SPRUCE_WOOD_STAIRS: - case E_BLOCK_STONE_BRICK_STAIRS: - { - return new cItemStairsHandler(a_ItemType); - } - - case E_BLOCK_WHITE_GLAZED_TERRACOTTA: - case E_BLOCK_ORANGE_GLAZED_TERRACOTTA: - case E_BLOCK_MAGENTA_GLAZED_TERRACOTTA: - case E_BLOCK_LIGHT_BLUE_GLAZED_TERRACOTTA: - case E_BLOCK_YELLOW_GLAZED_TERRACOTTA: - case E_BLOCK_LIME_GLAZED_TERRACOTTA: - case E_BLOCK_PINK_GLAZED_TERRACOTTA: - case E_BLOCK_GRAY_GLAZED_TERRACOTTA: - case E_BLOCK_LIGHT_GRAY_GLAZED_TERRACOTTA: - case E_BLOCK_CYAN_GLAZED_TERRACOTTA: - case E_BLOCK_PURPLE_GLAZED_TERRACOTTA: - case E_BLOCK_BLUE_GLAZED_TERRACOTTA: - case E_BLOCK_BROWN_GLAZED_TERRACOTTA: - case E_BLOCK_GREEN_GLAZED_TERRACOTTA: - case E_BLOCK_RED_GLAZED_TERRACOTTA: - case E_BLOCK_BLACK_GLAZED_TERRACOTTA: - { - return new cItemGlazedTerracottaHandler(a_ItemType); - } - - // Food (please keep alpha-sorted): - case E_ITEM_BAKED_POTATO: return new cItemFoodHandler(a_ItemType, FoodInfo(5, 6)); - case E_ITEM_BEETROOT: return new cItemFoodHandler(a_ItemType, FoodInfo(1, 1.2)); - case E_ITEM_BREAD: return new cItemFoodHandler(a_ItemType, FoodInfo(5, 6)); - case E_ITEM_COOKED_CHICKEN: return new cItemFoodHandler(a_ItemType, FoodInfo(6, 7.2)); - case E_ITEM_COOKED_MUTTON: return new cItemFoodHandler(a_ItemType, FoodInfo(6, 9.6)); - case E_ITEM_COOKED_PORKCHOP: return new cItemFoodHandler(a_ItemType, FoodInfo(8, 12.8)); - case E_ITEM_COOKED_RABBIT: return new cItemFoodHandler(a_ItemType, FoodInfo(5, 6)); - case E_ITEM_COOKIE: return new cItemFoodHandler(a_ItemType, FoodInfo(2, 0.5)); - case E_ITEM_GOLDEN_CARROT: return new cItemFoodHandler(a_ItemType, FoodInfo(6, 14.4)); - case E_ITEM_MELON_SLICE: return new cItemFoodHandler(a_ItemType, FoodInfo(2, 1.2)); - case E_ITEM_PUMPKIN_PIE: return new cItemFoodHandler(a_ItemType, FoodInfo(8, 4.8)); - case E_ITEM_RED_APPLE: return new cItemFoodHandler(a_ItemType, FoodInfo(4, 2.4)); - case E_ITEM_RAW_BEEF: return new cItemFoodHandler(a_ItemType, FoodInfo(3, 1.8)); - case E_ITEM_RAW_MUTTON: return new cItemFoodHandler(a_ItemType, FoodInfo(2, 1.2)); - case E_ITEM_RAW_PORKCHOP: return new cItemFoodHandler(a_ItemType, FoodInfo(3, 1.8)); - case E_ITEM_RAW_RABBIT: return new cItemFoodHandler(a_ItemType, FoodInfo(3, 1.8)); - case E_ITEM_STEAK: return new cItemFoodHandler(a_ItemType, FoodInfo(8, 12.8)); - - // Special-case food with their own handler - case E_ITEM_CHORUS_FRUIT: return new cItemChorusFruitHandler(); - case E_ITEM_COOKED_FISH: return new cItemCookedFishHandler(); - case E_ITEM_GOLDEN_APPLE: return new cItemGoldenAppleHandler(); - case E_ITEM_POISONOUS_POTATO: return new cItemPoisonousPotatoHandler(); - case E_ITEM_RAW_CHICKEN: return new cItemRawChickenHandler(); - case E_ITEM_RAW_FISH: return new cItemRawFishHandler(); - case E_ITEM_ROTTEN_FLESH: return new cItemRottenFleshHandler(); - case E_ITEM_SPIDER_EYE: return new cItemSpiderEyeHandler(); - - // Soup: - case E_ITEM_BEETROOT_SOUP: return new cItemSoupHandler(a_ItemType, FoodInfo(6, 7.2)); - case E_ITEM_MUSHROOM_SOUP: return new cItemSoupHandler(a_ItemType, FoodInfo(6, 7.2)); - case E_ITEM_RABBIT_STEW: return new cItemSoupHandler(a_ItemType, FoodInfo(10, 12)); - - // Armor: - case E_ITEM_ELYTRA: - case E_ITEM_LEATHER_CAP: - case E_ITEM_GOLD_HELMET: - case E_ITEM_CHAIN_HELMET: - case E_ITEM_IRON_HELMET: - case E_ITEM_DIAMOND_HELMET: - case E_ITEM_LEATHER_TUNIC: - case E_ITEM_GOLD_CHESTPLATE: - case E_ITEM_CHAIN_CHESTPLATE: - case E_ITEM_IRON_CHESTPLATE: - case E_ITEM_DIAMOND_CHESTPLATE: - case E_ITEM_LEATHER_PANTS: - case E_ITEM_GOLD_LEGGINGS: - case E_ITEM_CHAIN_LEGGINGS: - case E_ITEM_IRON_LEGGINGS: - case E_ITEM_DIAMOND_LEGGINGS: - case E_ITEM_LEATHER_BOOTS: - case E_ITEM_GOLD_BOOTS: - case E_ITEM_CHAIN_BOOTS: - case E_ITEM_IRON_BOOTS: - case E_ITEM_DIAMOND_BOOTS: - { - return new cItemArmorHandler(a_ItemType); - } + case E_BLOCK_ACACIA_DOOR: return ItemAcaciaDoorBlockHandler; + case E_BLOCK_ACACIA_FENCE: return ItemAcaciaFenceHandler; + case E_BLOCK_ACACIA_FENCE_GATE: return ItemAcaciaFenceGateHandler; + case E_BLOCK_ACACIA_WOOD_STAIRS: return ItemAcaciaStairsHandler; + case E_BLOCK_ACTIVATOR_RAIL: return ItemActivatorRailHandler; + case E_BLOCK_ACTIVE_COMPARATOR: return ItemActiveComparatorHandler; + case E_BLOCK_AIR: return ItemAirHandler; + case E_BLOCK_ANVIL: return ItemAnvilHandler; + case E_BLOCK_BARRIER: return ItemBarrierHandler; + case E_BLOCK_BEACON: return ItemBeaconHandler; + case E_BLOCK_BED: return ItemBedBlockHandler; + case E_BLOCK_BEDROCK: return ItemBedrockHandler; + case E_BLOCK_BEETROOTS: return ItemBeetrootsBlockHandler; + case E_BLOCK_BIG_FLOWER: return ItemBigFlowerHandler; + case E_BLOCK_BIRCH_DOOR: return ItemBirchDoorBlockHandler; + case E_BLOCK_BIRCH_FENCE: return ItemBirchFenceHandler; + case E_BLOCK_BIRCH_FENCE_GATE: return ItemBirchFenceGateHandler; + case E_BLOCK_BIRCH_WOOD_STAIRS: return ItemBirchStairsHandler; + case E_BLOCK_BLACK_GLAZED_TERRACOTTA: return ItemBlackGlazedTerracottaHandler; + case E_BLOCK_BLACK_SHULKER_BOX: return ItemBlackShulkerBoxHandler; + case E_BLOCK_BLOCK_OF_COAL: return ItemCoalBlockHandler; + case E_BLOCK_BLOCK_OF_REDSTONE: return ItemRedstoneBlockHandler; + case E_BLOCK_BLUE_GLAZED_TERRACOTTA: return ItemBlueGlazedTerracottaHandler; + case E_BLOCK_BLUE_SHULKER_BOX: return ItemBlueShulkerBoxHandler; + case E_BLOCK_BONE_BLOCK: return ItemBoneBlockHandler; + case E_BLOCK_BOOKCASE: return ItemBookshelfHandler; + case E_BLOCK_BREWING_STAND: return ItemBrewingStandBlockHandler; + case E_BLOCK_BRICK: return ItemBrickHandler; + case E_BLOCK_BRICK_STAIRS: return ItemBricksStairsHandler; + case E_BLOCK_BROWN_GLAZED_TERRACOTTA: return ItemBrownGlazedTerracottaHandler; + case E_BLOCK_BROWN_MUSHROOM: return ItemBrownMushroomBlockHandler; + case E_BLOCK_BROWN_SHULKER_BOX: return ItemBrownShulkerBoxHandler; + case E_BLOCK_CACTUS: return ItemCactusHandler; + case E_BLOCK_CAKE: return ItemCakeBlockHandler; + case E_BLOCK_CARPET: return ItemCarpetHandler; + case E_BLOCK_CARROTS: return ItemCarrotsBlockHandler; + case E_BLOCK_CAULDRON: return ItemCauldronBlockHandler; + case E_BLOCK_CHAIN_COMMAND_BLOCK: return ItemChainCommandBlockHandler; + case E_BLOCK_CHEST: return ItemChestBlockHandler; + case E_BLOCK_CHORUS_FLOWER: return ItemChorusFlowerHandler; + case E_BLOCK_CHORUS_PLANT: return ItemChorusPlantHandler; + case E_BLOCK_CLAY: return ItemClayBlockHandler; + case E_BLOCK_COAL_ORE: return ItemCoalOreHandler; + case E_BLOCK_COBBLESTONE: return ItemCobblestoneHandler; + case E_BLOCK_COBBLESTONE_STAIRS: return ItemCobblestoneStairsHandler; + case E_BLOCK_COBBLESTONE_WALL: return ItemCobblestoneWallHandler; + case E_BLOCK_COBWEB: return ItemCobwebHandler; + case E_BLOCK_COCOA_POD: return ItemCocoaPodHandler; + case E_BLOCK_COMMAND_BLOCK: return ItemCommandBlockHandler; + case E_BLOCK_CONCRETE: return ItemConcreteBlockHandler; + case E_BLOCK_CONCRETE_POWDER: return ItemConcretePowderHandler; + case E_BLOCK_CRAFTING_TABLE: return ItemWorkbenchHandler; + case E_BLOCK_CYAN_GLAZED_TERRACOTTA: return ItemCyanGlazedTerracottaHandler; + case E_BLOCK_CYAN_SHULKER_BOX: return ItemCyanShulkerBoxHandler; + case E_BLOCK_DANDELION: return ItemDandelionHandler; + case E_BLOCK_DARK_OAK_DOOR: return ItemDarkOakDoorBlockHandler; + case E_BLOCK_DARK_OAK_FENCE: return ItemDarkOakFenceHandler; + case E_BLOCK_DARK_OAK_FENCE_GATE: return ItemDarkOakFenceGateHandler; + case E_BLOCK_DARK_OAK_WOOD_STAIRS: return ItemDarkOakStairsHandler; + case E_BLOCK_DAYLIGHT_SENSOR: return ItemDaylightSensorBlockHandler; + case E_BLOCK_DEAD_BUSH: return ItemDeadBushHandler; + case E_BLOCK_DETECTOR_RAIL: return ItemDetectorRailHandler; + case E_BLOCK_DIAMOND_BLOCK: return ItemDiamondBlockHandler; + case E_BLOCK_DIAMOND_ORE: return ItemDiamondOreHandler; + case E_BLOCK_DIRT: return ItemDirtHandler; + case E_BLOCK_DISPENSER: return ItemDispenserHandler; + case E_BLOCK_DOUBLE_RED_SANDSTONE_SLAB: return ItemDoubleRedSandstoneSlabHandler; + case E_BLOCK_DOUBLE_STONE_SLAB: return ItemDoubleStoneSlabHandler; + case E_BLOCK_DOUBLE_WOODEN_SLAB: return ItemDoubleOakSlabHandler; + case E_BLOCK_DRAGON_EGG: return ItemDragonEggBlockHandler; + case E_BLOCK_DROPPER: return ItemDropperHandler; + case E_BLOCK_EMERALD_BLOCK: return ItemEmeraldBlockHandler; + case E_BLOCK_EMERALD_ORE: return ItemEmeraldOreHandler; + case E_BLOCK_ENCHANTMENT_TABLE: return ItemEnchantingTableHandler; + case E_BLOCK_ENDER_CHEST: return ItemEnderchestHandler; + case E_BLOCK_END_BRICKS: return ItemEndBricksHandler; + case E_BLOCK_END_GATEWAY: return ItemEndGatewayHandler; + case E_BLOCK_END_PORTAL: return ItemEndPortalBlockHandler; + case E_BLOCK_END_PORTAL_FRAME: return ItemEndPortalFrameHandler; + case E_BLOCK_END_ROD: return ItemEndRodHandler; + case E_BLOCK_END_STONE: return ItemEndStoneBlockHandler; + case E_BLOCK_FARMLAND: return ItemFarmlandHandler; + case E_BLOCK_FENCE: return ItemOakFenceHandler; + case E_BLOCK_FIRE: return ItemFireBlockHandler; + case E_BLOCK_FLOWER: return ItemPoppyHandler; + case E_BLOCK_FLOWER_POT: return ItemFlowerPotBlockHandler; + case E_BLOCK_FROSTED_ICE: return ItemFrostedIceHandler; + case E_BLOCK_FURNACE: return ItemFurnaceHandler; + case E_BLOCK_GLASS: return ItemGlassHandler; + case E_BLOCK_GLASS_PANE: return ItemGlassPaneBlockHandler; + case E_BLOCK_GLOWSTONE: return ItemGlowstoneBlockHandler; + case E_BLOCK_GOLD_BLOCK: return ItemGoldBlockHandler; + case E_BLOCK_GOLD_ORE: return ItemGoldOreHandler; + case E_BLOCK_GRASS: return ItemGrassBlockHandler; + case E_BLOCK_GRASS_PATH: return ItemGrassPathHandler; + case E_BLOCK_GRAVEL: return ItemGravelHandler; + case E_BLOCK_GRAY_GLAZED_TERRACOTTA: return ItemGrayGlazedTerracottaHandler; + case E_BLOCK_GRAY_SHULKER_BOX: return ItemGrayShulkerBoxHandler; + case E_BLOCK_GREEN_GLAZED_TERRACOTTA: return ItemGreenGlazedTerracottaHandler; + case E_BLOCK_GREEN_SHULKER_BOX: return ItemGreenShulkerBoxHandler; + case E_BLOCK_HARDENED_CLAY: return ItemHardenedClayHandler; + case E_BLOCK_HAY_BALE: return ItemHayBaleHandler; + case E_BLOCK_HEAD: return ItemHeadBlockHandler; + case E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE: return ItemHeavyWeightedPressurePlateBlockHandler; + case E_BLOCK_HOPPER: return ItemHopperHandler; + case E_BLOCK_HUGE_BROWN_MUSHROOM: return ItemHugeBrownMushroomBlockHandler; + case E_BLOCK_HUGE_RED_MUSHROOM: return ItemHugeRedMushroomBlockHandler; + case E_BLOCK_ICE: return ItemIceHandler; + case E_BLOCK_INACTIVE_COMPARATOR: return ItemInactiveComparatorHandler; + case E_BLOCK_INVERTED_DAYLIGHT_SENSOR: return ItemInvertedDaylightSensorHandler; + case E_BLOCK_IRON_BARS: return ItemIronBarsBlockHandler; + case E_BLOCK_IRON_BLOCK: return ItemIronBlockHandler; + case E_BLOCK_IRON_DOOR: return ItemIronDoorBlockHandler; + case E_BLOCK_IRON_ORE: return ItemIronOreHandler; + case E_BLOCK_IRON_TRAPDOOR: return ItemIronTrapdoorHandler; + case E_BLOCK_JACK_O_LANTERN: return ItemJackOLanternHandler; + case E_BLOCK_JUKEBOX: return ItemJukeboxHandler; + case E_BLOCK_JUNGLE_DOOR: return ItemJungleDoorBlockHandler; + case E_BLOCK_JUNGLE_FENCE: return ItemJungleFenceHandler; + case E_BLOCK_JUNGLE_FENCE_GATE: return ItemJungleFenceGateHandler; + case E_BLOCK_JUNGLE_WOOD_STAIRS: return ItemJungleStairsHandler; + case E_BLOCK_LADDER: return ItemLadderHandler; + case E_BLOCK_LAPIS_BLOCK: return ItemLapisBlockHandler; + case E_BLOCK_LAPIS_ORE: return ItemLapisOreHandler; + case E_BLOCK_LAVA: return ItemLavaHandler; + case E_BLOCK_LEAVES: return ItemLeavesHandler; + case E_BLOCK_LEVER: return ItemLeverHandler; + case E_BLOCK_LIGHT_BLUE_GLAZED_TERRACOTTA: return ItemLightBlueGlazedTerracottaHandler; + case E_BLOCK_LIGHT_BLUE_SHULKER_BOX: return ItemLightBlueShulkerBoxHandler; + case E_BLOCK_LIGHT_GRAY_GLAZED_TERRACOTTA: return ItemLightGrayGlazedTerracottaHandler; + case E_BLOCK_LIGHT_GRAY_SHULKER_BOX: return ItemLightGrayShulkerBoxHandler; + case E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE: return ItemLightWeightedPressurePlateBlockHandler; + case E_BLOCK_LILY_PAD: return ItemLilypadHandler; + case E_BLOCK_LIME_GLAZED_TERRACOTTA: return ItemLimeGlazedTerracottaHandler; + case E_BLOCK_LIME_SHULKER_BOX: return ItemLimeShulkerBoxHandler; + case E_BLOCK_LIT_FURNACE: return ItemLitFurnaceHandler; + case E_BLOCK_LOG: return ItemLogHandler; + case E_BLOCK_MAGENTA_GLAZED_TERRACOTTA: return ItemMagentaGlazedTerracottaHandler; + case E_BLOCK_MAGENTA_SHULKER_BOX: return ItemMagentaShulkerBoxHandler; + case E_BLOCK_MAGMA: return ItemMagmaBlockHandler; + case E_BLOCK_MELON: return ItemMelonBlockHandler; + case E_BLOCK_MELON_STEM: return ItemMelonStemHandler; + case E_BLOCK_MOB_SPAWNER: return ItemMobSpawnerBlockHandler; + case E_BLOCK_MOSSY_COBBLESTONE: return ItemMossyCobblestoneHandler; + case E_BLOCK_MYCELIUM: return ItemMyceliumHandler; + case E_BLOCK_NETHERRACK: return ItemNetherrackHandler; + case E_BLOCK_NETHER_BRICK: return ItemNetherBrickBlockHandler; + case E_BLOCK_NETHER_BRICK_FENCE: return ItemNetherBrickFenceBlockHandler; + case E_BLOCK_NETHER_BRICK_STAIRS: return ItemNetherBrickStairsHandler; + case E_BLOCK_NETHER_PORTAL: return ItemNetherPortalBlockHandler; + case E_BLOCK_NETHER_QUARTZ_ORE: return ItemNetherQuartzOreHandler; + case E_BLOCK_NETHER_WART: return ItemNetherWartBlockHandler; + case E_BLOCK_NETHER_WART_BLOCK: return ItemNetherWartBlockBlockHandler; + case E_BLOCK_NEW_LEAVES: return ItemNewLeavesHandler; + case E_BLOCK_NEW_LOG: return ItemNewLogHandler; + case E_BLOCK_NOTE_BLOCK: return ItemNoteBlockHandler; + case E_BLOCK_OAK_DOOR: return ItemOakDoorBlockHandler; + case E_BLOCK_OAK_FENCE_GATE: return ItemOakFenceGateHandler; + case E_BLOCK_OAK_WOOD_STAIRS: return ItemOakStairsHandler; + case E_BLOCK_OBSERVER: return ItemObserverHandler; + case E_BLOCK_OBSIDIAN: return ItemObsidianHandler; + case E_BLOCK_ORANGE_GLAZED_TERRACOTTA: return ItemOrangeGlazedTerracottaHandler; + case E_BLOCK_ORANGE_SHULKER_BOX: return ItemOrangeShulkerBoxHandler; + case E_BLOCK_PACKED_ICE: return ItemPackedIceHandler; + case E_BLOCK_PINK_GLAZED_TERRACOTTA: return ItemPinkGlazedTerracottaHandler; + case E_BLOCK_PINK_SHULKER_BOX: return ItemPinkShulkerBoxHandler; + case E_BLOCK_PISTON: return ItemPistonHandler; + case E_BLOCK_PISTON_EXTENSION: return ItemPistonExtensionHandler; + case E_BLOCK_PISTON_MOVED_BLOCK: return ItemPistonMovedBlockHandler; + case E_BLOCK_PLANKS: return ItemPlanksHandler; + case E_BLOCK_POTATOES: return ItemPotatoesBlockHandler; + case E_BLOCK_POWERED_RAIL: return ItemPoweredRailHandler; + case E_BLOCK_PRISMARINE_BLOCK: return ItemPrismarineBlockHandler; + case E_BLOCK_PUMPKIN: return ItemPumpkinHandler; + case E_BLOCK_PUMPKIN_STEM: return ItemPumpkinStemHandler; + case E_BLOCK_PURPLE_GLAZED_TERRACOTTA: return ItemPurpleGlazedTerracottaHandler; + case E_BLOCK_PURPLE_SHULKER_BOX: return ItemPurpleShulkerBoxHandler; + case E_BLOCK_PURPUR_BLOCK: return ItemPurpurBlockHandler; + case E_BLOCK_PURPUR_DOUBLE_SLAB: return ItemPurpurDoubleSlabHandler; + case E_BLOCK_PURPUR_PILLAR: return ItemPurpurPillarHandler; + case E_BLOCK_PURPUR_SLAB: return ItemPurpurSlabHandler; + case E_BLOCK_PURPUR_STAIRS: return ItemPurpurStairsHandler; + case E_BLOCK_QUARTZ_BLOCK: return ItemQuartzBlockHandler; + case E_BLOCK_QUARTZ_STAIRS: return ItemQuartzStairsHandler; + case E_BLOCK_RAIL: return ItemRailHandler; + case E_BLOCK_REDSTONE_LAMP_OFF: return ItemRedstoneLampOffHandler; + case E_BLOCK_REDSTONE_LAMP_ON: return ItemRedstoneLampOnHandler; + case E_BLOCK_REDSTONE_ORE: return ItemRedstoneOreHandler; + case E_BLOCK_REDSTONE_ORE_GLOWING: return ItemRedstoneOreGlowingHandler; + case E_BLOCK_REDSTONE_REPEATER_OFF: return ItemRedstoneRepeaterOffHandler; + case E_BLOCK_REDSTONE_REPEATER_ON: return ItemRedstoneRepeaterOnHandler; + case E_BLOCK_REDSTONE_TORCH_OFF: return ItemRedstoneTorchOffBlockHandler; + case E_BLOCK_REDSTONE_TORCH_ON: return ItemRedstoneTorchHandler; + case E_BLOCK_REDSTONE_WIRE: return ItemRedstoneWireHandler; + case E_BLOCK_RED_GLAZED_TERRACOTTA: return ItemRedGlazedTerracottaHandler; + case E_BLOCK_RED_MUSHROOM: return ItemRedMushroomBlockHandler; + case E_BLOCK_RED_NETHER_BRICK: return ItemRedNetherBricksHandler; + case E_BLOCK_RED_SANDSTONE: return ItemRedSandstoneHandler; + case E_BLOCK_RED_SANDSTONE_SLAB: return ItemRedSandstoneSlabHandler; + case E_BLOCK_RED_SANDSTONE_STAIRS: return ItemRedSandstoneStairsHandler; + case E_BLOCK_RED_SHULKER_BOX: return ItemRedShulkerBoxHandler; + case E_BLOCK_REPEATING_COMMAND_BLOCK: return ItemRepeatingCommandBlockHandler; + case E_BLOCK_SAND: return ItemSandHandler; + case E_BLOCK_SANDSTONE: return ItemSandstoneHandler; + case E_BLOCK_SANDSTONE_STAIRS: return ItemSandstoneStairsHandler; + case E_BLOCK_SAPLING: return ItemSaplingHandler; + case E_BLOCK_SEA_LANTERN: return ItemSeaLanternHandler; + case E_BLOCK_SIGN_POST: return ItemSignPostHandler; + case E_BLOCK_SILVERFISH_EGG: return ItemSilverfishEggBlockHandler; + case E_BLOCK_SLIME_BLOCK: return ItemSlimeBlockHandler; + case E_BLOCK_SNOW: return ItemSnowHandler; + case E_BLOCK_SNOW_BLOCK: return ItemSnowBlockHandler; + case E_BLOCK_SOULSAND: return ItemSoulsandHandler; + case E_BLOCK_SPONGE: return ItemSpongeHandler; + case E_BLOCK_SPRUCE_DOOR: return ItemSpruceDoorBlockHandler; + case E_BLOCK_SPRUCE_FENCE: return ItemSpruceFenceHandler; + case E_BLOCK_SPRUCE_FENCE_GATE: return ItemSpruceFenceGateHandler; + case E_BLOCK_SPRUCE_WOOD_STAIRS: return ItemSpruceStairsHandler; + case E_BLOCK_STAINED_GLASS: return ItemStainedGlassHandler; + case E_BLOCK_STAINED_GLASS_PANE: return ItemStainedGlassPaneHandler; + case E_BLOCK_STANDING_BANNER: return ItemStandingBannerHandler; + case E_BLOCK_STATIONARY_LAVA : return ItemStationaryLavaHandler; + case E_BLOCK_STATIONARY_WATER: return ItemStationaryWaterHandler; + case E_BLOCK_STICKY_PISTON: return ItemStickyPistonHandler; + case E_BLOCK_STONE: return ItemStoneHandler; + case E_BLOCK_STONE_BRICKS: return ItemStoneBricksHandler; + case E_BLOCK_STONE_BRICK_STAIRS: return ItemStoneBrickStairsHandler; + case E_BLOCK_STONE_BUTTON: return ItemStoneButtonHandler; + case E_BLOCK_STONE_PRESSURE_PLATE: return ItemStonePressurePlateBlockHandler; + case E_BLOCK_STONE_SLAB: return ItemStoneSlabHandler; + case E_BLOCK_STRUCTURE_BLOCK: return ItemStructureBlockHandler; + case E_BLOCK_STRUCTURE_VOID: return ItemStructureVoidHandler; + case E_BLOCK_SUGARCANE: return ItemSugarcaneHandler; + case E_BLOCK_TALL_GRASS: return ItemTallGrassHandler; + case E_BLOCK_TERRACOTTA: return ItemTerracottaHandler; + case E_BLOCK_TNT: return ItemTNTBlockHandler; + case E_BLOCK_TORCH: return ItemTorchBlockHandler; + case E_BLOCK_TRAPDOOR: return ItemOakTrapdoorHandler; + case E_BLOCK_TRAPPED_CHEST: return ItemTrappedChestHandler; + case E_BLOCK_TRIPWIRE: return ItemTripwireHandler; + case E_BLOCK_TRIPWIRE_HOOK: return ItemTripwireHookHandler; + case E_BLOCK_VINES: return ItemVineHandler; + case E_BLOCK_WALLSIGN: return ItemWallsignHandler; + case E_BLOCK_WALL_BANNER: return ItemWallBannerHandler; + case E_BLOCK_WATER: return ItemWaterHandler; + case E_BLOCK_WHEAT: return ItemWheatBlockHandler; + case E_BLOCK_WHITE_GLAZED_TERRACOTTA: return ItemWhiteGlazedTerracottaHandler; + case E_BLOCK_WHITE_SHULKER_BOX: return ItemWhiteShulkerBoxHandler; + case E_BLOCK_WOODEN_BUTTON: return ItemOakButtonHandler; + case E_BLOCK_WOODEN_PRESSURE_PLATE: return ItemWoodenPressurePlateBlockHandler; + case E_BLOCK_WOODEN_SLAB: return ItemOakSlabHandler; + case E_BLOCK_WOOL: return ItemWoolHandler; + case E_BLOCK_YELLOW_GLAZED_TERRACOTTA: return ItemYellowGlazedTerracottaHandler; + case E_BLOCK_YELLOW_SHULKER_BOX: return ItemYellowShulkerBoxHandler; + case E_ITEM_11_DISC: return Item11DiscHandler; + case E_ITEM_13_DISC: return Item13DiscHandler; + case E_ITEM_ACACIA_BOAT: return ItemAcaciaBoatHandler; + case E_ITEM_ACACIA_DOOR: return ItemAcaciaDoorHandler; + case E_ITEM_ARMOR_STAND: return ItemArmorStandHandler; + case E_ITEM_ARROW: return ItemArrowHandler; + case E_ITEM_BAKED_POTATO: return ItemBakedPotatoHandler; + case E_ITEM_BANNER: return ItemBannerHandler; + case E_ITEM_BED: return ItemBedHandler; + case E_ITEM_BEETROOT: return ItemBeetrootHandler; + case E_ITEM_BEETROOT_SEEDS: return ItemBeetrootSeedsHandler; + case E_ITEM_BEETROOT_SOUP: return ItemBeetrootSoupHandler; + case E_ITEM_BIRCH_BOAT: return ItemBirchBoatHandler; + case E_ITEM_BIRCH_DOOR: return ItemBirchDoorHandler; + case E_ITEM_BLAZE_POWDER: return ItemBlazePowderHandler; + case E_ITEM_BLAZE_ROD: return ItemBlazeRodHandler; + case E_ITEM_BLOCKS_DISC: return ItemBlocksDiscHandler; + case E_ITEM_BOAT: return ItemOakBoatHandler; + case E_ITEM_BONE: return ItemBoneHandler; + case E_ITEM_BOOK: return ItemBookHandler; + case E_ITEM_BOOK_AND_QUILL: return ItemBookAndQuillHandler; + case E_ITEM_BOTTLE_O_ENCHANTING: return ItemBottleOEnchantingHandler; + case E_ITEM_BOW: return ItemBowHandler; + case E_ITEM_BOWL: return ItemBowlHandler; + case E_ITEM_BREAD: return ItemBreadHandler; + case E_ITEM_BREWING_STAND: return ItemBrewingStandHandler; + case E_ITEM_BUCKET: return ItemBucketHandler; + case E_ITEM_CAKE: return ItemCakeHandler; + case E_ITEM_CARROT: return ItemCarrotHandler; + case E_ITEM_CARROT_ON_STICK: return ItemCarrotOnStickHandler; + case E_ITEM_CAT_DISC: return ItemCatDiscHandler; + case E_ITEM_CAULDRON: return ItemCauldronHandler; + case E_ITEM_CHAIN_BOOTS: return ItemChainBootsHandler; + case E_ITEM_CHAIN_CHESTPLATE: return ItemChainChestplateHandler; + case E_ITEM_CHAIN_HELMET: return ItemChainHelmetHandler; + case E_ITEM_CHAIN_LEGGINGS: return ItemChainLeggingsHandler; + case E_ITEM_CHEST_MINECART: return ItemChestMinecartHandler; + case E_ITEM_CHIRP_DISC: return ItemChirpDiscHandler; + case E_ITEM_CHORUS_FRUIT: return ItemChorusFruitHandler; + case E_ITEM_CLAY: return ItemClayHandler; + case E_ITEM_CLAY_BRICK: return ItemBricksHandler; + case E_ITEM_CLOCK: return ItemClockHandler; + case E_ITEM_COAL: return ItemCoalHandler; + case E_ITEM_COMPARATOR: return ItemComparatorHandler; + case E_ITEM_COMPASS: return ItemCompassHandler; + case E_ITEM_COOKED_CHICKEN: return ItemCookedChickenHandler; + case E_ITEM_COOKED_FISH: return ItemCookedFishHandler; + case E_ITEM_COOKED_MUTTON: return ItemCookedMuttonHandler; + case E_ITEM_COOKED_PORKCHOP: return ItemCookedPorkchopHandler; + case E_ITEM_COOKED_RABBIT: return ItemCookedRabbitHandler; + case E_ITEM_COOKIE: return ItemCookieHandler; + case E_ITEM_DARK_OAK_BOAT: return ItemDarkOakBoatHandler; + case E_ITEM_DARK_OAK_DOOR: return ItemDarkOakDoorHandler; + case E_ITEM_DIAMOND: return ItemDiamondHandler; + case E_ITEM_DIAMOND_AXE: return ItemDiamondAxeHandler; + case E_ITEM_DIAMOND_BOOTS: return ItemDiamondBootsHandler; + case E_ITEM_DIAMOND_CHESTPLATE: return ItemDiamondChestplateHandler; + case E_ITEM_DIAMOND_HELMET: return ItemDiamondHelmetHandler; + case E_ITEM_DIAMOND_HOE: return ItemDiamondHoeHandler; + case E_ITEM_DIAMOND_HORSE_ARMOR: return ItemDiamondHorseArmorHandler; + case E_ITEM_DIAMOND_LEGGINGS: return ItemDiamondLeggingsHandler; + case E_ITEM_DIAMOND_PICKAXE: return ItemDiamondPickaxeHandler; + case E_ITEM_DIAMOND_SHOVEL: return ItemDiamondShovelHandler; + case E_ITEM_DIAMOND_SWORD: return ItemDiamondSwordHandler; + case E_ITEM_DRAGON_BREATH: return ItemDragonBreathHandler; + case E_ITEM_DYE: return ItemDyeHandler; + case E_ITEM_EGG: return ItemEggHandler; + case E_ITEM_ELYTRA: return ItemElytraHandler; + case E_ITEM_EMERALD: return ItemEmeraldHandler; + case E_ITEM_EMPTY_MAP: return ItemEmptyMapHandler; + case E_ITEM_ENCHANTED_BOOK: return ItemEnchantedBookHandler; + case E_ITEM_ENDER_PEARL: return ItemEnderPearlHandler; + case E_ITEM_END_CRYSTAL: return ItemEndCrystalHandler; + case E_ITEM_EYE_OF_ENDER: return ItemEyeOfEnderHandler; + case E_ITEM_FAR_DISC: return ItemFarDiscHandler; + case E_ITEM_FEATHER: return ItemFeatherHandler; + case E_ITEM_FERMENTED_SPIDER_EYE: return ItemFermentedSpiderEyeHandler; + case E_ITEM_FIREWORK_ROCKET: return ItemFireworkRocketHandler; + case E_ITEM_FIREWORK_STAR: return ItemFireworkStarHandler; + case E_ITEM_FIRE_CHARGE: return ItemFireChargeHandler; + case E_ITEM_FISHING_ROD: return ItemFishingRodHandler; + case E_ITEM_FLINT: return ItemFlintHandler; + case E_ITEM_FLINT_AND_STEEL: return ItemFlintAndSteelHandler; + case E_ITEM_FLOWER_POT: return ItemFlowerPotHandler; + case E_ITEM_FURNACE_MINECART: return ItemFurnaceMinecartHandler; + case E_ITEM_GHAST_TEAR: return ItemGhastTearHandler; + case E_ITEM_GLASS_BOTTLE: return ItemGlassBottleHandler; + case E_ITEM_GLISTERING_MELON: return ItemGlisteringMelonHandler; + case E_ITEM_GLOWSTONE_DUST: return ItemGlowstoneDustHandler; + case E_ITEM_GOLD: return ItemGoldHandler; + case E_ITEM_GOLDEN_APPLE: return ItemGoldenAppleHandler; + case E_ITEM_GOLDEN_CARROT: return ItemGoldenCarrotHandler; + case E_ITEM_GOLD_AXE: return ItemGoldenAxeHandler; + case E_ITEM_GOLD_BOOTS: return ItemGoldenBootsHandler; + case E_ITEM_GOLD_CHESTPLATE: return ItemGoldenChestplateHandler; + case E_ITEM_GOLD_HELMET: return ItemGoldenHelmetHandler; + case E_ITEM_GOLD_HOE: return ItemGoldenHoeHandler; + case E_ITEM_GOLD_HORSE_ARMOR: return ItemGoldenHorseArmorHandler; + case E_ITEM_GOLD_LEGGINGS: return ItemGoldenLeggingsHandler; + case E_ITEM_GOLD_NUGGET: return ItemGoldNuggetHandler; + case E_ITEM_GOLD_PICKAXE: return ItemGoldenPickaxeHandler; + case E_ITEM_GOLD_SHOVEL: return ItemGoldenShovelHandler; + case E_ITEM_GOLD_SWORD: return ItemGoldenSwordHandler; + case E_ITEM_GUNPOWDER: return ItemGunpowderHandler; + case E_ITEM_HEAD: return ItemHeadHandler; + case E_ITEM_IRON: return ItemIronHandler; + case E_ITEM_IRON_AXE: return ItemIronAxeHandler; + case E_ITEM_IRON_BOOTS: return ItemIronBootsHandler; + case E_ITEM_IRON_CHESTPLATE: return ItemIronChestplateHandler; + case E_ITEM_IRON_DOOR: return ItemIronDoorHandler; + case E_ITEM_IRON_HELMET: return ItemIronHelmetHandler; + case E_ITEM_IRON_HOE: return ItemIronHoeHandler; + case E_ITEM_IRON_HORSE_ARMOR: return ItemIronHorseArmorHandler; + case E_ITEM_IRON_LEGGINGS: return ItemIronLeggingsHandler; + case E_ITEM_IRON_NUGGET: return ItemIronNuggetHandler; + case E_ITEM_IRON_PICKAXE: return ItemIronPickaxeHandler; + case E_ITEM_IRON_SHOVEL: return ItemIronShovelHandler; + case E_ITEM_IRON_SWORD: return ItemIronSwordHandler; + case E_ITEM_ITEM_FRAME: return ItemItemFrameHandler; + case E_ITEM_JUNGLE_BOAT: return ItemJungleBoatHandler; + case E_ITEM_JUNGLE_DOOR: return ItemJungleDoorHandler; + case E_ITEM_LAVA_BUCKET: return ItemLavaBucketHandler; + case E_ITEM_LEASH: return ItemLeashHandler; + case E_ITEM_LEATHER: return ItemLeatherHandler; + case E_ITEM_LEATHER_BOOTS: return ItemLeatherBootsHandler; + case E_ITEM_LEATHER_CAP: return ItemLeatherCapHandler; + case E_ITEM_LEATHER_PANTS: return ItemLeatherPantsHandler; + case E_ITEM_LEATHER_TUNIC: return ItemLeatherTunicHandler; + case E_ITEM_LINGERING_POTION: return ItemLingeringPotionHandler; + case E_ITEM_MAGMA_CREAM: return ItemMagmaCreamHandler; + case E_ITEM_MALL_DISC: return ItemMallDiscHandler; + case E_ITEM_MAP: return ItemMapHandler; + case E_ITEM_MELLOHI_DISC: return ItemMellohiDiscHandler; + case E_ITEM_MELON_SEEDS: return ItemMelonSeedsHandler; + case E_ITEM_MELON_SLICE: return ItemMelonSliceHandler; + case E_ITEM_MILK: return ItemMilkHandler; + case E_ITEM_MINECART: return ItemMinecartHandler; + case E_ITEM_MINECART_WITH_COMMAND_BLOCK: return ItemMinecartWithCommandBlockHandler; + case E_ITEM_MINECART_WITH_HOPPER: return ItemMinecartWithHopperHandler; + case E_ITEM_MINECART_WITH_TNT: return ItemMinecartWithTNTHandler; + case E_ITEM_MUSHROOM_SOUP: return ItemMushroomSoupHandler; + case E_ITEM_NAME_TAG: return ItemNameTagHandler; + case E_ITEM_NETHER_BRICK: return ItemNetherBrickHandler; + case E_ITEM_NETHER_QUARTZ: return ItemNetherQuartzHandler; + case E_ITEM_NETHER_STAR: return ItemNetherStarHandler; + case E_ITEM_NETHER_WART: return ItemNetherWartHandler; + case E_ITEM_PAINTING: return ItemPaintingHandler; + case E_ITEM_PAPER: return ItemPaperHandler; + case E_ITEM_POISONOUS_POTATO: return ItemPoisonousPotatoHandler; + case E_ITEM_POPPED_CHORUS_FRUIT: return ItemPoppedChorusFruitHandler; + case E_ITEM_POTATO: return ItemPotatoHandler; + case E_ITEM_POTION: return ItemPotionHandler; + case E_ITEM_PRISMARINE_CRYSTALS: return ItemPrismarineCrystalsHandler; + case E_ITEM_PRISMARINE_SHARD: return ItemPrismarineShardHandler; + case E_ITEM_PUMPKIN_PIE: return ItemPumpkinPieHandler; + case E_ITEM_PUMPKIN_SEEDS: return ItemPumpkinSeedsHandler; + case E_ITEM_RABBITS_FOOT: return ItemRabbitsFootHandler; + case E_ITEM_RABBIT_HIDE: return ItemRabbitHideHandler; + case E_ITEM_RABBIT_STEW: return ItemRabbitStewHandler; + case E_ITEM_RAW_BEEF: return ItemRawBeefHandler; + case E_ITEM_RAW_CHICKEN: return ItemRawChickenHandler; + case E_ITEM_RAW_FISH: return ItemRawFishHandler; + case E_ITEM_RAW_MUTTON: return ItemRawMuttonHandler; + case E_ITEM_RAW_PORKCHOP: return ItemRawPorkchopHandler; + case E_ITEM_RAW_RABBIT: return ItemRawRabbitHandler; + case E_ITEM_REDSTONE_DUST: return ItemRedstoneDustHandler; + case E_ITEM_REDSTONE_REPEATER: return ItemRedstoneRepeaterHandler; + case E_ITEM_RED_APPLE: return ItemAppleHandler; + case E_ITEM_ROTTEN_FLESH: return ItemRottenFleshHandler; + case E_ITEM_SADDLE: return ItemSaddleHandler; + case E_ITEM_SEEDS: return ItemSeedsHandler; + case E_ITEM_SHEARS: return ItemShearsHandler; + case E_ITEM_SHIELD: return ItemShieldHandler; + case E_ITEM_SHULKER_SHELL: return ItemShulkerShellHandler; + case E_ITEM_SIGN: return ItemSignHandler; + case E_ITEM_SLIMEBALL: return ItemSlimeballHandler; + case E_ITEM_SNOWBALL: return ItemSnowballHandler; + case E_ITEM_SPAWN_EGG: return ItemSpawnEggHandler; + case E_ITEM_SPECTRAL_ARROW: return ItemSpectralArrowHandler; + case E_ITEM_SPIDER_EYE: return ItemSpiderEyeHandler; + case E_ITEM_SPLASH_POTION: return ItemSplashPotionHandler; + case E_ITEM_SPRUCE_BOAT: return ItemSpruceBoatHandler; + case E_ITEM_SPRUCE_DOOR: return ItemSpruceDoorHandler; + case E_ITEM_STAL_DISC: return ItemStalDiscHandler; + case E_ITEM_STEAK: return ItemCookedBeefHandler; + case E_ITEM_STICK: return ItemStickHandler; + case E_ITEM_STONE_AXE: return ItemStoneAxeHandler; + case E_ITEM_STONE_HOE: return ItemStoneHoeHandler; + case E_ITEM_STONE_PICKAXE: return ItemStonePickaxeHandler; + case E_ITEM_STONE_SHOVEL: return ItemStoneShovelHandler; + case E_ITEM_STONE_SWORD: return ItemStoneSwordHandler; + case E_ITEM_STRAD_DISC: return ItemStradDiscHandler; + case E_ITEM_STRING: return ItemStringHandler; + case E_ITEM_SUGAR: return ItemSugarHandler; + case E_ITEM_SUGAR_CANE: return ItemSugarCaneHandler; + case E_ITEM_TIPPED_ARROW: return ItemTippedArrowHandler; + case E_ITEM_TOTEM_OF_UNDYING: return ItemTotemOfUndyingHandler; + case E_ITEM_WAIT_DISC: return ItemWaitDiscHandler; + case E_ITEM_WARD_DISC: return ItemWardDiscHandler; + case E_ITEM_WATER_BUCKET: return ItemWaterBucketHandler; + case E_ITEM_WHEAT: return ItemWheatHandler; + case E_ITEM_WOODEN_DOOR: return ItemOakDoorHandler; + case E_ITEM_WOODEN_AXE: return ItemWoodenAxeHandler; + case E_ITEM_WOODEN_HOE: return ItemWoodenHoeHandler; + case E_ITEM_WOODEN_PICKAXE: return ItemWoodenPickaxeHandler; + case E_ITEM_WOODEN_SHOVEL: return ItemWoodenShovelHandler; + case E_ITEM_WOODEN_SWORD: return ItemWoodenSwordHandler; + case E_ITEM_WRITTEN_BOOK: return ItemWrittenBookHandler; - case E_ITEM_ACACIA_BOAT: - case E_ITEM_BIRCH_BOAT: - case E_ITEM_BOAT: - case E_ITEM_DARK_OAK_BOAT: - case E_ITEM_JUNGLE_BOAT: - case E_ITEM_SPRUCE_BOAT: - { - return new cItemBoatHandler(a_ItemType); - } } + ASSERT("Unknown item type!"); + return ItemAirHandler; } -void cItemHandler::Deinit() -{ - for (size_t i = 0; i < ARRAYCOUNT(m_ItemHandler); i++) - { - delete m_ItemHandler[i]; - m_ItemHandler[i] = nullptr; - } - memset(m_ItemHandler, 0, sizeof(m_ItemHandler)); // Don't leave any dangling pointers around, just in case - m_HandlerInitialized = false; -} - - - - - -cItemHandler::cItemHandler(int a_ItemType) -{ - m_ItemType = a_ItemType; -} - - - - - -void cItemHandler::OnPlayerPlace(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_ClickedBlockPosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) +void cItemHandler::OnPlayerPlace(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_ClickedBlockPosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const { if (a_ClickedBlockFace == BLOCK_FACE_NONE) { @@ -527,7 +1118,7 @@ void cItemHandler::OnPlayerPlace(cPlayer & a_Player, const cItem & a_HeldItem, c bool cItemHandler::OnItemUse( cWorld * a_World, cPlayer * a_Player, cBlockPluginInterface & a_PluginInterface, const cItem & a_Item, const Vector3i a_ClickedBlockPos, eBlockFace a_ClickedBlockFace -) +) const { UNUSED(a_World); UNUSED(a_Player); @@ -549,7 +1140,7 @@ bool cItemHandler::OnDiggingBlock( const cItem & a_HeldItem, const Vector3i a_ClickedBlockPos, eBlockFace a_ClickedBlockFace -) +) const { UNUSED(a_World); UNUSED(a_Player); @@ -564,7 +1155,7 @@ bool cItemHandler::OnDiggingBlock( -void cItemHandler::OnEntityAttack(cPlayer * a_Attacker, cEntity * a_AttackedEntity) +void cItemHandler::OnEntityAttack(cPlayer * a_Attacker, cEntity * a_AttackedEntity) const { UNUSED(a_AttackedEntity); a_Attacker->UseEquippedItem(dlaAttackEntity); @@ -574,7 +1165,7 @@ void cItemHandler::OnEntityAttack(cPlayer * a_Attacker, cEntity * a_AttackedEnti -void cItemHandler::OnFoodEaten(cWorld * a_World, cPlayer * a_Player, cItem * a_Item) +void cItemHandler::OnFoodEaten(cWorld * a_World, cPlayer * a_Player, cItem * a_Item) const { UNUSED(a_World); UNUSED(a_Player); @@ -585,7 +1176,7 @@ void cItemHandler::OnFoodEaten(cWorld * a_World, cPlayer * a_Player, cItem * a_I -short cItemHandler::GetDurabilityLossByAction(eDurabilityLostAction a_Action) +short cItemHandler::GetDurabilityLossByAction(eDurabilityLostAction a_Action) const { UNUSED(a_Action); @@ -596,7 +1187,7 @@ short cItemHandler::GetDurabilityLossByAction(eDurabilityLostAction a_Action) -char cItemHandler::GetMaxStackSize(void) +char cItemHandler::GetMaxStackSize(void) const { if (m_ItemType < 256) { @@ -724,24 +1315,7 @@ char cItemHandler::GetMaxStackSize(void) -bool cItemHandler::IsTool() -{ - // TODO: Rewrite this to list all tools specifically - return - ((m_ItemType >= 256) && (m_ItemType <= 259)) || - (m_ItemType == 261) || - ((m_ItemType >= 267) && (m_ItemType <= 279)) || - ((m_ItemType >= 283) && (m_ItemType <= 286)) || - ((m_ItemType >= 290) && (m_ItemType <= 294)) || - (m_ItemType == 325) || - (m_ItemType == 346); -} - - - - - -bool cItemHandler::IsFood(void) +bool cItemHandler::IsFood(void) const { return false; } @@ -750,7 +1324,7 @@ bool cItemHandler::IsFood(void) -bool cItemHandler::IsDrinkable(short a_ItemDamage) +bool cItemHandler::IsDrinkable(short a_ItemDamage) const { UNUSED(a_ItemDamage); @@ -761,7 +1335,7 @@ bool cItemHandler::IsDrinkable(short a_ItemDamage) -bool cItemHandler::IsPlaceable(void) +bool cItemHandler::IsPlaceable(void) const { // We can place any block that has a corresponding E_BLOCK_TYPE: return (m_ItemType >= 1) && (m_ItemType <= E_BLOCK_MAX_TYPE_ID); @@ -771,7 +1345,7 @@ bool cItemHandler::IsPlaceable(void) -bool cItemHandler::CanRepairWithRawMaterial(short a_ItemType) +bool cItemHandler::CanRepairWithRawMaterial(short a_ItemType) const { UNUSED(a_ItemType); return false; @@ -781,7 +1355,7 @@ bool cItemHandler::CanRepairWithRawMaterial(short a_ItemType) -bool cItemHandler::CanHarvestBlock(BLOCKTYPE a_BlockType) +bool cItemHandler::CanHarvestBlock(BLOCKTYPE a_BlockType) const { switch (a_BlockType) { @@ -884,7 +1458,7 @@ bool cItemHandler::CanHarvestBlock(BLOCKTYPE a_BlockType) -bool cItemHandler::EatItem(cPlayer * a_Player, cItem * a_Item) +bool cItemHandler::EatItem(cPlayer * a_Player, cItem * a_Item) const { auto FoodInfo = GetFoodInfo(a_Item); return a_Player->Feed(FoodInfo.FoodLevel, FoodInfo.Saturation); @@ -894,7 +1468,7 @@ bool cItemHandler::EatItem(cPlayer * a_Player, cItem * a_Item) -cItemHandler::FoodInfo cItemHandler::GetFoodInfo(const cItem * a_Item) +cItemHandler::FoodInfo cItemHandler::GetFoodInfo(const cItem * a_Item) const { UNUSED(a_Item); return FoodInfo(0, 0); @@ -904,7 +1478,7 @@ cItemHandler::FoodInfo cItemHandler::GetFoodInfo(const cItem * a_Item) -float cItemHandler::GetBlockBreakingStrength(BLOCKTYPE a_Block) +float cItemHandler::GetBlockBreakingStrength(BLOCKTYPE a_Block) const { return 1.0f; } @@ -913,7 +1487,7 @@ float cItemHandler::GetBlockBreakingStrength(BLOCKTYPE a_Block) -bool cItemHandler::CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) +bool cItemHandler::CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const { ASSERT(m_ItemType < 256); // Items with IDs above 255 should all be handled by specific handlers. diff --git a/src/Items/ItemHandler.h b/src/Items/ItemHandler.h index 415f7f24f..da573df9a 100644 --- a/src/Items/ItemHandler.h +++ b/src/Items/ItemHandler.h @@ -22,6 +22,8 @@ class cItemHandler { public: + friend class cItem; + /** Actions that may cause durability of an item may be lost, where the magnitude of the loss depends on the specific item used to perform the action */ @@ -32,10 +34,10 @@ public: dlaBreakBlockInstant, }; - cItemHandler(int a_ItemType); + constexpr cItemHandler(int a_ItemType) : m_ItemType(a_ItemType) + { + } - /** Force virtual destructor */ - virtual ~cItemHandler() {} /** Called when the player tries to place the item (right mouse button, IsPlaceable() == true). a_ClickedBlockPos is the (neighbor) block that has been clicked to place this item. @@ -44,7 +46,7 @@ public: The default handler uses GetBlocksToPlace() and places the returned blocks. Override if the item needs advanced processing, such as spawning a mob based on the blocks being placed. If the block placement is refused inside this call, it will automatically revert the client-side changes. */ - void OnPlayerPlace(cPlayer & a_Player, const cItem & a_HeldItem, Vector3i a_ClickedBlockPosition, eBlockFace a_ClickedBlockFace, Vector3i a_CursorPosition); + void OnPlayerPlace(cPlayer & a_Player, const cItem & a_HeldItem, Vector3i a_ClickedBlockPosition, eBlockFace a_ClickedBlockFace, Vector3i a_CursorPosition) const; /** Called when the player tries to use the item (right mouse button). Descendants can return false to abort the usage (default behavior). */ @@ -55,17 +57,17 @@ public: const cItem & a_HeldItem, const Vector3i a_ClickedBlockPos, eBlockFace a_ClickedBlockFace - ); + ) const; /** Called when the client sends the SHOOT status in the lclk packet (releasing the bow). */ - virtual void OnItemShoot(cPlayer *, const Vector3i a_BlockPos, eBlockFace a_BlockFace) + virtual void OnItemShoot(cPlayer *, const Vector3i a_BlockPos, eBlockFace a_BlockFace) const { UNUSED(a_BlockPos); UNUSED(a_BlockFace); } /** Called every tick while the item is on the player's inventory (used by maps, for example) - For now, called only for equipped items */ - virtual void OnUpdate(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item) + virtual void OnUpdate(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item) const { UNUSED(a_World); UNUSED(a_Player); @@ -77,28 +79,28 @@ public: cWorld * a_World, cPlayer * a_Player, const cItem & a_HeldItem, const Vector3i a_ClickedBlockPos, eBlockFace a_ClickedBlockFace - ); + ) const; /** Called when a player attacks an entity with this item in hand. */ - virtual void OnEntityAttack(cPlayer * a_Attacker, cEntity * a_AttackedEntity); + virtual void OnEntityAttack(cPlayer * a_Attacker, cEntity * a_AttackedEntity) const; /** Called after the player has eaten this item. */ - virtual void OnFoodEaten(cWorld *a_World, cPlayer *a_Player, cItem *a_Item); + virtual void OnFoodEaten(cWorld *a_World, cPlayer *a_Player, cItem *a_Item) const; /** Get the durability lost which the item will get, when a specified action was performed. This is only relevant for uses where the damage taken may depend on the item used. */ - virtual short GetDurabilityLossByAction(eDurabilityLostAction a_Action); + virtual short GetDurabilityLossByAction(eDurabilityLostAction a_Action) const; /** Returns the maximum stack size for a given item */ - virtual char GetMaxStackSize(void); + virtual char GetMaxStackSize(void) const; struct FoodInfo { int FoodLevel; double Saturation; - FoodInfo(int a_FoodLevel, double a_Saturation) : + constexpr FoodInfo(int a_FoodLevel, double a_Saturation) : FoodLevel(a_FoodLevel), Saturation(a_Saturation) { @@ -106,53 +108,44 @@ public: } ; /** Returns the FoodInfo for this item. (FoodRecovery and Saturation) */ - virtual FoodInfo GetFoodInfo(const cItem * a_Item); + virtual FoodInfo GetFoodInfo(const cItem * a_Item) const; /** Lets the player eat a selected item. Returns true if the player ate the item */ - virtual bool EatItem(cPlayer * a_Player, cItem * a_Item); - - /** Indicates if this item is a tool */ - virtual bool IsTool(void); + virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) const; /** Indicates if this item is food */ - virtual bool IsFood(void); + virtual bool IsFood(void) const; /** Indicates if this item is drinkable */ - virtual bool IsDrinkable(short a_ItemDamage); + virtual bool IsDrinkable(short a_ItemDamage) const; /** Blocks simply get placed */ - virtual bool IsPlaceable(void); + virtual bool IsPlaceable(void) const; /** Can the anvil repair this item, when a_Item is the second input? */ - virtual bool CanRepairWithRawMaterial(short a_ItemType); + virtual bool CanRepairWithRawMaterial(short a_ItemType) const; /** Returns whether this tool / item can harvest a specific block (e.g. iron pickaxe can harvest diamond ore, but wooden one can't). Defaults to false unless overridden. */ - virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType); + virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType) const; /** Returns the strength to break a specific block. Defaults to 1 unless overriden. */ - virtual float GetBlockBreakingStrength(BLOCKTYPE a_Block); + virtual float GetBlockBreakingStrength(BLOCKTYPE a_Block) const; - static cItemHandler * GetItemHandler(int a_ItemType); - static cItemHandler * GetItemHandler(const cItem & a_Item) { return GetItemHandler(a_Item.m_ItemType); } - - static void Deinit(); protected: - int m_ItemType; - static cItemHandler * CreateItemHandler(int m_ItemType); + static const cItemHandler & For(int a_ItemType); + + ~cItemHandler() = default; + + const int m_ItemType; /** Performs the actual placement of this placeable item. The descendant handler should call a_Player.PlaceBlock(s) supplying correct values for the newly placed block. The default handler uses the stored block type and meta copied from the lowest 4 bits of the player's equipped item's damage value. Handlers return what a_Player.PlaceBlock(s) returns, indicating whether the placement was successful. */ - virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, Vector3i a_PlacePosition, eBlockFace a_ClickedBlockFace, Vector3i a_CursorPosition); - - static cItemHandler * m_ItemHandler[E_ITEM_LAST + 1]; - static bool m_HandlerInitialized; // used to detect if the itemhandlers are initialized + virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, Vector3i a_PlacePosition, eBlockFace a_ClickedBlockFace, Vector3i a_CursorPosition) const; }; -// Short function -inline cItemHandler *ItemHandler(int a_ItemType) { return cItemHandler::GetItemHandler(a_ItemType); } diff --git a/src/Items/ItemHoe.h b/src/Items/ItemHoe.h index b33ab6b90..2bca5f5ca 100644 --- a/src/Items/ItemHoe.h +++ b/src/Items/ItemHoe.h @@ -9,17 +9,14 @@ -class cItemHoeHandler: +class cItemHoeHandler final: public cItemHandler { using Super = cItemHandler; public: - cItemHoeHandler(int a_ItemType): - Super(a_ItemType) - { - } + using Super::Super; @@ -32,7 +29,7 @@ public: const cItem & a_HeldItem, const Vector3i a_ClickedBlockPos, eBlockFace a_ClickedBlockFace - ) override + ) const override { if ((a_ClickedBlockFace == BLOCK_FACE_NONE) || (a_ClickedBlockPos.y >= cChunkDef::Height)) { @@ -71,7 +68,7 @@ public: - virtual short GetDurabilityLossByAction(eDurabilityLostAction a_Action) override + virtual short GetDurabilityLossByAction(eDurabilityLostAction a_Action) const override { switch (a_Action) { diff --git a/src/Items/ItemHopper.h b/src/Items/ItemHopper.h index 2f0651a43..7b010ce5f 100644 --- a/src/Items/ItemHopper.h +++ b/src/Items/ItemHopper.h @@ -7,7 +7,7 @@ -class cItemHopperHandler : +class cItemHopperHandler final : public cItemHandler { using Super = cItemHandler; @@ -33,7 +33,7 @@ private: } - virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) override + virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const override { return a_Player.PlaceBlock(a_PlacePosition, E_BLOCK_HOPPER, BlockFaceToMetaData(a_ClickedBlockFace)); } diff --git a/src/Items/ItemItemFrame.h b/src/Items/ItemItemFrame.h index 0f7a4ee8c..70923c549 100644 --- a/src/Items/ItemItemFrame.h +++ b/src/Items/ItemItemFrame.h @@ -9,17 +9,14 @@ -class cItemItemFrameHandler: +class cItemItemFrameHandler final: public cItemHandler { using Super = cItemHandler; public: - cItemItemFrameHandler(int a_ItemType): - Super(a_ItemType) - { - } + using Super::Super; @@ -32,7 +29,7 @@ public: const cItem & a_HeldItem, const Vector3i a_ClickedBlockPos, eBlockFace a_ClickedBlockFace - ) override + ) const override { // Can only place on a side face: if ((a_ClickedBlockFace == BLOCK_FACE_NONE) || (a_ClickedBlockFace == BLOCK_FACE_YP) || (a_ClickedBlockFace == BLOCK_FACE_YM)) diff --git a/src/Items/ItemJackOLantern.h b/src/Items/ItemJackOLantern.h index 703088013..acd233701 100644 --- a/src/Items/ItemJackOLantern.h +++ b/src/Items/ItemJackOLantern.h @@ -8,7 +8,7 @@ -class cItemJackOLanternHandler : +class cItemJackOLanternHandler final : public cItemHandler { using Super = cItemHandler; @@ -19,7 +19,7 @@ public: private: - virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) override + virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const override { // Re-use the pumpkin converter for lanterns: return a_Player.PlaceBlock(a_PlacePosition, E_BLOCK_JACK_O_LANTERN, cBlockPumpkinHandler::YawToMetaData(a_Player.GetYaw())); diff --git a/src/Items/ItemLadder.h b/src/Items/ItemLadder.h index 67de799c5..a778fee6c 100644 --- a/src/Items/ItemLadder.h +++ b/src/Items/ItemLadder.h @@ -8,7 +8,7 @@ -class cItemLadderHandler : +class cItemLadderHandler final : public cItemHandler { using Super = cItemHandler; @@ -35,7 +35,7 @@ private: } - virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) override + virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const override { const auto & World = *a_Player.GetWorld(); const auto ClickedBlockType = World.GetBlock(AddFaceDirection(a_PlacePosition, a_ClickedBlockFace, true)); diff --git a/src/Items/ItemLeaves.h b/src/Items/ItemLeaves.h index abe2a76cf..b4795bf29 100644 --- a/src/Items/ItemLeaves.h +++ b/src/Items/ItemLeaves.h @@ -7,23 +7,20 @@ -class cItemLeavesHandler: +class cItemLeavesHandler final : public cItemHandler { using Super = cItemHandler; public: - cItemLeavesHandler(int a_ItemType): - Super(a_ItemType) - { - } + using Super::Super; - virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) override + virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const override { return a_Player.PlaceBlock( a_PlacePosition, diff --git a/src/Items/ItemLever.h b/src/Items/ItemLever.h index 66c83f485..e3791e460 100644 --- a/src/Items/ItemLever.h +++ b/src/Items/ItemLever.h @@ -7,7 +7,7 @@ -class cItemLeverHandler : +class cItemLeverHandler final : public cItemHandler { using Super = cItemHandler; @@ -36,7 +36,7 @@ private: } - virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) override + virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const override { return a_Player.PlaceBlock(a_PlacePosition, static_cast(a_HeldItem.m_ItemType), BlockFaceToMetaData(a_ClickedBlockFace)); } diff --git a/src/Items/ItemLighter.h b/src/Items/ItemLighter.h index 3fd8f3846..3e7d3e78f 100644 --- a/src/Items/ItemLighter.h +++ b/src/Items/ItemLighter.h @@ -9,17 +9,14 @@ -class cItemLighterHandler: +class cItemLighterHandler final: public cItemHandler { using Super = cItemHandler; public: - cItemLighterHandler(int a_ItemType): - Super(a_ItemType) - { - } + using Super::Super; @@ -32,7 +29,7 @@ public: const cItem & a_HeldItem, const Vector3i a_ClickedBlockPos, eBlockFace a_ClickedBlockFace - ) override + ) const override { if (a_ClickedBlockFace < 0) { diff --git a/src/Items/ItemLilypad.h b/src/Items/ItemLilypad.h index b448b33c8..f13212b07 100644 --- a/src/Items/ItemLilypad.h +++ b/src/Items/ItemLilypad.h @@ -9,14 +9,14 @@ -class cItemLilypadHandler: +class cItemLilypadHandler final: public cItemHandler { using Super = cItemHandler; public: - cItemLilypadHandler(int a_ItemType): + constexpr cItemLilypadHandler(int a_ItemType): Super(a_ItemType) { @@ -26,7 +26,7 @@ public: - virtual bool IsPlaceable(void) override + virtual bool IsPlaceable(void) const override { return false; // Set as not placeable so OnItemUse is called } @@ -42,7 +42,7 @@ public: const cItem & a_HeldItem, const Vector3i a_ClickedBlockPos, eBlockFace a_ClickedBlockFace - ) override + ) const override { // The client sends BLOCK_FACE_NONE when it determines it should do a tracing-based placement. // Otherwise, a normal block face is sent. diff --git a/src/Items/ItemMap.h b/src/Items/ItemMap.h index 59fddd3fb..83ec7cbc4 100644 --- a/src/Items/ItemMap.h +++ b/src/Items/ItemMap.h @@ -7,7 +7,7 @@ -class cItemMapHandler: +class cItemMapHandler final: public cItemHandler { using Super = cItemHandler; @@ -16,12 +16,9 @@ class cItemMapHandler: public: - cItemMapHandler(): - Super(E_ITEM_MAP) - { - } + using Super::Super; - virtual void OnUpdate(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item) override + virtual void OnUpdate(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item) const override { cMap * Map = a_World->GetMapManager().GetMapData(static_cast(a_Item.m_ItemDamage)); diff --git a/src/Items/ItemMilk.h b/src/Items/ItemMilk.h index e34efbc0f..fb346ec45 100644 --- a/src/Items/ItemMilk.h +++ b/src/Items/ItemMilk.h @@ -5,25 +5,22 @@ -class cItemMilkHandler: +class cItemMilkHandler final: public cItemHandler { using Super = cItemHandler; public: - cItemMilkHandler(): - Super(E_ITEM_MILK) - { - } + using Super::Super; - virtual bool IsDrinkable(short a_ItemDamage) override + virtual bool IsDrinkable(short a_ItemDamage) const override { UNUSED(a_ItemDamage); return true; } - virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) override + virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) const override { UNUSED(a_Item); a_Player->ClearEntityEffects(); diff --git a/src/Items/ItemMinecart.h b/src/Items/ItemMinecart.h index d108c2ca8..444e9e7d4 100644 --- a/src/Items/ItemMinecart.h +++ b/src/Items/ItemMinecart.h @@ -5,17 +5,14 @@ -class cItemMinecartHandler: +class cItemMinecartHandler final: public cItemHandler { using Super = cItemHandler; public: - cItemMinecartHandler(int a_ItemType): - Super(a_ItemType) - { - } + using Super::Super; @@ -28,7 +25,7 @@ public: const cItem & a_HeldItem, const Vector3i a_ClickedBlockPos, eBlockFace a_ClickedBlockFace - ) override + ) const override { // Must be used on a block if (a_ClickedBlockFace < 0) diff --git a/src/Items/ItemMobHead.h b/src/Items/ItemMobHead.h index 3d6f1d7aa..aa4189589 100644 --- a/src/Items/ItemMobHead.h +++ b/src/Items/ItemMobHead.h @@ -9,23 +9,20 @@ -class cItemMobHeadHandler: +class cItemMobHeadHandler final : public cItemHandler { using Super = cItemHandler; public: - cItemMobHeadHandler(int a_ItemType): - Super(a_ItemType) - { - } + using Super::Super; - virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) override + virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const override { // Cannot place a head at "no face" and from the bottom: if ((a_ClickedBlockFace == BLOCK_FACE_NONE) || (a_ClickedBlockFace == BLOCK_FACE_BOTTOM)) @@ -58,7 +55,7 @@ public: /** Called after placing a regular head block with no mob spawning. Adjusts the mob head entity based on the equipped item's data. */ - void RegularHeadPlaced(const cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace) + void RegularHeadPlaced(const cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace) const { const auto HeadType = static_cast(a_HeldItem.m_ItemDamage); const auto BlockMeta = static_cast(a_ClickedBlockFace); @@ -88,7 +85,7 @@ public: /** Spawns a wither if the wither skull placed at the specified coords completes wither's spawning formula. Returns true if the wither was created. */ - bool TrySpawnWitherAround(cPlayer & a_Player, const Vector3i a_BlockPos) + bool TrySpawnWitherAround(cPlayer & a_Player, const Vector3i a_BlockPos) const { // No wither can be created at Y < 2 - not enough space for the formula: if (a_BlockPos.y < 2) @@ -131,7 +128,7 @@ public: cWorld & a_World, cPlayer & a_Player, Vector3i a_PlacedHeadPos, int a_OffsetX, int a_OffsetZ - ) + ) const { // Image for the wither at the X axis: static const sSetBlock ImageWitherX[] = @@ -189,7 +186,7 @@ public: cWorld & a_World, cPlayer & a_Player, const sSetBlock (& a_Image)[9], Vector3i a_PlacedHeadPos, int a_OffsetX, int a_OffsetZ - ) + ) const { std::array PositionsToClear; @@ -280,7 +277,7 @@ public: /** Awards the achievement to all players close to the specified point. */ - void AwardSpawnWitherAchievement(cWorld & a_World, Vector3i a_BlockPos) + void AwardSpawnWitherAchievement(cWorld & a_World, Vector3i a_BlockPos) const { Vector3f Pos(a_BlockPos); a_World.ForEachPlayer([=](cPlayer & a_Player) @@ -323,7 +320,7 @@ public: - virtual bool IsPlaceable(void) override + virtual bool IsPlaceable(void) const override { return true; } diff --git a/src/Items/ItemNetherWart.h b/src/Items/ItemNetherWart.h index 61043226d..936e93f31 100644 --- a/src/Items/ItemNetherWart.h +++ b/src/Items/ItemNetherWart.h @@ -8,23 +8,20 @@ -class cItemNetherWartHandler: +class cItemNetherWartHandler final: public cItemHandler { using Super = cItemHandler; public: - cItemNetherWartHandler(int a_ItemType): - Super(a_ItemType) - { - } + using Super::Super; - virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) override + virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const override { // Only allow planting nether wart onto the top side of the block: if (a_ClickedBlockFace != BLOCK_FACE_TOP) @@ -39,7 +36,7 @@ public: - virtual bool IsPlaceable(void) override + virtual bool IsPlaceable(void) const override { return true; } diff --git a/src/Items/ItemObserver.h b/src/Items/ItemObserver.h index 9047386bd..719618410 100644 --- a/src/Items/ItemObserver.h +++ b/src/Items/ItemObserver.h @@ -8,7 +8,7 @@ -class cItemObserverHandler : +class cItemObserverHandler final : public cItemHandler { using Super = cItemHandler; @@ -19,7 +19,7 @@ public: private: - virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) override + virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const override { return a_Player.PlaceBlock(a_PlacePosition, E_BLOCK_OBSERVER, cBlockObserverHandler::DisplacementYawToMetaData(a_PlacePosition, a_Player.GetEyePosition(), a_Player.GetYaw())); } diff --git a/src/Items/ItemPainting.h b/src/Items/ItemPainting.h index 058f8d3b2..40e43f87e 100644 --- a/src/Items/ItemPainting.h +++ b/src/Items/ItemPainting.h @@ -10,17 +10,14 @@ -class cItemPaintingHandler: +class cItemPaintingHandler final: public cItemHandler { using Super = cItemHandler; public: - cItemPaintingHandler(int a_ItemType): - Super(a_ItemType) - { - } + using Super::Super; @@ -33,7 +30,7 @@ public: const cItem & a_HeldItem, const Vector3i a_ClickedBlockPos, eBlockFace a_ClickedBlockFace - ) override + ) const override { // Paintings can't be flatly placed: if ( diff --git a/src/Items/ItemPickaxe.h b/src/Items/ItemPickaxe.h index 9172146b7..3c38e372f 100644 --- a/src/Items/ItemPickaxe.h +++ b/src/Items/ItemPickaxe.h @@ -5,14 +5,14 @@ -class cItemPickaxeHandler: +class cItemPickaxeHandler final: public cItemHandler { using Super = cItemHandler; public: - cItemPickaxeHandler(int a_ItemType): + constexpr cItemPickaxeHandler(int a_ItemType): Super(a_ItemType) { @@ -20,7 +20,7 @@ public: - virtual short GetDurabilityLossByAction(eDurabilityLostAction a_Action) override + virtual short GetDurabilityLossByAction(eDurabilityLostAction a_Action) const override { switch (a_Action) { @@ -33,7 +33,7 @@ public: - char PickaxeLevel() + char PickaxeLevel() const { switch (m_ItemType) { @@ -47,7 +47,7 @@ public: } } - virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType) override + virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType) const override { // NOTICE: Make sure to update cItemHandler::CanHarvestBlock() if adding new blocks here! switch (a_BlockType) @@ -155,7 +155,7 @@ public: return Super::CanHarvestBlock(a_BlockType); } - virtual bool CanRepairWithRawMaterial(short a_ItemType) override + virtual bool CanRepairWithRawMaterial(short a_ItemType) const override { switch (m_ItemType) { @@ -169,7 +169,7 @@ public: } - virtual float GetBlockBreakingStrength(BLOCKTYPE a_Block) override + virtual float GetBlockBreakingStrength(BLOCKTYPE a_Block) const override { if (!IsBlockMaterialIron(a_Block) && (a_Block != E_BLOCK_ANVIL) && !IsBlockMaterialRock(a_Block)) { diff --git a/src/Items/ItemPiston.h b/src/Items/ItemPiston.h index 097c26d78..8a1611a69 100644 --- a/src/Items/ItemPiston.h +++ b/src/Items/ItemPiston.h @@ -8,7 +8,7 @@ -class cItemPistonHandler : +class cItemPistonHandler final: public cItemHandler { using Super = cItemHandler; @@ -19,7 +19,7 @@ public: private: - virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) override + virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const override { return a_Player.PlaceBlock(a_PlacePosition, static_cast(a_HeldItem.m_ItemType), cBlockPistonHandler::DisplacementYawToMetaData(a_PlacePosition, a_Player.GetEyePosition(), a_Player.GetYaw())); } diff --git a/src/Items/ItemPlanks.h b/src/Items/ItemPlanks.h index 537e44460..0bc079806 100644 --- a/src/Items/ItemPlanks.h +++ b/src/Items/ItemPlanks.h @@ -7,7 +7,7 @@ -class cItemPlanksHandler : +class cItemPlanksHandler final : public cItemHandler { using Super = cItemHandler; @@ -18,7 +18,7 @@ public: private: - virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) override + virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const override { return a_Player.PlaceBlock(a_PlacePosition, static_cast(a_HeldItem.m_ItemType), static_cast(a_HeldItem.m_ItemDamage)); } diff --git a/src/Items/ItemPoisonousPotato.h b/src/Items/ItemPoisonousPotato.h index 1950db90e..849633b5b 100644 --- a/src/Items/ItemPoisonousPotato.h +++ b/src/Items/ItemPoisonousPotato.h @@ -7,19 +7,19 @@ -class cItemPoisonousPotatoHandler: +class cItemPoisonousPotatoHandler final: public cItemFoodHandler { using Super = cItemFoodHandler; public: - cItemPoisonousPotatoHandler(): - Super(E_ITEM_POISONOUS_POTATO, FoodInfo(2, 1.2)) + constexpr cItemPoisonousPotatoHandler(int a_ItemType): + Super(a_ItemType, FoodInfo(2, 1.2)) { } - virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) override + virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) const override { if (!Super::EatItem(a_Player, a_Item)) { diff --git a/src/Items/ItemPotion.h b/src/Items/ItemPotion.h index 875fbec02..eaf3e0b44 100644 --- a/src/Items/ItemPotion.h +++ b/src/Items/ItemPotion.h @@ -4,24 +4,21 @@ #include "../Entities/EntityEffect.h" -class cItemPotionHandler: +class cItemPotionHandler final: public cItemHandler { using Super = cItemHandler; public: - cItemPotionHandler(): - Super(E_ITEM_POTION) - { - } + using Super::Super; // cItemHandler overrides: - virtual bool IsDrinkable(short a_ItemDamage) override + virtual bool IsDrinkable(short a_ItemDamage) const override { // Drinkable potion if 13th lowest bit is set // Ref.: https://minecraft.gamepedia.com/Potions#Data_value_table @@ -39,7 +36,7 @@ public: const cItem & a_HeldItem, const Vector3i a_ClickedBlockPos, eBlockFace a_ClickedBlockFace - ) override + ) const override { short PotionDamage = a_HeldItem.m_ItemDamage; @@ -72,7 +69,7 @@ public: - virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) override + virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) const override { short PotionDamage = a_Item->m_ItemDamage; diff --git a/src/Items/ItemPumpkin.h b/src/Items/ItemPumpkin.h index cd17472b5..d467cd94f 100644 --- a/src/Items/ItemPumpkin.h +++ b/src/Items/ItemPumpkin.h @@ -8,7 +8,7 @@ -class cItemPumpkinHandler: +class cItemPumpkinHandler final: public cItemHandler { using Super = cItemHandler; @@ -19,7 +19,7 @@ public: private: - virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) override + virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const override { // First try spawning a snow golem or an iron golem: if (TrySpawnGolem(a_Player, a_PlacePosition)) @@ -39,7 +39,7 @@ private: /** Spawns a snow / iron golem if the shape matches the recipe, supposing that the block placed at the specified coords is a pumpkin. Returns true if the golem blocks are removed (for spawning), false if the recipe is not matched. */ - bool TrySpawnGolem(cPlayer & a_Player, const Vector3i a_PumpkinPos) + bool TrySpawnGolem(cPlayer & a_Player, const Vector3i a_PumpkinPos) const { // A golem can't form with a pumpkin below level 2 or above level 255: if ((a_PumpkinPos.y < 2) || (a_PumpkinPos.y >= cChunkDef::Height)) @@ -69,7 +69,7 @@ private: /** Spawns a snow golem if the shape matches the recipe, supposing that the block placed at the specified coords is a pumpkin. Returns true if the golem blocks are removed (for spawning), false if the recipe is not matched. Assumes that the block below the specified block has already been checked and is a snow block. */ - bool TrySpawnSnowGolem(cWorld & a_World, cPlayer & a_Player, const Vector3i a_PumpkinPos) + bool TrySpawnSnowGolem(cWorld & a_World, cPlayer & a_Player, const Vector3i a_PumpkinPos) const { ASSERT(a_PumpkinPos.y > 1); ASSERT(a_World.GetBlock(a_PumpkinPos.addedY(-1)) == E_BLOCK_SNOW_BLOCK); @@ -106,7 +106,7 @@ private: /** Spawns an iron golem if the shape matches the recipe, supposing that the block placed at the specified coords is a pumpkin. Returns true if the golem blocks are removed (for spawning), false if the recipe is not matched. Assumes that the block below the specified block has already been checked and is an iron block. */ - bool TrySpawnIronGolem(cWorld & a_World, cPlayer & a_Player, const Vector3i a_PumpkinPos) + bool TrySpawnIronGolem(cWorld & a_World, cPlayer & a_Player, const Vector3i a_PumpkinPos) const { ASSERT(a_PumpkinPos.y > 1); ASSERT(a_World.GetBlock(a_PumpkinPos.addedY(-1)) == E_BLOCK_IRON_BLOCK); diff --git a/src/Items/ItemQuartz.h b/src/Items/ItemQuartz.h index a3aaa49e7..5f49e76dc 100644 --- a/src/Items/ItemQuartz.h +++ b/src/Items/ItemQuartz.h @@ -7,7 +7,7 @@ -class cItemQuartzHandler : +class cItemQuartzHandler final: public cItemHandler { using Super = cItemHandler; @@ -45,7 +45,7 @@ private: } - virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) override + virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const override { const auto Meta = static_cast(a_Player.GetEquippedItem().m_ItemDamage); diff --git a/src/Items/ItemRail.h b/src/Items/ItemRail.h index a259a2a6d..a53f620b2 100644 --- a/src/Items/ItemRail.h +++ b/src/Items/ItemRail.h @@ -8,7 +8,7 @@ -class cItemRailHandler : +class cItemRailHandler final : public cItemHandler { using Super = cItemHandler; @@ -19,7 +19,7 @@ public: private: - virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) override + virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const override { cChunkInterface ChunkInterface(a_Player.GetWorld()->GetChunkMap()); const auto RailType = static_cast(a_HeldItem.m_ItemType); diff --git a/src/Items/ItemRawChicken.h b/src/Items/ItemRawChicken.h index 95acd3194..f3522b449 100644 --- a/src/Items/ItemRawChicken.h +++ b/src/Items/ItemRawChicken.h @@ -7,19 +7,19 @@ -class cItemRawChickenHandler: +class cItemRawChickenHandler final: public cItemFoodHandler { using Super = cItemFoodHandler; public: - cItemRawChickenHandler(): - Super(E_ITEM_RAW_CHICKEN, FoodInfo(2, 1.2)) + constexpr cItemRawChickenHandler(int a_ItemType): + Super(a_ItemType, FoodInfo(2, 1.2)) { } - virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) override + virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) const override { if (!Super::EatItem(a_Player, a_Item)) { diff --git a/src/Items/ItemRawFish.h b/src/Items/ItemRawFish.h index 22836272f..e741aa3e0 100644 --- a/src/Items/ItemRawFish.h +++ b/src/Items/ItemRawFish.h @@ -7,19 +7,19 @@ -class cItemRawFishHandler: +class cItemRawFishHandler final: public cItemFoodHandler { using Super = cItemFoodHandler; public: - cItemRawFishHandler(): - Super(E_ITEM_RAW_FISH, FoodInfo(0, 0)) + constexpr cItemRawFishHandler(int a_ItemType): + Super(a_ItemType, FoodInfo(0, 0)) { } - virtual FoodInfo GetFoodInfo(const cItem * a_Item) override + virtual FoodInfo GetFoodInfo(const cItem * a_Item) const override { static const FoodInfo RawFishInfos[] = { @@ -37,7 +37,7 @@ public: return RawFishInfos[a_Item->m_ItemDamage]; } - virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) override + virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) const override { if (!Super::EatItem(a_Player, a_Item)) { diff --git a/src/Items/ItemRedstoneDust.h b/src/Items/ItemRedstoneDust.h index d1bb6556c..803dd601d 100644 --- a/src/Items/ItemRedstoneDust.h +++ b/src/Items/ItemRedstoneDust.h @@ -7,23 +7,20 @@ -class cItemRedstoneDustHandler: +class cItemRedstoneDustHandler final: public cItemHandler { using Super = cItemHandler; public: - cItemRedstoneDustHandler(int a_ItemType): - Super(a_ItemType) - { - } + using Super::Super; - virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) override + virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const override { return a_Player.PlaceBlock(a_PlacePosition, E_BLOCK_REDSTONE_WIRE, 0); } @@ -32,7 +29,7 @@ public: - virtual bool IsPlaceable(void) override + virtual bool IsPlaceable(void) const override { return true; } diff --git a/src/Items/ItemRedstoneRepeater.h b/src/Items/ItemRedstoneRepeater.h index 6461d3ffd..2f20d294a 100644 --- a/src/Items/ItemRedstoneRepeater.h +++ b/src/Items/ItemRedstoneRepeater.h @@ -8,23 +8,20 @@ -class cItemRedstoneRepeaterHandler: +class cItemRedstoneRepeaterHandler final : public cItemHandler { using Super = cItemHandler; public: - cItemRedstoneRepeaterHandler(int a_ItemType): - Super(a_ItemType) - { - } + using Super::Super; - virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) override + virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const override { return a_Player.PlaceBlock(a_PlacePosition, E_BLOCK_REDSTONE_REPEATER_OFF, cBlockRedstoneRepeaterHandler::YawToMetaData(a_Player.GetYaw())); } @@ -33,7 +30,7 @@ public: - virtual bool IsPlaceable() override + virtual bool IsPlaceable() const override { return true; } diff --git a/src/Items/ItemRottenFlesh.h b/src/Items/ItemRottenFlesh.h index bd7f67382..9eb7f2119 100644 --- a/src/Items/ItemRottenFlesh.h +++ b/src/Items/ItemRottenFlesh.h @@ -7,19 +7,19 @@ -class cItemRottenFleshHandler: +class cItemRottenFleshHandler final: public cItemFoodHandler { using Super = cItemFoodHandler; public: - cItemRottenFleshHandler(): - Super(E_ITEM_ROTTEN_FLESH, FoodInfo(4, 0.8)) + constexpr cItemRottenFleshHandler(int a_ItemType): + Super(a_ItemType, FoodInfo(4, 0.8)) { } - virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) override + virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) const override { if (!Super::EatItem(a_Player, a_Item)) { diff --git a/src/Items/ItemSapling.h b/src/Items/ItemSapling.h index 3f62af94f..59fd81350 100644 --- a/src/Items/ItemSapling.h +++ b/src/Items/ItemSapling.h @@ -7,20 +7,17 @@ -class cItemSaplingHandler: +class cItemSaplingHandler final : public cItemHandler { using Super = cItemHandler; public: - cItemSaplingHandler(int a_ItemType): - Super(a_ItemType) - { - } + using Super::Super; - virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) override + virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const override { return a_Player.PlaceBlock( a_PlacePosition, diff --git a/src/Items/ItemSeeds.h b/src/Items/ItemSeeds.h index 0bb9afbb9..821afb443 100644 --- a/src/Items/ItemSeeds.h +++ b/src/Items/ItemSeeds.h @@ -15,7 +15,7 @@ class cItemSeedsHandler: public: - cItemSeedsHandler(int a_ItemType): + constexpr cItemSeedsHandler(int a_ItemType): Super(a_ItemType) { @@ -25,7 +25,7 @@ public: - virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) override + virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const override { // Only allow planting seeds from the top side of the block: if (a_ClickedBlockFace != BLOCK_FACE_TOP) @@ -54,12 +54,20 @@ public: - virtual bool IsPlaceable(void) override + virtual bool IsPlaceable(void) const override { return true; } + +protected: + ~cItemSeedsHandler() = default; } ; +class cItemSimpleSeedsHandler final: + public cItemSeedsHandler +{ + using cItemSeedsHandler::cItemSeedsHandler; +}; diff --git a/src/Items/ItemShears.h b/src/Items/ItemShears.h index 140e26c5e..5f8e9e2f1 100644 --- a/src/Items/ItemShears.h +++ b/src/Items/ItemShears.h @@ -9,26 +9,14 @@ -class cItemShearsHandler: +class cItemShearsHandler final: public cItemHandler { using Super = cItemHandler; public: - cItemShearsHandler(int a_ItemType): - Super(a_ItemType) - { - } - - - - - - virtual bool IsTool(void) override - { - return true; - } + using Super::Super; @@ -40,7 +28,7 @@ public: const cItem & a_HeldItem, const Vector3i a_ClickedBlockPos, eBlockFace a_ClickedBlockFace - ) override + ) const override { BLOCKTYPE Block; NIBBLETYPE BlockMeta; @@ -59,7 +47,7 @@ public: - virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType) override + virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType) const override { switch (a_BlockType) { @@ -77,7 +65,7 @@ public: - virtual short GetDurabilityLossByAction(eDurabilityLostAction a_Action) override + virtual short GetDurabilityLossByAction(eDurabilityLostAction a_Action) const override { switch (a_Action) { @@ -92,7 +80,7 @@ public: - virtual float GetBlockBreakingStrength(BLOCKTYPE a_Block) override + virtual float GetBlockBreakingStrength(BLOCKTYPE a_Block) const override { if ((a_Block == E_BLOCK_COBWEB) || IsBlockMaterialLeaves(a_Block)) { diff --git a/src/Items/ItemShovel.h b/src/Items/ItemShovel.h index 1459a14ac..1be2aa6cc 100644 --- a/src/Items/ItemShovel.h +++ b/src/Items/ItemShovel.h @@ -12,21 +12,18 @@ -class cItemShovelHandler: +class cItemShovelHandler final: public cItemHandler { using Super = cItemHandler; public: - cItemShovelHandler(int a_ItemType): - Super(a_ItemType) - { - } + using Super::Super; - virtual short GetDurabilityLossByAction(eDurabilityLostAction a_Action) override + virtual short GetDurabilityLossByAction(eDurabilityLostAction a_Action) const override { switch (a_Action) { @@ -41,7 +38,7 @@ public: - virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType) override + virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType) const override { if (a_BlockType == E_BLOCK_SNOW) { @@ -54,7 +51,7 @@ public: - virtual bool CanRepairWithRawMaterial(short a_ItemType) override + virtual bool CanRepairWithRawMaterial(short a_ItemType) const override { switch (m_ItemType) { @@ -71,7 +68,7 @@ public: - virtual float GetBlockBreakingStrength(BLOCKTYPE a_Block) override + virtual float GetBlockBreakingStrength(BLOCKTYPE a_Block) const override { switch (a_Block) { diff --git a/src/Items/ItemSideways.h b/src/Items/ItemSideways.h index cb6403fd6..c1d68c1a6 100644 --- a/src/Items/ItemSideways.h +++ b/src/Items/ItemSideways.h @@ -11,7 +11,7 @@ /** Handler for blocks that have 3 orientations (hay bale, log), specified by the upper 2 bits in meta. Handles setting the correct orientation on placement. Additionally supports the metadata specifying block sub-type in its lower 2 bits. */ -class cItemSidewaysHandler : +class cItemSidewaysHandler final : public cItemHandler { using Super = cItemHandler; @@ -46,7 +46,7 @@ private: } - virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) override + virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const override { return a_Player.PlaceBlock(a_PlacePosition, static_cast(a_HeldItem.m_ItemType), BlockFaceToMetaData(a_ClickedBlockFace, static_cast(a_HeldItem.m_ItemDamage))); } diff --git a/src/Items/ItemSign.h b/src/Items/ItemSign.h index 02913b58f..5d521bb3b 100644 --- a/src/Items/ItemSign.h +++ b/src/Items/ItemSign.h @@ -9,7 +9,7 @@ -class cItemSignHandler: +class cItemSignHandler final: public cItemHandler { using Super = cItemHandler; @@ -40,7 +40,7 @@ private: } - virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) override + virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const override { if (a_ClickedBlockFace == BLOCK_FACE_TOP) { @@ -60,7 +60,7 @@ private: } - virtual bool IsPlaceable(void) override + virtual bool IsPlaceable(void) const override { return true; } diff --git a/src/Items/ItemSlab.h b/src/Items/ItemSlab.h index 467975047..88dbef1e4 100644 --- a/src/Items/ItemSlab.h +++ b/src/Items/ItemSlab.h @@ -7,7 +7,7 @@ -class cItemSlabHandler: +class cItemSlabHandler final: public cItemHandler { using Super = cItemHandler; @@ -18,7 +18,7 @@ public: private: - virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) override + virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const override { // Confer BlockSlab.h, which we're in cahoots with to make the below logic work. diff --git a/src/Items/ItemSnow.h b/src/Items/ItemSnow.h index 551b4d922..87fa71e5f 100644 --- a/src/Items/ItemSnow.h +++ b/src/Items/ItemSnow.h @@ -7,7 +7,7 @@ -class cItemSnowHandler : +class cItemSnowHandler final : public cItemHandler { using Super = cItemHandler; @@ -18,7 +18,7 @@ public: private: - virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) override + virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const override { BLOCKTYPE Block; NIBBLETYPE Meta; diff --git a/src/Items/ItemSoup.h b/src/Items/ItemSoup.h index 60a2f8d76..974a410a8 100644 --- a/src/Items/ItemSoup.h +++ b/src/Items/ItemSoup.h @@ -8,20 +8,20 @@ -class cItemSoupHandler: +class cItemSoupHandler final: public cItemFoodHandler { using Super = cItemFoodHandler; public: - cItemSoupHandler(int a_ItemType, FoodInfo a_FoodInfo): + constexpr cItemSoupHandler(int a_ItemType, FoodInfo a_FoodInfo): Super(a_ItemType, a_FoodInfo) { } - virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) override + virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) const override { // Skip over food handler, which does removal for us. if (!cItemHandler::EatItem(a_Player, a_Item)) diff --git a/src/Items/ItemSpawnEgg.h b/src/Items/ItemSpawnEgg.h index 8408bd815..ff84c54dc 100644 --- a/src/Items/ItemSpawnEgg.h +++ b/src/Items/ItemSpawnEgg.h @@ -9,21 +9,14 @@ -class cItemSpawnEggHandler: +class cItemSpawnEggHandler final: public cItemHandler { using Super = cItemHandler; public: - cItemSpawnEggHandler(int a_ItemType): - Super(a_ItemType) - { - } - - - - + using Super::Super; virtual bool OnItemUse( cWorld * a_World, @@ -32,7 +25,7 @@ public: const cItem & a_HeldItem, const Vector3i a_ClickedBlockPos, eBlockFace a_ClickedBlockFace - ) override + ) const override { // Must click a valid block: if (a_ClickedBlockFace < 0) diff --git a/src/Items/ItemSpiderEye.h b/src/Items/ItemSpiderEye.h index df371a010..63631e30c 100644 --- a/src/Items/ItemSpiderEye.h +++ b/src/Items/ItemSpiderEye.h @@ -7,19 +7,19 @@ -class cItemSpiderEyeHandler: +class cItemSpiderEyeHandler final: public cItemFoodHandler { using Super = cItemFoodHandler; public: - cItemSpiderEyeHandler(): - Super(E_ITEM_SPIDER_EYE, FoodInfo(2, 3.2)) + constexpr cItemSpiderEyeHandler(int a_ItemType): + Super(a_ItemType, FoodInfo(2, 3.2)) { } - virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) override + virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) const override { if (!Super::EatItem(a_Player, a_Item)) { diff --git a/src/Items/ItemStairs.h b/src/Items/ItemStairs.h index 6fe447be5..8a937ae56 100644 --- a/src/Items/ItemStairs.h +++ b/src/Items/ItemStairs.h @@ -8,7 +8,7 @@ -class cItemStairsHandler : +class cItemStairsHandler final : public cItemHandler { using Super = cItemHandler; @@ -19,7 +19,7 @@ public: private: - virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) override + virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const override { NIBBLETYPE Meta = cBlockStairsHandler::YawToMetaData(a_Player.GetYaw()); diff --git a/src/Items/ItemSword.h b/src/Items/ItemSword.h index cb2e63c87..ddc6632e4 100644 --- a/src/Items/ItemSword.h +++ b/src/Items/ItemSword.h @@ -8,20 +8,16 @@ -class cItemSwordHandler: +class cItemSwordHandler final : public cItemHandler { using Super = cItemHandler; public: - cItemSwordHandler(int a_ItemType): - Super(a_ItemType) - { - } - + using Super::Super; - virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType) override + virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType) const override { if (a_BlockType == E_BLOCK_COBWEB) { @@ -31,7 +27,7 @@ public: } - virtual bool CanRepairWithRawMaterial(short a_ItemType) override + virtual bool CanRepairWithRawMaterial(short a_ItemType) const override { switch (m_ItemType) { @@ -45,7 +41,7 @@ public: } - virtual short GetDurabilityLossByAction(eDurabilityLostAction a_Action) override + virtual short GetDurabilityLossByAction(eDurabilityLostAction a_Action) const override { switch (a_Action) { @@ -58,7 +54,7 @@ public: - virtual float GetBlockBreakingStrength(BLOCKTYPE a_Block) override + virtual float GetBlockBreakingStrength(BLOCKTYPE a_Block) const override { if (a_Block == E_BLOCK_COBWEB) { diff --git a/src/Items/ItemThrowable.h b/src/Items/ItemThrowable.h index 606f655e9..ed4d73316 100644 --- a/src/Items/ItemThrowable.h +++ b/src/Items/ItemThrowable.h @@ -14,7 +14,7 @@ class cItemThrowableHandler: public: - cItemThrowableHandler(int a_ItemType, cProjectileEntity::eKind a_ProjectileKind, double a_SpeedCoeff): + constexpr cItemThrowableHandler(int a_ItemType, cProjectileEntity::eKind a_ProjectileKind, double a_SpeedCoeff): Super(a_ItemType), m_ProjectileKind(a_ProjectileKind), m_SpeedCoeff(a_SpeedCoeff) @@ -32,7 +32,7 @@ public: const cItem & a_HeldItem, const Vector3i a_ClickedBlockPos, eBlockFace a_ClickedBlockFace - ) override + ) const override { auto Pos = a_Player->GetThrowStartPos(); auto Speed = a_Player->GetLookVector() * m_SpeedCoeff; @@ -62,21 +62,23 @@ protected: /** The speed multiplier (to the player's normalized look vector) to set for the new projectile. */ double m_SpeedCoeff; + + ~cItemThrowableHandler() = default; } ; -class cItemEggHandler: +class cItemEggHandler final: public cItemThrowableHandler { using Super = cItemThrowableHandler; public: - cItemEggHandler(): - Super(E_ITEM_EGG, cProjectileEntity::pkEgg, 30) + constexpr cItemEggHandler(int a_ItemType): + Super(a_ItemType, cProjectileEntity::pkEgg, 30) { } } ; @@ -84,15 +86,15 @@ public: -class cItemSnowballHandler: +class cItemSnowballHandler final: public cItemThrowableHandler { using Super = cItemThrowableHandler; public: - cItemSnowballHandler(): - Super(E_ITEM_SNOWBALL, cProjectileEntity::pkSnowball, 30) + constexpr cItemSnowballHandler(int a_ItemType): + Super(a_ItemType, cProjectileEntity::pkSnowball, 30) { } } ; @@ -101,15 +103,15 @@ public: -class cItemEnderPearlHandler: +class cItemEnderPearlHandler final: public cItemThrowableHandler { using Super = cItemThrowableHandler; public: - cItemEnderPearlHandler(): - Super(E_ITEM_ENDER_PEARL, cProjectileEntity::pkEnderPearl, 30) + constexpr cItemEnderPearlHandler(int a_ItemType): + Super(a_ItemType, cProjectileEntity::pkEnderPearl, 30) { } } ; @@ -118,15 +120,15 @@ public: -class cItemBottleOEnchantingHandler: +class cItemBottleOEnchantingHandler final : public cItemThrowableHandler { using Super = cItemThrowableHandler; public: - cItemBottleOEnchantingHandler(): - Super(E_ITEM_BOTTLE_O_ENCHANTING, cProjectileEntity::pkExpBottle, 14) + constexpr cItemBottleOEnchantingHandler(int a_ItemType): + Super(a_ItemType, cProjectileEntity::pkExpBottle, 14) { } }; @@ -135,15 +137,15 @@ public: -class cItemFireworkHandler: +class cItemFireworkHandler final: public cItemThrowableHandler { using Super = cItemThrowableHandler; public: - cItemFireworkHandler(): - Super(E_ITEM_FIREWORK_ROCKET, cProjectileEntity::pkFirework, 0) + constexpr cItemFireworkHandler(int a_ItemType): + Super(a_ItemType, cProjectileEntity::pkFirework, 0) { } @@ -158,7 +160,7 @@ public: const cItem & a_HeldItem, const Vector3i a_ClickedBlockPos, eBlockFace a_ClickedBlockFace - ) override + ) const override { if (a_World->GetBlock(a_ClickedBlockPos) == E_BLOCK_AIR) { @@ -177,5 +179,4 @@ public: return true; } - }; diff --git a/src/Items/ItemTorch.h b/src/Items/ItemTorch.h index a0ed86e93..753ac09a9 100644 --- a/src/Items/ItemTorch.h +++ b/src/Items/ItemTorch.h @@ -8,7 +8,7 @@ -class cItemTorchHandler : +class cItemTorchHandler final : public cItemHandler { using Super = cItemHandler; @@ -34,7 +34,7 @@ private: } - virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) override + virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const override { const auto & World = *a_Player.GetWorld(); BLOCKTYPE ClickedBlockType; diff --git a/src/Items/ItemTrapdoor.h b/src/Items/ItemTrapdoor.h index 9cb89b8bf..337e8ea15 100644 --- a/src/Items/ItemTrapdoor.h +++ b/src/Items/ItemTrapdoor.h @@ -8,7 +8,7 @@ -class cItemTrapdoorHandler : +class cItemTrapdoorHandler final : public cItemHandler { using Super = cItemHandler; @@ -32,7 +32,7 @@ private: } - virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) override + virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const override { NIBBLETYPE Meta; diff --git a/src/Items/ItemTripwireHook.h b/src/Items/ItemTripwireHook.h index 005bd5676..b30f3c85c 100644 --- a/src/Items/ItemTripwireHook.h +++ b/src/Items/ItemTripwireHook.h @@ -7,7 +7,7 @@ -class cItemTripwireHookHandler : +class cItemTripwireHookHandler final : public cItemHandler { using Super = cItemHandler; @@ -31,7 +31,7 @@ private: } - virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) override + virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const override { if ((a_ClickedBlockFace == BLOCK_FACE_YP) || (a_ClickedBlockFace == BLOCK_FACE_YM)) { diff --git a/src/Items/ItemVine.h b/src/Items/ItemVine.h index 1a56a23d0..be5cf4588 100644 --- a/src/Items/ItemVine.h +++ b/src/Items/ItemVine.h @@ -7,7 +7,7 @@ -class cItemVineHandler : +class cItemVineHandler final : public cItemHandler { using Super = cItemHandler; @@ -18,7 +18,7 @@ public: private: - virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) override + virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const override { BLOCKTYPE Block; NIBBLETYPE Meta; diff --git a/src/Items/SimplePlaceableItemHandler.h b/src/Items/SimplePlaceableItemHandler.h index 8b61f3198..2bfe756af 100644 --- a/src/Items/SimplePlaceableItemHandler.h +++ b/src/Items/SimplePlaceableItemHandler.h @@ -6,27 +6,27 @@ -class cSimplePlaceableItemHandler : +class cSimplePlaceableItemHandler final: public cItemHandler { using Super = cItemHandler; public: - cSimplePlaceableItemHandler(int a_ItemType, BLOCKTYPE a_BlockType) : + constexpr cSimplePlaceableItemHandler(int a_ItemType, BLOCKTYPE a_BlockType) : Super(a_ItemType), m_BlockType(a_BlockType) { } - virtual bool IsPlaceable(void) override + virtual bool IsPlaceable(void) const override { return true; } - virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) override + virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const override { return a_Player.PlaceBlock(a_PlacePosition, m_BlockType, 0); } diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index dc77dc0f8..3193f97ae 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -1511,7 +1511,7 @@ void cMonster::RightClickFeed(cPlayer & a_Player) void cMonster::AddRandomDropItem(cItems & a_Drops, unsigned int a_Min, unsigned int a_Max, short a_Item, short a_ItemHealth) { auto Count = GetRandomProvider().RandInt(a_Min, a_Max); - auto MaxStackSize = static_cast(ItemHandler(a_Item)->GetMaxStackSize()); + auto MaxStackSize = static_cast(cItem(a_Item).GetMaxStackSize()); while (Count > MaxStackSize) { a_Drops.emplace_back(a_Item, MaxStackSize, a_ItemHealth); diff --git a/src/Mobs/Wolf.cpp b/src/Mobs/Wolf.cpp index 2b45faa2b..553ca1c73 100644 --- a/src/Mobs/Wolf.cpp +++ b/src/Mobs/Wolf.cpp @@ -218,7 +218,7 @@ void cWolf::OnRightClicked(cPlayer & a_Player) { if (m_Health < m_MaxHealth) { - Heal(ItemHandler(EquippedItemType)->GetFoodInfo(&EquippedItem).FoodLevel); + Heal(EquippedItem.GetHandler().GetFoodInfo(&EquippedItem).FoodLevel); if (!a_Player.IsGameModeCreative()) { a_Player.GetInventory().RemoveOneEquippedItem(); diff --git a/src/Root.cpp b/src/Root.cpp index 462544ed2..77ea93f68 100644 --- a/src/Root.cpp +++ b/src/Root.cpp @@ -243,8 +243,6 @@ bool cRoot::Run(cSettingsRepositoryInterface & a_OverridesRepo) LOGD("Stopping plugin manager..."); delete m_PluginManager; m_PluginManager = nullptr; - cItemHandler::Deinit(); - LOG("Cleaning up..."); delete m_Server; m_Server = nullptr; diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index 6d27ea834..28f3054ce 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -138,8 +138,7 @@ void cSlotArea::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickA else if ((Slot.m_ItemType <= 0) || DraggingItem.IsEqual(Slot)) { // Drop one item in slot - cItemHandler * Handler = ItemHandler(Slot.m_ItemType); - if ((DraggingItem.m_ItemCount > 0) && (Slot.m_ItemCount < Handler->GetMaxStackSize())) + if ((DraggingItem.m_ItemCount > 0) && (Slot.m_ItemCount < Slot.GetMaxStackSize())) { char OldSlotCount = Slot.m_ItemCount; @@ -177,8 +176,7 @@ void cSlotArea::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickA else { // Same type, add items: - cItemHandler * Handler = ItemHandler(DraggingItem.m_ItemType); - int FreeSlots = Handler->GetMaxStackSize() - Slot.m_ItemCount; + int FreeSlots = DraggingItem.GetMaxStackSize() - Slot.m_ItemCount; if (FreeSlots < 0) { ASSERT(!"Bad item stack size - where did we get more items in a slot than allowed?"); @@ -365,7 +363,7 @@ void cSlotArea::DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ // Different items continue; } - char NumFit = ItemHandler(Slot->m_ItemType)->GetMaxStackSize() - Slot->m_ItemCount; + char NumFit = Slot->GetMaxStackSize() - Slot->m_ItemCount; if (NumFit <= 0) { // Full stack already @@ -636,8 +634,7 @@ void cSlotAreaCrafting::ClickedResult(cPlayer & a_Player) } else if (DraggingItem.IsEqual(Result)) { - cItemHandler * Handler = ItemHandler(Result.m_ItemType); - if (DraggingItem.m_ItemCount + Result.m_ItemCount <= Handler->GetMaxStackSize()) + if (DraggingItem.m_ItemCount + Result.m_ItemCount <= Result.GetMaxStackSize()) { DraggingItem.m_ItemCount += Result.m_ItemCount; Recipe.ConsumeIngredients(Grid); @@ -928,7 +925,7 @@ void cSlotAreaAnvil::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_C } if (!DraggingItem.IsEmpty()) { - if (!(DraggingItem.IsEqual(Slot) && ((DraggingItem.m_ItemCount + Slot.m_ItemCount) <= cItemHandler::GetItemHandler(Slot)->GetMaxStackSize()))) + if (!(DraggingItem.IsEqual(Slot) && ((DraggingItem.m_ItemCount + Slot.m_ItemCount) <= Slot.GetMaxStackSize()))) { return; } @@ -1004,7 +1001,7 @@ void cSlotAreaAnvil::DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bo // Different items continue; } - char NumFit = ItemHandler(Slot->m_ItemType)->GetMaxStackSize() - Slot->m_ItemCount; + char NumFit = Slot->GetMaxStackSize() - Slot->m_ItemCount; if (NumFit <= 0) { // Full stack already @@ -1151,7 +1148,7 @@ void cSlotAreaAnvil::UpdateResult(cPlayer & a_Player) RepairCost += Sacrifice.m_RepairCost; // Can we repair with sacrifce material? - if (Target.IsDamageable() && cItemHandler::GetItemHandler(Target)->CanRepairWithRawMaterial(Sacrifice.m_ItemType)) + if (Target.IsDamageable() && Target.GetHandler().CanRepairWithRawMaterial(Sacrifice.m_ItemType)) { // Tool and armor repair with special item (iron / gold / diamond / ...) int DamageDiff = std::min(static_cast(Target.m_ItemDamage), static_cast(Target.GetMaxDamage()) / 4); @@ -1620,7 +1617,7 @@ void cSlotAreaEnchanting::DistributeStack(cItem & a_ItemStack, cPlayer & a_Playe { // It's lapis, put it in the lapis spot. const cItem * Slot = GetSlot(1, a_Player); - char NumFit = ItemHandler(Slot->m_ItemType)->GetMaxStackSize() - Slot->m_ItemCount; + char NumFit = Slot->GetMaxStackSize() - Slot->m_ItemCount; if (NumFit <= 0) { // Full stack already @@ -2036,7 +2033,7 @@ void cSlotAreaFurnace::DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, return; } - char NumFit = ItemHandler(Slot->m_ItemType)->GetMaxStackSize() - Slot->m_ItemCount; + char NumFit = Slot->GetMaxStackSize() - Slot->m_ItemCount; if (NumFit <= 0) { // Full stack already @@ -2300,7 +2297,7 @@ void cSlotAreaBrewingstand::DistributeStack(cItem & a_ItemStack, cPlayer & a_Pla return; } - char NumFit = ItemHandler(Slot->m_ItemType)->GetMaxStackSize() - Slot->m_ItemCount; + char NumFit = Slot->GetMaxStackSize() - Slot->m_ItemCount; if (NumFit <= 0) { // Full stack already diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp index 23661e150..81704d6f0 100644 --- a/src/UI/Window.cpp +++ b/src/UI/Window.cpp @@ -696,7 +696,7 @@ void cWindow::OnMiddlePaintEnd(cPlayer & a_Player) // Fill available slots with full stacks of the dragging item const auto & DraggingItem = a_Player.GetDraggingItem(); - auto StackSize = ItemHandler(DraggingItem.m_ItemType)->GetMaxStackSize(); + auto StackSize = DraggingItem.GetMaxStackSize(); if (0 < DistributeItemToSlots(a_Player, DraggingItem, StackSize, a_Player.GetInventoryPaintSlots(), false)) { // If any items were distibuted, set dragging item empty -- cgit v1.2.3