MCPcopy Create free account
hub / github.com/cuberite/cuberite / GetSmallAppleTreeImage

Function GetSmallAppleTreeImage

src/Generating/Trees.cpp:285–332  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

283
284
285void GetSmallAppleTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noise, int a_Seq, sSetBlockVector & a_LogBlocks, sSetBlockVector & a_OtherBlocks)
286{
287 /* Small apple tree has:
288 - a top plus (no log)
289 - optional BigO1 + random corners (log)
290 - 2 layers of BigO2 + random corners (log)
291 - 1 to 3 blocks of trunk
292 */
293
294 int Random = a_Noise.IntNoise3DInt(a_BlockX + 64 * a_Seq, a_BlockY, a_BlockZ) >> 3;
295
296 int Heights[] = {1, 2, 2, 3} ;
297 int Height = 1 + Heights[Random & 3];
298 Random >>= 2;
299
300 // Pre-alloc so that we don't realloc too often later:
301 a_LogBlocks.reserve(Height + 5);
302 a_OtherBlocks.reserve(ARRAYCOUNT(BigO2) * 2 + ARRAYCOUNT(BigO1) + ARRAYCOUNT(Corners) * 3 + 3 + 5);
303
304 // Trunk:
305 for (int i = 0; i < Height; i++)
306 {
307 a_LogBlocks.push_back(sSetBlock(a_BlockX, a_BlockY + i, a_BlockZ, E_BLOCK_LOG, E_META_LOG_APPLE));
308 }
309 int Hei = a_BlockY + Height;
310
311 // 2 BigO2 + corners layers:
312 for (int i = 0; i < 2; i++)
313 {
314 PushCoordBlocks (a_BlockX, Hei, a_BlockZ, a_OtherBlocks, BigO2, ARRAYCOUNT(BigO2), E_BLOCK_LEAVES, E_META_LEAVES_APPLE);
315 PushCornerBlocks(a_BlockX, Hei, a_BlockZ, a_Seq, a_Noise, 0x5000000 - i * 0x10000000, a_OtherBlocks, 2, E_BLOCK_LEAVES, E_META_LEAVES_APPLE);
316 a_LogBlocks.push_back(sSetBlock(a_BlockX, Hei, a_BlockZ, E_BLOCK_LOG, E_META_LOG_APPLE));
317 Hei++;
318 } // for i - 2*
319
320 // Optional BigO1 + corners layer:
321 if ((Random & 1) == 0)
322 {
323 PushCoordBlocks (a_BlockX, Hei, a_BlockZ, a_OtherBlocks, BigO1, ARRAYCOUNT(BigO1), E_BLOCK_LEAVES, E_META_LEAVES_APPLE);
324 PushCornerBlocks(a_BlockX, Hei, a_BlockZ, a_Seq, a_Noise, 0x6000000, a_OtherBlocks, 1, E_BLOCK_LEAVES, E_META_LEAVES_APPLE);
325 a_LogBlocks.push_back(sSetBlock(a_BlockX, Hei, a_BlockZ, E_BLOCK_LOG, E_META_LOG_APPLE));
326 Hei++;
327 }
328
329 // Top plus:
330 PushCoordBlocks(a_BlockX, Hei, a_BlockZ, a_OtherBlocks, BigO1, ARRAYCOUNT(BigO1), E_BLOCK_LEAVES, E_META_LEAVES_APPLE);
331 a_OtherBlocks.push_back(sSetBlock(a_BlockX, Hei, a_BlockZ, E_BLOCK_LEAVES, E_META_LEAVES_APPLE));
332}
333
334
335

Callers 2

Trees.hFile · 0.85
GetAppleTreeImageFunction · 0.85

Calls 4

sSetBlockClass · 0.85
PushCoordBlocksFunction · 0.85
PushCornerBlocksFunction · 0.85
IntNoise3DIntMethod · 0.80

Tested by

no test coverage detected