aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/WoolCarpetTile.cpp
blob: 370b40100ffa8b0429d91e09d98622fb7367adcf (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
#include "stdafx.h"
#include "net.minecraft.world.phys.h"
#include "net.minecraft.world.level.h"
#include "SharedConstants.h"
#include "WoolCarpetTile.h"

WoolCarpetTile::WoolCarpetTile(int id) : Tile(id, Material::clothDecoration, isSolidRender() )
{
	setShape(0, 0, 0, 1, 1 / 16.0f, 1);
	setTicking(true);
	updateShape(0);
}

Icon *WoolCarpetTile::getTexture(int face, int data)
{
	return Tile::wool->getTexture(face, data);
}

AABB *WoolCarpetTile::getAABB(Level *level, int x, int y, int z)
{
	int height = 0;
	float offset = 1.0f / SharedConstants::WORLD_RESOLUTION;
	ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(Tile::tlsIdxShape));
	// 4J Stu - Added this so that the TLS shape is correct for this tile
	if(tls->tileId != this->id) updateDefaultShape();
	return AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1, y + (height * offset), z + tls->zz1);
}

bool WoolCarpetTile::blocksLight()
{
	return false;
}

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

bool WoolCarpetTile::isCubeShaped()
{
	return false;
}

void WoolCarpetTile::updateDefaultShape()
{
	updateShape(0);
}

void WoolCarpetTile::updateShape(LevelSource *level, int x, int y, int z, int forceData, shared_ptr<TileEntity> forceEntity)
{
	updateShape(level->getData(x, y, z));
}

void WoolCarpetTile::updateShape(int data)
{
	int height = 0;
	float o = 1 * (1 + height) / 16.0f;
	setShape(0, 0, 0, 1, o, 1);
}

bool WoolCarpetTile::mayPlace(Level *level, int x, int y, int z)
{
	return Tile::mayPlace(level, x, y, z) && canSurvive(level, x, y, z);
}

void WoolCarpetTile::neighborChanged(Level *level, int x, int y, int z, int type)
{
	checkCanSurvive(level, x, y, z);
}

bool WoolCarpetTile::checkCanSurvive(Level *level, int x, int y, int z)
{
	if (!canSurvive(level, x, y, z))
	{
		spawnResources(level, x, y, z, level->getData(x, y, z), 0);
		level->removeTile(x, y, z);
		return false;
	}
	return true;
}

bool WoolCarpetTile::canSurvive(Level *level, int x, int y, int z)
{
	return !level->isEmptyTile(x, y - 1, z);
}

bool WoolCarpetTile::shouldRenderFace(LevelSource *level, int x, int y, int z, int face)
{
	if (face == 1) return true;
	return Tile::shouldRenderFace(level, x, y, z, face);
}

int WoolCarpetTile::getSpawnResourcesAuxValue(int data)
{
	return data;
}

int WoolCarpetTile::getTileDataForItemAuxValue(int auxValue)
{
	return (~auxValue & 0xf);
}

int WoolCarpetTile::getItemAuxValueForTileData(int data)
{
	return (~data & 0xf);
}

void WoolCarpetTile::registerIcons(IconRegister *iconRegister)
{
	// None, delegates to cloth tile
}