From beccbacc73756b4175ce68efaf0dbb3a87686c2c Mon Sep 17 00:00:00 2001 From: teknomunk Date: Sat, 1 Jun 2024 20:23:38 +0000 Subject: [PATCH] Fix Stalker texture generation (#4343) This fixes stalker texture generation when the stalker is standing on a node that uses a texture using a texture modifier. Reviewed-on: https://git.minetest.land/VoxeLibre/VoxeLibre/pulls/4343 Reviewed-by: the-real-herowl Co-authored-by: teknomunk Co-committed-by: teknomunk --- mods/ENTITIES/mobs_mc/stalker.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mods/ENTITIES/mobs_mc/stalker.lua b/mods/ENTITIES/mobs_mc/stalker.lua index 5b1fd6a08..962fbdea9 100644 --- a/mods/ENTITIES/mobs_mc/stalker.lua +++ b/mods/ENTITIES/mobs_mc/stalker.lua @@ -35,7 +35,8 @@ local function get_texture(self) if not texture or texture == "" then texture = "vl_stalker_default.png" end - texture = "([combine:16x24:0,0=" .. texture .. ":0,16=" .. texture .. texture_suff + texture = texture:gsub("([\\^:\\[])","\\%1") -- escape texture modifiers + texture = "([combine:16x24:0,0=(" .. texture .. "):0,16=(" .. texture ..")".. texture_suff if self.attack then texture = texture .. ")^vl_mobs_stalker_overlay_angry.png" else @@ -131,7 +132,11 @@ mcl_mobs.register_mob("mobs_mc:stalker", { self:boom(mcl_util.get_object_center(self.object), self.explosion_strength) end end - self.object:set_properties({textures={get_texture(self)}}) + local new_texture = get_texture(self) + if self._stalker_texture ~= new_texture then + self.object:set_properties({textures={new_texture, "mobs_mc_empty.png"}}) + self._stalker_texture = new_texture + end end, on_die = function(self, pos, cmi_cause) -- Drop a random music disc when killed by skeleton or stray