From e6deab9664fb1b6c17b504434fe14f96bef0d184 Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Sun, 27 Oct 2024 00:56:04 -0400 Subject: [PATCH 1/3] Fix Headless Bug --- mods/src/init/init.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mods/src/init/init.cpp b/mods/src/init/init.cpp index 075769cd..8165cca3 100644 --- a/mods/src/init/init.cpp +++ b/mods/src/init/init.cpp @@ -20,7 +20,9 @@ __attribute__((constructor)) static void init() { init_input(); init_sign(); init_camera(); - init_atlas(); + if (!reborn_is_headless()) { + init_atlas(); + } init_title_screen(); if (!reborn_is_headless()) { init_skin(); From a0a566f594f0b37876564f56da52e8c22153baa9 Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Tue, 29 Oct 2024 22:48:23 -0400 Subject: [PATCH 2/3] F3 Tweak --- mods/src/f3/f3.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/mods/src/f3/f3.cpp b/mods/src/f3/f3.cpp index d64022ce..380ed964 100644 --- a/mods/src/f3/f3.cpp +++ b/mods/src/f3/f3.cpp @@ -83,6 +83,14 @@ static std::vector get_debug_info_left(const Minecraft *minecraft) // Return return info; } +static std::string format_type(const int id, const std::string &name) { + std::string out = std::to_string(id); + if (!name.empty()) { + out = name + " (" + out + ')'; + } + out = "Type: " + out; + return out; +} static std::vector get_debug_info_right(const Minecraft *minecraft) { std::vector info; // TPS @@ -104,20 +112,17 @@ static std::vector get_debug_info_right(const Minecraft *minecraft) type = "Tile"; if (minecraft->level) { const int id = minecraft->level->getTile(x, y, z); - std::string id_info = "ID: " + std::to_string(id); + std::string name; if (Tile *tile = Tile::tiles[id]) { const std::string description_id = tile->getDescriptionId(); - std::string name = description_id + ".name"; + name = description_id + ".name"; if (I18n::_strings.contains(name)) { name = I18n::_strings[name]; } else { name = description_id; } - if (!name.empty()) { - id_info += " (" + name + ')'; - } } - type_info.push_back(id_info); + type_info.push_back(format_type(id, name)); type_info.push_back("Data: " + std::to_string(minecraft->level->getData(x, y, z))); } xyz_precision = 0; @@ -128,7 +133,8 @@ static std::vector get_debug_info_right(const Minecraft *minecraft) y = entity->y - entity->height_offset; z = entity->z; type = "Entity"; - type_info.push_back("Type ID: " + std::to_string(entity->getEntityTypeId())); // TODO: Specify name when RJ PR is merged + const int type_id = entity->getEntityTypeId(); + type_info.push_back(format_type(type_id, "")); // TODO: Specify name when RJ PR is merged type_info.push_back("ID: " + std::to_string(entity->id)); if (entity->isMob()) { Mob *mob = (Mob *) entity; @@ -142,7 +148,7 @@ static std::vector get_debug_info_right(const Minecraft *minecraft) info.push_back("Target Y: " + to_string_with_precision(y, xyz_precision)); info.push_back("Target Z: " + to_string_with_precision(z, xyz_precision)); info.push_back(""); - info.push_back("Target Type: " + type); + info.push_back("Target: " + type); info.insert(info.end(), type_info.begin(), type_info.end()); } // Return From 419ad9c98c17c4a54892585d2fe8306a9bc6498f Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Wed, 30 Oct 2024 00:22:02 -0400 Subject: [PATCH 3/3] 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); + } } } }