aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/QuartzBlockTile.cpp
blob: 709e0c1e9779d9489eb782d5b6dab56f8ab15a27 (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
112
113
114
115
116
117
118
119
120
121
122
#include "stdafx.h"
#include "net.minecraft.h"
#include "net.minecraft.world.h"
#include "QuartzBlockTile.h"

// 4J Added
#include "Level.h"
#include "PistonBaseTile.h"
#include "Player.h"

int QuartzBlockTile::BLOCK_NAMES[QUARTZ_BLOCK_NAMES] = {
	IDS_TILE_QUARTZ_BLOCK, IDS_TILE_QUARTZ_BLOCK_CHISELED, IDS_TILE_QUARTZ_BLOCK_LINES, IDS_TILE_QUARTZ_BLOCK_LINES, IDS_TILE_QUARTZ_BLOCK_LINES
};

const wstring QuartzBlockTile::TEXTURE_TOP = L"top";
const wstring QuartzBlockTile::TEXTURE_CHISELED_TOP = L"chiseled_top";
const wstring QuartzBlockTile::TEXTURE_LINES_TOP = L"lines_top";
const wstring QuartzBlockTile::TEXTURE_BOTTOM = L"bottom";
const wstring QuartzBlockTile::TEXTURE_NAMES[QUARTZ_BLOCK_TEXTURES] = {	L"side", L"chiseled", L"lines", L"", L""};

QuartzBlockTile::QuartzBlockTile(int id) : Tile(id, Material::stone)
{
}

Icon *QuartzBlockTile::getTexture(int face, int data)
{
	if (data == TYPE_LINES_Y || data == TYPE_LINES_X || data == TYPE_LINES_Z)
	{
		if (data == TYPE_LINES_Y && (face == Facing::UP || face == Facing::DOWN))
		{
			return iconLinesTop;
		}
		else if (data == TYPE_LINES_X && (face == Facing::EAST || face == Facing::WEST))
		{
			return iconLinesTop;
		}
		else if (data == TYPE_LINES_Z && (face == Facing::NORTH || face == Facing::SOUTH))
		{
			return iconLinesTop;
		}

		return icons[data];
	}

	if (face == Facing::UP || (face == Facing::DOWN && data == TYPE_CHISELED))
	{
		if (data == TYPE_CHISELED)
		{
			return iconChiseledTop;
		}
		return iconTop;
	}
	if (face == Facing::DOWN)
	{
		return iconBottom;
	}
	if (data < 0 || data >= QUARTZ_BLOCK_TEXTURES) data = 0;
	return icons[data];
}

int QuartzBlockTile::getPlacedOnFaceDataValue(Level *level, int x, int y, int z, int face, float clickX, float clickY, float clickZ, int itemValue)
{
	if (itemValue == TYPE_LINES_Y)
	{
		switch (face)
		{
		case Facing::NORTH:
		case Facing::SOUTH:
			itemValue = TYPE_LINES_Z;
			break;
		case Facing::EAST:
		case Facing::WEST:
			itemValue = TYPE_LINES_X;
			break;
		case Facing::UP:
		case Facing::DOWN:
			itemValue = TYPE_LINES_Y;
			break;
		}
	}

	return itemValue;
}

int QuartzBlockTile::getSpawnResourcesAuxValue(int data)
{
	if (data == TYPE_LINES_X || data == TYPE_LINES_Z) return TYPE_LINES_Y;

	return data;
}

shared_ptr<ItemInstance> QuartzBlockTile::getSilkTouchItemInstance(int data)
{
	if (data == TYPE_LINES_X || data == TYPE_LINES_Z) return shared_ptr<ItemInstance>(new ItemInstance(id, 1, TYPE_LINES_Y));
	return Tile::getSilkTouchItemInstance(data);
}

int QuartzBlockTile::getRenderShape()
{
	return Tile::SHAPE_QUARTZ;
}


void QuartzBlockTile::registerIcons(IconRegister *iconRegister)
{
	for (int i = 0; i < QUARTZ_BLOCK_TEXTURES; i++)
	{
		if (TEXTURE_NAMES[i].empty())
		{
			icons[i] = icons[i - 1];
		}
		else
		{
			icons[i] = iconRegister->registerIcon(getIconName() + L"_" + TEXTURE_NAMES[i]);
		}
	}

	iconTop = iconRegister->registerIcon(getIconName() + L"_" + TEXTURE_TOP);
	iconChiseledTop = iconRegister->registerIcon(getIconName() + L"_" + TEXTURE_CHISELED_TOP);
	iconLinesTop = iconRegister->registerIcon(getIconName() + L"_" + TEXTURE_LINES_TOP);
	iconBottom = iconRegister->registerIcon(getIconName() + L"_" + TEXTURE_BOTTOM);
}