From fcfd6b9d19bbc1e894b8dafed490e04102c87878 Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Fri, 23 Apr 2021 21:14:23 -0400 Subject: [PATCH 01/16] Set up basics for breeding mechanics --- mods/ENTITIES/mcl_mobs/api/api.lua | 1 + mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua | 2 +- mods/ENTITIES/mcl_mobs/api/mob_functions/breeding.lua | 0 mods/ENTITIES/mcl_mobs/api/mob_functions/set_up.lua | 2 +- mods/ENTITIES/mobs_mc/cow+mooshroom.lua | 4 +++- 5 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 mods/ENTITIES/mcl_mobs/api/mob_functions/breeding.lua diff --git a/mods/ENTITIES/mcl_mobs/api/api.lua b/mods/ENTITIES/mcl_mobs/api/api.lua index 235453918c..f748a09355 100644 --- a/mods/ENTITIES/mcl_mobs/api/api.lua +++ b/mods/ENTITIES/mcl_mobs/api/api.lua @@ -164,6 +164,7 @@ dofile(api_path .. "sound_handling.lua") dofile(api_path .. "death_logic.lua") dofile(api_path .. "mob_effects.lua") dofile(api_path .. "projectile_handling.lua") +dofile(api_path .. "breeding.lua") mobs.spawning_mobs = {} diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua index 5295060640..ff1b72df6b 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua @@ -698,7 +698,7 @@ mobs.mob_step = function(self, dtime) --despawn mechanism --don't despawned tamed mobs - if not self.tamed then + if not self.tamed and not self.bred then self.lifetimer = self.lifetimer - dtime if self.lifetimer <= 0 then self.lifetimer = self.lifetimer_reset diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/breeding.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/breeding.lua new file mode 100644 index 0000000000..e69de29bb2 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 5f55d344a8..f4a050da21 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/set_up.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/set_up.lua @@ -7,7 +7,7 @@ mobs.mob_staticdata = function(self) --despawn mechanism --don't despawned tamed mobs - if not self.tamed then + if not self.tamed and not self.bred then if not mobs.check_for_player_within_area(self, 64) then --print("removing SERIALIZED!") self.object:remove() diff --git a/mods/ENTITIES/mobs_mc/cow+mooshroom.lua b/mods/ENTITIES/mobs_mc/cow+mooshroom.lua index 9cc4e5d158..dfc98aad4c 100644 --- a/mods/ENTITIES/mobs_mc/cow+mooshroom.lua +++ b/mods/ENTITIES/mobs_mc/cow+mooshroom.lua @@ -50,7 +50,9 @@ local cow_def = { }, follow = mobs_mc.follow.cow, on_rightclick = function(self, clicker) - if mobs:feed_tame(self, clicker, 1, true, true) then return end + if mobs:feed_tame(self, clicker, 1, true, true) then + return + end if self.child then return From ed9d629b99a9f873cebfa8e45239271a81a8025c Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Fri, 23 Apr 2021 21:59:42 -0400 Subject: [PATCH 02/16] Add in mob following for cows --- mods/ENTITIES/mcl_mobs/api/api.lua | 9 ++-- .../mcl_mobs/api/mob_functions/ai.lua | 49 +++++++++++++++++-- .../mcl_mobs/api/mob_functions/animation.lua | 22 +++++++++ .../mcl_mobs/api/mob_functions/breeding.lua | 33 +++++++++++++ .../mcl_mobs/api/mob_functions/set_up.lua | 2 +- mods/ENTITIES/mobs_mc/cow+mooshroom.lua | 14 +++--- 6 files changed, 114 insertions(+), 15 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api/api.lua b/mods/ENTITIES/mcl_mobs/api/api.lua index f748a09355..af2ce1d7c6 100644 --- a/mods/ENTITIES/mcl_mobs/api/api.lua +++ b/mods/ENTITIES/mcl_mobs/api/api.lua @@ -265,8 +265,6 @@ function mobs:register_mob(name, def) env_damage_timer = 0, tamed = false, pause_timer = 0, - horny = false, - hornytimer = 0, gotten = false, health = 0, reach = def.reach or 3, @@ -298,7 +296,6 @@ function mobs:register_mob(name, def) owner_loyal = def.owner_loyal, facing_fence = false, - _cmi_is_mob = true, pushable = def.pushable or true, @@ -331,6 +328,12 @@ function mobs:register_mob(name, def) skittish = def.skittish, lifetimer_reset = 30, --30 seconds lifetimer = 30, --30 seconds + + breedable = def.breedable, + breed_timer = 0, + breed_cooloff_timer = 5*60, -- 5 minutes + bred = false, + follow_distance = def.follow_distance or 2, --end j4i stuff -- MCL2 extensions diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua index ff1b72df6b..8a4add6568 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua @@ -6,6 +6,7 @@ local math_round = math.round local vector_multiply = vector.multiply local vector_add = vector.add local vector_new = vector.new +local vector_distance = vector.distance local minetest_yaw_to_dir = minetest.yaw_to_dir local minetest_get_item_group = minetest.get_item_group @@ -67,7 +68,8 @@ local land_state_list_wandering = {"stand", "walk"} local land_state_switch = function(self, dtime) - --do math after sure not attacking or running away + --do math before sure not attacking, following, or running away so continue + --doing random walking for mobs if all states are not met self.state_timer = self.state_timer - dtime --only run away @@ -76,18 +78,27 @@ local land_state_switch = function(self, dtime) if self.run_timer > 0 then return end - --continue end + --ignore everything else if following + if mobs.check_following(self) then + self.state = "follow" + return + --reset the state timer to get the mob out of + --the follow state - not the cleanest option + --but the easiest + elseif self.state == "follow" then + self.state_timer = 0 + end + --only attack if self.hostile and self.attacking then self.state = "attack" return end - - + --if finally reached here then do random wander if self.state_timer <= 0 then self.state_timer = math.random(4,10) + math.random() self.state = land_state_list_wandering[math.random(1,#land_state_list_wandering)] @@ -103,6 +114,16 @@ local land_state_execution = function(self,dtime) return end + --cool off after breeding + if self.breed_timer and self.breed_timer > 0 then + self.breed_timer = self.breed_timer - dtime + --do this to skip the first check, using as switch + if self.breed_timer <= 0 then + self.breed_timer = nil + end + end + + local pos = self.object:get_pos() local collisionbox = self.object:get_properties().collisionbox --get the center of the mob @@ -145,6 +166,24 @@ local land_state_execution = function(self,dtime) mobs.lock_yaw(self) + elseif self.state == "follow" then + + mobs.set_yaw_while_following(self) + + local distance_from_follow_person = vector_distance(self.object:get_pos(), self.following_person:get_pos()) + + if self.follow_distance < distance_from_follow_person then + mobs.set_mob_animation(self, "run") + mobs.set_velocity(self,self.run_velocity) + + if mobs.jump_check(self) == 1 then + mobs.jump(self) + end + else + mobs.set_mob_animation(self, "stand") + mobs.set_velocity(self,0) + end + elseif self.state == "walk" then self.walk_timer = self.walk_timer - dtime @@ -697,7 +736,7 @@ mobs.mob_step = function(self, dtime) end --despawn mechanism - --don't despawned tamed mobs + --don't despawned tamed or bred mobs if not self.tamed and not self.bred then self.lifetimer = self.lifetimer - dtime if self.lifetimer <= 0 then diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/animation.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/animation.lua index fbf140034c..809eacef5d 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/animation.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/animation.lua @@ -213,4 +213,26 @@ mobs.handle_explosion_animation = function(self) visual_size_modified.y = visual_size_modified.y * explosion_timer_adjust self.object:set_properties({visual_size = visual_size_modified}) +end + + +--this is used when a mob is following player +mobs.set_yaw_while_following = function(self) + + if self.object:get_properties().automatic_face_movement_dir then + self.object:set_properties{automatic_face_movement_dir = false} + end + + --turn positions into pseudo 2d vectors + local pos1 = self.object:get_pos() + pos1.y = 0 + + local pos2 = self.following_person:get_pos() + pos2.y = 0 + + local new_direction = vector_direction(pos1,pos2) + local new_yaw = minetest_dir_to_yaw(new_direction) + + self.object:set_yaw(new_yaw) + self.yaw = new_yaw end \ No newline at end of file diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/breeding.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/breeding.lua index e69de29bb2..975495f046 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/breeding.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/breeding.lua @@ -0,0 +1,33 @@ +--check to see if someone nearby has some tasty food +mobs.check_following = function(self) -- returns true or false + + --ignore + if not self.follow then + self.following_person = nil + return(false) + end + + --hey look, this thing works for passive mobs too! + local follower = mobs.detect_closest_player_within_radius(self,true,self.view_range,self.eye_height) + + --check if the follower is a player incase they log out + if follower and follower:is_player() then + local stack = follower:get_wielded_item() + --safety check + if not stack then + self.following_person = nil + return(false) + end + local item_name = stack:get_name() + + --all checks have passed, that guy has some good looking food + if item_name == self.follow then + self.following_person = follower + return(true) + end + end + + --everything failed + self.following_person = nil + return(false) +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 f4a050da21..864b888e81 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/set_up.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/set_up.lua @@ -6,7 +6,7 @@ local minetest_settings = minetest.settings mobs.mob_staticdata = function(self) --despawn mechanism - --don't despawned tamed mobs + --don't despawned tamed or bred mobs if not self.tamed and not self.bred then if not mobs.check_for_player_within_area(self, 64) then --print("removing SERIALIZED!") diff --git a/mods/ENTITIES/mobs_mc/cow+mooshroom.lua b/mods/ENTITIES/mobs_mc/cow+mooshroom.lua index dfc98aad4c..6dbb594f02 100644 --- a/mods/ENTITIES/mobs_mc/cow+mooshroom.lua +++ b/mods/ENTITIES/mobs_mc/cow+mooshroom.lua @@ -50,13 +50,13 @@ local cow_def = { }, follow = mobs_mc.follow.cow, on_rightclick = function(self, clicker) - if mobs:feed_tame(self, clicker, 1, true, true) then - return - end + --if mobs:feed_tame(self, clicker, 1, true, true) then + --return + --end - if self.child then - return - end + --if self.child then + -- return + --end local item = clicker:get_wielded_item() if item:get_name() == mobs_mc.items.bucket and clicker:get_inventory() then @@ -74,6 +74,8 @@ local cow_def = { return end end, + breedable = true, + follow_distance = 2, follow = mobs_mc.items.wheat, view_range = 10, fear_height = 4, From c37a82d4a2589d372f88b5101918858c2d210e57 Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Fri, 23 Apr 2021 22:03:29 -0400 Subject: [PATCH 03/16] Add comments --- mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua index 8a4add6568..cb755b03ea 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua @@ -168,10 +168,13 @@ local land_state_execution = function(self,dtime) elseif self.state == "follow" then + --always look at players mobs.set_yaw_while_following(self) + --check distance local distance_from_follow_person = vector_distance(self.object:get_pos(), self.following_person:get_pos()) + --don't push the player if too close if self.follow_distance < distance_from_follow_person then mobs.set_mob_animation(self, "run") mobs.set_velocity(self,self.run_velocity) From 6eb3eef21561ddf2091682f3703fa9a23e35915e Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Fri, 23 Apr 2021 22:34:40 -0400 Subject: [PATCH 04/16] Fix typo in function --- mods/ENTITIES/mcl_mobs/api/mob_functions/environment.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/environment.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/environment.lua index fe77305b0d..8320955adb 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/environment.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/environment.lua @@ -67,12 +67,12 @@ mobs.detect_closest_player_within_radius = function(self, line_of_sight, radius, end --do a default radius max - local shortest_disance = radius + 1 + local shortest_distance = radius + 1 --sort through players and find the closest player for player,distance in pairs(players_in_area) do - if distance < shortest_disance then - shortest_disance = distance + if distance < shortest_distance then + shortest_distance = distance winner_player = player end end From 79cb6ddc4923ea8a009b2810efe785cf3720c63f Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Fri, 23 Apr 2021 22:35:35 -0400 Subject: [PATCH 05/16] Fix lua locals in environment.lua --- mods/ENTITIES/mcl_mobs/api/mob_functions/environment.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/environment.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/environment.lua index 8320955adb..5b5dc5d47a 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/environment.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/environment.lua @@ -9,6 +9,7 @@ local minetest_registered_nodes = minetest.registered_nodes local minetest_get_connected_players = minetest.get_connected_players local vector_new = vector.new +local vector_add = vector.add local vector_multiply = vector.multiply local vector_distance = vector.distance @@ -39,7 +40,7 @@ mobs.detect_closest_player_within_radius = function(self, line_of_sight, radius, local pos2 = player:get_pos() - local distance = vector.distance(pos1,pos2) + local distance = vector_distance(pos1,pos2) if distance <= radius then if line_of_sight then @@ -94,7 +95,7 @@ mobs.jump_check = function(self,dtime) vector_multiply(dir, radius) --only jump if there's a node and a non-solid node above it - local test_dir = vector.add(pos,dir) + local test_dir = vector_add(pos,dir) local green_flag_1 = minetest_get_item_group(minetest_get_node(test_dir).name, "solid") ~= 0 From 531253008a13559cdab63f420e9d35c78b382c95 Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Fri, 23 Apr 2021 23:56:59 -0400 Subject: [PATCH 06/16] Complete mob breeding, make cows breedable --- mods/ENTITIES/mcl_mobs/api/api.lua | 16 +- .../mcl_mobs/api/mob_functions/ai.lua | 97 +++++++++++- .../mcl_mobs/api/mob_functions/animation.lua | 21 +++ .../mcl_mobs/api/mob_functions/breeding.lua | 146 +++++++++++++++++- .../api/mob_functions/mob_effects.lua | 30 ++++ .../mcl_mobs/api/mob_functions/set_up.lua | 32 ++-- mods/ENTITIES/mobs_mc/cow+mooshroom.lua | 20 ++- 7 files changed, 333 insertions(+), 29 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api/api.lua b/mods/ENTITIES/mcl_mobs/api/api.lua index af2ce1d7c6..ac771164e9 100644 --- a/mods/ENTITIES/mcl_mobs/api/api.lua +++ b/mods/ENTITIES/mcl_mobs/api/api.lua @@ -245,7 +245,6 @@ function mobs:register_mob(name, def) shoot_interval = def.shoot_interval, sounds = def.sounds or {}, animation = def.animation, - follow = def.follow, jump = def.jump ~= false, walk_chance = def.walk_chance or 50, attacks_monsters = def.attacks_monsters or false, @@ -329,11 +328,24 @@ function mobs:register_mob(name, def) lifetimer_reset = 30, --30 seconds lifetimer = 30, --30 seconds + --breeding stuff breedable = def.breedable, breed_timer = 0, - breed_cooloff_timer = 5*60, -- 5 minutes + breed_lookout_timer = 0, + breed_distance = def.breed_distance or 1.5, --how far away mobs have to be to begin actual breeding + breed_lookout_timer_goal = 30, --30 seconds (this timer is for how long the mob looks for a mate) + breed_timer_cooloff = 5*60, -- 5 minutes (this timer is for how long the mob has to wait before being bred again) bred = false, + follow = def.follow, --this item is also used for the breeding mechanism follow_distance = def.follow_distance or 2, + baby_size = def.baby_size or 0.5, + baby = false, + grow_up_timer = 0, + grow_up_goal = 20*60, --in 20 minutes the mob grows up + + backup_visual_size = def.visual_size, + backup_collisionbox = collisionbox, + backup_selectionbox = def.selectionbox or def.collisionbox, --end j4i stuff -- MCL2 extensions diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua index cb755b03ea..b5af5f5330 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua @@ -81,8 +81,20 @@ local land_state_switch = function(self, dtime) --continue end + --ignore everything else if breeding + if self.breed_lookout_timer and self.breed_lookout_timer > 0 then + self.state = "breed" + return + --reset the state timer to get the mob out of + --the breed state + elseif self.state == "breed" then + self.state_timer = 0 + end + --ignore everything else if following - if mobs.check_following(self) then + if mobs.check_following(self) and + (not self.breed_lookout_timer or (self.breed_lookout_timer and self.breed_lookout_timer == 0)) and + (not self.breed_timer or (self.breed_timer and self.breed_timer == 0)) then self.state = "follow" return --reset the state timer to get the mob out of @@ -109,17 +121,37 @@ end -- states are executed here local land_state_execution = function(self,dtime) + --[[ -- this is a debug which shows the timer and makes mobs breed 100 times faster + print(self.breed_timer) + if self.breed_timer > 0 then + self.breed_timer = self.breed_timer - (dtime * 100) + if self.breed_timer <= 0 then + self.breed_timer = 0 + end + end + ]]-- + --no collisionbox exception if not self.object:get_properties() then return end + + + --timer to time out looking for mate + if self.breed_lookout_timer and self.breed_lookout_timer > 0 then + self.breed_lookout_timer = self.breed_lookout_timer - dtime + --looking for mate failed + if self.breed_lookout_timer <= 0 then + self.breed_lookout_timer = 0 + end + end --cool off after breeding if self.breed_timer and self.breed_timer > 0 then self.breed_timer = self.breed_timer - dtime --do this to skip the first check, using as switch if self.breed_timer <= 0 then - self.breed_timer = nil + self.breed_timer = 0 end end @@ -165,7 +197,6 @@ local land_state_execution = function(self,dtime) end mobs.lock_yaw(self) - elseif self.state == "follow" then --always look at players @@ -288,6 +319,48 @@ local land_state_execution = function(self,dtime) mobs.projectile_attack_walk(self,dtime) end + elseif self.state == "breed" then + + mobs.breeding_effect(self) + + local mate = mobs.look_for_mate(self) + + --found a mate + if mate then + mobs.set_yaw_while_breeding(self,mate) + mobs.set_velocity(self, self.walk_velocity) + + --smoosh together basically + if vector_distance(self.object:get_pos(), mate:get_pos()) <= self.breed_distance then + mobs.set_mob_animation(self, "stand") + if self.special_breed_timer == 0 then + self.special_breed_timer = 2 --breeding takes 2 seconds + end + + self.special_breed_timer = self.special_breed_timer - dtime + if self.special_breed_timer <= 0 then + + --pop a baby out, it's a miracle! + local baby_pos = vector.divide(vector.add(self.object:get_pos(), mate:get_pos()), 2) + local baby_mob = minetest.add_entity(pos, self.name, minetest.serialize({baby = true, grow_up_timer = self.grow_up_goal, bred = true})) + + self.special_breed_timer = 0 + self.breed_lookout_timer = 0 + self.breed_timer = self.breed_timer_cooloff + + mate:get_luaentity().special_breed_timer = 0 + mate:get_luaentity().breed_lookout_timer = 0 + mate:get_luaentity().breed_timer = self.breed_timer_cooloff -- can reuse because it's the same mob + end + else + mobs.set_mob_animation(self, "walk") + end + --couldn't find a mate, just stand there until the player pushes it towards one + --or the timer runs out + else + mobs.set_mob_animation(self, "stand") + mobs.set_velocity(self,0) + end end @@ -777,6 +850,24 @@ mobs.mob_step = function(self, dtime) return end + --baby grows up + if self.baby then + --print(self.grow_up_timer) + --catch missing timer + if not self.grow_up_timer then + self.grow_up_timer = self.grow_up_goal + end + + self.grow_up_timer = self.grow_up_timer - dtime + + --baby grows up! + if self.grow_up_timer <= 0 then + self.grow_up_timer = 0 + mobs.baby_grow_up(self) + end + end + + --do custom mob instructions if self.do_custom then diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/animation.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/animation.lua index 809eacef5d..c26d330897 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/animation.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/animation.lua @@ -233,6 +233,27 @@ mobs.set_yaw_while_following = function(self) local new_direction = vector_direction(pos1,pos2) local new_yaw = minetest_dir_to_yaw(new_direction) + self.object:set_yaw(new_yaw) + self.yaw = new_yaw +end + +--this is used for when mobs breed +mobs.set_yaw_while_breeding = function(self, mate) + + if self.object:get_properties().automatic_face_movement_dir then + self.object:set_properties{automatic_face_movement_dir = false} + end + + --turn positions into pseudo 2d vectors + local pos1 = self.object:get_pos() + pos1.y = 0 + + local pos2 = mate:get_pos() + pos2.y = 0 + + local new_direction = vector_direction(pos1,pos2) + local new_yaw = minetest_dir_to_yaw(new_direction) + self.object:set_yaw(new_yaw) self.yaw = new_yaw end \ No newline at end of file diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/breeding.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/breeding.lua index 975495f046..f71018aba5 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/breeding.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/breeding.lua @@ -1,3 +1,7 @@ +local minetest_get_objects_inside_radius = minetest.get_objects_inside_radius + +local vector_distance = vector.distance + --check to see if someone nearby has some tasty food mobs.check_following = function(self) -- returns true or false @@ -18,8 +22,8 @@ mobs.check_following = function(self) -- returns true or false self.following_person = nil return(false) end - local item_name = stack:get_name() + local item_name = stack:get_name() --all checks have passed, that guy has some good looking food if item_name == self.follow then self.following_person = follower @@ -30,4 +34,144 @@ mobs.check_following = function(self) -- returns true or false --everything failed self.following_person = nil return(false) +end + +--a function which attempts to make mobs enter +--the breeding state +mobs.enter_breed_state = function(self,clicker) + + --do not breed if baby + if self.baby then + return(false) + end + + --do not do anything if looking for mate or + --if cooling off from breeding + if self.breed_lookout_timer > 0 or self.breed_timer > 0 then + return(false) + end + + --if this is caught, that means something has gone + --seriously wrong + if not clicker or not clicker:is_player() then + return(false) + end + + local stack = clicker:get_wielded_item() + --safety check + if not stack then + return(false) + end + + local item_name = stack:get_name() + --all checks have passed, that guy has some good looking food + if item_name == self.follow then + if not minetest.is_creative_enabled(clicker:get_player_name()) then + stack:take_item() + clicker:set_wielded_item(stack) + end + self.breed_lookout_timer = self.breed_lookout_timer_goal + self.bred = true + return(true) + end + + --everything failed + return(false) +end + + +--find the closest mate in the area +mobs.look_for_mate = function(self) + + local pos1 = self.object:get_pos() + pos1.y = pos1.y + self.eye_height + + local mates_in_area = {} + local winner_mate = nil + local mates_detected = 0 + local radius = self.view_range + + --get mates in radius + for _,mate in pairs(minetest_get_objects_inside_radius(pos1, radius)) do + + --look for a breeding mate + if mate and mate:get_luaentity() + and mate:get_luaentity()._cmi_is_mob + and mate:get_luaentity().name == self.name + and mate:get_luaentity().breed_lookout_timer > 0 + and mate:get_luaentity() ~= self then + + local pos2 = mate:get_pos() + + local distance = vector_distance(pos1,pos2) + + if distance <= radius then + if line_of_sight then + --must add eye height or stuff breaks randomly because of + --seethrough nodes being a blocker (like grass) + if minetest_line_of_sight( + vector_new(pos1.x, pos1.y, pos1.z), + vector_new(pos2.x, pos2.y + mate:get_properties().eye_height, pos2.z) + ) then + mates_detected = mates_detected + 1 + mates_in_area[mate] = distance + end + else + mates_detected = mates_detected + 1 + mates_in_area[mate] = distance + end + end + end + end + + + --return if there's no one near by + if mates_detected <= 0 then --handle negative numbers for some crazy error that could possibly happen + return nil + end + + --do a default radius max + local shortest_distance = radius + 1 + + --sort through mates and find the closest mate + for mate,distance in pairs(mates_in_area) do + if distance < shortest_distance then + shortest_distance = distance + winner_mate = mate + end + end + + return(winner_mate) + +end + +--make the baby grow up +mobs.baby_grow_up = function(self) + self.baby = nil + self.visual_size = self.backup_visual_size + self.collisionbox = self.backup_collisionbox + self.selectionbox = self.backup_selectionbox + self.object:set_properties(self) +end + +--makes the baby grow up faster with diminishing returns +mobs.make_baby_grow_faster = function(self,clicker) + if clicker and clicker:is_player() then + local stack = clicker:get_wielded_item() + --safety check + if not stack then + return + end + + local item_name = stack:get_name() + --all checks have passed, that guy has some good looking food + if item_name == self.follow then + self.grow_up_timer = self.grow_up_timer - (self.grow_up_timer * 0.10) --take 10 percent off - diminishing returns + + if not minetest.is_creative_enabled(clicker:get_player_name()) then + stack:take_item() + clicker:set_wielded_item(stack) + end + end + end end \ No newline at end of file diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/mob_effects.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/mob_effects.lua index b01920f18b..847315ff18 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/mob_effects.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/mob_effects.lua @@ -119,4 +119,34 @@ mobs.tamed_effect = function(self) vertical = false, texture = "heart.png", }) +end + +--hearts when breeding +mobs.breeding_effect = function(self) + local pos = self.object:get_pos() + local yaw = self.object:get_yaw() + local collisionbox = self.object:get_properties().collisionbox + + local min, max + + if collisionbox then + min = {x=collisionbox[1], y=collisionbox[2], z=collisionbox[3]} + max = {x=collisionbox[4], y=collisionbox[5], z=collisionbox[6]} + end + + minetest_add_particlespawner({ + amount = 2, + time = 0.0001, + minpos = vector.add(pos, min), + maxpos = vector.add(pos, max), + minvel = vector.new(-1,1,-1), + maxvel = vector.new(1,3,1), + minexptime = 0.7, + maxexptime = 1, + minsize = 1, + maxsize = 2, + collisiondetection = false, + vertical = false, + texture = "heart.png", + }) 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 864b888e81..41f3932f75 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/set_up.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/set_up.lua @@ -107,12 +107,12 @@ mobs.mob_activate = function(self, staticdata, def, dtime) mesh = def.gotten_mesh end - -- set child objects to half size - if self.child == true then + -- set baby mobs to half size + if self.baby == true then vis_size = { - x = self.base_size.x * .5, - y = self.base_size.y * .5, + x = self.base_size.x * self.baby_size, + y = self.base_size.y * self.baby_size, } if def.child_texture then @@ -120,20 +120,20 @@ mobs.mob_activate = function(self, staticdata, def, dtime) end colbox = { - self.base_colbox[1] * .5, - self.base_colbox[2] * .5, - self.base_colbox[3] * .5, - self.base_colbox[4] * .5, - self.base_colbox[5] * .5, - self.base_colbox[6] * .5 + self.base_colbox[1] * self.baby_size, + self.base_colbox[2] * self.baby_size, + self.base_colbox[3] * self.baby_size, + self.base_colbox[4] * self.baby_size, + self.base_colbox[5] * self.baby_size, + self.base_colbox[6] * self.baby_size } selbox = { - self.base_selbox[1] * .5, - self.base_selbox[2] * .5, - self.base_selbox[3] * .5, - self.base_selbox[4] * .5, - self.base_selbox[5] * .5, - self.base_selbox[6] * .5 + self.base_selbox[1] * self.baby_size, + self.base_selbox[2] * self.baby_size, + self.base_selbox[3] * self.baby_size, + self.base_selbox[4] * self.baby_size, + self.base_selbox[5] * self.baby_size, + self.base_selbox[6] * self.baby_size } end diff --git a/mods/ENTITIES/mobs_mc/cow+mooshroom.lua b/mods/ENTITIES/mobs_mc/cow+mooshroom.lua index 6dbb594f02..87e6f25523 100644 --- a/mods/ENTITIES/mobs_mc/cow+mooshroom.lua +++ b/mods/ENTITIES/mobs_mc/cow+mooshroom.lua @@ -48,15 +48,19 @@ local cow_def = { walk_end = 40, run_start = 0, run_end = 40, }, - follow = mobs_mc.follow.cow, + --follow = mobs_mc.follow.cow, on_rightclick = function(self, clicker) - --if mobs:feed_tame(self, clicker, 1, true, true) then - --return - --end - --if self.child then - -- return - --end + --attempt to enter breed state + if mobs.enter_breed_state(self,clicker) then + return + end + + if self.baby then + mobs.make_baby_grow_faster(self,clicker) + --do child timer thing %10 + return + end local item = clicker:get_wielded_item() if item:get_name() == mobs_mc.items.bucket and clicker:get_inventory() then @@ -75,6 +79,8 @@ local cow_def = { end end, breedable = true, + breed_distance = 1.5, + baby_size = 0.5, follow_distance = 2, follow = mobs_mc.items.wheat, view_range = 10, From 0568c14a435e663dccc1a42ae999a76d0936f153 Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Fri, 23 Apr 2021 23:59:35 -0400 Subject: [PATCH 07/16] Fix timer and make mooshroom breedable --- mods/ENTITIES/mcl_mobs/api/api.lua | 1 + mods/ENTITIES/mobs_mc/cow+mooshroom.lua | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api/api.lua b/mods/ENTITIES/mcl_mobs/api/api.lua index ac771164e9..1fc3edf46e 100644 --- a/mods/ENTITIES/mcl_mobs/api/api.lua +++ b/mods/ENTITIES/mcl_mobs/api/api.lua @@ -342,6 +342,7 @@ function mobs:register_mob(name, def) baby = false, grow_up_timer = 0, grow_up_goal = 20*60, --in 20 minutes the mob grows up + special_breed_timer = 0, --this is used for the AHEM AHEM part of breeding backup_visual_size = def.visual_size, backup_collisionbox = collisionbox, diff --git a/mods/ENTITIES/mobs_mc/cow+mooshroom.lua b/mods/ENTITIES/mobs_mc/cow+mooshroom.lua index 87e6f25523..41befd8090 100644 --- a/mods/ENTITIES/mobs_mc/cow+mooshroom.lua +++ b/mods/ENTITIES/mobs_mc/cow+mooshroom.lua @@ -56,9 +56,9 @@ local cow_def = { return end + --make baby grow faster if self.baby then mobs.make_baby_grow_faster(self,clicker) - --do child timer thing %10 return end @@ -95,11 +95,17 @@ local mooshroom_def = table.copy(cow_def) mooshroom_def.mesh = "mobs_mc_cow.b3d" mooshroom_def.textures = { {"mobs_mc_mooshroom.png", "mobs_mc_mushroom_red.png"}, {"mobs_mc_mooshroom_brown.png", "mobs_mc_mushroom_brown.png" } } mooshroom_def.on_rightclick = function(self, clicker) - if mobs:feed_tame(self, clicker, 1, true, true) then return end - - if self.child then + --attempt to enter breed state + if mobs.enter_breed_state(self,clicker) then return end + + --make baby grow faster + if self.baby then + mobs.make_baby_grow_faster(self,clicker) + return + end + local item = clicker:get_wielded_item() -- Use shears to get mushrooms and turn mooshroom into cow if item:get_name() == mobs_mc.items.shears then From 2dab0773dffd40cb166c8a14ad79035ac898d4dc Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Sat, 24 Apr 2021 00:00:21 -0400 Subject: [PATCH 08/16] Remove unused breedable api call --- mods/ENTITIES/mcl_mobs/api/api.lua | 1 - mods/ENTITIES/mobs_mc/cow+mooshroom.lua | 1 - 2 files changed, 2 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api/api.lua b/mods/ENTITIES/mcl_mobs/api/api.lua index 1fc3edf46e..0d1a347c58 100644 --- a/mods/ENTITIES/mcl_mobs/api/api.lua +++ b/mods/ENTITIES/mcl_mobs/api/api.lua @@ -329,7 +329,6 @@ function mobs:register_mob(name, def) lifetimer = 30, --30 seconds --breeding stuff - breedable = def.breedable, breed_timer = 0, breed_lookout_timer = 0, breed_distance = def.breed_distance or 1.5, --how far away mobs have to be to begin actual breeding diff --git a/mods/ENTITIES/mobs_mc/cow+mooshroom.lua b/mods/ENTITIES/mobs_mc/cow+mooshroom.lua index 41befd8090..d3791ab3d7 100644 --- a/mods/ENTITIES/mobs_mc/cow+mooshroom.lua +++ b/mods/ENTITIES/mobs_mc/cow+mooshroom.lua @@ -78,7 +78,6 @@ local cow_def = { return end end, - breedable = true, breed_distance = 1.5, baby_size = 0.5, follow_distance = 2, From 3649e5f6f50c917e3c29bbd0b95327e3667ae1ef Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Sat, 24 Apr 2021 00:17:09 -0400 Subject: [PATCH 09/16] Make horse breedable --- mods/ENTITIES/mobs_mc/horse.lua | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/mods/ENTITIES/mobs_mc/horse.lua b/mods/ENTITIES/mobs_mc/horse.lua index 404efc2921..d35e5bc9d4 100644 --- a/mods/ENTITIES/mobs_mc/horse.lua +++ b/mods/ENTITIES/mobs_mc/horse.lua @@ -117,7 +117,7 @@ local horse = { fly = false, walk_chance = 60, view_range = 16, - follow = mobs_mc.follow.horse, + follow = "mcl_farming:wheat_item", passive = true, hp_min = 15, hp_max = 30, @@ -217,6 +217,22 @@ local horse = { local iname = item:get_name() local heal = 0 + --sneak click to breed the horse/feed it + if self.owner and self.owner == clicker:get_player_name() and clicker:get_player_control().sneak then + --attempt to enter breed state + if mobs.enter_breed_state(self,clicker) then + return + end + + --make baby grow faster + if self.baby then + mobs.make_baby_grow_faster(self,clicker) + return + end + + return + end + -- Taming self.temper = self.temper or (math.random(1,100)) From 6f2e2ab4c57fe651dd90b4897e4f10673da1de3a Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Sat, 24 Apr 2021 00:17:22 -0400 Subject: [PATCH 10/16] Make chicken breedable --- mods/ENTITIES/mobs_mc/chicken.lua | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/mods/ENTITIES/mobs_mc/chicken.lua b/mods/ENTITIES/mobs_mc/chicken.lua index 5f619c0510..538baa33a6 100644 --- a/mods/ENTITIES/mobs_mc/chicken.lua +++ b/mods/ENTITIES/mobs_mc/chicken.lua @@ -65,12 +65,25 @@ mobs:register_mob("mobs_mc:chicken", { run_start = 0, run_end = 40, }, - follow = mobs_mc.follow.chicken, + follow = "mcl_farming:wheat_seeds", + breed_distance = 1.5, + baby_size = 0.5, + follow_distance = 2, view_range = 16, fear_height = 4, + --why do chickend breed if they lay eggs?? on_rightclick = function(self, clicker) - if mobs:feed_tame(self, clicker, 1, true, true) then return end + --attempt to enter breed state + if mobs.enter_breed_state(self,clicker) then + return + end + + --make baby grow faster + if self.baby then + mobs.make_baby_grow_faster(self,clicker) + return + end end, do_custom = function(self, dtime) From 0d4d85bac6b3412a2fec3f01ebc5b3ff6c294173 Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Sat, 24 Apr 2021 00:19:41 -0400 Subject: [PATCH 11/16] Fix horse literally blinding you following you --- mods/ENTITIES/mobs_mc/horse.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/mods/ENTITIES/mobs_mc/horse.lua b/mods/ENTITIES/mobs_mc/horse.lua index d35e5bc9d4..3099f0f09b 100644 --- a/mods/ENTITIES/mobs_mc/horse.lua +++ b/mods/ENTITIES/mobs_mc/horse.lua @@ -118,6 +118,7 @@ local horse = { walk_chance = 60, view_range = 16, follow = "mcl_farming:wheat_item", + follow_distance = 3, passive = true, hp_min = 15, hp_max = 30, From dbe712bc17cc875c5e9b4b1a919880b0f6893ea1 Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Sat, 24 Apr 2021 00:23:33 -0400 Subject: [PATCH 12/16] Make llama breedable --- mods/ENTITIES/mobs_mc/llama.lua | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/mods/ENTITIES/mobs_mc/llama.lua b/mods/ENTITIES/mobs_mc/llama.lua index 81120dfdd8..cd3b1ea2cc 100644 --- a/mods/ENTITIES/mobs_mc/llama.lua +++ b/mods/ENTITIES/mobs_mc/llama.lua @@ -58,6 +58,9 @@ mobs:register_mob("mobs_mc:llama", { walk_velocity = 1, run_velocity = 4.4, follow_velocity = 4.4, + breed_distance = 1.5, + baby_size = 0.5, + follow_distance = 2, floats = 1, reach = 6, drops = { @@ -92,7 +95,7 @@ mobs:register_mob("mobs_mc:llama", { look_start = 78, look_end = 108, }, - follow = mobs_mc.follow.llama, + follow = mobs_mc.items.hay_bale, view_range = 16, do_custom = function(self, dtime) @@ -135,15 +138,18 @@ mobs:register_mob("mobs_mc:llama", { return end - local item = clicker:get_wielded_item() - if item:get_name() == mobs_mc.items.hay_bale then - -- Breed with hay bale - if mobs:feed_tame(self, clicker, 1, true, false) then return end - else - -- Feed with anything else - if mobs:feed_tame(self, clicker, 1, false, true) then return end + --attempt to enter breed state + if mobs.enter_breed_state(self,clicker) then + return end + --make baby grow faster + if self.baby then + mobs.make_baby_grow_faster(self,clicker) + return + end + + -- Make sure tamed llama is mature and being clicked by owner only if self.tamed and not self.child and self.owner == clicker:get_player_name() then From 53c96cae2d28c3a6f4642b8a6d5b72365d32267d Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Sat, 24 Apr 2021 00:26:45 -0400 Subject: [PATCH 13/16] Make pigs shift click breedable --- mods/ENTITIES/mobs_mc/pig.lua | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/mods/ENTITIES/mobs_mc/pig.lua b/mods/ENTITIES/mobs_mc/pig.lua index 8ce0f1829c..5ba091c44a 100644 --- a/mods/ENTITIES/mobs_mc/pig.lua +++ b/mods/ENTITIES/mobs_mc/pig.lua @@ -24,6 +24,9 @@ mobs:register_mob("mobs_mc:pig", { walk_velocity = 1, run_velocity = 3, follow_velocity = 3.4, + breed_distance = 1.5, + baby_size = 0.5, + follow_distance = 2, drops = { {name = mobs_mc.items.porkchop_raw, chance = 1, @@ -50,7 +53,7 @@ mobs:register_mob("mobs_mc:pig", { run_start = 0, run_end = 40, }, - follow = mobs_mc.follow.pig, + follow = "mcl_farming:carrot_item", view_range = 8, do_custom = function(self, dtime) @@ -91,10 +94,17 @@ mobs:register_mob("mobs_mc:pig", { return end - local wielditem = clicker:get_wielded_item() - -- Feed pig - if wielditem:get_name() ~= mobs_mc.items.carrot_on_a_stick then - if mobs:feed_tame(self, clicker, 1, true, true) then return end + if clicker:get_player_control().sneak then + --attempt to enter breed state + if mobs.enter_breed_state(self,clicker) then + return + end + + --make baby grow faster + if self.baby then + mobs.make_baby_grow_faster(self,clicker) + return + end end if self.child then From efce97c1723ac25e9dabdfd9572781a6d50f0821 Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Sat, 24 Apr 2021 00:27:17 -0400 Subject: [PATCH 14/16] Make llamas shift click breedable --- mods/ENTITIES/mobs_mc/llama.lua | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/mods/ENTITIES/mobs_mc/llama.lua b/mods/ENTITIES/mobs_mc/llama.lua index cd3b1ea2cc..c396635280 100644 --- a/mods/ENTITIES/mobs_mc/llama.lua +++ b/mods/ENTITIES/mobs_mc/llama.lua @@ -138,15 +138,17 @@ mobs:register_mob("mobs_mc:llama", { return end - --attempt to enter breed state - if mobs.enter_breed_state(self,clicker) then - return - end + if clicker:get_player_control().sneak then + --attempt to enter breed state + if mobs.enter_breed_state(self,clicker) then + return + end - --make baby grow faster - if self.baby then - mobs.make_baby_grow_faster(self,clicker) - return + --make baby grow faster + if self.baby then + mobs.make_baby_grow_faster(self,clicker) + return + end end From a27e6731cd97a1e41861d8a2acbdd4d2d530c220 Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Sat, 24 Apr 2021 00:29:30 -0400 Subject: [PATCH 15/16] Make sheep breedable --- mods/ENTITIES/mobs_mc/sheep.lua | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/mods/ENTITIES/mobs_mc/sheep.lua b/mods/ENTITIES/mobs_mc/sheep.lua index dfd1c612b2..bad7e7c558 100644 --- a/mods/ENTITIES/mobs_mc/sheep.lua +++ b/mods/ENTITIES/mobs_mc/sheep.lua @@ -63,6 +63,10 @@ mobs:register_mob("mobs_mc:sheep", { xp_min = 1, xp_max = 3, skittish = true, + breed_distance = 1.5, + baby_size = 0.5, + follow_distance = 2, + follow = mobs_mc.items.wheat, collisionbox = {-0.45, -0.01, -0.45, 0.45, 1.29, 0.45}, rotate = 270, visual = "mesh", @@ -100,7 +104,6 @@ mobs:register_mob("mobs_mc:sheep", { walk_start = 0, walk_end = 40, run_start = 0, run_end = 40, }, - follow = mobs_mc.follow.sheep, view_range = 12, -- Eat grass @@ -196,7 +199,16 @@ mobs:register_mob("mobs_mc:sheep", { on_rightclick = function(self, clicker) local item = clicker:get_wielded_item() - if mobs:feed_tame(self, clicker, 1, true, true) then return end + --attempt to enter breed state + if mobs.enter_breed_state(self,clicker) then + return + end + + --make baby grow faster + if self.baby then + mobs.make_baby_grow_faster(self,clicker) + return + end if item:get_name() == mobs_mc.items.shears and not self.gotten and not self.child then self.gotten = true From 81713a342d8038c2b51140dbd4bc00f1440b73e8 Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Sat, 24 Apr 2021 00:38:50 -0400 Subject: [PATCH 16/16] Allow tamed wolves to be shift click bred --- mods/ENTITIES/mobs_mc/wolf.lua | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/mods/ENTITIES/mobs_mc/wolf.lua b/mods/ENTITIES/mobs_mc/wolf.lua index aad4db037e..4cd76dd323 100644 --- a/mods/ENTITIES/mobs_mc/wolf.lua +++ b/mods/ENTITIES/mobs_mc/wolf.lua @@ -76,6 +76,7 @@ local wolf = { dog:set_yaw(yaw) ent = dog:get_luaentity() ent.owner = clicker:get_player_name() + ent.tamed = true -- cornfirm taming minetest.sound_play("mobs_mc_wolf_bark", {object=dog, max_hear_distance=16}, true) -- Replace wolf @@ -143,12 +144,29 @@ dog.owner_loyal = true dog.follow_velocity = 3.2 -- Automatically teleport dog to owner dog.do_custom = mobs_mc.make_owner_teleport_function(12) -dog.follow = mobs_mc.follow.dog dog.attack_animals = nil dog.specific_attack = nil +dog.breed_distance = 1.5 +dog.baby_size = 0.5 +dog.follow_distance = 2 +dog.follow = "mcl_mobitems:beef" + dog.on_rightclick = function(self, clicker) local item = clicker:get_wielded_item() + if self.owner and self.owner == clicker:get_player_name() and clicker:get_player_control().sneak then + --attempt to enter breed state + if mobs.enter_breed_state(self,clicker) then + return + end + + --make baby grow faster + if self.baby then + mobs.make_baby_grow_faster(self,clicker) + return + end + end + if is_food(item:get_name()) then -- Feed to increase health local hp = self.health