aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/GrassTile_SPU.cpp
blob: 833025ad0e32ff5f1e60c5661b81c6561592c479 (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
#include "stdafx.h"
#include "GrassTile_SPU.h"
// #include "net.minecraft.world.level.h"
// #include "net.minecraft.world.level.biome.h"
// #include "net.minecraft.h"
// #include "net.minecraft.world.h"

#include "Facing_SPU.h"
#include "ChunkRebuildData.h"


Icon_SPU *GrassTile_SPU::getTexture(int face, int data)
{
    if (face == Facing::UP) return &ms_pTileData->grass_iconTop;
    if (face == Facing::DOWN) return TileRef_SPU(dirt_Id)->getTexture(face);
    return icon();
}

Icon_SPU *GrassTile_SPU::getTexture(ChunkRebuildData *level, int x, int y, int z, int face)
{
    if (face == Facing::UP) return &ms_pTileData->grass_iconTop;
    if (face == Facing::DOWN) return TileRef_SPU(dirt_Id)->getTexture(face);
     Material_SPU *above = level->getMaterial(x, y + 1, z);
     if (above->getID() == Material_SPU::topSnow_Id || above->getID() == Material_SPU::snow_Id) 
 		return &ms_pTileData->grass_iconSnowSide;
     else 
		return icon();
}


int GrassTile_SPU::getColor(ChunkRebuildData *level, int x, int y, int z)
{
	return getColor( level, x, y, z, level->getData( x, y, z ) );
}

// 4J - changed interface to have data passed in, and put existing interface as wrapper above
int GrassTile_SPU::getColor(ChunkRebuildData *level, int x, int y, int z, int data)
{
	//return level->getBiomeSource()->getBiome(x, z)->getGrassColor(level, x, y, z);

	int totalRed = 0;
	int totalGreen = 0;
	int totalBlue = 0;

	for (int oz = -1; oz <= 1; oz++)
	{
		for (int ox = -1; ox <= 1; ox++)
		{
			int grassColor = level->getGrassColor(x + ox, z + oz);
			totalRed += (grassColor & 0xff0000) >> 16;
			totalGreen += (grassColor & 0xff00) >> 8;
			totalBlue += (grassColor & 0xff);
		}
	}

	//        return level.getBiomeSource().getBiome(x, z).getGrassColor(level, x, y, z);
	return (((totalRed / 9) & 0xFF) << 16) | (((totalGreen / 9) & 0xFF) << 8) | (((totalBlue / 9) & 0xFF));
}


Icon_SPU *GrassTile_SPU::getSideTextureOverlay()
{
	return &ms_pTileData->grass_iconSideOverlay;
}