Merge branch 'master' into mineclone5

This commit is contained in:
jordan4ibanez 2021-04-12 17:31:51 -04:00
commit f851f5c7ca
4 changed files with 19 additions and 12 deletions

View file

@ -60,7 +60,7 @@ mobs:register_mob("mobs_mc:enderdragon", {
}, },
ignores_nametag = true, ignores_nametag = true,
do_custom = function(self) do_custom = function(self)
mcl_bossbars.update_boss(self, "Ender Dragon", "light_purple") mcl_bossbars.update_boss(self.object, "Ender Dragon", "light_purple")
for _, obj in ipairs(minetest.get_objects_inside_radius(self.object:get_pos(), 80)) do for _, obj in ipairs(minetest.get_objects_inside_radius(self.object:get_pos(), 80)) do
local luaentity = obj:get_luaentity() local luaentity = obj:get_luaentity()
if luaentity and luaentity.name == "mcl_end:crystal" then if luaentity and luaentity.name == "mcl_end:crystal" then

View file

@ -73,7 +73,7 @@ mobs:register_mob("mobs_mc:wither", {
self.object:set_properties({textures={self.base_texture}}) self.object:set_properties({textures={self.base_texture}})
self.armor = {undead = 80, fleshy = 80} self.armor = {undead = 80, fleshy = 80}
end end
mcl_bossbars.update_boss(self, "Wither", "dark_purple") mcl_bossbars.update_boss(self.object, "Wither", "dark_purple")
end, end,
on_spawn = function(self) on_spawn = function(self)
minetest.sound_play("mobs_mc_wither_spawn", {object=self.object, gain=1.0, max_hear_distance=64}) minetest.sound_play("mobs_mc_wither_spawn", {object=self.object, gain=1.0, max_hear_distance=64})

View file

@ -60,12 +60,12 @@ function mcl_bossbars.add_bar(player, def, dynamic, priority)
bar.id = last_id + 1 bar.id = last_id + 1
last_id = bar.id last_id = bar.id
mcl_bossbars.static[bar.id] = bar mcl_bossbars.static[bar.id] = bar
return id return bar.id
end end
end end
function mcl_bossbars.remove_bar(id) function mcl_bossbars.remove_bar(id)
mcl_bossbars.static[id].bar.static = false mcl_bossbars.static[id].bar.id = nil
mcl_bossbars.static[id] = nil mcl_bossbars.static[id] = nil
end end
@ -76,16 +76,23 @@ function mcl_bossbars.update_bar(id, def, priority)
old.priority = priority or old.priority old.priority = priority or old.priority
end end
function mcl_bossbars.update_boss(luaentity, name, color) function mcl_bossbars.update_boss(object, name, color)
local object = luaentity.object local props = object:get_luaentity()
if not props or not props._cmi_is_mob then
props = object:get_properties()
props.health = object:get_hp()
end
local bardef = { local bardef = {
text = luaentity.nametag,
percentage = math.floor(luaentity.health / luaentity.hp_max * 100),
color = color, color = color,
text = props.nametag,
percentage = math.floor(props.health / props.hp_max * 100),
} }
if not bardef.text or bardef.text == "" then if not bardef.text or bardef.text == "" then
bardef.text = name bardef.text = name
end end
local pos = object:get_pos() local pos = object:get_pos()
for _, player in pairs(minetest.get_connected_players()) do for _, player in pairs(minetest.get_connected_players()) do
local d = vector.distance(pos, player:get_pos()) local d = vector.distance(pos, player:get_pos())

View file

@ -210,26 +210,26 @@ minetest.register_globalstep(function(dtime)
if parent then if parent then
local parent_yaw = degrees(parent:get_yaw()) local parent_yaw = degrees(parent:get_yaw())
player:set_properties({collisionbox = {-0.35,0,-0.35,0.35,1.8,0.35}, eye_height = 1.5, nametag_color = { r = 225, b = 225, a = 225, g = 225 }}) player:set_properties({collisionbox = {-0.312,0,-0.312,0.312,1.8,0.312}, eye_height = 1.5, nametag_color = { r = 225, b = 225, a = 225, g = 225 }})
player:set_bone_position("Head", vector.new(0,6.3,0), vector.new(pitch, -limit_vel_yaw(yaw, parent_yaw) + parent_yaw, 0)) player:set_bone_position("Head", vector.new(0,6.3,0), vector.new(pitch, -limit_vel_yaw(yaw, parent_yaw) + parent_yaw, 0))
player:set_bone_position("Body_Control", vector.new(0,6.3,0), vector.new(0,0,0)) player:set_bone_position("Body_Control", vector.new(0,6.3,0), vector.new(0,0,0))
elseif controls.sneak then elseif controls.sneak then
-- controls head pitch when sneaking -- controls head pitch when sneaking
player:set_bone_position("Head", vector.new(0,6.3,0), vector.new(pitch+36,0,0)) player:set_bone_position("Head", vector.new(0,6.3,0), vector.new(pitch+36,0,0))
-- sets eye height, and nametag color accordingly -- sets eye height, and nametag color accordingly
player:set_properties({collisionbox = {-0.35,0,-0.35,0.35,1.8,0.35}, eye_height = 1.35, nametag_color = { r = 225, b = 225, a = 0, g = 225 }}) player:set_properties({collisionbox = {-0.312,0,-0.312,0.312,1.8,0.312}, eye_height = 1.35, nametag_color = { r = 225, b = 225, a = 0, g = 225 }})
-- sneaking body conrols -- sneaking body conrols
player:set_bone_position("Body_Control", vector.new(0,6.3,0), vector.new(0,0,0)) player:set_bone_position("Body_Control", vector.new(0,6.3,0), vector.new(0,0,0))
elseif get_item_group(mcl_playerinfo[name].node_head, "water") ~= 0 and is_sprinting(name) == true then elseif get_item_group(mcl_playerinfo[name].node_head, "water") ~= 0 and is_sprinting(name) == true then
-- set head pitch and yaw when swimming -- set head pitch and yaw when swimming
player:set_bone_position("Head", vector.new(0,6.3,0), vector.new(pitch+90-degrees(dir_to_pitch(player_velocity)),player_vel_yaw - yaw,0)) player:set_bone_position("Head", vector.new(0,6.3,0), vector.new(pitch+90-degrees(dir_to_pitch(player_velocity)),player_vel_yaw - yaw,0))
-- sets eye height, and nametag color accordingly -- sets eye height, and nametag color accordingly
player:set_properties({collisionbox = {-0.35,0,-0.35,0.35,0.8,0.35}, eye_height = 0.5, nametag_color = { r = 225, b = 225, a = 225, g = 225 }}) player:set_properties({collisionbox = {-0.312,0,-0.312,0.312,0.8,0.312}, eye_height = 0.5, nametag_color = { r = 225, b = 225, a = 225, g = 225 }})
-- control body bone when swimming -- control body bone when swimming
player:set_bone_position("Body_Control", vector.new(0,6.3,0), vector.new(degrees(dir_to_pitch(player_velocity)) - 90,-player_vel_yaw + yaw + 180,0)) player:set_bone_position("Body_Control", vector.new(0,6.3,0), vector.new(degrees(dir_to_pitch(player_velocity)) - 90,-player_vel_yaw + yaw + 180,0))
else else
-- sets eye height, and nametag color accordingly -- sets eye height, and nametag color accordingly
player:set_properties({collisionbox = {-0.35,0,-0.35,0.35,1.8,0.35}, eye_height = 1.5, nametag_color = { r = 225, b = 225, a = 225, g = 225 }}) player:set_properties({collisionbox = {-0.312,0,-0.312,0.312,1.8,0.312}, eye_height = 1.5, nametag_color = { r = 225, b = 225, a = 225, g = 225 }})
player:set_bone_position("Head", vector.new(0,6.3,0), vector.new(pitch, player_vel_yaw - yaw, 0)) player:set_bone_position("Head", vector.new(0,6.3,0), vector.new(pitch, player_vel_yaw - yaw, 0))
player:set_bone_position("Body_Control", vector.new(0,6.3,0), vector.new(0, -player_vel_yaw + yaw, 0)) player:set_bone_position("Body_Control", vector.new(0,6.3,0), vector.new(0, -player_vel_yaw + yaw, 0))