Merge branch 'master' of https://gitea.thebrokenrail.com/minecraft-pi-reborn/minecraft-pi-reborn
This commit is contained in:
commit
4475c14668
@ -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::pair<int, int>> atlas_key_to_pos;
|
||||||
static std::unordered_map<int, std::vector<std::pair<int, int>>> tile_texture_to_atlas_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) {
|
static void render_atlas(Textures *textures) {
|
||||||
int x = 0;
|
int x = 0;
|
||||||
int y = 0;
|
int y = 0;
|
||||||
@ -61,13 +72,10 @@ static void render_atlas(Textures *textures) {
|
|||||||
media_glPopMatrix();
|
media_glPopMatrix();
|
||||||
// Store
|
// Store
|
||||||
atlas_key_to_pos[key] = {x, y};
|
atlas_key_to_pos[key] = {x, y};
|
||||||
if (id < 256) {
|
if (is_flat_tile(id)) {
|
||||||
Tile *tile = Tile::tiles[id];
|
|
||||||
if (tile && !TileRenderer::canRender(tile->getRenderShape())) {
|
|
||||||
int icon = item->getIcon(data);
|
int icon = item->getIcon(data);
|
||||||
tile_texture_to_atlas_pos[icon].push_back(atlas_key_to_pos[key]);
|
tile_texture_to_atlas_pos[icon].push_back(atlas_key_to_pos[key]);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// Advance To Next Slot
|
// Advance To Next Slot
|
||||||
x++;
|
x++;
|
||||||
if (x >= ATLAS_SIZE) {
|
if (x >= ATLAS_SIZE) {
|
||||||
|
@ -83,6 +83,14 @@ static std::vector<std::string> get_debug_info_left(const Minecraft *minecraft)
|
|||||||
// Return
|
// Return
|
||||||
return info;
|
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) {
|
static std::vector<std::string> get_debug_info_right(const Minecraft *minecraft) {
|
||||||
std::vector<std::string> info;
|
std::vector<std::string> info;
|
||||||
// TPS
|
// TPS
|
||||||
@ -105,18 +113,17 @@ static std::vector<std::string> get_debug_info_right(const Minecraft *minecraft)
|
|||||||
if (minecraft->level) {
|
if (minecraft->level) {
|
||||||
const int id = minecraft->level->getTile(x, y, z);
|
const int id = minecraft->level->getTile(x, y, z);
|
||||||
std::string id_info = "Type: ";
|
std::string id_info = "Type: ";
|
||||||
|
std::string name;
|
||||||
if (Tile *tile = Tile::tiles[id]) {
|
if (Tile *tile = Tile::tiles[id]) {
|
||||||
const std::string description_id = tile->getDescriptionId();
|
const std::string description_id = tile->getDescriptionId();
|
||||||
std::string name = description_id + ".name";
|
name = description_id + ".name";
|
||||||
if (I18n::_strings.contains(name)) {
|
if (I18n::_strings.contains(name)) {
|
||||||
name = I18n::_strings[name];
|
name = I18n::_strings[name];
|
||||||
} else {
|
} else {
|
||||||
name = description_id;
|
name = description_id;
|
||||||
}
|
}
|
||||||
id_info += name;
|
|
||||||
}
|
}
|
||||||
id_info += " (" + std::to_string(id) + ")";
|
type_info.push_back(format_type(id, name));
|
||||||
type_info.push_back(id_info);
|
|
||||||
type_info.push_back("Data: " + std::to_string(minecraft->level->getData(x, y, z)));
|
type_info.push_back("Data: " + std::to_string(minecraft->level->getData(x, y, z)));
|
||||||
}
|
}
|
||||||
xyz_precision = 0;
|
xyz_precision = 0;
|
||||||
@ -126,11 +133,9 @@ static std::vector<std::string> get_debug_info_right(const Minecraft *minecraft)
|
|||||||
x = entity->x;
|
x = entity->x;
|
||||||
y = entity->y - entity->height_offset;
|
y = entity->y - entity->height_offset;
|
||||||
z = entity->z;
|
z = entity->z;
|
||||||
type = "Entity";
|
|
||||||
type_info.push_back("ID: " + std::to_string(entity->id));
|
type_info.push_back("ID: " + std::to_string(entity->id));
|
||||||
std::string type_str = "Type: " + misc_get_entity_type_name(entity)
|
const int type_id = entity->getEntityTypeId();
|
||||||
+ " (" + std::to_string(entity->getEntityTypeId()) + ")";
|
type_info.push_back(format_type(type_id, misc_get_entity_type_name(entity))); // TODO: Specify name when RJ PR is merged
|
||||||
type_info.push_back(type_str);
|
|
||||||
if (entity->isMob()) {
|
if (entity->isMob()) {
|
||||||
Mob *mob = (Mob *) entity;
|
Mob *mob = (Mob *) entity;
|
||||||
type_info.push_back("Health: " + std::to_string(mob->health) + '/' + std::to_string(mob->getMaxHealth()));
|
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 Y: " + to_string_with_precision(y, xyz_precision));
|
||||||
info.push_back("Target Z: " + to_string_with_precision(z, xyz_precision));
|
info.push_back("Target Z: " + to_string_with_precision(z, xyz_precision));
|
||||||
info.push_back("");
|
info.push_back("");
|
||||||
info.push_back("Target Type: " + type);
|
info.push_back("Target: " + type);
|
||||||
info.insert(info.end(), type_info.begin(), type_info.end());
|
info.insert(info.end(), type_info.begin(), type_info.end());
|
||||||
}
|
}
|
||||||
// Return
|
// Return
|
||||||
|
@ -20,7 +20,9 @@ __attribute__((constructor)) static void init() {
|
|||||||
init_input();
|
init_input();
|
||||||
init_sign();
|
init_sign();
|
||||||
init_camera();
|
init_camera();
|
||||||
|
if (!reborn_is_headless()) {
|
||||||
init_atlas();
|
init_atlas();
|
||||||
|
}
|
||||||
init_title_screen();
|
init_title_screen();
|
||||||
if (!reborn_is_headless()) {
|
if (!reborn_is_headless()) {
|
||||||
init_skin();
|
init_skin();
|
||||||
|
@ -32,10 +32,12 @@ static void Minecraft_tick_injection(const Minecraft *minecraft) {
|
|||||||
media_glTexSubImage2D_with_scaling(data, x_offset, y_offset, 16, 16, 256, 256, texture->pixels);
|
media_glTexSubImage2D_with_scaling(data, x_offset, y_offset, 16, 16, 256, 256, texture->pixels);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (textures->current_texture == textures->loadTexture("terrain.png", true)) {
|
||||||
atlas_update_tile(textures, texture->texture_index, texture->pixels);
|
atlas_update_tile(textures, texture->texture_index, texture->pixels);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Scale Texture (Remember To Free)
|
// Scale Texture (Remember To Free)
|
||||||
#define PIXEL_SIZE 4
|
#define PIXEL_SIZE 4
|
||||||
|
Loading…
Reference in New Issue
Block a user