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 "StairTile_SPU.h"
3#include "ChunkRebuildData.h"
4
5
6void StairTile_SPU::updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData, TileEntity* forceEntity) // 4J added forceData, forceEntity param
7{
8 setShape(0, 0, 0, 1, 1, 1);
9}
10
11bool StairTile_SPU::isSolidRender(bool isServerLevel)
12{
13 return false;
14}
15
16int StairTile_SPU::getRenderShape()
17{
18 return Tile_SPU::SHAPE_STAIRS;
19}
20
21void StairTile_SPU::setBaseShape(ChunkRebuildData *level, int x, int y, int z)
22{
23 int data = level->getData(x, y, z);
24
25 if ((data & UPSIDEDOWN_BIT) != 0)
26 {
27 setShape(0, .5f, 0, 1, 1, 1);
28 }
29 else
30 {
31 setShape(0, 0, 0, 1, .5f, 1);
32 }
33}
34
35bool StairTile_SPU::isStairs(int id)
36{
37 switch(id)
38 {
39 case Tile_SPU::stairs_wood_Id:
40 case Tile_SPU::stairs_stone_Id:
41 case Tile_SPU::stairs_bricks_Id:
42 case Tile_SPU::stairs_stoneBrickSmooth_Id:
43 case Tile_SPU::stairs_netherBricks_Id:
44 case Tile_SPU::stairs_sandstone_Id:
45 case Tile_SPU::stairs_sprucewood_Id:
46 case Tile_SPU::stairs_birchwood_Id:
47 return true;
48 default:
49 return false;
50 }
51 return false;
52}
53
54bool StairTile_SPU::isLockAttached(ChunkRebuildData *level, int x, int y, int z, int data)
55{
56 int lockTile = level->getTile(x, y, z);
57 if (isStairs(lockTile) && level->getData(x, y, z) == data)
58 {
59 return true;
60 }
61
62 return false;
63}
64
65bool StairTile_SPU::setStepShape(ChunkRebuildData *level, int x, int y, int z)
66{
67 int data = level->getData(x, y, z);
68 int dir = data & 0x3;
69
70 float bottom = 0.5f;
71 float top = 1.0f;
72
73 if ((data & UPSIDEDOWN_BIT) != 0)
74 {
75 bottom = 0;
76 top = .5f;
77 }
78
79 float west = 0;
80 float east = 1;
81 float north = 0;
82 float south = .5f;
83
84 bool checkInnerPiece = true;
85
86 if (dir == DIR_EAST)
87 {
88 west = .5f;
89 south = 1;
90
91 int backTile = level->getTile(x + 1, y, z);
92 int backData = level->getData(x + 1, y, z);
93 if (isStairs(backTile) && ((data & UPSIDEDOWN_BIT) == (backData & UPSIDEDOWN_BIT)))
94 {
95 int backDir = backData & 0x3;
96 if (backDir == DIR_NORTH && !isLockAttached(level, x, y, z + 1, data))
97 {
98 south = .5f;
99 checkInnerPiece = false;
100 }
101 else if (backDir == DIR_SOUTH && !isLockAttached(level, x, y, z - 1, data))
102 {
103 north = .5f;
104 checkInnerPiece = false;
105 }
106 }
107 }
108 else if (dir == DIR_WEST)
109 {
110 east = .5f;
111 south = 1;
112
113 int backTile = level->getTile(x - 1, y, z);
114 int backData = level->getData(x - 1, y, z);
115 if (isStairs(backTile) && ((data & UPSIDEDOWN_BIT) == (backData & UPSIDEDOWN_BIT)))
116 {
117 int backDir = backData & 0x3;
118 if (backDir == DIR_NORTH && !isLockAttached(level, x, y, z + 1, data))
119 {
120 south = .5f;
121 checkInnerPiece = false;
122 }
123 else if (backDir == DIR_SOUTH && !isLockAttached(level, x, y, z - 1, data))
124 {
125 north = .5f;
126 checkInnerPiece = false;
127 }
128 }
129 }
130 else if (dir == DIR_SOUTH)
131 {
132 north = .5f;
133 south = 1;
134
135 int backTile = level->getTile(x, y, z + 1);
136 int backData = level->getData(x, y, z + 1);
137 if (isStairs(backTile) && ((data & UPSIDEDOWN_BIT) == (backData & UPSIDEDOWN_BIT)))
138 {
139 int backDir = backData & 0x3;
140 if (backDir == DIR_WEST && !isLockAttached(level, x + 1, y, z, data))
141 {
142 east = .5f;
143 checkInnerPiece = false;
144 }
145 else if (backDir == DIR_EAST && !isLockAttached(level, x - 1, y, z, data))
146 {
147 west = .5f;
148 checkInnerPiece = false;
149 }
150 }
151 }
152 else if (dir == DIR_NORTH)
153 {
154 int backTile = level->getTile(x, y, z - 1);
155 int backData = level->getData(x, y, z - 1);
156 if (isStairs(backTile) && ((data & UPSIDEDOWN_BIT) == (backData & UPSIDEDOWN_BIT)))
157 {
158 int backDir = backData & 0x3;
159 if (backDir == DIR_WEST && !isLockAttached(level, x + 1, y, z, data))
160 {
161 east = .5f;
162 checkInnerPiece = false;
163 }
164 else if (backDir == DIR_EAST && !isLockAttached(level, x - 1, y, z, data))
165 {
166 west = .5f;
167 checkInnerPiece = false;
168 }
169 }
170 }
171
172 setShape(west, bottom, north, east, top, south);
173 return checkInnerPiece;
174}
175
176/*
177* This method adds an extra 1/8 block if the stairs can attach as an
178* "inner corner."
179*/
180bool StairTile_SPU::setInnerPieceShape(ChunkRebuildData *level, int x, int y, int z)
181{
182 int data = level->getData(x, y, z);
183 int dir = data & 0x3;
184
185 float bottom = 0.5f;
186 float top = 1.0f;
187
188 if ((data & UPSIDEDOWN_BIT) != 0)
189 {
190 bottom = 0;
191 top = .5f;
192 }
193
194 float west = 0;
195 float east = .5f;
196 float north = .5f;
197 float south = 1.0f;
198
199 bool hasInnerPiece = false;
200
201 if (dir == DIR_EAST)
202 {
203 int frontTile = level->getTile(x - 1, y, z);
204 int frontData = level->getData(x - 1, y, z);
205 if (isStairs(frontTile) && ((data & UPSIDEDOWN_BIT) == (frontData & UPSIDEDOWN_BIT)))
206 {
207 int frontDir = frontData & 0x3;
208 if (frontDir == DIR_NORTH && !isLockAttached(level, x, y, z - 1, data))
209 {
210 north = 0;
211 south = .5f;
212 hasInnerPiece = true;
213 }
214 else if (frontDir == DIR_SOUTH && !isLockAttached(level, x, y, z + 1, data))
215 {
216 north = .5f;
217 south = 1;
218 hasInnerPiece = true;
219 }
220 }
221 }
222 else if (dir == DIR_WEST)
223 {
224 int frontTile = level->getTile(x + 1, y, z);
225 int frontData = level->getData(x + 1, y, z);
226 if (isStairs(frontTile) && ((data & UPSIDEDOWN_BIT) == (frontData & UPSIDEDOWN_BIT)))
227 {
228 west = .5f;
229 east = 1.0f;
230 int frontDir = frontData & 0x3;
231 if (frontDir == DIR_NORTH && !isLockAttached(level, x, y, z - 1, data))
232 {
233 north = 0;
234 south = .5f;
235 hasInnerPiece = true;
236 }
237 else if (frontDir == DIR_SOUTH && !isLockAttached(level, x, y, z + 1, data))
238 {
239 north = .5f;
240 south = 1;
241 hasInnerPiece = true;
242 }
243 }
244 }
245 else if (dir == DIR_SOUTH)
246 {
247 int frontTile = level->getTile(x, y, z - 1);
248 int frontData = level->getData(x, y, z - 1);
249 if (isStairs(frontTile) && ((data & UPSIDEDOWN_BIT) == (frontData & UPSIDEDOWN_BIT)))
250 {
251 north = 0;
252 south = .5f;
253
254 int frontDir = frontData & 0x3;
255 if (frontDir == DIR_WEST && !isLockAttached(level, x - 1, y, z, data))
256 {
257 hasInnerPiece = true;
258 }
259 else if (frontDir == DIR_EAST && !isLockAttached(level, x + 1, y, z, data))
260 {
261 west = .5f;
262 east = 1.0f;
263 hasInnerPiece = true;
264 }
265 }
266 }
267 else if (dir == DIR_NORTH)
268 {
269 int frontTile = level->getTile(x, y, z + 1);
270 int frontData = level->getData(x, y, z + 1);
271 if (isStairs(frontTile) && ((data & UPSIDEDOWN_BIT) == (frontData & UPSIDEDOWN_BIT)))
272 {
273 int frontDir = frontData & 0x3;
274 if (frontDir == DIR_WEST && !isLockAttached(level, x - 1, y, z, data))
275 {
276 hasInnerPiece = true;
277 }
278 else if (frontDir == DIR_EAST && !isLockAttached(level, x + 1, y, z, data))
279 {
280 west = .5f;
281 east = 1.0f;
282 hasInnerPiece = true;
283 }
284 }
285 }
286
287 if (hasInnerPiece)
288 {
289 setShape(west, bottom, north, east, top, south);
290 }
291 return hasInnerPiece;
292}