From a964fd768c1a7d2006bf6981e269b4f391c992ca Mon Sep 17 00:00:00 2001 From: Jean-Patrick Guerrero Date: Tue, 24 Nov 2020 17:12:25 +0100 Subject: [PATCH] Handle entity models --- init.lua | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index 157319e..59a3233 100644 --- a/init.lua +++ b/init.lua @@ -18,12 +18,12 @@ local singleplayer = core.is_singleplayer() local reg_items = core.registered_items local reg_tools = core.registered_tools +local reg_entities = core.registered_entities local reg_aliases = core.registered_aliases local log = core.log local after = core.after local clr = core.colorize -local sound_play = core.sound_play local parse_json = core.parse_json local write_json = core.write_json local chat_send = core.chat_send_player @@ -217,6 +217,11 @@ local group_names = { ["color_dark_green,dye"] = S"Any dark green dye", } +craftguide.model_alias = { + ["boats:boat"] = {name = "boats:boat", drawtype = "entity"}, + --["carts:cart"] = {name = "carts:cart", drawtype = "entity"}, -- the cart animation is broken +} + local function err(str) return log("error", str) end @@ -1173,8 +1178,20 @@ local function get_title_fs(query_item, favs, lang_code, fs, spacing) "style_type[label;font=normal]") local def = reg_items[query_item] + local model_alias = craftguide.model_alias[query_item] + + if def.drawtype == "mesh" or model_alias then + if model_alias then + if model_alias.drawtype == "entity" then + def = reg_entities[model_alias.name] + local init_props = def.initial_properties + def.textures = init_props and init_props.textures or def.textures + def.mesh = init_props and init_props.mesh or def.mesh + else + def = reg_items[model_alias.name] + end + end - if def.drawtype == "mesh" then local tiles = def.tiles or def.textures local t = {}