mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-08-20 09:57:09 +00:00
Button placement backport Ceiling/Floor
Placing Buttons On the ceiling or the floor of a block was introduced later i reintroduced this feature which matches it 1:1 to vanilla
This commit is contained in:
parent
41b734ebdb
commit
a18f7b3b8d
|
|
@ -46,11 +46,13 @@ bool ButtonTile::isCubeShaped()
|
|||
|
||||
bool ButtonTile::mayPlace(Level *level, int x, int y, int z, int face)
|
||||
{
|
||||
if (face == 0 && level->isSolidBlockingTile(x, y + 1, z)) return true; // STARSEED- support for ceiling button placement
|
||||
if (face == 1 && level->isSolidBlockingTile(x, y - 1, z)) return true; // STARSEED- support for floor button placement
|
||||
if (face == 2 && level->isSolidBlockingTile(x, y, z + 1)) return true;
|
||||
if (face == 3 && level->isSolidBlockingTile(x, y, z - 1)) return true;
|
||||
if (face == 4 && level->isSolidBlockingTile(x + 1, y, z)) return true;
|
||||
if (face == 5 && level->isSolidBlockingTile(x - 1, y, z)) return true;
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ButtonTile::mayPlace(Level *level, int x, int y, int z)
|
||||
|
|
@ -71,23 +73,67 @@ bool ButtonTile::mayPlace(Level *level, int x, int y, int z)
|
|||
{
|
||||
return true;
|
||||
}
|
||||
if (level->isSolidBlockingTile(x, y - 1, z))
|
||||
{
|
||||
return true; // STARSEED- floor
|
||||
}
|
||||
if (level->isSolidBlockingTile(x, y + 1, z))
|
||||
{
|
||||
return true; // STARSEED- ceiling
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
shared_ptr<Player> ButtonTile::lastPlayer;
|
||||
int ButtonTile::getPlacedOnFaceDataValue(Level *level, int x, int y, int z, int face, float clickX, float clickY, float clickZ, int itemValue)
|
||||
{
|
||||
int dir = level->getData(x, y, z);
|
||||
int dir = level->getData(x, y, z);
|
||||
|
||||
int oldFlip = dir & 8;
|
||||
dir &= 7;
|
||||
int oldFlip = dir & 8;
|
||||
dir &= 7;
|
||||
|
||||
if (face == 2 && level->isSolidBlockingTile(x, y, z + 1)) dir = 4;
|
||||
else if (face == 3 && level->isSolidBlockingTile(x, y, z - 1)) dir = 3;
|
||||
else if (face == 4 && level->isSolidBlockingTile(x + 1, y, z)) dir = 2;
|
||||
else if (face == 5 && level->isSolidBlockingTile(x - 1, y, z)) dir = 1;
|
||||
else dir = findFace(level, x, y, z);
|
||||
if (face == 0 && level->isSolidBlockingTile(x, y + 1, z))
|
||||
{
|
||||
int rot = 0;
|
||||
|
||||
return dir + oldFlip;
|
||||
if (lastPlayer)
|
||||
{
|
||||
rot = (int)(lastPlayer->yRot * 4.0f / 360.0f + 0.5f) & 3;
|
||||
}
|
||||
|
||||
if (rot == 0 || rot == 2)
|
||||
{
|
||||
dir = 0; // ceiling northsouth
|
||||
}
|
||||
else
|
||||
{
|
||||
dir = 7; // ceiling eastwest
|
||||
}
|
||||
}
|
||||
else if (face == 1 && level->isSolidBlockingTile(x, y - 1, z))
|
||||
{
|
||||
int rot = 0;
|
||||
|
||||
if (lastPlayer)
|
||||
{
|
||||
rot = (int)(lastPlayer->yRot * 4.0f / 360.0f + 0.5f) & 3;
|
||||
}
|
||||
|
||||
if (rot == 0 || rot == 2)
|
||||
{
|
||||
dir = 5; // floor northsouth
|
||||
}
|
||||
else
|
||||
{
|
||||
dir = 6; // floor eastwest
|
||||
}
|
||||
}
|
||||
else if (face == 2 && level->isSolidBlockingTile(x, y, z + 1)) dir = 4;
|
||||
else if (face == 3 && level->isSolidBlockingTile(x, y, z - 1)) dir = 3;
|
||||
else if (face == 4 && level->isSolidBlockingTile(x + 1, y, z)) dir = 2;
|
||||
else if (face == 5 && level->isSolidBlockingTile(x - 1, y, z)) dir = 1;
|
||||
else dir = findFace(level, x, y, z);
|
||||
|
||||
return dir + oldFlip;
|
||||
}
|
||||
|
||||
int ButtonTile::findFace(Level *level, int x, int y, int z)
|
||||
|
|
@ -108,6 +154,14 @@ int ButtonTile::findFace(Level *level, int x, int y, int z)
|
|||
{
|
||||
return 4;
|
||||
}
|
||||
if (level->isSolidBlockingTile(x, y - 1, z)) //STARSEED- floor/ceiling
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
if (level->isSolidBlockingTile(x, y + 1, z)) // STARSEED- floor/ceiling
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -122,6 +176,9 @@ void ButtonTile::neighborChanged(Level *level, int x, int y, int z, int type)
|
|||
if (!level->isSolidBlockingTile(x + 1, y, z) && dir == 2) replace = true;
|
||||
if (!level->isSolidBlockingTile(x, y, z - 1) && dir == 3) replace = true;
|
||||
if (!level->isSolidBlockingTile(x, y, z + 1) && dir == 4) replace = true;
|
||||
if (!level->isSolidBlockingTile(x, y - 1, z) && dir == 5) replace = true; // STARSEED- support for floor/ceiling
|
||||
if (!level->isSolidBlockingTile(x, y + 1, z) && dir == 0) replace = true; // STARSEED- support for floor/ceiling
|
||||
|
||||
|
||||
if (replace)
|
||||
{
|
||||
|
|
@ -175,6 +232,22 @@ void ButtonTile::updateShape(int data)
|
|||
{
|
||||
setShape(0.5f - r, h0, 1 - d, 0.5f + r, h1, 1);
|
||||
}
|
||||
else if (dir == 5) // STARSEED- bounding box for floor and correct shape
|
||||
{
|
||||
setShape(0.5f - r, 0, 0.5f - (h1 - h0) / 2, 0.5f + r, d, 0.5f + (h1 - h0) / 2);
|
||||
}
|
||||
else if (dir == 6) // STARSEED- rotated floor
|
||||
{
|
||||
setShape(0.5f - (h1 - h0) / 2, 0, 0.5f - r, 0.5f + (h1 - h0) / 2, d, 0.5f + r);
|
||||
}
|
||||
else if (dir == 0) // STARSEED- bounding box for ceiling and correct shape
|
||||
{
|
||||
setShape(0.5f - r, 1 - d, 0.5f - (h1 - h0) / 2, 0.5f + r, 1, 0.5f + (h1 - h0) / 2);
|
||||
}
|
||||
else if (dir == 7) // STARSEED- rotated ceiling
|
||||
{
|
||||
setShape(0.5f - (h1 - h0) / 2, 1 - d, 0.5f - r, 0.5f + (h1 - h0) / 2, 1, 0.5f + r);
|
||||
}
|
||||
}
|
||||
|
||||
void ButtonTile::attack(Level *level, int x, int y, int z, shared_ptr<Player> player)
|
||||
|
|
@ -240,6 +313,8 @@ int ButtonTile::getDirectSignal(LevelSource *level, int x, int y, int z, int dir
|
|||
if (myDir == 3 && dir == 3) return Redstone::SIGNAL_MAX;
|
||||
if (myDir == 2 && dir == 4) return Redstone::SIGNAL_MAX;
|
||||
if (myDir == 1 && dir == 5) return Redstone::SIGNAL_MAX;
|
||||
if (myDir == 5 && dir == 0) return Redstone::SIGNAL_MAX; // STARSEED- floor
|
||||
if (myDir == 0 && dir == 1) return Redstone::SIGNAL_MAX; // STARSEED- ceiling
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
@ -350,10 +425,14 @@ void ButtonTile::updateNeighbours(Level *level, int x, int y, int z, int dir)
|
|||
{
|
||||
level->updateNeighborsAt(x, y, z + 1, id);
|
||||
}
|
||||
else
|
||||
{
|
||||
level->updateNeighborsAt(x, y - 1, z, id);
|
||||
}
|
||||
else if (dir == 5) // STARSEED- floor
|
||||
{
|
||||
level->updateNeighborsAt(x, y - 1, z, id);
|
||||
}
|
||||
else if (dir == 0) // STARSEED- ceiling
|
||||
{
|
||||
level->updateNeighborsAt(x, y + 1, z, id);
|
||||
}
|
||||
}
|
||||
|
||||
bool ButtonTile::shouldTileTick(Level *level, int x,int y,int z)
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ protected:
|
|||
ButtonTile(int id, bool sensitive);
|
||||
|
||||
public:
|
||||
static shared_ptr<Player> lastPlayer;
|
||||
Icon *getTexture(int face, int data);
|
||||
virtual AABB *getAABB(Level *level, int x, int y, int z);
|
||||
virtual int getTickDelay(Level *level);
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@ bool TileItem::useOn(shared_ptr<ItemInstance> instance, shared_ptr<Player> playe
|
|||
Tile *tile = Tile::tiles[tileId];
|
||||
// 4J - Adding this from 1.6
|
||||
int itemValue = getLevelDataForAuxValue(instance->getAuxValue());
|
||||
ButtonTile::lastPlayer = player; // STARSEED- used for retrieving player rotation
|
||||
int dataValue = Tile::tiles[tileId]->getPlacedOnFaceDataValue(level, x, y, z, face, clickX, clickY, clickZ, itemValue);
|
||||
if (level->setTileAndData(x, y, z, tileId, dataValue, Tile::UPDATE_ALL))
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue