Something went wrong. Try again.
the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
Something went wrong. Try again.
6.6 kB · 292 lines
C++
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293#include "stdafx.h"#include "StairTile_SPU.h"#include "ChunkRebuildData.h"
void StairTile_SPU::updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData, TileEntity* forceEntity) // 4J added forceData, forceEntity param{ setShape(0, 0, 0, 1, 1, 1);}
bool StairTile_SPU::isSolidRender(bool isServerLevel){ return false;}
int StairTile_SPU::getRenderShape(){ return Tile_SPU::SHAPE_STAIRS;}
void StairTile_SPU::setBaseShape(ChunkRebuildData *level, int x, int y, int z){ int data = level->getData(x, y, z);
if ((data & UPSIDEDOWN_BIT) != 0) { setShape(0, .5f, 0, 1, 1, 1); } else { setShape(0, 0, 0, 1, .5f, 1); }}
bool StairTile_SPU::isStairs(int id){ switch(id) { case Tile_SPU::stairs_wood_Id: case Tile_SPU::stairs_stone_Id: case Tile_SPU::stairs_bricks_Id: case Tile_SPU::stairs_stoneBrickSmooth_Id: case Tile_SPU::stairs_netherBricks_Id: case Tile_SPU::stairs_sandstone_Id: case Tile_SPU::stairs_sprucewood_Id: case Tile_SPU::stairs_birchwood_Id: return true; default: return false; } return false;}
bool StairTile_SPU::isLockAttached(ChunkRebuildData *level, int x, int y, int z, int data){ int lockTile = level->getTile(x, y, z); if (isStairs(lockTile) && level->getData(x, y, z) == data) { return true; }
return false;}
bool StairTile_SPU::setStepShape(ChunkRebuildData *level, int x, int y, int z){ int data = level->getData(x, y, z); int dir = data & 0x3;
float bottom = 0.5f; float top = 1.0f;
if ((data & UPSIDEDOWN_BIT) != 0) { bottom = 0; top = .5f; }
float west = 0; float east = 1; float north = 0; float south = .5f;
bool checkInnerPiece = true;
if (dir == DIR_EAST) { west = .5f; south = 1;
int backTile = level->getTile(x + 1, y, z); int backData = level->getData(x + 1, y, z); if (isStairs(backTile) && ((data & UPSIDEDOWN_BIT) == (backData & UPSIDEDOWN_BIT))) { int backDir = backData & 0x3; if (backDir == DIR_NORTH && !isLockAttached(level, x, y, z + 1, data)) { south = .5f; checkInnerPiece = false; } else if (backDir == DIR_SOUTH && !isLockAttached(level, x, y, z - 1, data)) { north = .5f; checkInnerPiece = false; } } } else if (dir == DIR_WEST) { east = .5f; south = 1;
int backTile = level->getTile(x - 1, y, z); int backData = level->getData(x - 1, y, z); if (isStairs(backTile) && ((data & UPSIDEDOWN_BIT) == (backData & UPSIDEDOWN_BIT))) { int backDir = backData & 0x3; if (backDir == DIR_NORTH && !isLockAttached(level, x, y, z + 1, data)) { south = .5f; checkInnerPiece = false; } else if (backDir == DIR_SOUTH && !isLockAttached(level, x, y, z - 1, data)) { north = .5f; checkInnerPiece = false; } } } else if (dir == DIR_SOUTH) { north = .5f; south = 1;
int backTile = level->getTile(x, y, z + 1); int backData = level->getData(x, y, z + 1); if (isStairs(backTile) && ((data & UPSIDEDOWN_BIT) == (backData & UPSIDEDOWN_BIT))) { int backDir = backData & 0x3; if (backDir == DIR_WEST && !isLockAttached(level, x + 1, y, z, data)) { east = .5f; checkInnerPiece = false; } else if (backDir == DIR_EAST && !isLockAttached(level, x - 1, y, z, data)) { west = .5f; checkInnerPiece = false; } } } else if (dir == DIR_NORTH) { int backTile = level->getTile(x, y, z - 1); int backData = level->getData(x, y, z - 1); if (isStairs(backTile) && ((data & UPSIDEDOWN_BIT) == (backData & UPSIDEDOWN_BIT))) { int backDir = backData & 0x3; if (backDir == DIR_WEST && !isLockAttached(level, x + 1, y, z, data)) { east = .5f; checkInnerPiece = false; } else if (backDir == DIR_EAST && !isLockAttached(level, x - 1, y, z, data)) { west = .5f; checkInnerPiece = false; } } }
setShape(west, bottom, north, east, top, south); return checkInnerPiece;}
/** This method adds an extra 1/8 block if the stairs can attach as an* "inner corner."*/bool StairTile_SPU::setInnerPieceShape(ChunkRebuildData *level, int x, int y, int z){ int data = level->getData(x, y, z); int dir = data & 0x3;
float bottom = 0.5f; float top = 1.0f;
if ((data & UPSIDEDOWN_BIT) != 0) { bottom = 0; top = .5f; }
float west = 0; float east = .5f; float north = .5f; float south = 1.0f;
bool hasInnerPiece = false;
if (dir == DIR_EAST) { int frontTile = level->getTile(x - 1, y, z); int frontData = level->getData(x - 1, y, z); if (isStairs(frontTile) && ((data & UPSIDEDOWN_BIT) == (frontData & UPSIDEDOWN_BIT))) { int frontDir = frontData & 0x3; if (frontDir == DIR_NORTH && !isLockAttached(level, x, y, z - 1, data)) { north = 0; south = .5f; hasInnerPiece = true; } else if (frontDir == DIR_SOUTH && !isLockAttached(level, x, y, z + 1, data)) { north = .5f; south = 1; hasInnerPiece = true; } } } else if (dir == DIR_WEST) { int frontTile = level->getTile(x + 1, y, z); int frontData = level->getData(x + 1, y, z); if (isStairs(frontTile) && ((data & UPSIDEDOWN_BIT) == (frontData & UPSIDEDOWN_BIT))) { west = .5f; east = 1.0f; int frontDir = frontData & 0x3; if (frontDir == DIR_NORTH && !isLockAttached(level, x, y, z - 1, data)) { north = 0; south = .5f; hasInnerPiece = true; } else if (frontDir == DIR_SOUTH && !isLockAttached(level, x, y, z + 1, data)) { north = .5f; south = 1; hasInnerPiece = true; } } } else if (dir == DIR_SOUTH) { int frontTile = level->getTile(x, y, z - 1); int frontData = level->getData(x, y, z - 1); if (isStairs(frontTile) && ((data & UPSIDEDOWN_BIT) == (frontData & UPSIDEDOWN_BIT))) { north = 0; south = .5f;
int frontDir = frontData & 0x3; if (frontDir == DIR_WEST && !isLockAttached(level, x - 1, y, z, data)) { hasInnerPiece = true; } else if (frontDir == DIR_EAST && !isLockAttached(level, x + 1, y, z, data)) { west = .5f; east = 1.0f; hasInnerPiece = true; } } } else if (dir == DIR_NORTH) { int frontTile = level->getTile(x, y, z + 1); int frontData = level->getData(x, y, z + 1); if (isStairs(frontTile) && ((data & UPSIDEDOWN_BIT) == (frontData & UPSIDEDOWN_BIT))) { int frontDir = frontData & 0x3; if (frontDir == DIR_WEST && !isLockAttached(level, x - 1, y, z, data)) { hasInnerPiece = true; } else if (frontDir == DIR_EAST && !isLockAttached(level, x + 1, y, z, data)) { west = .5f; east = 1.0f; hasInnerPiece = true; } } }
if (hasInnerPiece) { setShape(west, bottom, north, east, top, south); } return hasInnerPiece;}