summaryrefslogtreecommitdiffstats
path: root/source/DispenserEntity.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-05-25 13:59:13 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-05-25 13:59:13 +0200
commitc640e9346c5e6c72b62b1beeaf5ec6de9cdc6924 (patch)
tree567565c41bab4e0fbab4eee5e3d2e647a896772c /source/DispenserEntity.cpp
parentFixed the cWorld:DoWithChestAt(), DoWithDispenserAt() and DoWithFurnaceAt() callbacks binding. (diff)
downloadcuberite-c640e9346c5e6c72b62b1beeaf5ec6de9cdc6924.tar
cuberite-c640e9346c5e6c72b62b1beeaf5ec6de9cdc6924.tar.gz
cuberite-c640e9346c5e6c72b62b1beeaf5ec6de9cdc6924.tar.bz2
cuberite-c640e9346c5e6c72b62b1beeaf5ec6de9cdc6924.tar.lz
cuberite-c640e9346c5e6c72b62b1beeaf5ec6de9cdc6924.tar.xz
cuberite-c640e9346c5e6c72b62b1beeaf5ec6de9cdc6924.tar.zst
cuberite-c640e9346c5e6c72b62b1beeaf5ec6de9cdc6924.zip
Diffstat (limited to '')
-rw-r--r--source/DispenserEntity.cpp31
1 files changed, 14 insertions, 17 deletions
diff --git a/source/DispenserEntity.cpp b/source/DispenserEntity.cpp
index 1c95172e2..ccf4e0f95 100644
--- a/source/DispenserEntity.cpp
+++ b/source/DispenserEntity.cpp
@@ -31,9 +31,8 @@
-cDispenserEntity::cDispenserEntity(int a_X, int a_Y, int a_Z, cWorld * a_World) :
- cBlockEntity(E_BLOCK_DISPENSER, a_X, a_Y, a_Z, a_World),
- m_Contents(3, 3),
+cDispenserEntity::cDispenserEntity(int a_BlockX, int a_BlockY, int a_BlockZ) :
+ super(E_BLOCK_DISPENSER, a_BlockX, a_BlockY, a_BlockZ, ContentsWidth, ContentsHeight, NULL),
m_ShouldDispense(false)
{
SetBlockEntity(this); // cBlockEntityWindowOwner
@@ -43,27 +42,25 @@ cDispenserEntity::cDispenserEntity(int a_X, int a_Y, int a_Z, cWorld * a_World)
-cDispenserEntity::~cDispenserEntity()
+cDispenserEntity::cDispenserEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World) :
+ super(E_BLOCK_DISPENSER, a_BlockX, a_BlockY, a_BlockZ, ContentsWidth, ContentsHeight, a_World),
+ m_ShouldDispense(false)
{
- // Tell window its owner is destroyed
- cWindow * Window = GetWindow();
- if (Window != NULL)
- {
- Window->OwnerDestroyed();
- }
+ SetBlockEntity(this); // cBlockEntityWindowOwner
}
-void cDispenserEntity::Destroy(void)
+cDispenserEntity::~cDispenserEntity()
{
- // Drop items
- cItems Pickups;
- m_Contents.CopyToItems(Pickups);
- m_Contents.Clear();
- m_World->SpawnItemPickups(Pickups, m_PosX, m_PosY, m_PosZ);
+ // Tell window its owner is destroyed
+ cWindow * Window = GetWindow();
+ if (Window != NULL)
+ {
+ Window->OwnerDestroyed();
+ }
}
@@ -97,7 +94,7 @@ void cDispenserEntity::Dispense(void)
// Pick an item to dispense:
MTRand r1;
- int RandomSlot = r1.randInt(SlotsCnt);
+ int RandomSlot = r1.randInt(SlotsCnt - 1);
cItem & Drop = m_Contents.GetSlot(OccupiedSlots[RandomSlot]);
// Dispense the item: