diff --git a/README.txt b/README.txt index 6b4579a..1c99d58 100644 --- a/README.txt +++ b/README.txt @@ -21,9 +21,11 @@ There are 3 hostile mobs that want to kill the player: dirt monster - The desert monster spawns in deserts and is faster but less strong than the dirt monster -There is also 1 friendly mob: +There are also 2 friendly mobs: - The sheep spawns on grass. You can get wool from it when you rightclick it and meat if you kill it. Meat can bee cooked in the furnace to eat it. +- The rat is the same as in 0.3. You can cook it or replace it in the + world if you catched it with an rightclick. For developers: This mod add some functions that you can use in other mods: diff --git a/init.lua b/init.lua index 089c442..bfa5ec4 100644 --- a/init.lua +++ b/init.lua @@ -496,3 +496,51 @@ minetest.register_craft({ recipe = "mobs:meat_raw", cooktime = 5, }) + +mobs:register_animal("mobs:rat", { + hp_max = 1, + collisionbox = {-0.25, -0.175, -0.25, 0.25, 0.1, 0.25}, + visual = "upright_sprite", + visual_size = {x=0.7, y=0.35}, + textures = {"mobs_rat.png", "mobs_rat.png"}, + makes_footstep_sound = false, + walk_velocity = 1, + drop = "", + drop_count = 0, + drawtype = "side", + + on_rightclick = function(self, clicker) + if clicker:is_player() and clicker:get_inventory() then + clicker:get_inventory():add_item("main", "mobs:rat") + self.object:remove() + end + end, +}) +mobs:register_spawn("mobs:rat", {"default:dirt_with_grass", "default:stone"}, 20, -1) + +minetest.register_craftitem("mobs:rat", { + description = "Rat", + inventory_image = "mobs_rat.png", + + on_place = function(itemstack, placer, pointed_thing) + if pointed_thing.above then + minetest.env:add_entity(pointed_thing.above, "mobs:rat") + itemstack:take_item() + end + return itemstack + end, +}) + +minetest.register_craftitem("mobs:rat_cooked", { + description = "Cooked Rat", + inventory_image = "mobs_cooked_rat.png", + + on_use = minetest.item_eat(3), +}) + +minetest.register_craft({ + type = "cooking", + output = "mobs:rat_cooked", + recipe = "mobs:rat", + cooktime = 5, +}) diff --git a/textures/mobs_cooked_rat.png b/textures/mobs_cooked_rat.png new file mode 100644 index 0000000..daad3be Binary files /dev/null and b/textures/mobs_cooked_rat.png differ diff --git a/textures/mobs_rat.png b/textures/mobs_rat.png new file mode 100644 index 0000000..d1a0e2a Binary files /dev/null and b/textures/mobs_rat.png differ