aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/TileEntity.h
blob: 8addb3ed03fcc36a407c72174461d10e3e71b0ac (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
#pragma once
using namespace std;

#include "HashExtension.h"
#include "..\Minecraft.World\JavaIntHash.h"

class Level;
class Packet;
class CompoundTag;

typedef TileEntity *(*tileEntityCreateFn)();

class TileEntity : public enable_shared_from_this<TileEntity>
{
public:
	static void staticCtor();
	virtual eINSTANCEOF GetType() { return eTYPE_TILEENTITY; }
private:
	typedef unordered_map<wstring, tileEntityCreateFn> idToCreateMapType;
	typedef unordered_map<eINSTANCEOF, wstring, eINSTANCEOFKeyHash, eINSTANCEOFKeyEq> classToIdMapType;
	static idToCreateMapType idCreateMap;
	static classToIdMapType classIdMap;
	static void setId(tileEntityCreateFn createFn, eINSTANCEOF clas, wstring id);
	bool remove;
	unsigned char renderRemoveStage;	// 4J added

public:
	Level *level;
	int x, y, z;

	// 4J added
	enum  RenderRemoveStage
	{
		e_RenderRemoveStageKeep,
		e_RenderRemoveStageFlaggedAtChunk,
		e_RenderRemoveStageRemove
	};

	int data;
	Tile *tile;

public:
	// 4J Java does not have a ctor, but we need one to do some initialisation of the member variables
	TileEntity();
	virtual ~TileEntity() {}

	void setRenderRemoveStage(unsigned char stage);	// 4J added
	void upgradeRenderRemoveStage(); // 4J added
	bool shouldRemoveForRender();	// 4J added

	virtual Level *getLevel();
	virtual void setLevel(Level *level);
	virtual bool hasLevel();
	virtual void load(CompoundTag *tag);
	virtual void save(CompoundTag *tag);
	virtual void tick();
	static shared_ptr<TileEntity> loadStatic(CompoundTag *tag);
	virtual int getData();
	virtual void setData(int data, int updateFlags);
	virtual void setChanged();
	virtual double distanceToSqr(double xPlayer, double yPlayer, double zPlayer);
	virtual double getViewDistance();
	virtual Tile *getTile();
	virtual shared_ptr<Packet> getUpdatePacket();
	virtual bool isRemoved();
	virtual void setRemoved();
	virtual void clearRemoved();
	virtual bool triggerEvent(int b0, int b1);
	virtual void clearCache();

	// 4J Added
	virtual shared_ptr<TileEntity> clone() = 0;
protected:
	void clone(shared_ptr<TileEntity> tileEntity);
};