aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/PS3/SPU_Tasks/ChunkUpdate/ThinFenceTile_SPU.cpp
blob: 9e7d30de6ab9b84d7bc227e7ae3aa90b85d153b1 (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
#include "stdafx.h"
#include "ThinFenceTile_SPU.h"
#include "ChunkRebuildData.h"

bool ThinFenceTile_SPU::isSolidRender(bool isServerLevel)
{
	return false;
}

int ThinFenceTile_SPU::getRenderShape()
{
	return Tile_SPU::SHAPE_IRON_FENCE;
}

bool ThinFenceTile_SPU::shouldRenderFace(ChunkRebuildData *level, int x, int y, int z, int face)
{
    int id = level->getTile(x, y, z);
    if (id == this->id) return false;
    return Tile_SPU::shouldRenderFace(level, x, y, z, face);
}

void ThinFenceTile_SPU::updateDefaultShape()
{
	setShape(0, 0, 0, 1, 1, 1);
}

void ThinFenceTile_SPU::updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData, TileEntity* forceEntity) // 4J added forceData, forceEntity param
{
    float minX = 7.0f / 16.0f;
    float maxX = 9.0f / 16.0f;
    float minZ = 7.0f / 16.0f;
    float maxZ = 9.0f / 16.0f;

    bool n = attachsTo(level->getTile(x, y, z - 1));
    bool s = attachsTo(level->getTile(x, y, z + 1));
    bool w = attachsTo(level->getTile(x - 1, y, z));
    bool e = attachsTo(level->getTile(x + 1, y, z));

    if ((w && e) || (!w && !e && !n && !s))
	{
        minX = 0;
        maxX = 1;
    }
	else if (w && !e)
	{
        minX = 0;
    }
	else if (!w && e)
	{
        maxX = 1;
    }
    if ((n && s) || (!w && !e && !n && !s))
	{
        minZ = 0;
        maxZ = 1;
    }
	else if (n && !s)
	{
        minZ = 0;
    }
	else if (!n && s)
	{
        maxZ = 1;
    }
	setShape(minX, 0, minZ, maxX, 1, maxZ);
}

Icon_SPU *ThinFenceTile_SPU::getEdgeTexture()
{
	if(id == Tile_SPU::ironFence_Id)
		return &ms_pTileData->ironFence_EdgeTexture;
	if(id == Tile_SPU::thinGlass_Id)
		return &ms_pTileData->thinGlass_EdgeTexture;
#ifndef SN_TARGET_PS3_SPU
	assert(0);
#endif
	return nullptr;
}

bool ThinFenceTile_SPU::attachsTo(int tile)
{
	return ms_pTileData->solid[tile] || tile == id || tile == Tile_SPU::glass_Id;
}