1
0

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 bf12043fdc
* way to detect newer engines, for the sound_play extra parameter
  cherry picked from commit e644a1b52343c5c7e821d53c8b2f6dc9751a16fc
  backported from e644a1b523
  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
This commit is contained in:
general 2024-03-31 01:48:05 -04:00
parent bc8892e022
commit 976a83012d
12 changed files with 132 additions and 49 deletions

12
bee.lua
View File

@ -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()
})

View File

@ -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
if math.random(100) == 1 then
minetest.add_item(pos, "mobs:egg")
minetest.sound_play("default_place_node_hard", {
pos = pos,
gain = 1.0,
max_hear_distance = 5
})
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",

View File

@ -1,5 +1,6 @@
mobs
default?
farming?
lucky_block?
intllib?
tnt?

View File

@ -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

View File

@ -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

View File

@ -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) <Your Email>" "pt_BR.po"

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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
})

10
settingtypes.txt Normal file
View File

@ -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

View File

@ -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
@ -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