From 976a83012dad17ddd2fe789b7f24328df3f5af86 Mon Sep 17 00:00:00 2001 From: general Date: Sun, 31 Mar 2024 01:48:05 -0400 Subject: [PATCH] upgrade animal mobs part to 20240101 version, fixed bugs and tune chicken * added settings to disable specific animals * honey blocks and beehives aren't ground content closes https://codeberg.org/tenplus1/mobs_animal/pulls/1 closes https://github.com/pandorabox-io/pandorabox.io#836 * Many node definitions seem to have not set is_ground_content to false, means jumping a ship near mapblocks that haven't been generated yet, can lead to loss of ships or at least parts of it. * chickens eat seed on ground, so add farming dependency missing * backported the have chance of chicken dropping a feather * backported commit bf12043fdcab68acfef299e26b6896a918ce1512 from https://codeberg.org/tenplus1/mobs_animal/commit/bf12043fdcab68acfef299e26b6896a918ce1512 * way to detect newer engines, for the sound_play extra parameter cherry picked from commit e644a1b52343c5c7e821d53c8b2f6dc9751a16fc backported from https://codeberg.org/tenplus1/mobs_animal/commit/e644a1b52343c5c7e821d53c8b2f6dc9751a16fc minetest.sound_play uses optional parameter only in 5.3+ so autodetectting for future uses * add nil check to sheepy, fix warning msg when dye'ing sheep --- bee.lua | 12 +++++++++++- chicken.lua | 50 ++++++++++++++++++++++++++++++++++-------------- depends.txt | 3 ++- init.lua | 35 ++++++++++++++++++++++----------- kitten.lua | 25 +++++++++++++----------- locale/README.md | 2 ++ lucky_block.lua | 6 ++++++ mod.conf | 3 ++- panda.lua | 4 ++-- penguin.lua | 2 +- settingtypes.txt | 10 ++++++++++ sheep.lua | 29 +++++++++++++++++++++------- 12 files changed, 132 insertions(+), 49 deletions(-) create mode 100644 settingtypes.txt diff --git a/bee.lua b/bee.lua index a7f1c25..cf2f166 100644 --- a/bee.lua +++ b/bee.lua @@ -91,6 +91,7 @@ minetest.register_node(":mobs:beehive", { sunlight_propagates = true, walkable = true, groups = {oddly_breakable_by_hand = 3, flammable = 1, disable_suffocation = 1}, + is_ground_content = false, sounds = default and default.node_sound_defaults(), on_construct = function(pos) @@ -123,7 +124,15 @@ minetest.register_node(":mobs:beehive", { on_punch = function(pos, node, puncher) -- yep, bee's don't like having their home punched by players - puncher:set_hp(puncher:get_hp() - 4) + minetest.after(0.2, function() + + if puncher then + + local hp = puncher:get_hp() + + if hp then puncher:set_hp(hp - 4) end + end + end) end, allow_metadata_inventory_put = function(pos, listname, index, stack, player) @@ -157,6 +166,7 @@ minetest.register_node(":mobs:honey_block", { description = S("Honey Block"), tiles = {"mobs_honey_block.png"}, groups = {snappy = 3, flammable = 2}, + is_ground_content = false, sounds = default and default.node_sound_dirt_defaults() }) diff --git a/chicken.lua b/chicken.lua index 850acaa..0d5fc12 100644 --- a/chicken.lua +++ b/chicken.lua @@ -57,9 +57,23 @@ mobs:register_mob(":mobs_animal:chicken", { }, follow = { "farming:seed_wheat", "farming:seed_cotton", "farming:seed_barley", - "farming:seed_oat", "farming:seed_rye" + "farming:seed_oat", "farming:seed_rye", "farming:seed_rice", + "farming:seed_hemp", "farming:seed_sunflower", "farming:seed_mint" }, view_range = 5, + replace_rate = 5, + replace_what = { + {"farming:seed_wheat", "air", 0}, + {"farming:seed_cotton", "air", 0}, + {"farming:seed_barley", "air", 0}, + {"farming:seed_oat", "air", 0}, + {"farming:seed_rye", "air", 0}, + {"farming:seed_rice", "air", 0}, + {"farming:seed_hemp", "air", 0}, + {"farming:seed_mint", "air", 0}, + {"farming:seed_sunflower", "air", 0} + }, + stay_near = {{"group:seed"}, 7}, on_rightclick = function(self, clicker) @@ -76,20 +90,25 @@ mobs:register_mob(":mobs_animal:chicken", { end self.egg_timer = 0 - if self.child - or math.random(100) > 1 then + if self.child then return end local pos = self.object:get_pos() ; if not pos then return end - minetest.add_item(pos, "mobs:egg") + if math.random(100) == 1 then - minetest.sound_play("default_place_node_hard", { - pos = pos, - gain = 1.0, - max_hear_distance = 5 - }) + minetest.add_item(pos, "mobs:egg") + + if mobs.is52a then + minetest.sound_play("default_place_node_hard", { pos = pos, gain = 1.0, max_hear_distance = 5}, true) + else + minetest.sound_play("default_place_node_hard", { pos = pos, gain = 1.0, max_hear_distance = 5}) + end + + elseif math.random(100) < 6 then + minetest.add_item(pos, "mobs:chicken_feather") + end end }) @@ -161,10 +180,13 @@ mobs:register_arrow(":mobs_animal:egg_entity", { return end - local staticdata = minetest.serialize( - {child = true, tamed = true, owner = self.playername}) - - minetest.add_entity(pos, "mobs_animal:chicken", staticdata) + mobs:add_mob(pos, { + name = "mobs_animal:chicken", + child = true, + owner = self.playername, +-- nametag = "Chicky", + ignore_count = true -- ignores mob count per map area + }) end }) @@ -231,7 +253,7 @@ minetest.register_node(":mobs:egg", { wield_image = "mobs_chicken_egg.png", paramtype = "light", walkable = false, - is_ground_content = true, + is_ground_content = false, sunlight_propagates = true, selection_box = { type = "fixed", diff --git a/depends.txt b/depends.txt index c5ea0fb..5a90437 100644 --- a/depends.txt +++ b/depends.txt @@ -1,6 +1,7 @@ mobs default? +farming? lucky_block? intllib? tnt? -fire? \ No newline at end of file +fire? diff --git a/init.lua b/init.lua index 60bf10e..2258baa 100644 --- a/init.lua +++ b/init.lua @@ -23,8 +23,11 @@ else end end -mobs.intllib_animal = S +local is50 = minetest.has_feature("object_use_texture_alpha") or nil +local is54 = minetest.has_feature("use_texture_alpha_string_modes") or nil +mobs.intllib_animal = S +mobs.is54a = is54 -- Check for custom mob spawn file local input = io.open(path .. "spawn.lua", "r") @@ -35,18 +38,28 @@ if input then input = nil end +-- helper function +local function ddoo(mob) + + if minetest.settings:get_bool("mobs_animal." .. mob) == false then + print("[Mobs_Animal] " .. mob .. " disabled!") + return + end + + dofile(path .. mob .. ".lua") +end if not minetest.get_modpath("mobs_animal") then -dofile(path .. "chicken.lua") -- JKmurray -dofile(path .. "cow.lua") -- KrupnoPavel -dofile(path .. "rat.lua") -- PilzAdam -dofile(path .. "sheep.lua") -- PilzAdam -dofile(path .. "warthog.lua") -- KrupnoPavel -dofile(path .. "bee.lua") -- KrupnoPavel -dofile(path .. "bunny.lua") -- ExeterDad -dofile(path .. "kitten.lua") -- Jordach/BFD -dofile(path .. "penguin.lua") -- D00Med -dofile(path .. "panda.lua") -- AspireMint +ddoo("chicken") -- JKmurray +ddoo("cow") -- KrupnoPavel +ddoo("rat") -- PilzAdam +ddoo("sheep") -- PilzAdam +ddoo("warthog") -- KrupnoPavel +ddoo("bee") -- KrupnoPavel +ddoo("bunny") -- ExeterDad +ddoo("kitten") -- Jordach/BFD +ddoo("penguin") -- D00Med +ddoo("panda") -- AspireMint end if not minetest.get_modpath("mobs_doomed") or not minetest.get_modpath("dmobs") then diff --git a/kitten.lua b/kitten.lua index 96328a0..d307351 100644 --- a/kitten.lua +++ b/kitten.lua @@ -127,28 +127,30 @@ mobs:register_mob(":mobs_animal:kitten", { local pos = self.object:get_pos() minetest.add_item(pos, "mobs:hairball") - - minetest.sound_play("default_dig_snappy", { - pos = pos, gain = 1.0, max_hear_distance = 5}, true) + if mobs.is54a then + minetest.sound_play("default_dig_snappy", { pos = pos, gain = 1.0, max_hear_distance = 5}, true) + else + minetest.sound_play("default_dig_snappy", { pos = pos, gain = 1.0, max_hear_distance = 5}) + end end }) -local spawn_on = {"default:dirt_with_grass"} +local spawn_on = "default:dirt_with_grass" if minetest.get_modpath("ethereal") then - spawn_on = {"ethereal:grove_dirt","default:dirt_with_grass"} + spawn_on = "ethereal:grove_dirt" end if not mobs.custom_spawn_animal then mobs:spawn({ name = ":mobs_animal:kitten", - nodes = spawn_on, + nodes = {spawn_on}, neighbors = {"group:grass"}, min_light = 14, interval = 60, - chance = 8000, + chance = 10000, min_height = 5, max_height = 50, day_toggle = true @@ -187,10 +189,11 @@ minetest.register_craftitem(":mobs:hairball", { and minetest.registered_items[item] then minetest.add_item(newpos, {name = item}) end - - minetest.sound_play("default_place_node_hard", { - pos = newpos, gain = 1.0, max_hear_distance = 5}, true) - + if mobs.is50a then + minetest.sound_play("default_place_node_hard", {pos = newpos, gain = 1.0, max_hear_distance = 5}, true) + else + minetest.sound_play("default_place_node_hard", {pos = newpos, gain = 1.0, max_hear_distance = 5}) + end itemstack:take_item() return itemstack diff --git a/locale/README.md b/locale/README.md index 4887b9e..99d58eb 100644 --- a/locale/README.md +++ b/locale/README.md @@ -1,5 +1,7 @@ # Convert '.po' file to '.txt' file. +This is only used for older engines.. newer ones uses the plain text files with tr extensions + ### COMMAND SAMPLE '''' $ lua po2tr.lua "Your Name (Your Site) " "pt_BR.po" diff --git a/lucky_block.lua b/lucky_block.lua index 7dc5df7..f120ee4 100644 --- a/lucky_block.lua +++ b/lucky_block.lua @@ -26,3 +26,9 @@ lucky_block:add_blocks({ {name = "mobs:lava_orb", max = 1}}}, }) +if minetest.registered_nodes["default:nyancat"] then + + lucky_block:add_blocks({ + {"tro", "default:nyancat", "mobs_kitten", true} + }) +end diff --git a/mod.conf b/mod.conf index 1437e9f..1a982c2 100644 --- a/mod.conf +++ b/mod.conf @@ -1,4 +1,5 @@ name = mobs_jam depends = mobs -optional_depends = default, lucky_block, intllib, tnt, fire +optional_depends = default, farming, lucky_block, tnt, fire description = MOBS mod of animals, monters and extra, reduced version from tenplush1 and others mods +min_minetest_version = 0.4.16 diff --git a/panda.lua b/panda.lua index 77176cc..a991ea0 100644 --- a/panda.lua +++ b/panda.lua @@ -73,7 +73,8 @@ local spawn_on = {"default:dirt_with_grass"} if minetest.get_modpath("ethereal") then spawn_on = {"ethereal:bamboo_dirt", "default:dirt_with_grass"} end -if not mobs.custom_spawn_animal then +if minetest.get_modpath("ethereal") and not mobs.custom_spawn_animal then + mobs:spawn({ name = ":mobs_animal:panda", nodes = spawn_on, @@ -85,7 +86,6 @@ if not mobs.custom_spawn_animal then max_height = 80, day_toggle = true }) - end diff --git a/penguin.lua b/penguin.lua index 5dac2f4..19edb1d 100644 --- a/penguin.lua +++ b/penguin.lua @@ -69,7 +69,7 @@ if not mobs.custom_spawn_animal then min_light = 14, interval = 60, chance = 10000, - min_height = 1000, + min_height = 0, max_height = 200, day_toggle = true }) diff --git a/settingtypes.txt b/settingtypes.txt new file mode 100644 index 0000000..2cc549a --- /dev/null +++ b/settingtypes.txt @@ -0,0 +1,10 @@ +mobs_animal.bee (Enable Bee) bool true +mobs_animal.bunny (Enable Bunny) bool true +mobs_animal.chicken (Enable Chicken) bool true +mobs_animal.cow (Enable Cow) bool true +mobs_animal.kitten (Enable Kitten) bool true +mobs_animal.panda (Enable Panda) bool true +mobs_animal.penguin (Enable Penguin) bool true +mobs_animal.rat (Enable Rat) bool true +mobs_animal.sheep (Enable Sheep) bool true +mobs_animal.warthog (Enable Warthog) bool true diff --git a/sheep.lua b/sheep.lua index 8683294..8329708 100644 --- a/sheep.lua +++ b/sheep.lua @@ -34,6 +34,18 @@ for _, col in ipairs(all_colours) do local function horn_texture_sel(horns, gotten, colr) + -- get override colours hex value from table + if colr then + + for _2, col2 in ipairs(all_colours) do + + if col2[1] == colr then + colr = col2[3] + break + end + end + end + local base_text = "mobs_sheep_base.png" local wool_shave_text = "mobs_sheep_wool.png" local shav_text = "mobs_sheep_shaved.png" @@ -370,9 +382,9 @@ end if not mobs.custom_spawn_animal then local max_ht = 400 - local spawn_on = {"default:dirt_with_grass"} + local spawn_on = {"default:dirt_with_grass", "ethereal:green_dirt"} local mod_ethereal = minetest.get_modpath("ethereal") - local spawn_chance = 4000 + local spawn_chance = mod_ethereal and 9000 or 4000 if mod_ethereal then spawn_on = {"default:dirt_with_grass", "ethereal:green_dirt"} end @@ -392,11 +404,11 @@ if not mobs.custom_spawn_animal then on_spawn = function(self, pos) local nat_colors = {-- reference for all_colours table - ["white"] = 14, - ["grey"] = 8, + ["white"] = 14, + ["grey"] = 8, ["dark_grey"] = 6, - ["black"] = 1, - ["brown"] = 3 + ["black"] = 1, + ["brown"] = 3 } local function random_sheep(pos, first) @@ -432,7 +444,10 @@ if not mobs.custom_spawn_animal then local entity = mobs:add_mob(pos, {name = "mobs_animal:sheep_" .. types, child = lamb}) - if entity and not lamb then + -- nil check + if not entity then return end + + if not lamb then -- Set horns attribute, lower height will be rarer. -- This wont affect mobs spawned by egg those only spawn hornless sheep. local horns = random(max_ht) <= pos.y