aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/StructureFeature.h
blob: ace5593de86cc2e4da75bd13d402987667e7aead (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
#pragma once
#include "LargeFeature.h"
#include "StructureFeatureSavedData.h"

class StructureStart;

//#define ENABLE_STRUCTURE_SAVING

class StructureFeature : public LargeFeature
{
public:
	// 4J added - Maps to values in the game rules xml
	enum EFeatureTypes
	{
		eFeature_Mineshaft,
		eFeature_NetherBridge,
		eFeature_Temples,
		eFeature_Stronghold,
		eFeature_Village,
	};

#ifdef ENABLE_STRUCTURE_SAVING
private:
	shared_ptr<StructureFeatureSavedData> savedData;
#endif


protected:
	unordered_map<__int64, StructureStart *> cachedStructures;

public:
	StructureFeature();
	~StructureFeature();

	virtual wstring getFeatureName() = 0;

	virtual void addFeature(Level *level, int x, int z, int xOffs, int zOffs, byteArray blocks);

	bool postProcess(Level *level, Random *random, int chunkX, int chunkZ);
	bool isIntersection(int cellX, int cellZ);

	bool isInsideFeature(int cellX, int cellY, int cellZ);

protected:
	StructureStart *getStructureAt(int cellX, int cellY, int cellZ);

public:
	bool isInsideBoundingFeature(int cellX, int cellY, int cellZ);
	TilePos *getNearestGeneratedFeature(Level *level, int cellX, int cellY, int cellZ);

protected:
	vector<TilePos> *getGuesstimatedFeaturePositions(); 

private:
	virtual void restoreSavedData(Level *level);
	virtual void saveFeature(int chunkX, int chunkZ, StructureStart *feature);

	/**
	* Returns true if the given chunk coordinates should hold a structure
	* source.
	* 
	* @param x
	*            chunk x
	* @param z
	*            chunk z
	* @return
	*/
protected:
	virtual bool isFeatureChunk(int x, int z, bool bIsSuperflat=false) = 0;

	/**
	* Creates a new instance of a structure source at the given chunk
	* coordinates.
	* 
	* @param x
	*            chunk x
	* @param z
	*            chunk z
	* @return
	*/
	virtual StructureStart *createStructureStart(int x, int z) = 0;
};