From 419ad9c98c17c4a54892585d2fe8306a9bc6498f Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Wed, 30 Oct 2024 00:22:02 -0400 Subject: [PATCH] Minor Tweaks --- mods/src/atlas/atlas.cpp | 20 ++++++++++++++------ mods/src/textures/textures.cpp | 4 +++- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/mods/src/atlas/atlas.cpp b/mods/src/atlas/atlas.cpp index bdc14676..c6037a04 100644 --- a/mods/src/atlas/atlas.cpp +++ b/mods/src/atlas/atlas.cpp @@ -20,6 +20,17 @@ static int get_atlas_key(Item *item, const int data) { } static std::unordered_map> atlas_key_to_pos; static std::unordered_map>> tile_texture_to_atlas_pos; +static bool is_flat_tile(const int id) { + // Check If An Item Is A Tile + if (id < 256) { + Tile *tile = Tile::tiles[id]; + // Check If It Renders Without A Model ("Flat" Rendering) + if (tile && !TileRenderer::canRender(tile->getRenderShape())) { + return true; + } + } + return false; +} static void render_atlas(Textures *textures) { int x = 0; int y = 0; @@ -61,12 +72,9 @@ static void render_atlas(Textures *textures) { media_glPopMatrix(); // Store atlas_key_to_pos[key] = {x, y}; - if (id < 256) { - Tile *tile = Tile::tiles[id]; - if (tile && !TileRenderer::canRender(tile->getRenderShape())) { - int icon = item->getIcon(data); - tile_texture_to_atlas_pos[icon].push_back(atlas_key_to_pos[key]); - } + if (is_flat_tile(id)) { + int icon = item->getIcon(data); + tile_texture_to_atlas_pos[icon].push_back(atlas_key_to_pos[key]); } // Advance To Next Slot x++; diff --git a/mods/src/textures/textures.cpp b/mods/src/textures/textures.cpp index ee9ff9d9..4c3c7311 100644 --- a/mods/src/textures/textures.cpp +++ b/mods/src/textures/textures.cpp @@ -32,7 +32,9 @@ static void Minecraft_tick_injection(const Minecraft *minecraft) { media_glTexSubImage2D_with_scaling(data, x_offset, y_offset, 16, 16, 256, 256, texture->pixels); } } - atlas_update_tile(textures, texture->texture_index, texture->pixels); + if (textures->current_texture == textures->loadTexture("terrain.png", true)) { + atlas_update_tile(textures, texture->texture_index, texture->pixels); + } } } }