aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/FurnaceTileEntity.h
blob: c77f8e44bec33fea8b92edf2c545bde37bff48d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#pragma once
using namespace std;

#include "FurnaceTile.h"
#include "TileEntity.h"
#include "WorldlyContainer.h"

class Player;
class Level;

class FurnaceTileEntity : public TileEntity, public WorldlyContainer
{
public:
	eINSTANCEOF GetType() { return eTYPE_FURNACETILEENTITY; }
	static TileEntity *create() { return new FurnaceTileEntity(); }

	using TileEntity::setChanged;

	static const int SLOT_INPUT = 0;
	static const int SLOT_FUEL = 1;
	static const int SLOT_RESULT = 2;

private:
	static const intArray SLOTS_FOR_UP;
	static const intArray SLOTS_FOR_DOWN;
	static const intArray SLOTS_FOR_SIDES;

	static const int BURN_INTERVAL;
	ItemInstanceArray items;

	// 4J-JEV: Added for 'Renewable Energy' achievement.
	// Should be true iff characoal was consumed whilst cooking the current stack.
	bool m_charcoalUsed;

public:
	int litTime;
	int litDuration;
	int tickCount;

private:

	wstring name;

public:
	// 4J Stu - Need a ctor to initialise member variables
	FurnaceTileEntity();
	virtual ~FurnaceTileEntity();

	virtual unsigned int getContainerSize();
	virtual shared_ptr<ItemInstance> getItem(unsigned int slot);
	virtual shared_ptr<ItemInstance> removeItem(unsigned int slot, int count);
	virtual shared_ptr<ItemInstance> removeItemNoUpdate(int slot);
	virtual void setItem(unsigned int slot, shared_ptr<ItemInstance> item);
	virtual wstring getName();
	virtual wstring getCustomName();
	virtual bool hasCustomName();
	virtual void setCustomName(const wstring &name);
	virtual void load(CompoundTag *base);
	virtual void save(CompoundTag *base);
	virtual int getMaxStackSize() const;
	int getBurnProgress(int max);
	int getLitProgress(int max);
	bool isLit();
	virtual void tick();

private:
	bool canBurn();

public:
	void burn();

	static int getBurnDuration(shared_ptr<ItemInstance> itemInstance);
	static bool isFuel(shared_ptr<ItemInstance> item);

public:
	virtual bool stillValid(shared_ptr<Player> player);
	virtual void setChanged();

	void startOpen();
	void stopOpen();

	virtual bool canPlaceItem(int slot, shared_ptr<ItemInstance> item);
	virtual intArray getSlotsForFace(int face);
	virtual bool canPlaceItemThroughFace(int slot, shared_ptr<ItemInstance> item, int face);
	virtual bool canTakeItemThroughFace(int slot, shared_ptr<ItemInstance> item, int face);

	// 4J Added
	virtual shared_ptr<TileEntity> clone();

	// 4J-JEV: Added for 'Renewable Energy' achievement.
	bool wasCharcoalUsed() { return m_charcoalUsed; }
};