aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/NetherBridgePieces.h
blob: 81cb156033d4a22f2d7c8bc1bcae4d309d2c33b9 (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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
#pragma once
#include "StructurePiece.h"

class NetherBridgePieces
{
private:
	static const int MAX_DEPTH = 30;
	// the dungeon starts at 64 and traverses downwards to this point
	static const int LOWEST_Y_POSITION = 10;

	// 4J - added to replace use of Class<? extends NetherBridgePiece> within this class
	enum EPieceClass
	{
		EPieceClass_BridgeStraight,
		EPieceClass_BridgeEndFiller,
		EPieceClass_BridgeCrossing,
		EPieceClass_RoomCrossing,
		EPieceClass_StairsRoom,
		EPieceClass_MonsterThrone,
		EPieceClass_CastleEntrance,
		EPieceClass_CastleStalkRoom,
		EPieceClass_CastleSmallCorridorPiece,
		EPieceClass_CastleSmallCorridorCrossingPiece,
		EPieceClass_CastleSmallCorridorRightTurnPiece,
		EPieceClass_CastleSmallCorridorLeftTurnPiece,
		EPieceClass_CastleCorridorStairsPiece,
		EPieceClass_CastleCorridorTBalconyPiece
	};

public:
	static void loadStatic();

private:
	class PieceWeight
	{
	public:
		EPieceClass pieceClass;
		const int weight;
		int placeCount;
		int maxPlaceCount;
		bool allowInRow;

		PieceWeight(EPieceClass pieceClass, int weight, int maxPlaceCount, bool allowInRow);
		PieceWeight(EPieceClass pieceClass, int weight, int maxPlaceCount);
		bool doPlace(int depth);
		bool isValid();
	};

	static const int BRIDGE_PIECEWEIGHTS_COUNT = 6;
	static const int CASTLE_PIECEWEIGHTS_COUNT = 7;
	static NetherBridgePieces::PieceWeight *bridgePieceWeights[BRIDGE_PIECEWEIGHTS_COUNT];
	static NetherBridgePieces::PieceWeight *castlePieceWeights[CASTLE_PIECEWEIGHTS_COUNT];

private:
	class NetherBridgePiece;
	static NetherBridgePiece *findAndCreateBridgePieceFactory(NetherBridgePieces::PieceWeight *piece, list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int depth);

	/**
	* 
	*
	*/
public:
	class StartPiece;
private:

	class NetherBridgePiece : public StructurePiece
	{
	protected:
		static const int FORTRESS_TREASURE_ITEMS_COUNT = 11;
		static WeighedTreasure *fortressTreasureItems[FORTRESS_TREASURE_ITEMS_COUNT];

	public:
		NetherBridgePiece();

	protected:
		NetherBridgePiece(int genDepth);

		virtual void readAdditonalSaveData(CompoundTag *tag);
		virtual void addAdditonalSaveData(CompoundTag *tag);

	private:
		int updatePieceWeight(list<PieceWeight *> *currentPieces);

		NetherBridgePiece *generatePiece(StartPiece *startPiece, list<NetherBridgePieces::PieceWeight *> *currentPieces, list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int depth);
		StructurePiece *generateAndAddPiece(StartPiece *startPiece, list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int depth, bool isCastle);
	protected:
		StructurePiece *generateChildForward(StartPiece *startPiece, list<StructurePiece *> *pieces, Random *random, int xOff, int yOff, bool isCastle);
		StructurePiece *generateChildLeft(StartPiece *startPiece, list<StructurePiece *> *pieces, Random *random, int yOff, int zOff, bool isCastle);
		StructurePiece *generateChildRight(StartPiece *startPiece, list<StructurePiece *> *pieces, Random *random, int yOff, int zOff, bool isCastle);

		static bool isOkBox(BoundingBox *box, StartPiece *startRoom); // 4J added startRoom param
		void generateLightPost(Level *level, Random *random, BoundingBox *chunkBB, int x, int y, int z, int xOff, int zOff);

		void generateLightPostFacingRight(Level *level, Random *random, BoundingBox *chunkBB, int x, int y, int z);
		void generateLightPostFacingLeft(Level *level, Random *random, BoundingBox *chunkBB, int x, int y, int z);
		void generateLightPostFacingUp(Level *level, Random *random, BoundingBox *chunkBB, int x, int y, int z);
		void generateLightPostFacingDown(Level *level, Random *random, BoundingBox *chunkBB, int x, int y, int z);
	};

	/**
	* 
	*
	*/
	class BridgeStraight : public NetherBridgePiece
	{
	public:
		static StructurePiece *Create() { return new BridgeStraight(); }
		virtual EStructurePiece GetType() { return eStructurePiece_BridgeStraight; }

	private:
		static const int width = 5;
		static const int height = 10;
		static const int depth = 19;

	public:
		BridgeStraight();
		BridgeStraight(int genDepth, Random *random, BoundingBox *stairsBox, int direction);
		virtual void addChildren(StructurePiece *startPiece, list<StructurePiece *> *pieces, Random *random);
		static BridgeStraight *createPiece(list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
		virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
	};

	class BridgeEndFiller : public NetherBridgePiece
	{
	public:
		static StructurePiece *Create() { return new BridgeEndFiller(); }
		virtual EStructurePiece GetType() { return eStructurePiece_BridgeEndFiller; }

	private:
		static const int width = 5;
		static const int height = 10;
		static const int depth = 8;

		int selfSeed;

	public:
		BridgeEndFiller();
		BridgeEndFiller(int genDepth, Random *random, BoundingBox *stairsBox, int direction);

		static BridgeEndFiller *createPiece(list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
		virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);

	protected:
		void readAdditonalSaveData(CompoundTag *tag);
		void addAdditonalSaveData(CompoundTag *tag);
	};

	class BridgeCrossing : public NetherBridgePiece
	{
	public:
		static StructurePiece *Create() { return new BridgeCrossing(); }
		virtual EStructurePiece GetType() { return eStructurePiece_BridgeCrossing; }

	private:
		static const int width = 19;
		static const int height = 10;
		static const int depth = 19;

	public:
		BridgeCrossing();
		BridgeCrossing(int genDepth, Random *random, BoundingBox *stairsBox, int direction);
	protected:
		BridgeCrossing(Random *random, int west, int north);
	public:
		virtual void addChildren(StructurePiece *startPiece, list<StructurePiece *> *pieces, Random *random);
		static BridgeCrossing *createPiece(list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
		virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
	};

public:
	class StartPiece : public BridgeCrossing
	{
	public:
		virtual EStructurePiece GetType() { return eStructurePiece_NetherBridgeStartPiece; }

	public:
		PieceWeight *previousPiece;
		Level *m_level;

		list<PieceWeight *> availableBridgePieces;
		list<PieceWeight *> availableCastlePieces;

		// this queue is used so that the addChildren calls are
		// called in a random order
		vector<StructurePiece *> pendingChildren;

		StartPiece();
		StartPiece(Random *random, int west, int north, Level *level); // 4J Added level param

	protected:
		virtual void readAdditonalSaveData(CompoundTag *tag);
		virtual void addAdditonalSaveData(CompoundTag *tag);
	};

private:
	class RoomCrossing : public NetherBridgePiece
	{
	public:
		static StructurePiece *Create() { return new RoomCrossing(); }
		virtual EStructurePiece GetType() { return eStructurePiece_RoomCrossing; }

	private:
		static const int width = 7;
		static const int height = 9;
		static const int depth = 7;

	public:
		RoomCrossing();
		RoomCrossing(int genDepth, Random *random, BoundingBox *box, int direction);
		virtual void addChildren(StructurePiece *startPiece, list<StructurePiece *> *pieces, Random *random);
		static RoomCrossing *createPiece(list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
		virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
	};

	class StairsRoom : public NetherBridgePiece
	{
	public:
		static StructurePiece *Create() { return new StairsRoom(); }
		virtual EStructurePiece GetType() { return eStructurePiece_StairsRoom; }

	private:
		static const int width = 7;
		static const int height = 11;
		static const int depth = 7;

	public:
		StairsRoom();
		StairsRoom(int genDepth, Random *random, BoundingBox *box, int direction);
		virtual void addChildren(StructurePiece *startPiece, list<StructurePiece *> *pieces, Random *random);
		static StairsRoom *createPiece(list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
		virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
	};

	class MonsterThrone : public NetherBridgePiece
	{
	public:
		static StructurePiece *Create() { return new MonsterThrone(); }
		virtual EStructurePiece GetType() { return eStructurePiece_MonsterThrone; }

	private:
		static const int width = 7;
		static const int height = 8;
		static const int depth = 9;

		bool hasPlacedMobSpawner;

	public:
		MonsterThrone();
		MonsterThrone(int genDepth, Random *random, BoundingBox *box, int direction);

	protected:
		virtual void readAdditonalSaveData(CompoundTag *tag);
		virtual void addAdditonalSaveData(CompoundTag *tag);

	public:
		static MonsterThrone *createPiece(list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
		virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
	};

	/**
	* 
	*
	*/
	class CastleEntrance : public NetherBridgePiece
	{
	public:
		static StructurePiece *Create() { return new CastleEntrance(); }
		virtual EStructurePiece GetType() { return eStructurePiece_CastleEntrance; }

	private:
		static const int width = 13;
		static const int height = 14;
		static const int depth = 13;
	public:
		CastleEntrance();
		CastleEntrance(int genDepth, Random *random, BoundingBox *stairsBox, int direction);
		virtual void addChildren(StructurePiece *startPiece, list<StructurePiece *> *pieces, Random *random);
		static CastleEntrance *createPiece(list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
		virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
	};

	/**
	* 
	*
	*/
	class CastleStalkRoom : public NetherBridgePiece
	{
	public:
		static StructurePiece *Create() { return new CastleStalkRoom(); }
		virtual EStructurePiece GetType() { return eStructurePiece_CastleStalkRoom; }

	private:
		static const int width = 13;
		static const int height = 14;
		static const int depth = 13;

	public:
		CastleStalkRoom();
		CastleStalkRoom(int genDepth, Random *random, BoundingBox *stairsBox, int direction);
		virtual void addChildren(StructurePiece *startPiece, list<StructurePiece *> *pieces, Random *random);
		static CastleStalkRoom *createPiece(list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
		virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
	};

	/**
	* 
	*
	*/
	class CastleSmallCorridorPiece : public NetherBridgePiece
	{
	public:
		static StructurePiece *Create() { return new CastleSmallCorridorPiece(); }
		virtual EStructurePiece GetType() { return eStructurePiece_CastleSmallCorridorPiece; }

	private:
		static const int width = 5;
		static const int height = 7;
		static const int depth = 5;

	public:
		CastleSmallCorridorPiece();
		CastleSmallCorridorPiece(int genDepth, Random *random, BoundingBox *stairsBox, int direction);
		virtual void addChildren(StructurePiece *startPiece, list<StructurePiece *> *pieces, Random *random);
		static CastleSmallCorridorPiece *createPiece(list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
		virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
	};

	/**
	* 
	*
	*/
	class CastleSmallCorridorCrossingPiece : public NetherBridgePiece
	{
	public:
		static StructurePiece *Create() { return new CastleSmallCorridorCrossingPiece(); }
		virtual EStructurePiece GetType() { return eStructurePiece_CastleSmallCorridorCrossingPiece; }

	private:
		static const int width = 5;
		static const int height = 7;
		static const int depth = 5;

	public:
		CastleSmallCorridorCrossingPiece();
		CastleSmallCorridorCrossingPiece(int genDepth, Random *random, BoundingBox *stairsBox, int direction);
		virtual void addChildren(StructurePiece *startPiece, list<StructurePiece *> *pieces, Random *random);
		static CastleSmallCorridorCrossingPiece *createPiece(list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
		virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
	};

	/**
	* 
	*
	*/
	class CastleSmallCorridorRightTurnPiece : public NetherBridgePiece
	{
	public:
		static StructurePiece *Create() { return new CastleSmallCorridorRightTurnPiece(); }
		virtual EStructurePiece GetType() { return eStructurePiece_CastleSmallCorridorRightTurnPiece; }

	private:
		static const int width = 5;
		static const int height = 7;
		static const int depth = 5;

		bool isNeedingChest;

	public:
		CastleSmallCorridorRightTurnPiece();
		CastleSmallCorridorRightTurnPiece(int genDepth, Random *random, BoundingBox *stairsBox, int direction);

	protected:
		virtual void readAdditonalSaveData(CompoundTag *tag);
		virtual void addAdditonalSaveData(CompoundTag *tag);

	public:
		virtual void addChildren(StructurePiece *startPiece, list<StructurePiece *> *pieces, Random *random);
		static CastleSmallCorridorRightTurnPiece *createPiece(list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
		virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);

	};

	/**
	* 
	*
	*/
	class CastleSmallCorridorLeftTurnPiece : public NetherBridgePiece
	{
	public:
		static StructurePiece *Create() { return new CastleSmallCorridorLeftTurnPiece(); }
		virtual EStructurePiece GetType() { return eStructurePiece_CastleSmallCorridorLeftTurnPiece; }

	private:
		static const int width = 5;
		static const int height = 7;
		static const int depth = 5;
		bool isNeedingChest;

	public:
		CastleSmallCorridorLeftTurnPiece();
		CastleSmallCorridorLeftTurnPiece(int genDepth, Random *random, BoundingBox *stairsBox, int direction);

	protected:
		virtual void readAdditonalSaveData(CompoundTag *tag);
		virtual void addAdditonalSaveData(CompoundTag *tag);

	public:
		virtual void addChildren(StructurePiece *startPiece, list<StructurePiece *> *pieces, Random *random);
		static CastleSmallCorridorLeftTurnPiece *createPiece(list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
		virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
	};

	/**
	* 
	*
	*/
	class CastleCorridorStairsPiece : public NetherBridgePiece
	{
	public:
		static StructurePiece *Create() { return new CastleCorridorStairsPiece(); }
		virtual EStructurePiece GetType() { return eStructurePiece_CastleCorridorStairsPiece; }

	private:
		static const int width = 5;
		static const int height = 14;
		static const int depth = 10;

	public:
		CastleCorridorStairsPiece();
		CastleCorridorStairsPiece(int genDepth, Random *random, BoundingBox *stairsBox, int direction);
		virtual void addChildren(StructurePiece *startPiece, list<StructurePiece *> *pieces, Random *random);
		static CastleCorridorStairsPiece *createPiece(list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
		virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);

	};

	/**
	* 
	*
	*/
	class CastleCorridorTBalconyPiece : public NetherBridgePiece
	{
	public:
		static StructurePiece *Create() { return new CastleCorridorTBalconyPiece(); }
		virtual EStructurePiece GetType() { return eStructurePiece_CastleCorridorTBalconyPiece; }

	private:
		static const int width = 9;
		static const int height = 7;
		static const int depth = 9;

	public:
		CastleCorridorTBalconyPiece();
		CastleCorridorTBalconyPiece(int genDepth, Random *random, BoundingBox *stairsBox, int direction);
		virtual void addChildren(StructurePiece *startPiece, list<StructurePiece *> *pieces, Random *random);
		static CastleCorridorTBalconyPiece *createPiece(list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int genDepth);
		virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
	};
};