From 5c3235ecdc3f718ce20e006f1ecfa2159df82c87 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Sun, 26 May 2013 14:39:04 +0000 Subject: Implemented droppers Added a common ancestor class "DropSpenser" that has the common code for dropper and dispenser and is Lua-accessible, too. The Debuggers plugin now triggers both droppers and dispensers when rclking them with a redstone torch. git-svn-id: http://mc-server.googlecode.com/svn/trunk@1514 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/UI/SlotArea.cpp | 32 ++++++++------------------------ source/UI/SlotArea.h | 9 ++++----- source/UI/Window.cpp | 8 ++++---- source/UI/Window.h | 14 +++++++++----- 4 files changed, 25 insertions(+), 38 deletions(-) (limited to 'source/UI') diff --git a/source/UI/SlotArea.cpp b/source/UI/SlotArea.cpp index 07b191292..abe964454 100644 --- a/source/UI/SlotArea.cpp +++ b/source/UI/SlotArea.cpp @@ -7,7 +7,7 @@ #include "SlotArea.h" #include "../Player.h" #include "../ChestEntity.h" -#include "../DispenserEntity.h" +#include "../DropSpenserEntity.h" #include "../FurnaceEntity.h" #include "../Items/ItemHandler.h" #include "Window.h" @@ -474,11 +474,11 @@ cCraftingRecipe & cSlotAreaCrafting::GetRecipeForPlayer(cPlayer & a_Player) /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// cSlotAreaFurnace: +// cSlotAreaDropSpenser: -cSlotAreaDispenser::cSlotAreaDispenser(cDispenserEntity * a_Dispenser, cWindow & a_ParentWindow) : +cSlotAreaDropSpenser::cSlotAreaDropSpenser(cDropSpenserEntity * a_DropSpenser, cWindow & a_ParentWindow) : cSlotArea(9, a_ParentWindow), - m_Dispenser(a_Dispenser) + m_DropSpenser(a_DropSpenser) { } @@ -486,34 +486,18 @@ cSlotAreaDispenser::cSlotAreaDispenser(cDispenserEntity * a_Dispenser, cWindow & -void cSlotAreaDispenser::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) -{ - super::Clicked(a_Player, a_SlotNum, a_ClickAction, a_ClickedItem); - - if (m_Dispenser == NULL) - { - LOGERROR("cSlotAreaDispenser::Clicked(): m_Dispenser == NULL"); - ASSERT(!"cSlotAreaDispenser::Clicked(): m_Dispenser == NULL"); - return; - } -} - - - - - -const cItem * cSlotAreaDispenser::GetSlot(int a_SlotNum, cPlayer & a_Player) +const cItem * cSlotAreaDropSpenser::GetSlot(int a_SlotNum, cPlayer & a_Player) { - return &(m_Dispenser->GetSlot(a_SlotNum)); + return &(m_DropSpenser->GetSlot(a_SlotNum)); } -void cSlotAreaDispenser::SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) +void cSlotAreaDropSpenser::SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) { - m_Dispenser->SetSlot(a_SlotNum, a_Item); + m_DropSpenser->SetSlot(a_SlotNum, a_Item); } diff --git a/source/UI/SlotArea.h b/source/UI/SlotArea.h index 2b56f3228..8358f5316 100644 --- a/source/UI/SlotArea.h +++ b/source/UI/SlotArea.h @@ -15,7 +15,7 @@ class cWindow; class cPlayer; class cChestEntity; -class cDispenserEntity; +class cDropSpenserEntity; class cFurnaceEntity; class cCraftingRecipe; @@ -250,20 +250,19 @@ protected: -class cSlotAreaDispenser : +class cSlotAreaDropSpenser : public cSlotArea { typedef cSlotArea super; public: - cSlotAreaDispenser(cDispenserEntity * a_Dispenser, cWindow & a_ParentWindow); + cSlotAreaDropSpenser(cDropSpenserEntity * a_DropSpenser, cWindow & a_ParentWindow); - virtual void Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) override; virtual const cItem * GetSlot(int a_SlotNum, cPlayer & a_Player) override; virtual void SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) override; protected: - cDispenserEntity * m_Dispenser; + cDropSpenserEntity * m_DropSpenser; } ; diff --git a/source/UI/Window.cpp b/source/UI/Window.cpp index bb80a7ce7..b21c2adba 100644 --- a/source/UI/Window.cpp +++ b/source/UI/Window.cpp @@ -482,12 +482,12 @@ cChestWindow::~cChestWindow() /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// cDispenserWindow: +// cDropSpenserWindow: -cDispenserWindow::cDispenserWindow(int a_BlockX, int a_BlockY, int a_BlockZ, cDispenserEntity * a_Dispenser) : - cWindow(cWindow::Dispenser, "MCS-Dispenser") +cDropSpenserWindow::cDropSpenserWindow(int a_BlockX, int a_BlockY, int a_BlockZ, cDropSpenserEntity * a_DropSpenser) : + cWindow(cWindow::DropSpenser, "MCS-DropSpenser") { - m_SlotAreas.push_back(new cSlotAreaDispenser(a_Dispenser, *this)); + m_SlotAreas.push_back(new cSlotAreaDropSpenser(a_DropSpenser, *this)); m_SlotAreas.push_back(new cSlotAreaInventory(*this)); m_SlotAreas.push_back(new cSlotAreaHotBar(*this)); } diff --git a/source/UI/Window.h b/source/UI/Window.h index 7bd87a2ce..86ea1849b 100644 --- a/source/UI/Window.h +++ b/source/UI/Window.h @@ -19,7 +19,7 @@ class cPlayer; class cWindowOwner; class cClientHandle; class cChestEntity; -class cDispenserEntity; +class cDropSpenserEntity; class cFurnaceEntity; class cSlotArea; class cWorld; @@ -49,9 +49,13 @@ public: Chest = 0, Workbench = 1, Furnace = 2, - Dispenser = 3, + DropSpenser = 3, // Dropper or Dispenser Enchantment = 4, - Brewery = 5 + Brewery = 5, + NPCTrade = 6, + Beacon = 7, + Anvil = 8, + Hopper = 9, }; static const int c_NumInventorySlots = 36; @@ -149,11 +153,11 @@ public: -class cDispenserWindow : +class cDropSpenserWindow : public cWindow { public: - cDispenserWindow(int a_BlockX, int a_BlockY, int a_BlockZ, cDispenserEntity * a_Dispenser); + cDropSpenserWindow(int a_BlockX, int a_BlockY, int a_BlockZ, cDropSpenserEntity * a_Dispenser); } ; -- cgit v1.2.3