From f6db31eae34e850e57bdc3551e03f8ac092049ef Mon Sep 17 00:00:00 2001 From: epCode Date: Sat, 10 Apr 2021 14:47:26 -0700 Subject: [PATCH 1/8] add criticle and sprint hits. --- mods/PLAYER/mcl_playerplus/init.lua | 31 +++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/mods/PLAYER/mcl_playerplus/init.lua b/mods/PLAYER/mcl_playerplus/init.lua index 82b681f6d..4dadeb9a0 100644 --- a/mods/PLAYER/mcl_playerplus/init.lua +++ b/mods/PLAYER/mcl_playerplus/init.lua @@ -119,6 +119,37 @@ end local pitch, name, node_stand, node_stand_below, node_head, node_feet, pos + +minetest.register_on_punchplayer(function(player, hitter, damage) + if hitter:is_player() then + if hitter:get_player_control().aux1 then + player:add_velocity(hitter:get_velocity()) + end + if hitter:get_velocity().y < -6 then + player:set_hp(player:get_hp() - (damage * math.random(0.50 , 0.75))) + local pos = player:get_pos() + minetest.add_particlespawner({ + amount = 15, + time = 0.1, + minpos = {x=pos.x-0.5, y=pos.y-0.5, z=pos.z-0.5}, + maxpos = {x=pos.x+0.5, y=pos.y+0.5, z=pos.z+0.5}, + minvel = {x=-0.1, y=-0.1, z=-0.1}, + maxvel = {x=0.1, y=0.1, z=0.1}, + minacc = {x=0, y=0, z=0}, + maxacc = {x=0, y=0, z=0}, + minexptime = 1, + maxexptime = 2, + minsize = 1.5, + maxsize = 1.5, + collisiondetection = false, + vertical = false, + texture = "mcl_particles_crit.png^[colorize:#bc7a57:127", + }) + end + end +end) + + minetest.register_globalstep(function(dtime) time = time + dtime From 3ff214ec2d8dc4c79c867af180aeba2b34dfb756 Mon Sep 17 00:00:00 2001 From: epCode Date: Sat, 10 Apr 2021 15:06:16 -0700 Subject: [PATCH 2/8] lessen the push strength for players --- mods/PLAYER/mcl_playerplus/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/PLAYER/mcl_playerplus/init.lua b/mods/PLAYER/mcl_playerplus/init.lua index 4dadeb9a0..cbd93ada8 100644 --- a/mods/PLAYER/mcl_playerplus/init.lua +++ b/mods/PLAYER/mcl_playerplus/init.lua @@ -46,7 +46,7 @@ local player_collision = function(player) end end - return({x * 5,z * 5}) + return({x,z}) end -- converts yaw to degrees From b14ca5a84310adb4f3e0fcc615bf2ed97cea6708 Mon Sep 17 00:00:00 2001 From: kay27 Date: Sun, 11 Apr 2021 02:10:27 +0400 Subject: [PATCH 3/8] Revert "[mcl_mobs, mobs_mc] TEMP! Remove `goto` to run on RasbPI4, Oil_boi free to revert" This reverts commit ea41c82834d1664ba29d41adddf532c4d5121250. --- mods/ENTITIES/mcl_mobs/spawning.lua | 197 ++++++++++++++++------------ mods/ENTITIES/mobs_mc/enderman.lua | 41 +++--- 2 files changed, 132 insertions(+), 106 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/spawning.lua b/mods/ENTITIES/mcl_mobs/spawning.lua index a0572f50b..206dfdd41 100644 --- a/mods/ENTITIES/mcl_mobs/spawning.lua +++ b/mods/ENTITIES/mcl_mobs/spawning.lua @@ -1,15 +1,14 @@ --lua locals -local get_node = minetest.get_node -local get_item_group = minetest.get_item_group -local get_node_light = minetest.get_node_light +local get_node = minetest.get_node +local get_item_group = minetest.get_item_group +local get_node_light = minetest.get_node_light local find_nodes_in_area_under_air = minetest.find_nodes_in_area_under_air -local get_biome_data = minetest.get_biome_data -local new_vector = vector.new -local math_random = math.random -local get_biome_name = minetest.get_biome_name -local max = math.max +local new_vector = vector.new +local math_random = math.random +local get_biome_name = minetest.get_biome_name +local max = math.max local get_objects_inside_radius = minetest.get_objects_inside_radius -local vector_distance = vector.distance +local vector_distance = vector.distance -- range for mob count local aoc_range = 32 @@ -537,87 +536,113 @@ end --todo mob limiting --MAIN LOOP if mobs_spawn then - local timer = 0 - minetest.register_globalstep(function(dtime) - timer = timer + dtime - if timer >= 8 then - timer = 0 - for _,player in pairs(minetest.get_connected_players()) do - for i = 1,math_random(3,8) do + local timer = 0 + minetest.register_globalstep(function(dtime) + timer = timer + dtime + if timer >= 8 then + timer = 0 + for _,player in ipairs(minetest.get_connected_players()) do + for i = 1,math.random(3,8) do - local player_pos = player:get_pos() + local player_pos = player:get_pos() - local _,dimension = mcl_worlds.y_to_layer(player_pos.y) + local _,dimension = mcl_worlds.y_to_layer(player_pos.y) - if dimension ~= "void" and dimension ~= "default" then + if dimension == "void" or dimension == "default" then + goto continue -- ignore void and unloaded area + end + + local min,max = decypher_limits(player_pos.y) - local min,max = decypher_limits(player_pos.y) + local goal_pos = position_calculation(player_pos) + + local spawning_position_list = find_nodes_in_area_under_air(new_vector(goal_pos.x,min,goal_pos.z), vector.new(goal_pos.x,max,goal_pos.z), {"group:solid", "group:water", "group:lava"}) - local goal_pos = position_calculation(player_pos) - - local spawning_position_list = find_nodes_in_area_under_air(new_vector(goal_pos.x,min,goal_pos.z), vector.new(goal_pos.x,max,goal_pos.z), {"group:solid", "group:water", "group:lava"}) - - if #spawning_position_list > 0 then --couldn't find node - local spawning_position = spawning_position_list[math_random(1,#spawning_position_list)] - - --Prevent strange behavior/too close to player - if spawning_position and vector_distance(player_pos, spawning_position) > 15 then - - local gotten_node = get_node(spawning_position).name - - if gotten_node and gotten_node ~= "air" then --skip air nodes - - local gotten_biome = get_biome_data(spawning_position) - - if gotten_biome then --skip if in unloaded area - - gotten_biome = get_biome_name(gotten_biome.biome) --makes it easier to work with - - --grab random mob - local mob_def = spawn_dictionary[math.random(1,#spawn_dictionary)] - - if mob_def --skip if something ridiculous happens (nil mob def) - and mob_def.dimension == dimension --skip if not correct dimension - and biome_check(mob_def.biomes, gotten_biome) then --skip if not in correct biome - - --add this so mobs don't spawn inside nodes - spawning_position.y = spawning_position.y + 1 - - if spawning_position.y >= mob_def.min_height and spawning_position.y <= mob_def.max_height then - - --only need to poll for node light if everything else worked - local gotten_light = get_node_light(spawning_position) - - --don't spawn if not in light limits - if gotten_light >= mob_def.min_light and gotten_light <= mob_def.max_light then - - local is_water = get_item_group(gotten_node, "water") ~= 0 - local is_lava = get_item_group(gotten_node, "lava") ~= 0 - - if mob_def.type_of_spawning ~= "ground" or not (is_water or is_lava) then - - --finally do the heavy check (for now) of mobs in area - if count_mobs(spawning_position, mob_def.spawn_class) < mob_def.aoc then - - --adjust the position for water and lava mobs - if mob_def.type_of_spawning == "water" or mob_def.type_of_spawning == "lava" then - spawning_position.y = spawning_position.y - 1 - end - - --everything is correct, spawn mob - minetest.add_entity(spawning_position, mob_def.name) - end - end - end - end - end - end - end - end - end + --couldn't find node + if #spawning_position_list <= 0 then + goto continue end - end - end - end - end) + + local spawning_position = spawning_position_list[math_random(1,#spawning_position_list)] + + --Prevent strange behavior/too close to player + if not spawning_position or vector_distance(player_pos, spawning_position) < 15 then + goto continue + end + + local gotten_node = get_node(spawning_position).name + + if not gotten_node or gotten_node == "air" then --skip air nodes + goto continue + end + + local gotten_biome = minetest.get_biome_data(spawning_position) + + if not gotten_biome then + goto continue --skip if in unloaded area + end + + gotten_biome = get_biome_name(gotten_biome.biome) --makes it easier to work with + + --grab random mob + local mob_def = spawn_dictionary[math.random(1,#spawn_dictionary)] + + if not mob_def then + goto continue --skip if something ridiculous happens (nil mob def) + end + + --skip if not correct dimension + if mob_def.dimension ~= dimension then + goto continue + end + + --skip if not in correct biome + if not biome_check(mob_def.biomes, gotten_biome) then + goto continue + end + + --add this so mobs don't spawn inside nodes + spawning_position.y = spawning_position.y + 1 + + if spawning_position.y < mob_def.min_height or spawning_position.y > mob_def.max_height then + goto continue + end + + --only need to poll for node light if everything else worked + local gotten_light = get_node_light(spawning_position) + + --don't spawn if not in light limits + if gotten_light < mob_def.min_light or gotten_light > mob_def.max_light then + goto continue + end + + local is_water = get_item_group(gotten_node, "water") ~= 0 + local is_lava = get_item_group(gotten_node, "lava") ~= 0 + + if mob_def.type_of_spawning == "ground" and is_water then + goto continue + end + + if mob_def.type_of_spawning == "ground" and is_lava then + goto continue + end + + --finally do the heavy check (for now) of mobs in area + if count_mobs(spawning_position, mob_def.spawn_class) >= mob_def.aoc then + goto continue + end + + --adjust the position for water and lava mobs + if mob_def.type_of_spawning == "water" or mob_def.type_of_spawning == "lava" then + spawning_position.y = spawning_position.y - 1 + end + + --everything is correct, spawn mob + minetest.add_entity(spawning_position, mob_def.name) + + ::continue:: --this is a safety catch + end + end + end + end) end diff --git a/mods/ENTITIES/mobs_mc/enderman.lua b/mods/ENTITIES/mobs_mc/enderman.lua index 5c00bc6e2..ba04f8b59 100644 --- a/mods/ENTITIES/mobs_mc/enderman.lua +++ b/mods/ENTITIES/mobs_mc/enderman.lua @@ -346,28 +346,29 @@ mobs:register_mob("mobs_mc:enderman", { --skip player if they have no data - log it if not player_eye_height then minetest.log("error", "Enderman at location: ".. dump(enderpos).." has indexed a null player!") - else - - --calculate very quickly the exact location the player is looking - --within the distance between the two "heads" (player and enderman) - local look_pos = vector.new(player_pos.x, player_pos.y + player_eye_height, player_pos.z) - local look_pos_base = look_pos - local ender_eye_pos = vector.new(enderpos.x, enderpos.y + 2.75, enderpos.z) - local eye_distance_from_player = vector.distance(ender_eye_pos, look_pos) - look_pos = vector.add(look_pos, vector.multiply(look_dir, eye_distance_from_player)) - - --if looking in general head position, turn hostile - if minetest.line_of_sight(ender_eye_pos, look_pos_base) and vector.distance(look_pos, ender_eye_pos) <= 0.4 then - self.provoked = "staring" - self.attack = minetest.get_player_by_name(obj:get_player_name()) - break - else -- I'm not sure what this part does, but I don't want to break anything - jordan4ibanez - if self.provoked == "staring" then - self.provoked = "broke_contact" - end - end + goto continue end + --calculate very quickly the exact location the player is looking + --within the distance between the two "heads" (player and enderman) + local look_pos = vector.new(player_pos.x, player_pos.y + player_eye_height, player_pos.z) + local look_pos_base = look_pos + local ender_eye_pos = vector.new(enderpos.x, enderpos.y + 2.75, enderpos.z) + local eye_distance_from_player = vector.distance(ender_eye_pos, look_pos) + look_pos = vector.add(look_pos, vector.multiply(look_dir, eye_distance_from_player)) + + --if looking in general head position, turn hostile + if minetest.line_of_sight(ender_eye_pos, look_pos_base) and vector.distance(look_pos, ender_eye_pos) <= 0.4 then + self.provoked = "staring" + self.attack = minetest.get_player_by_name(obj:get_player_name()) + break + else -- I'm not sure what this part does, but I don't want to break anything - jordan4ibanez + if self.provoked == "staring" then + self.provoked = "broke_contact" + end + end + + ::continue:: -- this is a sweep over statement, this can be used to continue even when errors occurred end end end From a76fe2b4875fa02e59edda08663a95432f1a6b4f Mon Sep 17 00:00:00 2001 From: kay27 Date: Sun, 11 Apr 2021 01:54:40 +0400 Subject: [PATCH 4/8] [mcl_mobs] Replace `goto` to `repeat-break-until true` in spawning.lua --- mods/ENTITIES/mcl_mobs/spawning.lua | 164 ++++++++++++++-------------- 1 file changed, 82 insertions(+), 82 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/spawning.lua b/mods/ENTITIES/mcl_mobs/spawning.lua index 206dfdd41..ff52128df 100644 --- a/mods/ENTITIES/mcl_mobs/spawning.lua +++ b/mods/ENTITIES/mcl_mobs/spawning.lua @@ -535,114 +535,114 @@ end --todo mob limiting --MAIN LOOP + if mobs_spawn then - local timer = 0 - minetest.register_globalstep(function(dtime) - timer = timer + dtime - if timer >= 8 then - timer = 0 - for _,player in ipairs(minetest.get_connected_players()) do - for i = 1,math.random(3,8) do + local timer = 0 + minetest.register_globalstep(function(dtime) + timer = timer + dtime + if timer >= 8 then + timer = 0 + for _,player in pairs(minetest.get_connected_players()) do + for i = 1,math_random(3,8) do + repeat -- after this line each "break" means "continue" + local player_pos = player:get_pos() - local player_pos = player:get_pos() + local _,dimension = mcl_worlds.y_to_layer(player_pos.y) - local _,dimension = mcl_worlds.y_to_layer(player_pos.y) - - if dimension == "void" or dimension == "default" then - goto continue -- ignore void and unloaded area - end + if dimension == "void" or dimension == "default" then + break -- ignore void and unloaded area + end - local min,max = decypher_limits(player_pos.y) + local min,max = decypher_limits(player_pos.y) - local goal_pos = position_calculation(player_pos) + local goal_pos = position_calculation(player_pos) - local spawning_position_list = find_nodes_in_area_under_air(new_vector(goal_pos.x,min,goal_pos.z), vector.new(goal_pos.x,max,goal_pos.z), {"group:solid", "group:water", "group:lava"}) + local spawning_position_list = find_nodes_in_area_under_air(new_vector(goal_pos.x,min,goal_pos.z), vector.new(goal_pos.x,max,goal_pos.z), {"group:solid", "group:water", "group:lava"}) - --couldn't find node - if #spawning_position_list <= 0 then - goto continue - end + --couldn't find node + if #spawning_position_list <= 0 then + break + end - local spawning_position = spawning_position_list[math_random(1,#spawning_position_list)] + local spawning_position = spawning_position_list[math_random(1,#spawning_position_list)] - --Prevent strange behavior/too close to player - if not spawning_position or vector_distance(player_pos, spawning_position) < 15 then - goto continue - end + --Prevent strange behavior/too close to player + if not spawning_position or vector_distance(player_pos, spawning_position) < 15 then + break + end - local gotten_node = get_node(spawning_position).name + local gotten_node = get_node(spawning_position).name - if not gotten_node or gotten_node == "air" then --skip air nodes - goto continue - end + if not gotten_node or gotten_node == "air" then --skip air nodes + break + end - local gotten_biome = minetest.get_biome_data(spawning_position) + local gotten_biome = minetest.get_biome_data(spawning_position) - if not gotten_biome then - goto continue --skip if in unloaded area - end + if not gotten_biome then + break --skip if in unloaded area + end - gotten_biome = get_biome_name(gotten_biome.biome) --makes it easier to work with + gotten_biome = get_biome_name(gotten_biome.biome) --makes it easier to work with - --grab random mob - local mob_def = spawn_dictionary[math.random(1,#spawn_dictionary)] + --grab random mob + local mob_def = spawn_dictionary[math.random(1,#spawn_dictionary)] - if not mob_def then - goto continue --skip if something ridiculous happens (nil mob def) - end + if not mob_def then + break --skip if something ridiculous happens (nil mob def) + end - --skip if not correct dimension - if mob_def.dimension ~= dimension then - goto continue - end + --skip if not correct dimension + if mob_def.dimension ~= dimension then + break + end - --skip if not in correct biome - if not biome_check(mob_def.biomes, gotten_biome) then - goto continue - end + --skip if not in correct biome + if not biome_check(mob_def.biomes, gotten_biome) then + break + end - --add this so mobs don't spawn inside nodes - spawning_position.y = spawning_position.y + 1 + --add this so mobs don't spawn inside nodes + spawning_position.y = spawning_position.y + 1 - if spawning_position.y < mob_def.min_height or spawning_position.y > mob_def.max_height then - goto continue - end + if spawning_position.y < mob_def.min_height or spawning_position.y > mob_def.max_height then + break + end - --only need to poll for node light if everything else worked - local gotten_light = get_node_light(spawning_position) + --only need to poll for node light if everything else worked + local gotten_light = get_node_light(spawning_position) - --don't spawn if not in light limits - if gotten_light < mob_def.min_light or gotten_light > mob_def.max_light then - goto continue - end + --don't spawn if not in light limits + if gotten_light < mob_def.min_light or gotten_light > mob_def.max_light then + break + end - local is_water = get_item_group(gotten_node, "water") ~= 0 - local is_lava = get_item_group(gotten_node, "lava") ~= 0 + local is_water = get_item_group(gotten_node, "water") ~= 0 + local is_lava = get_item_group(gotten_node, "lava") ~= 0 - if mob_def.type_of_spawning == "ground" and is_water then - goto continue - end + if mob_def.type_of_spawning == "ground" and is_water then + break + end - if mob_def.type_of_spawning == "ground" and is_lava then - goto continue - end + if mob_def.type_of_spawning == "ground" and is_lava then + break + end - --finally do the heavy check (for now) of mobs in area - if count_mobs(spawning_position, mob_def.spawn_class) >= mob_def.aoc then - goto continue - end + --finally do the heavy check (for now) of mobs in area + if count_mobs(spawning_position, mob_def.spawn_class) >= mob_def.aoc then + break + end - --adjust the position for water and lava mobs - if mob_def.type_of_spawning == "water" or mob_def.type_of_spawning == "lava" then - spawning_position.y = spawning_position.y - 1 - end + --adjust the position for water and lava mobs + if mob_def.type_of_spawning == "water" or mob_def.type_of_spawning == "lava" then + spawning_position.y = spawning_position.y - 1 + end - --everything is correct, spawn mob - minetest.add_entity(spawning_position, mob_def.name) - - ::continue:: --this is a safety catch - end - end - end - end) + --everything is correct, spawn mob + minetest.add_entity(spawning_position, mob_def.name) + until true --this is a safety catch + end + end + end + end) end From 40c733c91381ec83ca9a6ab8ebe110b93b1f0c85 Mon Sep 17 00:00:00 2001 From: kay27 Date: Sun, 11 Apr 2021 01:59:13 +0400 Subject: [PATCH 5/8] [mobs_mc] Remove `goto` from enderman.lua --- mods/ENTITIES/mobs_mc/enderman.lua | 39 +++++++++++++++--------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/mods/ENTITIES/mobs_mc/enderman.lua b/mods/ENTITIES/mobs_mc/enderman.lua index ba04f8b59..6c87b9305 100644 --- a/mods/ENTITIES/mobs_mc/enderman.lua +++ b/mods/ENTITIES/mobs_mc/enderman.lua @@ -346,29 +346,28 @@ mobs:register_mob("mobs_mc:enderman", { --skip player if they have no data - log it if not player_eye_height then minetest.log("error", "Enderman at location: ".. dump(enderpos).." has indexed a null player!") - goto continue - end + else - --calculate very quickly the exact location the player is looking - --within the distance between the two "heads" (player and enderman) - local look_pos = vector.new(player_pos.x, player_pos.y + player_eye_height, player_pos.z) - local look_pos_base = look_pos - local ender_eye_pos = vector.new(enderpos.x, enderpos.y + 2.75, enderpos.z) - local eye_distance_from_player = vector.distance(ender_eye_pos, look_pos) - look_pos = vector.add(look_pos, vector.multiply(look_dir, eye_distance_from_player)) + --calculate very quickly the exact location the player is looking + --within the distance between the two "heads" (player and enderman) + local look_pos = vector.new(player_pos.x, player_pos.y + player_eye_height, player_pos.z) + local look_pos_base = look_pos + local ender_eye_pos = vector.new(enderpos.x, enderpos.y + 2.75, enderpos.z) + local eye_distance_from_player = vector.distance(ender_eye_pos, look_pos) + look_pos = vector.add(look_pos, vector.multiply(look_dir, eye_distance_from_player)) - --if looking in general head position, turn hostile - if minetest.line_of_sight(ender_eye_pos, look_pos_base) and vector.distance(look_pos, ender_eye_pos) <= 0.4 then - self.provoked = "staring" - self.attack = minetest.get_player_by_name(obj:get_player_name()) - break - else -- I'm not sure what this part does, but I don't want to break anything - jordan4ibanez - if self.provoked == "staring" then - self.provoked = "broke_contact" - end - end + --if looking in general head position, turn hostile + if minetest.line_of_sight(ender_eye_pos, look_pos_base) and vector.distance(look_pos, ender_eye_pos) <= 0.4 then + self.provoked = "staring" + self.attack = minetest.get_player_by_name(obj:get_player_name()) + break + else -- I'm not sure what this part does, but I don't want to break anything - jordan4ibanez + if self.provoked == "staring" then + self.provoked = "broke_contact" + end + end - ::continue:: -- this is a sweep over statement, this can be used to continue even when errors occurred + end end end end From ce49cd02ac5273a21a673329d28e4ceb32b5db34 Mon Sep 17 00:00:00 2001 From: epCode Date: Sat, 10 Apr 2021 15:41:50 -0700 Subject: [PATCH 6/8] make player collision box MUCH closer to MC --- mods/PLAYER/mcl_playerplus/init.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mods/PLAYER/mcl_playerplus/init.lua b/mods/PLAYER/mcl_playerplus/init.lua index cbd93ada8..de346256f 100644 --- a/mods/PLAYER/mcl_playerplus/init.lua +++ b/mods/PLAYER/mcl_playerplus/init.lua @@ -210,26 +210,26 @@ minetest.register_globalstep(function(dtime) if parent then 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("Body_Control", vector.new(0,6.3,0), vector.new(0,0,0)) elseif controls.sneak then -- controls head pitch when sneaking player:set_bone_position("Head", vector.new(0,6.3,0), vector.new(pitch+36,0,0)) -- 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 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 -- 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)) -- 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 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 -- 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("Body_Control", vector.new(0,6.3,0), vector.new(0, -player_vel_yaw + yaw, 0)) From 2313012f607e11283dcb1a2600eccc7b7a89a02c Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Sun, 11 Apr 2021 10:41:11 +0200 Subject: [PATCH 7/8] Fix #1528 --- mods/HUD/mcl_bossbars/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/HUD/mcl_bossbars/init.lua b/mods/HUD/mcl_bossbars/init.lua index a95d533ce..b5bec1334 100644 --- a/mods/HUD/mcl_bossbars/init.lua +++ b/mods/HUD/mcl_bossbars/init.lua @@ -60,7 +60,7 @@ function mcl_bossbars.add_bar(player, def, dynamic, priority) bar.id = last_id + 1 last_id = bar.id mcl_bossbars.static[bar.id] = bar - return id + return bar.id end end From af044e6a96fba49bd573eff01be751067403f0e3 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Sun, 11 Apr 2021 11:15:09 +0200 Subject: [PATCH 8/8] Bossbars: Add support for non-mob bosses --- mods/HUD/mcl_bossbars/init.lua | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/mods/HUD/mcl_bossbars/init.lua b/mods/HUD/mcl_bossbars/init.lua index b5bec1334..209d9a2c1 100644 --- a/mods/HUD/mcl_bossbars/init.lua +++ b/mods/HUD/mcl_bossbars/init.lua @@ -76,16 +76,23 @@ function mcl_bossbars.update_bar(id, def, priority) old.priority = priority or old.priority end -function mcl_bossbars.update_boss(luaentity, name, color) - local object = luaentity.object +function mcl_bossbars.update_boss(object, name, color) + 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 = { - text = luaentity.nametag, - percentage = math.floor(luaentity.health / luaentity.hp_max * 100), color = color, + text = props.nametag, + percentage = math.floor(props.health / props.hp_max * 100), } + if not bardef.text or bardef.text == "" then bardef.text = name end + local pos = object:get_pos() for _, player in pairs(minetest.get_connected_players()) do local d = vector.distance(pos, player:get_pos())