From c4bf00f5c92a877eea8b205771abd89cad8cadf8 Mon Sep 17 00:00:00 2001 From: Milan2018 Date: Sat, 28 Dec 2019 16:10:26 +0100 Subject: [PATCH] =?UTF-8?q?Nahr=C3=A1t=20soubory=20do=20'mobs=5Fanimal'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mobs_animal/bee.lua | 202 +++++++++++++++++++++++++++++ mobs_animal/bunny.lua | 178 ++++++++++++++++++++++++++ mobs_animal/cow.lua | 246 ++++++++++++++++++++++++++++++++++++ mobs_animal/depends.txt | 4 + mobs_animal/description.txt | 1 + 5 files changed, 631 insertions(+) create mode 100644 mobs_animal/bee.lua create mode 100644 mobs_animal/bunny.lua create mode 100644 mobs_animal/cow.lua create mode 100644 mobs_animal/depends.txt create mode 100644 mobs_animal/description.txt diff --git a/mobs_animal/bee.lua b/mobs_animal/bee.lua new file mode 100644 index 0000000..dec94e2 --- /dev/null +++ b/mobs_animal/bee.lua @@ -0,0 +1,202 @@ + +local S = mobs.intllib + +-- Bee by KrupnoPavel + +mobs:register_mob("mobs_animal:bee", { + type = "animal", + passive = true, + hp_min = 1, + hp_max = 2, + armor = 200, + collisionbox = {-0.2, -0.01, -0.2, 0.2, 0.5, 0.2}, + visual = "mesh", + mesh = "mobs_bee.x", + textures = { + {"mobs_bee.png"}, + }, + blood_texture = "mobs_bee_inv.png", + blood_amount = 1, + makes_footstep_sound = false, + sounds = { + random = "mobs_bee", + }, + walk_velocity = 1, + jump = true, + drops = { + {name = "mobs:honey", chance = 2, min = 1, max = 2}, + }, + water_damage = 1, + lava_damage = 2, + light_damage = 0, + fall_damage = 0, + fall_speed = -3, + animation = { + speed_normal = 15, + stand_start = 0, + stand_end = 30, + walk_start = 35, + walk_end = 65, + }, + on_rightclick = function(self, clicker) + mobs:capture_mob(self, clicker, 50, 90, 0, true, "mobs_animal:bee") + end, +-- after_activate = function(self, staticdata, def, dtime) +-- print ("------", self.name, dtime, self.health) +-- end, +}) + +mobs:spawn({ + name = "mobs_animal:bee", + nodes = {"group:flower"}, + min_light = 14, + interval = 60, + chance = 7000, + min_height = 3, + max_height = 200, + day_toggle = true, +}) + +mobs:register_egg("mobs_animal:bee", S("Bee"), "mobs_bee_inv.png", 0) + +-- compatibility +mobs:alias_mob("mobs:bee", "mobs_animal:bee") + +-- honey +minetest.register_craftitem(":mobs:honey", { + description = S("Honey"), + inventory_image = "mobs_honey_inv.png", + on_use = minetest.item_eat(4), + groups = {food_honey = 1, food_sugar = 1, flammable = 1}, +}) + +-- beehive (when placed spawns bee) +minetest.register_node(":mobs:beehive", { + description = S("Beehive"), + drawtype = "plantlike", + tiles = {"mobs_beehive.png"}, + inventory_image = "mobs_beehive.png", + paramtype = "light", + sunlight_propagates = true, + walkable = true, + groups = {oddly_breakable_by_hand = 3, flammable = 1}, + sounds = default.node_sound_defaults(), + + on_construct = function(pos) + + local meta = minetest.get_meta(pos) + + meta:set_string("formspec", "size[8,6]" + ..default.gui_bg..default.gui_bg_img..default.gui_slots + .. "image[3,0.8;0.8,0.8;mobs_bee_inv.png]" + .. "list[current_name;beehive;4,0.5;1,1;]" + .. "list[current_player;main;0,2.35;8,4;]" + .. "listring[]") + + meta:get_inventory():set_size("beehive", 1) + end, + + after_place_node = function(pos, placer, itemstack) + + if placer and placer:is_player() then + + minetest.set_node(pos, {name = "mobs:beehive", param2 = 1}) + + if math.random(1, 4) == 1 then + minetest.add_entity(pos, "mobs_animal:bee") + end + end + end, + + 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) + end, + + allow_metadata_inventory_put = function(pos, listname, index, stack, player) + + if listname == "beehive" then + return 0 + end + + return stack:get_count() + end, + + can_dig = function(pos,player) + + local meta = minetest.get_meta(pos) + + -- only dig beehive if no honey inside + return meta:get_inventory():is_empty("beehive") + end, + +}) + +minetest.register_craft({ + output = "mobs:beehive", + recipe = { + {"mobs:bee","mobs:bee","mobs:bee"}, + } +}) + +-- honey block +minetest.register_node(":mobs:honey_block", { + description = S("Honey Block"), + tiles = {"mobs_honey_block.png"}, + groups = {snappy = 3, flammable = 2}, + sounds = default.node_sound_dirt_defaults(), +}) + +minetest.register_craft({ + output = "mobs:honey_block", + recipe = { + {"mobs:honey", "mobs:honey", "mobs:honey"}, + {"mobs:honey", "mobs:honey", "mobs:honey"}, + {"mobs:honey", "mobs:honey", "mobs:honey"}, + } +}) + +minetest.register_craft({ + output = "mobs:honey 9", + recipe = { + {"mobs:honey_block"}, + } +}) + +-- beehive workings +minetest.register_abm({ + nodenames = {"mobs:beehive"}, + interval = 12, + chance = 6, + catch_up = false, + action = function(pos, node) + + -- bee's only make honey during the day + local tod = (minetest.get_timeofday() or 0) * 24000 + + if tod < 5500 or tod > 18500 then + return + end + + -- is hive full? + local meta = minetest.get_meta(pos) + if not meta then return end -- for older beehives + local inv = meta:get_inventory() + local honey = inv:get_stack("beehive", 1):get_count() + + -- is hive full? + if honey > 11 then + return + end + + -- no flowers no honey, nuff said! + if #minetest.find_nodes_in_area_under_air( + {x = pos.x - 4, y = pos.y - 3, z = pos.z - 4}, + {x = pos.x + 4, y = pos.y + 3, z = pos.z + 4}, + "group:flower") > 3 then + + inv:add_item("beehive", "mobs:honey") + end + end +}) diff --git a/mobs_animal/bunny.lua b/mobs_animal/bunny.lua new file mode 100644 index 0000000..32c33f8 --- /dev/null +++ b/mobs_animal/bunny.lua @@ -0,0 +1,178 @@ + +local S = mobs.intllib + + +-- Bunny by ExeterDad + +mobs:register_mob("mobs_animal:bunny", { +stepheight = 0.6, + type = "animal", + passive = true, + reach = 1, + hp_min = 1, + hp_max = 4, + armor = 200, + collisionbox = {-0.268, -0.5, -0.268, 0.268, 0.167, 0.268}, + visual = "mesh", + mesh = "mobs_bunny.b3d", + drawtype = "front", + textures = { + {"mobs_bunny_grey.png"}, + {"mobs_bunny_brown.png"}, + {"mobs_bunny_white.png"}, + }, + sounds = {}, + makes_footstep_sound = false, + walk_velocity = 1, + run_velocity = 2, + runaway = true, + runaway_from = {"mobs_animal:pumba", "player"}, + jump = true, + jump_height = 6, + drops = { + {name = "mobs:rabbit_raw", chance = 1, min = 1, max = 1}, + {name = "mobs:rabbit_hide", chance = 1, min = 0, max = 1}, + }, + water_damage = 0, + lava_damage = 4, + light_damage = 0, + fear_height = 2, + animation = { + speed_normal = 15, + stand_start = 1, + stand_end = 15, + walk_start = 16, + walk_end = 24, + punch_start = 16, + punch_end = 24, + }, + follow = {"farming:carrot", "farming_plus:carrot_item", "default:grass_1"}, + view_range = 8, + replace_rate = 10, + replace_what = {"farming:carrot_7", "farming:carrot_8", "farming_plus:carrot"}, + replace_with = "air", + on_rightclick = function(self, clicker) + + -- feed or tame + if mobs:feed_tame(self, clicker, 4, true, true) then return end + if mobs:protect(self, clicker) then return end + if mobs:capture_mob(self, clicker, 30, 50, 80, false, nil) then return end + + -- Monty Python tribute + local item = clicker:get_wielded_item() + + if item:get_name() == "mobs:lava_orb" then + + if not mobs.is_creative(clicker:get_player_name()) then + item:take_item() + clicker:set_wielded_item(item) + end + + self.object:set_properties({ + textures = {"mobs_bunny_evil.png"}, + }) + + self.type = "monster" + self.health = 20 + self.passive = false + + return + end + end, + on_spawn = function(self) + + local pos = self.object:get_pos() ; pos.y = pos.y - 1 + + -- white snowy bunny + if minetest.find_node_near(pos, 1, + {"default:snow", "default:snowblock", "default:dirt_with_snow"}) then + self.base_texture = {"mobs_bunny_white.png"} + self.object:set_properties({textures = self.base_texture}) + -- brown desert bunny + elseif minetest.find_node_near(pos, 1, + {"default:desert_sand", "default:desert_stone"}) then + self.base_texture = {"mobs_bunny_brown.png"} + self.object:set_properties({textures = self.base_texture}) + -- grey stone bunny + elseif minetest.find_node_near(pos, 1, + {"default:stone", "default:gravel"}) then + self.base_texture = {"mobs_bunny_grey.png"} + self.object:set_properties({textures = self.base_texture}) + end + + return true -- run only once, false/nil runs every activation + end, + attack_type = "dogfight", + damage = 5, +}) + + +local spawn_on = "default:dirt_with_grass" + +if minetest.get_modpath("ethereal") then + spawn_on = "ethereal:prairie_dirt" +end + +mobs:spawn({ + name = "mobs_animal:bunny", + nodes = {spawn_on}, + neighbors = {"group:grass"}, + min_light = 14, + interval = 60, + chance = 8000, -- 15000 + min_height = 5, + max_height = 200, + day_toggle = true, +}) + + +mobs:register_egg("mobs_animal:bunny", S("Bunny"), "mobs_bunny_inv.png", 0) + + +mobs:alias_mob("mobs:bunny", "mobs_animal:bunny") -- compatibility + + +-- raw rabbit +minetest.register_craftitem(":mobs:rabbit_raw", { + description = S("Raw Rabbit"), + inventory_image = "mobs_rabbit_raw.png", + on_use = minetest.item_eat(3), + groups = {food_meat_raw = 1, food_rabbit_raw = 1, flammable = 2}, +}) + +-- cooked rabbit +minetest.register_craftitem(":mobs:rabbit_cooked", { + description = S("Cooked Rabbit"), + inventory_image = "mobs_rabbit_cooked.png", + on_use = minetest.item_eat(5), + groups = {food_meat = 1, food_rabbit = 1, flammable = 2}, +}) + +minetest.register_craft({ + type = "cooking", + output = "mobs:rabbit_cooked", + recipe = "mobs:rabbit_raw", + cooktime = 5, +}) + +-- rabbit hide +minetest.register_craftitem(":mobs:rabbit_hide", { + description = S("Rabbit Hide"), + inventory_image = "mobs_rabbit_hide.png", + groups = {flammable = 2}, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "mobs:rabbit_hide", + burntime = 2, +}) + +minetest.register_craft({ + output = "mobs:leather", + type = "shapeless", + recipe = { + "mobs:rabbit_hide", "mobs:rabbit_hide", + "mobs:rabbit_hide", "mobs:rabbit_hide" + } +}) diff --git a/mobs_animal/cow.lua b/mobs_animal/cow.lua new file mode 100644 index 0000000..f50c43b --- /dev/null +++ b/mobs_animal/cow.lua @@ -0,0 +1,246 @@ + +local S = mobs.intllib + + +-- Cow by Krupnovpavel (additional texture by JurajVajda) + +mobs:register_mob("mobs_animal:cow", { + type = "animal", + passive = false, + attack_type = "dogfight", + attack_npcs = false, + reach = 2, + damage = 4, + hp_min = 5, + hp_max = 20, + armor = 200, + collisionbox = {-0.4, -0.01, -0.4, 0.4, 1.2, 0.4}, + visual = "mesh", + mesh = "mobs_cow.x", + textures = { + {"mobs_cow.png"}, + {"mobs_cow2.png"}, + }, + makes_footstep_sound = true, + sounds = { + random = "mobs_cow", + }, + walk_velocity = 1, + run_velocity = 2, + jump = true, + jump_height = 6, + pushable = true, + drops = { + {name = "mobs:meat_raw", chance = 1, min = 1, max = 3}, + {name = "mobs:leather", chance = 1, min = 0, max = 2}, + }, + water_damage = 0, + lava_damage = 5, + light_damage = 0, + animation = { + speed_normal = 15, + speed_run = 15, + stand_start = 0, + stand_end = 30, + walk_start = 35, + walk_end = 65, + run_start = 105, + run_end = 135, + punch_start = 70, + punch_end = 100, + }, + follow = {"farming:wheat", "default:grass_1"}, + view_range = 8, + replace_rate = 10, + replace_what = { + {"group:grass", "air", 0}, + {"default:dirt_with_grass", "default:dirt", -1} + }, + fear_height = 2, + on_rightclick = function(self, clicker) + + -- feed or tame + if mobs:feed_tame(self, clicker, 8, true, true) then + + -- if fed 7x wheat or grass then cow can be milked again + if self.food and self.food > 6 then + self.gotten = false + end + + return + end + + if mobs:protect(self, clicker) then return end + if mobs:capture_mob(self, clicker, 0, 5, 60, false, nil) then return end + + local tool = clicker:get_wielded_item() + local name = clicker:get_player_name() + + -- milk cow with empty bucket + if tool:get_name() == "bucket:bucket_empty" then + + --if self.gotten == true + if self.child == true then + return + end + + if self.gotten == true then + minetest.chat_send_player(name, + S("Cow already milked!")) + return + end + + local inv = clicker:get_inventory() + + tool:take_item() + clicker:set_wielded_item(tool) + + if inv:room_for_item("main", {name = "mobs:bucket_milk"}) then + clicker:get_inventory():add_item("main", "mobs:bucket_milk") + else + local pos = self.object:get_pos() + pos.y = pos.y + 0.5 + minetest.add_item(pos, {name = "mobs:bucket_milk"}) + end + + self.gotten = true -- milked + + return + end + end, + on_replace = function(self, pos, oldnode, newnode) + + self.food = (self.food or 0) + 1 + + -- if cow replaces 8x grass then it can be milked again + if self.food >= 8 then + self.food = 0 + self.gotten = false + end + end, +}) + + +mobs:spawn({ + name = "mobs_animal:cow", + nodes = {"default:dirt_with_grass", "ethereal:green_dirt"}, + neighbors = {"group:grass"}, + min_light = 14, + interval = 60, + chance = 8000, -- 15000 + min_height = 5, + max_height = 200, + day_toggle = true, +}) + + +mobs:register_egg("mobs_animal:cow", S("Cow"), "default_grass.png", 1) + + +mobs:alias_mob("mobs:cow", "mobs_animal:cow") -- compatibility + + +-- bucket of milk +minetest.register_craftitem(":mobs:bucket_milk", { + description = S("Bucket of Milk"), + inventory_image = "mobs_bucket_milk.png", + stack_max = 1, + on_use = minetest.item_eat(8, 'bucket:bucket_empty'), + groups = {food_milk = 1, flammable = 3}, +}) + +-- glass of milk +minetest.register_craftitem(":mobs:glass_milk", { + description = S("Glass of Milk"), + inventory_image = "mobs_glass_milk.png", + on_use = minetest.item_eat(2, 'vessels:drinking_glass'), + groups = {food_milk_glass = 1, flammable = 3, vessel = 1}, +}) + +minetest.register_craft({ + type = "shapeless", + output = "mobs:glass_milk 4", + recipe = { + 'vessels:drinking_glass', 'vessels:drinking_glass', + 'vessels:drinking_glass', 'vessels:drinking_glass', + 'mobs:bucket_milk' + }, + replacements = { {"mobs:bucket_milk", "bucket:bucket_empty"} } +}) + +minetest.register_craft({ + type = "shapeless", + output = "mobs:bucket_milk", + recipe = { + 'mobs:glass_milk', 'mobs:glass_milk', + 'mobs:glass_milk', 'mobs:glass_milk', + 'bucket:bucket_empty' + }, + replacements = { {"mobs:glass_milk", "vessels:drinking_glass 4"} } +}) + + +-- butter +minetest.register_craftitem(":mobs:butter", { + description = S("Butter"), + inventory_image = "mobs_butter.png", + on_use = minetest.item_eat(1), + groups = {food_butter = 1, flammable = 2}, +}) + +if minetest.get_modpath("farming") and farming and farming.mod then +minetest.register_craft({ + type = "shapeless", + output = "mobs:butter", + recipe = {"mobs:bucket_milk", "farming:salt"}, + replacements = {{ "mobs:bucket_milk", "bucket:bucket_empty"}} +}) +else -- some saplings are high in sodium so makes a good replacement item +minetest.register_craft({ + type = "shapeless", + output = "mobs:butter", + recipe = {"mobs:bucket_milk", "default:sapling"}, + replacements = {{ "mobs:bucket_milk", "bucket:bucket_empty"}} +}) +end + +-- cheese wedge +minetest.register_craftitem(":mobs:cheese", { + description = S("Cheese"), + inventory_image = "mobs_cheese.png", + on_use = minetest.item_eat(4), + groups = {food_cheese = 1, flammable = 2}, +}) + +minetest.register_craft({ + type = "cooking", + output = "mobs:cheese", + recipe = "mobs:bucket_milk", + cooktime = 5, + replacements = {{ "mobs:bucket_milk", "bucket:bucket_empty"}} +}) + +-- cheese block +minetest.register_node(":mobs:cheeseblock", { + description = S("Cheese Block"), + tiles = {"mobs_cheeseblock.png"}, + is_ground_content = false, + groups = {crumbly = 3}, + sounds = default.node_sound_dirt_defaults() +}) + +minetest.register_craft({ + output = "mobs:cheeseblock", + recipe = { + {'mobs:cheese', 'mobs:cheese', 'mobs:cheese'}, + {'mobs:cheese', 'mobs:cheese', 'mobs:cheese'}, + {'mobs:cheese', 'mobs:cheese', 'mobs:cheese'}, + } +}) + +minetest.register_craft({ + output = "mobs:cheese 9", + recipe = { + {'mobs:cheeseblock'}, + } +}) diff --git a/mobs_animal/depends.txt b/mobs_animal/depends.txt new file mode 100644 index 0000000..58b4e62 --- /dev/null +++ b/mobs_animal/depends.txt @@ -0,0 +1,4 @@ +default +mobs +intllib? +lucky_block? diff --git a/mobs_animal/description.txt b/mobs_animal/description.txt new file mode 100644 index 0000000..85afccd --- /dev/null +++ b/mobs_animal/description.txt @@ -0,0 +1 @@ +Adds farm animals. \ No newline at end of file