mirror of
https://github.com/celisej567/mcpe.git
synced 2026-09-17 20:10:23 +03:00
* Fix grass rendering and add grass blocks to the inventory.
This commit is contained in:
@@ -2322,19 +2322,38 @@ LABEL_102:
|
||||
return result;
|
||||
}
|
||||
|
||||
// this is very hacky
|
||||
#ifdef ENH_SHADE_HELD_TILES
|
||||
|
||||
#define SHADE_PREPARE \
|
||||
float red = bright, grn = bright, blu = bright; \
|
||||
#ifdef MOD_DONT_COLOR_GRASS
|
||||
# define SHADE_IS_DECOLOR_GRASS_DEFINED true
|
||||
#else
|
||||
# define SHADE_IS_DECOLOR_GRASS_DEFINED false
|
||||
#endif
|
||||
|
||||
#define SHADE_DEFINE float red = 1, grn = 1, blu = 1
|
||||
|
||||
#define SHADE_PREPARE do { \
|
||||
red = bright, grn = bright, blu = bright; \
|
||||
if (tile->m_ID == Tile::leaves->m_ID) \
|
||||
red *= 0.35f, grn *= 0.65f, blu *= 0.25f;
|
||||
red *= 0.35f, grn *= 0.65f, blu *= 0.25f; \
|
||||
if (!SHADE_IS_DECOLOR_GRASS_DEFINED && tile->m_ID == Tile::grass->m_ID) \
|
||||
red *= 0.25f, grn *= 0.60f, blu *= 0.25f; \
|
||||
} while (0)
|
||||
|
||||
#define SHADE_IF_NEEDED(col) t.color(col*red,col*grn,col*blu,1.0f)
|
||||
|
||||
#define SHADE_FIXUP_GRASS do { \
|
||||
if (tile->m_ID == Tile::grass->m_ID) \
|
||||
red = bright, grn = bright, blu = bright; \
|
||||
} while (0)
|
||||
|
||||
#else
|
||||
|
||||
#define SHADE_PREPARE ;
|
||||
#define SHADE_IF_NEEDED(col) ;
|
||||
#define SHADE_DEFINE 0
|
||||
#define SHADE_PREPARE 0
|
||||
#define SHADE_IF_NEEDED(col) 0
|
||||
#define SHADE_FIXUP_GRASS(col) 0
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2353,11 +2372,13 @@ void TileRenderer::renderTile(Tile* tile, int data RENDER_TILE_ARG_PATCH)
|
||||
{
|
||||
glTranslatef(-0.5f, -0.5f, -0.5f);
|
||||
t.begin();
|
||||
SHADE_DEFINE;
|
||||
SHADE_PREPARE;
|
||||
SHADE_IF_NEEDED(0.5f);
|
||||
renderFaceUp (tile, 0.0f, 0.0f, 0.0f, tile->getTexture(DIR_YNEG, data));
|
||||
SHADE_IF_NEEDED(1.0f);
|
||||
renderFaceDown(tile, 0.0f, 0.0f, 0.0f, tile->getTexture(DIR_YPOS, data));
|
||||
SHADE_FIXUP_GRASS;
|
||||
SHADE_IF_NEEDED(0.5f);
|
||||
renderFaceUp (tile, 0.0f, 0.0f, 0.0f, tile->getTexture(DIR_YNEG, data));
|
||||
SHADE_IF_NEEDED(0.8f);
|
||||
renderNorth (tile, 0.0f, 0.0f, 0.0f, tile->getTexture(DIR_ZNEG, data));
|
||||
renderSouth (tile, 0.0f, 0.0f, 0.0f, tile->getTexture(DIR_ZPOS, data));
|
||||
@@ -2413,6 +2434,7 @@ void TileRenderer::renderTile(Tile* tile, int data RENDER_TILE_ARG_PATCH)
|
||||
|
||||
|
||||
t.begin();
|
||||
SHADE_DEFINE;
|
||||
SHADE_PREPARE;
|
||||
SHADE_IF_NEEDED(0.5f);
|
||||
renderFaceUp (tile, 0.0f, 0.0f, 0.0f, tile->getTexture(DIR_YNEG, data));
|
||||
|
||||
@@ -17,6 +17,7 @@ void Inventory::prepareCreativeInventory()
|
||||
|
||||
m_items.clear();
|
||||
|
||||
// Original list of items.
|
||||
addCreativeItem(Tile::rock->m_ID);
|
||||
addCreativeItem(Tile::stoneBrick->m_ID);
|
||||
addCreativeItem(Tile::sandStone->m_ID);
|
||||
@@ -53,6 +54,9 @@ void Inventory::prepareCreativeInventory()
|
||||
addCreativeItem(Tile::reeds->m_ID);
|
||||
addCreativeItem(Tile::obsidian->m_ID);
|
||||
addCreativeItem(Tile::dirt->m_ID);
|
||||
|
||||
// New items that weren't in the inventory before.
|
||||
addCreativeItem(Tile::grass->m_ID);
|
||||
addCreativeItem(Tile::tnt->m_ID);
|
||||
addCreativeItem(Tile::gravel->m_ID);
|
||||
addCreativeItem(Tile::cloth->m_ID);
|
||||
|
||||
@@ -28,6 +28,15 @@ int GrassTile::getResource(int i, Random* random)
|
||||
return Tile::dirt->getResource(i, random);
|
||||
}
|
||||
|
||||
int GrassTile::getTexture(int dir)
|
||||
{
|
||||
if (dir == DIR_YPOS)
|
||||
return TEXTURE_GRASS_TOP;
|
||||
|
||||
// no one will notice that I omitted the bottom one. Like grass_carried in MCPE
|
||||
return TEXTURE_GRASS_SIDE;
|
||||
}
|
||||
|
||||
int GrassTile::getTexture(LevelSource* level, int x, int y, int z, int dir)
|
||||
{
|
||||
if (dir == DIR_YPOS)
|
||||
|
||||
@@ -299,6 +299,7 @@ public:
|
||||
|
||||
int getResource(int, Random*) override;
|
||||
int getColor(LevelSource*, int x, int y, int z) override;
|
||||
int getTexture(int dir) override;
|
||||
int getTexture(LevelSource*, int x, int y, int z, int dir) override;
|
||||
void tick(Level*, int x, int y, int z, Random*) override;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user