mirror of
https://github.com/neoStudiosLCE/neoLegacy.git
synced 2026-07-06 14:57:03 +00:00
fix: slime block
now craftable + pushable
This commit is contained in:
parent
05c14bc0fe
commit
8511248572
|
|
@ -101,7 +101,17 @@ void ItemRenderer::render(shared_ptr<Entity> _itemEntity, double x, double y, do
|
|||
}
|
||||
|
||||
glScalef(s, s, s);
|
||||
for (int i = 0; i < count; i++)
|
||||
|
||||
bool bSlimeItem = (tile != nullptr && tile->id == Tile::slimeBlock->id);
|
||||
if (bSlimeItem)
|
||||
{
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glEnable(GL_BLEND);
|
||||
glDepthMask(false);
|
||||
}
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
glPushMatrix();
|
||||
if (i > 0)
|
||||
|
|
@ -116,6 +126,13 @@ void ItemRenderer::render(shared_ptr<Entity> _itemEntity, double x, double y, do
|
|||
tileRenderer->renderTile(tile, item->getAuxValue(), br);
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
if (bSlimeItem)
|
||||
{
|
||||
glDepthMask(true);
|
||||
glEnable(GL_ALPHA_TEST);
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
}
|
||||
else if (item->getIconType() == Icon::TYPE_ITEM && item->getItem()->hasMultipleSpriteLayers())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -31,6 +31,9 @@ void OreRecipies::_init()
|
|||
|
||||
ADD_OBJECT(map[7],Tile::hayBlock);
|
||||
ADD_OBJECT(map[7],new ItemInstance(Item::wheat, 9));
|
||||
|
||||
ADD_OBJECT(map[8],Tile::slimeBlock);
|
||||
ADD_OBJECT(map[8],new ItemInstance(Item::slimeBall, 9));
|
||||
}
|
||||
void OreRecipies::addRecipes(Recipes *r)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#define MAX_ORE_RECIPES 8
|
||||
#define MAX_ORE_RECIPES 9
|
||||
|
||||
class OreRecipies
|
||||
{
|
||||
|
|
|
|||
|
|
@ -360,36 +360,85 @@ bool PistonBaseTile::triggerEvent(Level *level, int x, int y, int z, int param1,
|
|||
|
||||
if (block == Tile::slimeBlock->id)
|
||||
{
|
||||
for (int face = 0; face < 6; face++)
|
||||
struct MoveBlock
|
||||
{
|
||||
int adjX = twoX + Facing::STEP_X[face];
|
||||
int adjY = twoY + Facing::STEP_Y[face];
|
||||
int adjZ = twoZ + Facing::STEP_Z[face];
|
||||
int x;
|
||||
int y;
|
||||
int z;
|
||||
int block;
|
||||
int data;
|
||||
};
|
||||
|
||||
int adjBlock = level->getTile(adjX, adjY, adjZ);
|
||||
if (adjBlock == 0)
|
||||
vector<MoveBlock> movedBlocks;
|
||||
movedBlocks.push_back({ twoX, twoY, twoZ, block, blockData });
|
||||
|
||||
auto alreadyMoved = [&movedBlocks](int x, int y, int z)
|
||||
{
|
||||
for (const auto &move : movedBlocks)
|
||||
{
|
||||
if (move.x == x && move.y == y && move.z == z)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
for (size_t i = 0; i < movedBlocks.size(); i++)
|
||||
{
|
||||
if (movedBlocks.size() >= MAX_PUSH_DEPTH)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (movedBlocks[i].block != Tile::slimeBlock->id)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isPushable(adjBlock, level, adjX, adjY, adjZ, false))
|
||||
for (int face = 0; face < 6; face++)
|
||||
{
|
||||
continue;
|
||||
if (movedBlocks.size() >= MAX_PUSH_DEPTH)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
int adjX = movedBlocks[i].x + Facing::STEP_X[face];
|
||||
int adjY = movedBlocks[i].y + Facing::STEP_Y[face];
|
||||
int adjZ = movedBlocks[i].z + Facing::STEP_Z[face];
|
||||
|
||||
if (alreadyMoved(adjX, adjY, adjZ))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
int adjBlock = level->getTile(adjX, adjY, adjZ);
|
||||
if (adjBlock == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isPushable(adjBlock, level, adjX, adjY, adjZ, false))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
int adjData = level->getData(adjX, adjY, adjZ);
|
||||
int destX = adjX - Facing::STEP_X[facing];
|
||||
int destY = adjY - Facing::STEP_Y[facing];
|
||||
int destZ = adjZ - Facing::STEP_Z[facing];
|
||||
|
||||
stopSharingIfServer(level, destX, destY, destZ);
|
||||
level->setTileAndData(destX, destY, destZ, Tile::pistonMovingPiece_Id, adjData, Tile::UPDATE_NONE);
|
||||
level->setTileEntity(destX, destY, destZ, PistonMovingPiece::newMovingPieceEntity(adjBlock, adjData, facing, false, false));
|
||||
|
||||
ignoreUpdate(false);
|
||||
level->removeTile(adjX, adjY, adjZ);
|
||||
ignoreUpdate(true);
|
||||
level->updateNeighborsAt(adjX, adjY, adjZ, adjBlock);
|
||||
|
||||
movedBlocks.push_back({ adjX, adjY, adjZ, adjBlock, adjData });
|
||||
}
|
||||
|
||||
int adjData = level->getData(adjX, adjY, adjZ);
|
||||
int destX = adjX - Facing::STEP_X[facing];
|
||||
int destY = adjY - Facing::STEP_Y[facing];
|
||||
int destZ = adjZ - Facing::STEP_Z[facing];
|
||||
|
||||
stopSharingIfServer(level, destX, destY, destZ);
|
||||
level->setTileAndData(destX, destY, destZ, Tile::pistonMovingPiece_Id, adjData, Tile::UPDATE_NONE);
|
||||
level->setTileEntity(destX, destY, destZ, PistonMovingPiece::newMovingPieceEntity(adjBlock, adjData, facing, false, false));
|
||||
|
||||
ignoreUpdate(false);
|
||||
level->removeTile(adjX, adjY, adjZ);
|
||||
ignoreUpdate(true);
|
||||
level->updateNeighborsAt(adjX, adjY, adjZ, adjBlock);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue