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.level.tile.h"
4#include "net.minecraft.world.phys.h"
5#include "net.minecraft.world.h"
6#include "net.minecraft.h"
7#include "WallTile.h"
8
9const float WallTile::WALL_WIDTH = 3.0f / 16.0f;
10const float WallTile::WALL_HEIGHT = 13.0f / 16.0f;
11const float WallTile::POST_WIDTH = 4.0f / 16.0f;
12const float WallTile::POST_HEIGHT = 16.0f / 16.0f;
13
14const unsigned int WallTile::COBBLE_NAMES[2] = { IDS_TILE_COBBLESTONE_WALL,
15 IDS_TILE_COBBLESTONE_WALL_MOSSY,
16};
17
18WallTile::WallTile(int id, Tile *baseTile) : Tile(id, baseTile->material, isSolidRender())
19{
20 setDestroyTime(baseTile->destroySpeed);
21 setExplodeable(baseTile->explosionResistance / 3);
22 setSoundType(baseTile->soundType);
23}
24
25Icon *WallTile::getTexture(int face, int data)
26{
27 if (data == TYPE_MOSSY)
28 {
29 return Tile::mossyCobblestone->getTexture(face);
30 }
31 return Tile::cobblestone->getTexture(face);
32}
33
34int WallTile::getRenderShape()
35{
36 return SHAPE_WALL;
37}
38
39bool WallTile::isCubeShaped()
40{
41 return false;
42}
43
44bool WallTile::isPathfindable(LevelSource *level, int x, int y, int z)
45{
46 return false;
47}
48
49bool WallTile::isSolidRender(bool isServerLevel)
50{
51 return false;
52}
53
54void WallTile::updateShape(LevelSource *level, int x, int y, int z, int forceData, shared_ptr<TileEntity> forceEntity)
55{
56 bool n = connectsTo(level, x, y, z - 1);
57 bool s = connectsTo(level, x, y, z + 1);
58 bool w = connectsTo(level, x - 1, y, z);
59 bool e = connectsTo(level, x + 1, y, z);
60
61 float west = .5f - POST_WIDTH;
62 float east = .5f + POST_WIDTH;
63 float north = .5f - POST_WIDTH;
64 float south = .5f + POST_WIDTH;
65 float up = POST_HEIGHT;
66
67 if (n)
68 {
69 north = 0;
70 }
71 if (s)
72 {
73 south = 1;
74 }
75 if (w)
76 {
77 west = 0;
78 }
79 if (e)
80 {
81 east = 1;
82 }
83
84 if (n && s && !w && !e)
85 {
86 up = WALL_HEIGHT;
87 west = .5f - WALL_WIDTH;
88 east = .5f + WALL_WIDTH;
89 }
90 else if (!n && !s && w && e)
91 {
92 up = WALL_HEIGHT;
93 north = .5f - WALL_WIDTH;
94 south = .5f + WALL_WIDTH;
95 }
96
97 setShape(west, 0, north, east, up, south);
98}
99
100AABB *WallTile::getAABB(Level *level, int x, int y, int z)
101{
102 // 4J-JEV: Changed to avoid race conditions associated with calling update shape.
103
104 bool n = connectsTo(level, x, y, z - 1);
105 bool s = connectsTo(level, x, y, z + 1);
106 bool w = connectsTo(level, x - 1, y, z);
107 bool e = connectsTo(level, x + 1, y, z);
108
109 float west = .5f - POST_WIDTH;
110 float east = .5f + POST_WIDTH;
111 float north = .5f - POST_WIDTH;
112 float south = .5f + POST_WIDTH;
113 float up = POST_HEIGHT;
114
115 if (n)
116 {
117 north = 0;
118 }
119 if (s)
120 {
121 south = 1;
122 }
123 if (w)
124 {
125 west = 0;
126 }
127 if (e)
128 {
129 east = 1;
130 }
131
132 /* 4J-JEV:
133 Stopping the width changing here, it's causing cows/mobs/passers-by to 'jump' up when they are pressed against the
134 wall and then the wall section is upgraded to a wall post expanding the bounding box.
135 It's only a 1/16 of a block difference, it shouldn't matter if we leave it a little larger.
136 */
137 if (n && s && !w && !e)
138 {
139 up = WALL_HEIGHT;
140 //west = .5f - WALL_WIDTH;
141 //east = .5f + WALL_WIDTH;
142 }
143 else if (!n && !s && w && e)
144 {
145 up = WALL_HEIGHT;
146 //north = .5f - WALL_WIDTH;
147 //south = .5f + WALL_WIDTH;
148 }
149
150 return AABB::newTemp(x+west, y, z+north, x+east, y+1.5f, z+south);
151}
152
153
154bool WallTile::connectsTo(LevelSource *level, int x, int y, int z)
155{
156 int tile = level->getTile(x, y, z);
157 if (tile == id || tile == Tile::fenceGate_Id)
158 {
159 return true;
160 }
161 Tile *tileInstance = Tile::tiles[tile];
162 if (tileInstance != NULL)
163 {
164 if (tileInstance->material->isSolidBlocking() && tileInstance->isCubeShaped())
165 {
166 return tileInstance->material != Material::vegetable;
167 }
168 }
169 return false;
170}
171
172int WallTile::getSpawnResourcesAuxValue(int data)
173{
174 return data;
175}
176
177bool WallTile::shouldRenderFace(LevelSource *level, int x, int y, int z, int face)
178{
179 if (face == Facing::DOWN)
180 {
181 return Tile::shouldRenderFace(level, x, y, z, face);
182 }
183 return true;
184}
185
186void WallTile::registerIcons(IconRegister *iconRegister)
187{
188 // None
189}