From 2e2f56122d11d94eb6fc5b67913e0bb58dfbfa52 Mon Sep 17 00:00:00 2001 From: epCode Date: Mon, 29 May 2023 21:59:35 -0700 Subject: [PATCH 01/13] Incorperate sheep eating animation. #3734 --- mods/ENTITIES/mcl_mobs/movement.lua | 3 +++ .../mobs_mc/models/mobs_mc_sheepfur.b3d | Bin 71995 -> 74299 bytes mods/ENTITIES/mobs_mc/sheep.lua | 4 +++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/mods/ENTITIES/mcl_mobs/movement.lua b/mods/ENTITIES/mcl_mobs/movement.lua index 377e25f6e..df86c8161 100644 --- a/mods/ENTITIES/mcl_mobs/movement.lua +++ b/mods/ENTITIES/mcl_mobs/movement.lua @@ -480,6 +480,7 @@ end -- find and replace what mob is looking for (grass, wheat etc.) function mob_class:replace_node(pos) + if not self.replace_rate or not self.replace_what or self.child == true @@ -519,6 +520,8 @@ function mob_class:replace_node(pos) if on_replace_return ~= false then if mobs_griefing then + self.state = "eat" + self:set_animation("eat") minetest.set_node(pos, newnode) end diff --git a/mods/ENTITIES/mobs_mc/models/mobs_mc_sheepfur.b3d b/mods/ENTITIES/mobs_mc/models/mobs_mc_sheepfur.b3d index 7ee15fb553a18a438c50e362d36910af7e77c356..31044fbafe375d57aa6b28a4ed025160742095b9 100644 GIT binary patch delta 10698 zcmb7|eN;{99>f)h>79a4Wnb#=;?}8QNMO)FzsV|9c4qp*sEoYa!WDTr zsuAAtpYyzF{&+vHrS9?jPDZ)vnuLqT8m2cVx-47=>e`!6*WwK^P6jXb47; z7!AcJ3Zr2d4abPXNQ)7Vkq#q0Mk6p9iBU90qcDoWXf#G+FdB=IfRTui0i$sk#bPub zqd1J>F`9tUM2r$JnuHN~+N0<46pW@~G!3IfjHY9hgi$g^GcYn@l!DRw7|q1!1B_;2 zG#jH-j6TF@4n}h^O2cR#M)NUB$7lgY85k|ZC=;VBj22;(jnQI^mSD6Lqa2KuVU&we z9!ASC%ExF0Mg7Nf%$9l_|R0)^Us`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ENTITIES/mobs_mc/sheep.lua index c71fa9b54..b4fbda52c 100644 --- a/mods/ENTITIES/mobs_mc/sheep.lua +++ b/mods/ENTITIES/mobs_mc/sheep.lua @@ -101,17 +101,19 @@ mcl_mobs.register_mob("mobs_mc:sheep", { stand_start = 0, stand_end = 0, walk_start = 0, walk_end = 40, walk_speed = 30, run_start = 0, run_end = 40, run_speed = 40, + eat_start = 40, eat_end = 80, }, child_animations = { stand_start = 81, stand_end = 81, walk_start = 81, walk_end = 121, walk_speed = 45, run_start = 81, run_end = 121, run_speed = 60, + eat_start = 121, eat_start = 161, }, follow = { "mcl_farming:wheat_item" }, view_range = 12, -- Eat grass - replace_rate = 20, + replace_rate = 40, replace_what = { { "mcl_core:dirt_with_grass", "mcl_core:dirt", -1 }, { "mcl_flowers:tallgrass", "air", 0 }, From 1f5247df063211d48db704fbd0fa696764c04ce4 Mon Sep 17 00:00:00 2001 From: epCode Date: Tue, 30 May 2023 11:48:32 -0700 Subject: [PATCH 02/13] Make mobs slide less, and fix ageold jump dilema --- mods/ENTITIES/mcl_mobs/movement.lua | 6 ++++-- mods/ENTITIES/mcl_mobs/physics.lua | 10 +++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/movement.lua b/mods/ENTITIES/mcl_mobs/movement.lua index df86c8161..4e8ce3392 100644 --- a/mods/ENTITIES/mcl_mobs/movement.lua +++ b/mods/ENTITIES/mcl_mobs/movement.lua @@ -355,9 +355,11 @@ function mob_class:do_jump() jump_c_multiplier = v2/self.walk_velocity/2 end + local yaw_dir = minetest.yaw_to_dir(self.object:get_yaw()) + -- where is front - local dir_x = -math.sin(yaw) * (self.collisionbox[4] + 0.5)*jump_c_multiplier+0.6 - local dir_z = math.cos(yaw) * (self.collisionbox[4] + 0.5)*jump_c_multiplier+0.6 + local dir_x = -math.sin(yaw) * (self.collisionbox[4] + 0.5)*jump_c_multiplier+yaw_dir.x + local dir_z = math.cos(yaw) * (self.collisionbox[4] + 0.5)*jump_c_multiplier+yaw_dir.z -- what is in front of mob? nod = node_ok({ diff --git a/mods/ENTITIES/mcl_mobs/physics.lua b/mods/ENTITIES/mcl_mobs/physics.lua index 1fbe1e24d..e1b23d78a 100644 --- a/mods/ENTITIES/mcl_mobs/physics.lua +++ b/mods/ENTITIES/mcl_mobs/physics.lua @@ -184,7 +184,7 @@ function mob_class:collision() end function mob_class:check_death_and_slow_mob() - local d = 0.85 + local d = 0.7 local dying = self:check_dying() if dying then d = 0.92 end @@ -217,7 +217,7 @@ function mob_class:set_velocity(v) local vv = self.object:get_velocity() if vv and yaw then - self.acc = vector.new(((math.sin(yaw) * -v) + c_x) * .27, 0, ((math.cos(yaw) * v) + c_y) * .27) + self.acc = vector.new(((math.sin(yaw) * -v) + c_x) * .4, 0, ((math.cos(yaw) * v) + c_y) * .4) end end @@ -327,9 +327,9 @@ function mob_class:set_yaw(yaw, delay, dtime) end if math.deg(yaw) > 360 then - yaw=yaw%360 + yaw=math.rad(math.deg(yaw)%360) elseif math.deg(yaw) < 0 then - yaw=((360*5)-yaw)%360 + yaw=math.rad(((360*5)-math.deg(yaw))%360) end --calculate the shortest way to turn to find our target @@ -353,7 +353,7 @@ function mob_class:set_yaw(yaw, delay, dtime) ddtime = dtime end - if math.abs(target_shortest_path_nums) > 5 then + if math.abs(target_shortest_path_nums) > 10 then self.object:set_yaw(self.object:get_yaw()+(target_shortest_path*(3.6*ddtime))) if self.acc then self.acc=vector.rotate_around_axis(self.acc,vector.new(0,1,0), target_shortest_path*(3.6*ddtime)) From c049113f26f0747c55b0e8526f2970311ae2d204 Mon Sep 17 00:00:00 2001 From: epCode Date: Tue, 30 May 2023 12:03:13 -0700 Subject: [PATCH 03/13] Fix sheep sliding, make eating timed, fix animation repeat --- mods/ENTITIES/mcl_mobs/movement.lua | 13 ++++++++++++- mods/ENTITIES/mobs_mc/sheep.lua | 4 ++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/movement.lua b/mods/ENTITIES/mcl_mobs/movement.lua index 4e8ce3392..5909350ad 100644 --- a/mods/ENTITIES/mcl_mobs/movement.lua +++ b/mods/ENTITIES/mcl_mobs/movement.lua @@ -524,7 +524,18 @@ function mob_class:replace_node(pos) if mobs_griefing then self.state = "eat" self:set_animation("eat") - minetest.set_node(pos, newnode) + self:set_velocity(0) + minetest.after(0.5, function() + if self and self.object and not self.dead then + self.object:set_velocity(vector.new(0,0,0)) + minetest.set_node(pos, newnode) + end + end) + minetest.after(2.5, function() + if self and self.object and self.state == 'eat' and not self.dead then + self.state = "walk" + end + end) end end diff --git a/mods/ENTITIES/mobs_mc/sheep.lua b/mods/ENTITIES/mobs_mc/sheep.lua index b4fbda52c..f7d6e87f1 100644 --- a/mods/ENTITIES/mobs_mc/sheep.lua +++ b/mods/ENTITIES/mobs_mc/sheep.lua @@ -101,13 +101,13 @@ mcl_mobs.register_mob("mobs_mc:sheep", { stand_start = 0, stand_end = 0, walk_start = 0, walk_end = 40, walk_speed = 30, run_start = 0, run_end = 40, run_speed = 40, - eat_start = 40, eat_end = 80, + eat_start = 40, eat_end = 80, eat_loop = false, }, child_animations = { stand_start = 81, stand_end = 81, walk_start = 81, walk_end = 121, walk_speed = 45, run_start = 81, run_end = 121, run_speed = 60, - eat_start = 121, eat_start = 161, + eat_start = 121, eat_start = 161, eat_loop = false, }, follow = { "mcl_farming:wheat_item" }, view_range = 12, From 74e55ca3618864ce2710cf01d1ad87bf1831cf2a Mon Sep 17 00:00:00 2001 From: epCode Date: Tue, 30 May 2023 12:40:14 -0700 Subject: [PATCH 04/13] Fix eat replace timer for sheep --- mods/ENTITIES/mcl_mobs/movement.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ENTITIES/mcl_mobs/movement.lua b/mods/ENTITIES/mcl_mobs/movement.lua index 5909350ad..ebd0c4863 100644 --- a/mods/ENTITIES/mcl_mobs/movement.lua +++ b/mods/ENTITIES/mcl_mobs/movement.lua @@ -525,7 +525,7 @@ function mob_class:replace_node(pos) self.state = "eat" self:set_animation("eat") self:set_velocity(0) - minetest.after(0.5, function() + minetest.after(1.5, function() if self and self.object and not self.dead then self.object:set_velocity(vector.new(0,0,0)) minetest.set_node(pos, newnode) From 91d94800d7f4a7f0f0ce482e12e85a375845607c Mon Sep 17 00:00:00 2001 From: epCode Date: Tue, 30 May 2023 13:05:12 -0700 Subject: [PATCH 05/13] Adjust grass replace timer --- mods/ENTITIES/mcl_mobs/movement.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ENTITIES/mcl_mobs/movement.lua b/mods/ENTITIES/mcl_mobs/movement.lua index ebd0c4863..99b1fdf89 100644 --- a/mods/ENTITIES/mcl_mobs/movement.lua +++ b/mods/ENTITIES/mcl_mobs/movement.lua @@ -525,7 +525,7 @@ function mob_class:replace_node(pos) self.state = "eat" self:set_animation("eat") self:set_velocity(0) - minetest.after(1.5, function() + minetest.after(1.3, function() if self and self.object and not self.dead then self.object:set_velocity(vector.new(0,0,0)) minetest.set_node(pos, newnode) From 908ba9fba6400e08e61b11e183b3f5c31eaca59f Mon Sep 17 00:00:00 2001 From: epCode Date: Tue, 30 May 2023 19:54:24 -0700 Subject: [PATCH 06/13] Put on_replace call in correct place (wool regrow on grass to dirt) --- mods/ENTITIES/mcl_mobs/movement.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/movement.lua b/mods/ENTITIES/mcl_mobs/movement.lua index 99b1fdf89..c165bdf89 100644 --- a/mods/ENTITIES/mcl_mobs/movement.lua +++ b/mods/ENTITIES/mcl_mobs/movement.lua @@ -513,11 +513,8 @@ function mob_class:replace_node(pos) local oldnode = {name = what, param2 = node.param2} local newnode = {name = with, param2 = node.param2} - local on_replace_return + local on_replace_return = true - if self.on_replace then - on_replace_return = self.on_replace(self, pos, oldnode, newnode) - end if on_replace_return ~= false then @@ -529,6 +526,9 @@ function mob_class:replace_node(pos) if self and self.object and not self.dead then self.object:set_velocity(vector.new(0,0,0)) minetest.set_node(pos, newnode) + if self.on_replace then + on_replace_return = self.on_replace(self, pos, oldnode, newnode) + end end end) minetest.after(2.5, function() From 86cd5711ca462d30306b528cac1c2f4a5448d794 Mon Sep 17 00:00:00 2001 From: epCode Date: Sun, 4 Jun 2023 13:20:29 -0700 Subject: [PATCH 07/13] Rearange on replace code to be more general purpous --- mods/ENTITIES/mcl_mobs/init.lua | 3 +- mods/ENTITIES/mcl_mobs/movement.lua | 21 ++++--------- mods/ENTITIES/mobs_mc/sheep.lua | 48 +++++++++++++++++++---------- 3 files changed, 39 insertions(+), 33 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/init.lua b/mods/ENTITIES/mcl_mobs/init.lua index 6bd39b2cf..62100c627 100644 --- a/mods/ENTITIES/mcl_mobs/init.lua +++ b/mods/ENTITIES/mcl_mobs/init.lua @@ -217,6 +217,7 @@ function mcl_mobs.register_mob(name, def) replace_with = def.replace_with, replace_offset = def.replace_offset or 0, on_replace = def.on_replace, + replace_delay = def.replace_delay or 0, timer = 0, env_damage_timer = 0, tamed = false, @@ -490,7 +491,7 @@ function mcl_mobs.register_egg(mob, desc, background_color, overlay_color, addeg on_place = function(itemstack, placer, pointed_thing) local pos = pointed_thing.above - + -- am I clicking on something with existing on_rightclick function? local under = minetest.get_node(pointed_thing.under) local def = minetest.registered_nodes[under.name] diff --git a/mods/ENTITIES/mcl_mobs/movement.lua b/mods/ENTITIES/mcl_mobs/movement.lua index c165bdf89..7a89e010c 100644 --- a/mods/ENTITIES/mcl_mobs/movement.lua +++ b/mods/ENTITIES/mcl_mobs/movement.lua @@ -513,27 +513,18 @@ function mob_class:replace_node(pos) local oldnode = {name = what, param2 = node.param2} local newnode = {name = with, param2 = node.param2} - local on_replace_return = true + local on_replace_return = false + if self.on_replace then + on_replace_return = self.on_replace(self, pos, oldnode, newnode) + end if on_replace_return ~= false then if mobs_griefing then - self.state = "eat" - self:set_animation("eat") - self:set_velocity(0) - minetest.after(1.3, function() - if self and self.object and not self.dead then - self.object:set_velocity(vector.new(0,0,0)) + minetest.after(self.replace_delay, function() + if self and self.object and self.object:get_velocity() and self.health > 0 then minetest.set_node(pos, newnode) - if self.on_replace then - on_replace_return = self.on_replace(self, pos, oldnode, newnode) - end - end - end) - minetest.after(2.5, function() - if self and self.object and self.state == 'eat' and not self.dead then - self.state = "walk" end end) end diff --git a/mods/ENTITIES/mobs_mc/sheep.lua b/mods/ENTITIES/mobs_mc/sheep.lua index f7d6e87f1..fbebb2655 100644 --- a/mods/ENTITIES/mobs_mc/sheep.lua +++ b/mods/ENTITIES/mobs_mc/sheep.lua @@ -113,29 +113,43 @@ mcl_mobs.register_mob("mobs_mc:sheep", { view_range = 12, -- Eat grass - replace_rate = 40, + replace_rate = 1, + replace_delay = 1.3, replace_what = { { "mcl_core:dirt_with_grass", "mcl_core:dirt", -1 }, { "mcl_flowers:tallgrass", "air", 0 }, }, -- Properly regrow wool after eating grass on_replace = function(self, pos, oldnode, newnode) - if not self.color or not colors[self.color] then - self.color = "unicolor_white" - end - self.gotten = false - self.base_texture = sheep_texture(self.color) - self.object:set_properties({ textures = self.base_texture }) - self.drops = { - {name = "mcl_mobitems:mutton", - chance = 1, - min = 1, - max = 2,}, - {name = colors[self.color][1], - chance = 1, - min = 1, - max = 1,}, - } + self.state = "eat" + self:set_animation("eat") + self:set_velocity(0) + minetest.after(self.replace_delay, function() + self.object:set_velocity(vector.zero()) + if self and self.object and not self.object:get_velocity() and self.health > 0 then + if not self.color or not colors[self.color] then + self.color = "unicolor_white" + end + self.gotten = false + self.base_texture = sheep_texture(self.color) + self.object:set_properties({ textures = self.base_texture }) + self.drops = { + {name = "mcl_mobitems:mutton", + chance = 1, + min = 1, + max = 2,}, + {name = colors[self.color][1], + chance = 1, + min = 1, + max = 1,}, + } + end + end) + minetest.after(2.5, function() + if self and self.object and self.state == 'eat' and self.health > 0 and self.object:get_velocity() then + self.state = "walk" + end + end) end, -- Set random color on spawn From 92887f55012670918af4c98c073095fcb032f757 Mon Sep 17 00:00:00 2001 From: epCode Date: Sun, 4 Jun 2023 13:21:12 -0700 Subject: [PATCH 08/13] fix sheep replace rate --- mods/ENTITIES/mobs_mc/sheep.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ENTITIES/mobs_mc/sheep.lua b/mods/ENTITIES/mobs_mc/sheep.lua index fbebb2655..6ea66923e 100644 --- a/mods/ENTITIES/mobs_mc/sheep.lua +++ b/mods/ENTITIES/mobs_mc/sheep.lua @@ -113,7 +113,7 @@ mcl_mobs.register_mob("mobs_mc:sheep", { view_range = 12, -- Eat grass - replace_rate = 1, + replace_rate = 80, replace_delay = 1.3, replace_what = { { "mcl_core:dirt_with_grass", "mcl_core:dirt", -1 }, From e53b6c124c423b1e83d78eef574769ae6d37e4a6 Mon Sep 17 00:00:00 2001 From: epCode Date: Sun, 4 Jun 2023 14:38:29 -0700 Subject: [PATCH 09/13] Make sheep always drop 1 wool (MC continuity) --- mods/ENTITIES/mobs_mc/sheep.lua | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/mods/ENTITIES/mobs_mc/sheep.lua b/mods/ENTITIES/mobs_mc/sheep.lua index 6ea66923e..e64bc7c30 100644 --- a/mods/ENTITIES/mobs_mc/sheep.lua +++ b/mods/ENTITIES/mobs_mc/sheep.lua @@ -133,16 +133,6 @@ mcl_mobs.register_mob("mobs_mc:sheep", { self.gotten = false self.base_texture = sheep_texture(self.color) self.object:set_properties({ textures = self.base_texture }) - self.drops = { - {name = "mcl_mobitems:mutton", - chance = 1, - min = 1, - max = 2,}, - {name = colors[self.color][1], - chance = 1, - min = 1, - max = 1,}, - } end end) minetest.after(2.5, function() @@ -242,12 +232,6 @@ mcl_mobs.register_mob("mobs_mc:sheep", { item:add_wear(mobs_mc.shears_wear) clicker:get_inventory():set_stack("main", clicker:get_wield_index(), item) end - self.drops = { - {name = "mcl_mobitems:mutton", - chance = 1, - min = 1, - max = 2,}, - } return end -- Dye sheep From e49eac6d85f017022a770b790dc8ff5f6e8d727c Mon Sep 17 00:00:00 2001 From: epCode Date: Sun, 4 Jun 2023 16:24:37 -0700 Subject: [PATCH 10/13] Fix sheep not regrowing wool after eating --- mods/ENTITIES/mobs_mc/sheep.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ENTITIES/mobs_mc/sheep.lua b/mods/ENTITIES/mobs_mc/sheep.lua index e64bc7c30..bc5026bd2 100644 --- a/mods/ENTITIES/mobs_mc/sheep.lua +++ b/mods/ENTITIES/mobs_mc/sheep.lua @@ -126,7 +126,7 @@ mcl_mobs.register_mob("mobs_mc:sheep", { self:set_velocity(0) minetest.after(self.replace_delay, function() self.object:set_velocity(vector.zero()) - if self and self.object and not self.object:get_velocity() and self.health > 0 then + if self and self.object and self.object:get_velocity() and self.health > 0 then if not self.color or not colors[self.color] then self.color = "unicolor_white" end From 5e4fa30aaea38fd45ade6b5a355f7377f382ba1a Mon Sep 17 00:00:00 2001 From: epCode Date: Sun, 4 Jun 2023 20:19:18 -0700 Subject: [PATCH 11/13] Punch node after change --- mods/ENTITIES/mcl_mobs/movement.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ENTITIES/mcl_mobs/movement.lua b/mods/ENTITIES/mcl_mobs/movement.lua index 7a89e010c..c5c7a6823 100644 --- a/mods/ENTITIES/mcl_mobs/movement.lua +++ b/mods/ENTITIES/mcl_mobs/movement.lua @@ -525,10 +525,10 @@ function mob_class:replace_node(pos) minetest.after(self.replace_delay, function() if self and self.object and self.object:get_velocity() and self.health > 0 then minetest.set_node(pos, newnode) + minetest.punch_node(pos) end end) end - end end end From df8592df41cc8c902aca128f9932863e0cb61f4b Mon Sep 17 00:00:00 2001 From: epCode Date: Sun, 4 Jun 2023 21:53:39 -0700 Subject: [PATCH 12/13] Revert add punch node --- mods/ENTITIES/mcl_mobs/movement.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/mods/ENTITIES/mcl_mobs/movement.lua b/mods/ENTITIES/mcl_mobs/movement.lua index c5c7a6823..317ac9f28 100644 --- a/mods/ENTITIES/mcl_mobs/movement.lua +++ b/mods/ENTITIES/mcl_mobs/movement.lua @@ -525,7 +525,6 @@ function mob_class:replace_node(pos) minetest.after(self.replace_delay, function() if self and self.object and self.object:get_velocity() and self.health > 0 then minetest.set_node(pos, newnode) - minetest.punch_node(pos) end end) end From cc5a0971ac18f90e01b27d343af0bb727c91cc28 Mon Sep 17 00:00:00 2001 From: ancientmarinerdev Date: Mon, 5 Jun 2023 15:03:45 +0100 Subject: [PATCH 13/13] Object reference check before setting velocity --- mods/ENTITIES/mobs_mc/sheep.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ENTITIES/mobs_mc/sheep.lua b/mods/ENTITIES/mobs_mc/sheep.lua index bc5026bd2..6c095fc9b 100644 --- a/mods/ENTITIES/mobs_mc/sheep.lua +++ b/mods/ENTITIES/mobs_mc/sheep.lua @@ -125,8 +125,8 @@ mcl_mobs.register_mob("mobs_mc:sheep", { self:set_animation("eat") self:set_velocity(0) minetest.after(self.replace_delay, function() - self.object:set_velocity(vector.zero()) if self and self.object and self.object:get_velocity() and self.health > 0 then + self.object:set_velocity(vector.zero()) if not self.color or not colors[self.color] then self.color = "unicolor_white" end