Use action icon: check that block type exists first

I saw that yyy257's fork
This commit is contained in:
xtreme8000 2024-05-28 14:43:14 +02:00
parent 1b1a37b1df
commit ca0591f90d

View file

@ -368,12 +368,13 @@ static void screen_ingame_render2D(struct screen* s, int width, int height) {
int icon_offset = 32;
icon_offset += gutil_control_icon(icon_offset, IB_INVENTORY, "Inventory");
icon_offset += gutil_control_icon(icon_offset, IB_JUMP, "Jump");
if(gstate.camera_hit.hit) {
struct item_data item;
struct block_data bd
= world_get_block(&gstate.world, gstate.camera_hit.x,
gstate.camera_hit.y, gstate.camera_hit.z);
if(blocks[bd.type]->onRightClick) {
if(blocks[bd.type] && blocks[bd.type]->onRightClick) {
icon_offset += gutil_control_icon(icon_offset, IB_ACTION2, "Use");
} else if(inventory_get_hotbar_item(
windowc_get_latest(gstate.windows[WINDOWC_INVENTORY]),
@ -388,6 +389,7 @@ static void screen_ingame_render2D(struct screen* s, int width, int height) {
} else {
icon_offset += gutil_control_icon(icon_offset, IB_ACTION1, "Punch");
}
icon_offset += gutil_control_icon(icon_offset, IB_HOME, "Save & quit");
// draw hotbar