diff --git a/init.lua b/init.lua index a14cb29..2537b33 100644 --- a/init.lua +++ b/init.lua @@ -43,6 +43,7 @@ i3 = { usages_cache = {}, recipes_cache = {}, cubes = {}, + plants = {}, tabs = {}, craft_types = {}, diff --git a/src/caches.lua b/src/caches.lua index 8f1b802..4e634fe 100644 --- a/src/caches.lua +++ b/src/caches.lua @@ -316,11 +316,16 @@ end local function init_cubes() for name, def in pairs(reg_nodes) do - if def and def.drawtype == "normal" or def.drawtype == "liquid" or - sub(def.drawtype, 1, 9) == "glasslike" or - sub(def.drawtype, 1, 8) == "allfaces" then + if def then local id = core.get_content_id(name) - i3.cubes[id] = get_cube(def.tiles) + + if def.drawtype == "normal" or def.drawtype == "liquid" or + sub(def.drawtype, 1, 9) == "glasslike" or + sub(def.drawtype, 1, 8) == "allfaces" then + i3.cubes[id] = get_cube(def.tiles) + elseif sub(def.drawtype, 1, 9) == "plantlike" or sub(def.drawtype, 1, 8) == "firelike" then + i3.plants[id] = def.inventory_image .. "^\\[resize:16x16" + end end end end diff --git a/src/gui.lua b/src/gui.lua index 6e157e3..073bfe9 100644 --- a/src/gui.lua +++ b/src/gui.lua @@ -243,14 +243,21 @@ local function get_isometric_view(fs, pos, X, Y) for idx in area:iterp(pos1, pos2) do local cube = i3.cubes[data[idx]] + local plant = i3.plants[data[idx]] - if cube then + if cube or plant then local p = area:position(idx) p = vec_sub(p, pos) local x = 2 + (size / 2 * (p.z - p.x)) local y = 1.15 + (size / 4 * (p.x + p.z - 2 * p.y)) - local elem = fmt("image[%f,%f;%.1f,%.1f;%s]", x + X, y + Y, size, size, cube) + local elem + + if cube then + elem = fmt("image[%f,%f;%.1f,%.1f;%s]", x + X, y + Y, size, size, cube) + else + elem = fmt("image[%f,%f;%.1f,%.1f;%s]", x + X, y + Y, size - 0.05, size - 0.05, plant) + end insert(fs, elem) end