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
123
124
125
126
127
128
129
|
#include "stdafx.h"
#include "net.minecraft.world.level.h"
#include "net.minecraft.world.item.h"
#include "Material.h"
#include "SignTileEntity.h"
#include "SignTile.h"
SignTile::SignTile(int id, eINSTANCEOF clas, bool onGround) : BaseEntityTile(id, Material::wood, isSolidRender())
{
this->onGround = onGround;
this->clas = clas;
updateDefaultShape();
}
Icon *SignTile::getTexture(int face, int data)
{
return Tile::wood->getTexture(face);
}
void SignTile::updateDefaultShape()
{
float r = 4 / 16.0f;
float h = 16 / 16.0f;
this->setShape(0.5f - r, 0, 0.5f - r, 0.5f + r, h, 0.5f + r);
}
AABB *SignTile::getAABB(Level *level, int x, int y, int z)
{
return NULL;
}
AABB *SignTile::getTileAABB(Level *level, int x, int y, int z)
{
updateShape(level, x, y, z);
return BaseEntityTile::getTileAABB(level, x, y, z);
}
void SignTile::updateShape(LevelSource *level, int x, int y, int z, int forceData, shared_ptr<TileEntity> forceEntity) // 4J added forceData, forceEntity param
{
if (onGround) return;
int face = level->getData(x, y, z);
float h0 = (4 + 0.5f) / 16.0f;
float h1 = (12 + 0.5f) / 16.0f;
float w0 = 0 / 16.0f;
float w1 = 16 / 16.0f;
float d0 = 2 / 16.0f;
setShape(0, 0, 0, 1, 1, 1);
if (face == 2) setShape(w0, h0, 1 - d0, w1, h1, 1);
if (face == 3) setShape(w0, h0, 0, w1, h1, d0);
if (face == 4) setShape(1 - d0, h0, w0, 1, h1, w1);
if (face == 5) setShape(0, h0, w0, d0, h1, w1);
}
int SignTile::getRenderShape()
{
return Tile::SHAPE_INVISIBLE;
}
bool SignTile::isCubeShaped()
{
return false;
}
bool SignTile::isPathfindable(LevelSource *level, int x, int y, int z)
{
return true;
}
bool SignTile::isSolidRender(bool isServerLevel)
{
return false;
}
shared_ptr<TileEntity> SignTile::newTileEntity(Level *level)
{
//try {
// 4J Stu - For some reason the newInstance wasn't working right, but doing it like the other TileEntities is fine
return shared_ptr<TileEntity>( new SignTileEntity() );
//return dynamic_pointer_cast<TileEntity>( clas->newInstance() );
//} catch (Exception e) {
// TODO 4J Stu - Exception handling
// throw new RuntimeException(e);
//}
}
int SignTile::getResource(int data, Random *random, int playerBonusLevel)
{
return Item::sign->id;
}
void SignTile::neighborChanged(Level *level, int x, int y, int z, int type)
{
bool remove = false;
if (onGround)
{
if (!level->getMaterial(x, y - 1, z)->isSolid()) remove = true;
}
else
{
int face = level->getData(x, y, z);
remove = true;
if (face == 2 && level->getMaterial(x, y, z + 1)->isSolid()) remove = false;
if (face == 3 && level->getMaterial(x, y, z - 1)->isSolid()) remove = false;
if (face == 4 && level->getMaterial(x + 1, y, z)->isSolid()) remove = false;
if (face == 5 && level->getMaterial(x - 1, y, z)->isSolid()) remove = false;
}
if (remove)
{
spawnResources(level, x, y, z, level->getData(x, y, z), 0);
level->removeTile(x, y, z);
}
BaseEntityTile::neighborChanged(level, x, y, z, type);
}
int SignTile::cloneTileId(Level *level, int x, int y, int z)
{
return Item::sign_Id;
}
void SignTile::registerIcons(IconRegister *iconRegister)
{
// None
}
|