the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#include "stdafx.h"
2#include "net.minecraft.world.level.h"
3#include "net.minecraft.world.item.h"
4#include "Material.h"
5#include "SignTileEntity.h"
6#include "SignTile.h"
7
8SignTile::SignTile(int id, eINSTANCEOF clas, bool onGround) : BaseEntityTile(id, Material::wood, isSolidRender())
9{
10 this->onGround = onGround;
11 this->clas = clas;
12 updateDefaultShape();
13}
14
15Icon *SignTile::getTexture(int face, int data)
16{
17 return Tile::wood->getTexture(face);
18}
19
20void SignTile::updateDefaultShape()
21{
22 float r = 4 / 16.0f;
23 float h = 16 / 16.0f;
24 this->setShape(0.5f - r, 0, 0.5f - r, 0.5f + r, h, 0.5f + r);
25}
26
27AABB *SignTile::getAABB(Level *level, int x, int y, int z)
28{
29 return NULL;
30}
31
32AABB *SignTile::getTileAABB(Level *level, int x, int y, int z)
33{
34 updateShape(level, x, y, z);
35 return BaseEntityTile::getTileAABB(level, x, y, z);
36}
37
38void SignTile::updateShape(LevelSource *level, int x, int y, int z, int forceData, shared_ptr<TileEntity> forceEntity) // 4J added forceData, forceEntity param
39{
40 if (onGround) return;
41
42 int face = level->getData(x, y, z);
43
44 float h0 = (4 + 0.5f) / 16.0f;
45 float h1 = (12 + 0.5f) / 16.0f;
46 float w0 = 0 / 16.0f;
47 float w1 = 16 / 16.0f;
48
49 float d0 = 2 / 16.0f;
50
51 setShape(0, 0, 0, 1, 1, 1);
52 if (face == 2) setShape(w0, h0, 1 - d0, w1, h1, 1);
53 if (face == 3) setShape(w0, h0, 0, w1, h1, d0);
54 if (face == 4) setShape(1 - d0, h0, w0, 1, h1, w1);
55 if (face == 5) setShape(0, h0, w0, d0, h1, w1);
56}
57
58int SignTile::getRenderShape()
59{
60 return Tile::SHAPE_INVISIBLE;
61}
62
63bool SignTile::isCubeShaped()
64{
65 return false;
66}
67
68bool SignTile::isPathfindable(LevelSource *level, int x, int y, int z)
69{
70 return true;
71}
72
73bool SignTile::isSolidRender(bool isServerLevel)
74{
75 return false;
76}
77
78shared_ptr<TileEntity> SignTile::newTileEntity(Level *level)
79{
80 //try {
81 // 4J Stu - For some reason the newInstance wasn't working right, but doing it like the other TileEntities is fine
82 return shared_ptr<TileEntity>( new SignTileEntity() );
83 //return dynamic_pointer_cast<TileEntity>( clas->newInstance() );
84 //} catch (Exception e) {
85 // TODO 4J Stu - Exception handling
86 // throw new RuntimeException(e);
87 //}
88}
89
90int SignTile::getResource(int data, Random *random, int playerBonusLevel)
91{
92 return Item::sign->id;
93}
94
95void SignTile::neighborChanged(Level *level, int x, int y, int z, int type)
96{
97 bool remove = false;
98
99 if (onGround)
100 {
101 if (!level->getMaterial(x, y - 1, z)->isSolid()) remove = true;
102 }
103 else
104 {
105 int face = level->getData(x, y, z);
106 remove = true;
107 if (face == 2 && level->getMaterial(x, y, z + 1)->isSolid()) remove = false;
108 if (face == 3 && level->getMaterial(x, y, z - 1)->isSolid()) remove = false;
109 if (face == 4 && level->getMaterial(x + 1, y, z)->isSolid()) remove = false;
110 if (face == 5 && level->getMaterial(x - 1, y, z)->isSolid()) remove = false;
111 }
112 if (remove)
113 {
114 spawnResources(level, x, y, z, level->getData(x, y, z), 0);
115 level->removeTile(x, y, z);
116 }
117
118 BaseEntityTile::neighborChanged(level, x, y, z, type);
119}
120
121int SignTile::cloneTileId(Level *level, int x, int y, int z)
122{
123 return Item::sign_Id;
124}
125
126void SignTile::registerIcons(IconRegister *iconRegister)
127{
128 // None
129}