From 1616cb7538141cd38485b4bf59a7b8b049ddd3f0 Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Sun, 25 Apr 2021 04:09:35 -0400 Subject: [PATCH] Fix nametags --- mods/ENTITIES/mcl_mobs/api/api.lua | 1 - .../api/mob_functions/backup_code_api.lua | 23 ------------------- .../api/mob_functions/interaction.lua | 10 +++++++- .../mcl_mobs/api/mob_functions/set_up.lua | 6 +---- 4 files changed, 10 insertions(+), 30 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api/api.lua b/mods/ENTITIES/mcl_mobs/api/api.lua index 8850a238de..017756ee2a 100644 --- a/mods/ENTITIES/mcl_mobs/api/api.lua +++ b/mods/ENTITIES/mcl_mobs/api/api.lua @@ -53,7 +53,6 @@ local vector_multiply = vector.multiply local vector_divide = vector.divide -- mob constants -local MAX_MOB_NAME_LENGTH = 30 local BREED_TIME = 30 local BREED_TIME_AGAIN = 300 local CHILD_GROW_TIME = 60*20 diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/backup_code_api.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/backup_code_api.lua index 528f2b70e9..67718c7327 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/backup_code_api.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/backup_code_api.lua @@ -940,30 +940,7 @@ local smart_mobs = function(self, s, p, dist, dtime) end end -local update_tag = function(self) - local tag - if mobs_debug then - tag = "nametag = '"..tostring(self.nametag).."'\n".. - "state = '"..tostring(self.state).."'\n".. - "order = '"..tostring(self.order).."'\n".. - "attack = "..tostring(self.attack).."\n".. - "health = "..tostring(self.health).."\n".. - "breath = "..tostring(self.breath).."\n".. - "gotten = "..tostring(self.gotten).."\n".. - "tamed = "..tostring(self.tamed).."\n".. - "horny = "..tostring(self.horny).."\n".. - "hornytimer = "..tostring(self.hornytimer).."\n".. - "runaway_timer = "..tostring(self.runaway_timer).."\n".. - "following = "..tostring(self.following) - else - tag = self.nametag - end - self.object:set_properties({ - nametag = tag, - }) - update_roll(self) -end diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/interaction.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/interaction.lua index b2f8117527..6b23d2fe7d 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/interaction.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/interaction.lua @@ -9,6 +9,8 @@ local math_random = math.random local vector_direction = vector.direction local vector_multiply = vector.multiply +local MAX_MOB_NAME_LENGTH = 30 + mobs.feed_tame = function(self) return nil end @@ -28,7 +30,7 @@ local on_rightclick_prefix = function(self, clicker) end self.nametag = tag - update_tag(self) + mobs.update_tag(self) if not mobs.is_creative(clicker:get_player_name()) then item:take_item() @@ -280,4 +282,10 @@ mobs.shoot_projectile = function(self) --call internal shoot_arrow function self.shoot_arrow(self,pos1,dir) +end + +mobs.update_tag = function(self) + self.object:set_properties({ + nametag = self.nametag, + }) end \ No newline at end of file diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/set_up.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/set_up.lua index 918373272a..dfef98ee81 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/set_up.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/set_up.lua @@ -199,11 +199,7 @@ mobs.mob_activate = function(self, staticdata, def, dtime) else self.object:set_texture_mod("") end - - -- check existing nametag - if not self.nametag then - self.nametag = def.nametag - end + -- set anything changed above self.object:set_properties(self)