the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#include "stdafx.h"
2#include "LeafTile_SPU.h"
3#include "ChunkRebuildData.h"
4
5
6// const unsigned int LeafTile::LEAF_NAMES[LEAF_NAMES_LENGTH] = { IDS_TILE_LEAVES_OAK,
7// IDS_TILE_LEAVES_SPRUCE,
8// IDS_TILE_LEAVES_BIRCH,
9// };
10//
11// const wstring LeafTile::TEXTURES[2][4] = { {L"leaves", L"leaves_spruce", L"leaves", L"leaves_jungle"}, {L"leaves_opaque", L"leaves_spruce_opaque", L"leaves_opaque", L"leaves_jungle_opaque"},};
12
13
14// from TransparentTile, since we're no longer inheriting
15bool LeafTile_SPU::shouldRenderFace(ChunkRebuildData *level, int x, int y, int z, int face)
16{
17 int id = level->getTile(x, y, z);
18 if (!ms_pTileData->leafTile_allowSame && id == this->id) return false;
19 return Tile_SPU::shouldRenderFace(level, x, y, z, face);
20}
21
22int LeafTile_SPU::getColor(ChunkRebuildData *level, int x, int y, int z)
23{
24 return getColor(level, x, y, z, level->getData(x, y, z) );
25}
26
27// 4J - changed interface to have data passed in, and put existing interface as wrapper above
28int LeafTile_SPU::getColor(ChunkRebuildData *level, int x, int y, int z, int data)
29{
30 if ((data & LEAF_TYPE_MASK) == EVERGREEN_LEAF)
31 {
32 return ms_pTileData->foliageColor_evergreenColor; //FoliageColor::getEvergreenColor();
33 }
34 if ((data & LEAF_TYPE_MASK) == BIRCH_LEAF)
35 {
36 return ms_pTileData->foliageColor_birchColor;//FoliageColor::getBirchColor();
37 }
38
39 //return level->getBiomeSource()->getBiome(x, z)->getFolageColor(level, x, y, z);
40
41 int totalRed = 0;
42 int totalGreen = 0;
43 int totalBlue = 0;
44
45 for (int oz = -1; oz <= 1; oz++)
46 {
47 for (int ox = -1; ox <= 1; ox++)
48 {
49 int foliageColor = level->getFoliageColor(x + ox, z + oz);
50
51 totalRed += (foliageColor & 0xff0000) >> 16;
52 totalGreen += (foliageColor & 0xff00) >> 8;
53 totalBlue += (foliageColor & 0xff);
54 }
55 }
56
57 // return level.getBiomeSource().getBiome(x, z).getGrassColor(level, x, y, z);
58 return (((totalRed / 9) & 0xFF) << 16) | (((totalGreen / 9) & 0xFF) << 8) | (((totalBlue / 9) & 0xFF));
59}
60
61
62
63bool LeafTile_SPU::isSolidRender(bool isServerLevel)
64{
65 // 4J Stu - The server level shouldn't care how the tile is rendered!
66 // Fix for #9407 - Gameplay: Destroying a block of snow on top of trees, removes any adjacent snow.
67 if(isServerLevel) return true;
68 return !ms_pTileData->leafTile_allowSame;
69}
70
71Icon_SPU *LeafTile_SPU::getTexture(int face, int data)
72{
73 if ((data & LEAF_TYPE_MASK) == EVERGREEN_LEAF)
74 {
75 return &ms_pTileData->leafTile_icons[ms_pTileData->leafTile_fancyTextureSet][EVERGREEN_LEAF];
76 }
77 if ((data & LEAF_TYPE_MASK) == JUNGLE_LEAF)
78 {
79 return &ms_pTileData->leafTile_icons[ms_pTileData->leafTile_fancyTextureSet][JUNGLE_LEAF];
80 }
81 return &ms_pTileData->leafTile_icons[ms_pTileData->leafTile_fancyTextureSet][0];
82}
83
84void LeafTile_SPU::setFancy(bool fancyGraphics)
85{
86 ms_pTileData->leafTile_allowSame = fancyGraphics;
87 ms_pTileData->leafTile_fancyTextureSet = (fancyGraphics ? 0 : 1);
88}