This commit is contained in:
Bigjango13 2024-10-30 00:19:59 -07:00
commit 4475c14668
4 changed files with 34 additions and 17 deletions

View File

@ -20,6 +20,17 @@ static int get_atlas_key(Item *item, const int data) {
}
static std::unordered_map<int, std::pair<int, int>> atlas_key_to_pos;
static std::unordered_map<int, std::vector<std::pair<int, int>>> 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++;

View File

@ -83,6 +83,14 @@ static std::vector<std::string> 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<std::string> get_debug_info_right(const Minecraft *minecraft) {
std::vector<std::string> info;
// TPS
@ -105,18 +113,17 @@ static std::vector<std::string> get_debug_info_right(const Minecraft *minecraft)
if (minecraft->level) {
const int id = minecraft->level->getTile(x, y, z);
std::string id_info = "Type: ";
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;
}
id_info += name;
}
id_info += " (" + std::to_string(id) + ")";
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;
@ -126,11 +133,9 @@ static std::vector<std::string> get_debug_info_right(const Minecraft *minecraft)
x = entity->x;
y = entity->y - entity->height_offset;
z = entity->z;
type = "Entity";
type_info.push_back("ID: " + std::to_string(entity->id));
std::string type_str = "Type: " + misc_get_entity_type_name(entity)
+ " (" + std::to_string(entity->getEntityTypeId()) + ")";
type_info.push_back(type_str);
const int type_id = entity->getEntityTypeId();
type_info.push_back(format_type(type_id, misc_get_entity_type_name(entity))); // TODO: Specify name when RJ PR is merged
if (entity->isMob()) {
Mob *mob = (Mob *) entity;
type_info.push_back("Health: " + std::to_string(mob->health) + '/' + std::to_string(mob->getMaxHealth()));
@ -143,7 +148,7 @@ static std::vector<std::string> 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

View File

@ -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();

View File

@ -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);
}
}
}
}