diff --git a/README.txt b/README.txt index a4c8cb0..0b39c36 100644 --- a/README.txt +++ b/README.txt @@ -28,6 +28,7 @@ This mod contains the following additions: Changelog: +1.0 - more work on Api so that certain mobs can float in water while some sink like a brick :) 0.9 - Spawn eggs added for all mobs (admin only, cannot be placed in protected areas)... Api tweaked 0.8 - Added sounds to monster mobs (thanks Cyberpangolin for the sfx) and also chicken sound 0.7 - mobs.protected switch added to api.lua, when set to 1 mobs no longer spawn in protected areas, also bug fixes diff --git a/api.lua b/api.lua index 382f324..092e94d 100644 --- a/api.lua +++ b/api.lua @@ -58,8 +58,8 @@ function mobs:register_mob(name, def) blood_amount = def.blood_amount or 5, blood_texture = def.blood_texture or "mobs_blood.png", rewards = def.rewards or nil, - animaltype = def.animaltype, shoot_offset = def.shoot_offset or 0, + floats = def.floats or 1, -- floats in water by default stimer = 0, timer = 0, @@ -72,7 +72,7 @@ function mobs:register_mob(name, def) tamed = false, last_state = nil, pause_timer = 0, - + do_attack = function(self, player, dist) if self.state ~= "attack" then -- if self.sounds.war_cry then @@ -133,58 +133,44 @@ function mobs:register_mob(name, def) self.animation.current = "" end if type == "stand" and self.animation.current ~= "stand" then - if - self.animation.stand_start - and self.animation.stand_end - and self.animation.speed_normal - then - self.object:set_animation( - {x=self.animation.stand_start,y=self.animation.stand_end}, - self.animation.speed_normal, 0 - ) + if self.animation.stand_start + and self.animation.stand_end + and self.animation.speed_normal then + self.object:set_animation({x=self.animation.stand_start, + y=self.animation.stand_end},self.animation.speed_normal, 0) self.animation.current = "stand" end elseif type == "walk" and self.animation.current ~= "walk" then - if - self.animation.walk_start - and self.animation.walk_end - and self.animation.speed_normal - then - self.object:set_animation( - {x=self.animation.walk_start,y=self.animation.walk_end}, - self.animation.speed_normal, 0 - ) + if self.animation.walk_start + and self.animation.walk_end + and self.animation.speed_normal then + self.object:set_animation({x=self.animation.walk_start,y=self.animation.walk_end}, + self.animation.speed_normal, 0) self.animation.current = "walk" end elseif type == "run" and self.animation.current ~= "run" then - if - self.animation.run_start - and self.animation.run_end - and self.animation.speed_run - then - self.object:set_animation( - {x=self.animation.run_start,y=self.animation.run_end}, - self.animation.speed_run, 0 - ) + if self.animation.run_start + and self.animation.run_end + and self.animation.speed_run then + self.object:set_animation({x=self.animation.run_start,y=self.animation.run_end}, + self.animation.speed_run, 0) self.animation.current = "run" end elseif type == "punch" and self.animation.current ~= "punch" then - if - self.animation.punch_start - and self.animation.punch_end - and self.animation.speed_normal - then - self.object:set_animation( - {x=self.animation.punch_start,y=self.animation.punch_end}, - self.animation.speed_normal, 0 - ) + if self.animation.punch_start + and self.animation.punch_end + and self.animation.speed_normal then + self.object:set_animation({x=self.animation.punch_start,y=self.animation.punch_end}, + self.animation.speed_normal, 0) self.animation.current = "punch" end end end, on_step = function(self, dtime) -local yaw = 0 + + local yaw = 0 + if self.type == "monster" and peaceful_only then self.object:remove() end @@ -195,6 +181,7 @@ local yaw = 0 for _,obj in ipairs(minetest.get_objects_inside_radius(self.object:getpos(), 10)) do if obj:is_player() then player_count = player_count+1 + break -- only really need 1 player to be found end end if player_count == 0 and self.state ~= "attack" then @@ -205,37 +192,23 @@ local yaw = 0 end -- drop egg - if self.animaltype == "clucky" then + if name == "mobs:chicken" then if math.random(1, 3000) <= 1 and minetest.get_node(self.object:getpos()).name == "air" and self.state == "stand" then minetest.set_node(self.object:getpos(), {name="mobs:egg"}) end end - - if self.object:getvelocity().y > 0.1 then - local yaw = self.object:getyaw() - if self.drawtype == "side" then - yaw = yaw+(math.pi/2) - end - local x = math.sin(yaw) * -2 - local z = math.cos(yaw) * 2 --- self.object:setacceleration({x=x, y=-10, z=z}) --- else --- self.object:setacceleration({x=0, y=-10, z=0}) --- end --- Mobs float in water now, to revert uncomment previous 4 lines and remove following block of 12 - if minetest.get_item_group(minetest.get_node(self.object:getpos()).name, "water") ~= 0 then - self.object:setacceleration({x = x, y = 1.5, z = z}) - else - self.object:setacceleration({x = x, y = -10, z = z}) -- 14.5 - end - else + + -- gravity, falling or floating in water + if self.floats == 1 then if minetest.get_item_group(minetest.get_node(self.object:getpos()).name, "water") ~= 0 then self.object:setacceleration({x = 0, y = 1.5, z = 0}) else self.object:setacceleration({x = 0, y = -10, z = 0}) -- 14.5 end + else + self.object:setacceleration({x=0, y=-10, z=0}) end -- fall damage @@ -265,7 +238,7 @@ local yaw = 0 return end - self.timer = self.timer+dtime + self.timer = self.timer + dtime if self.state ~= "attack" then if self.timer < 1 then return @@ -278,35 +251,33 @@ local yaw = 0 end local do_env_damage = function(self) + local pos = self.object:getpos() local n = minetest.get_node(pos) + local lit = minetest.get_node_light(pos) or 0 + local tod = minetest.get_timeofday() if self.light_damage and self.light_damage ~= 0 - and pos.y>0 - and minetest.get_node_light(pos) - and minetest.get_node_light(pos) > 4 - and minetest.get_timeofday() > 0.2 - and minetest.get_timeofday() < 0.8 - then - self.object:set_hp(self.object:get_hp()-self.light_damage) + and pos.y > 0 + and lit > 4 + and tod > 0.2 and tod < 0.8 then + self.object:set_hp(self.object:get_hp()-self.light_damage) ; --print ("light damage") if self.object:get_hp() < 1 then self.object:remove() end end - if self.water_damage and self.water_damage ~= 0 and - minetest.get_item_group(n.name, "water") ~= 0 - then - self.object:set_hp(self.object:get_hp()-self.water_damage) + if self.water_damage and self.water_damage ~= 0 + and minetest.get_item_group(n.name, "water") ~= 0 then + self.object:set_hp(self.object:get_hp()-self.water_damage) ; --print ("water damage") if self.object:get_hp() < 1 then self.object:remove() end end - if self.lava_damage and self.lava_damage ~= 0 and - minetest.get_item_group(n.name, "lava") ~= 0 - then - self.object:set_hp(self.object:get_hp()-self.lava_damage) + if self.lava_damage and self.lava_damage ~= 0 + and minetest.get_item_group(n.name, "lava") ~= 0 then + self.object:set_hp(self.object:get_hp()-self.lava_damage) ; --print ("lava damage") if self.object:get_hp() < 1 then self.object:remove() end @@ -323,11 +294,14 @@ local yaw = 0 -- FIND SOMEONE TO ATTACK if ( self.type == "monster" or self.type == "barbarian" ) and damage_enabled and self.state ~= "attack" then + local s = self.object:getpos() local inradius = minetest.get_objects_inside_radius(s,self.view_range) local player = nil local type = nil + for _,oir in ipairs(inradius) do + if oir:is_player() then player = oir type = "player" @@ -387,6 +361,7 @@ local yaw = 0 end if self.following and self.following:is_player() then + if self.following:get_wielded_item():get_name() ~= self.follow then self.following = nil else @@ -435,6 +410,7 @@ local yaw = 0 -- if there is a player nearby look at them local lp = nil local s = self.object:getpos() + if self.type == "npc" then local o = minetest.get_objects_inside_radius(self.object:getpos(), 3) @@ -446,6 +422,7 @@ local yaw = 0 end end end + if lp ~= nil then local vec = {x=lp.x-s.x, y=lp.y-s.y, z=lp.z-s.z} yaw = math.atan(vec.z/vec.x)+math.pi/2 @@ -462,12 +439,15 @@ local yaw = 0 end self.set_velocity(self, 0) self.set_animation(self, "stand") + if math.random(1, 100) <= self.walk_chance then self.set_velocity(self, self.walk_velocity) self.state = "walk" self.set_animation(self, "walk") end + elseif self.state == "walk" then + if math.random(1, 100) <= 30 then self.object:setyaw(self.object:getyaw()+((math.random(0,360)-180)/180*math.pi)) end @@ -483,7 +463,9 @@ local yaw = 0 self.state = "stand" self:set_animation("stand") end + elseif self.state == "attack" and self.attack_type == "dogfight" then + if not self.attack.player or not self.attack.player:getpos() then print("stop attacking") self.state = "stand" @@ -551,7 +533,9 @@ local yaw = 0 end end end + elseif self.state == "attack" and self.attack_type == "shoot" then + if not self.attack.player or not self.attack.player:is_player() then self.state = "stand" self:set_animation("stand") @@ -639,7 +623,7 @@ local yaw = 0 if self.lifetimer <= 0 and not self.tamed and self.type ~= "npc" then self.object:remove() end - + -- Internal check to see if player damage is still enabled damage_enabled = minetest.setting_getbool("enable_damage") @@ -666,14 +650,13 @@ local yaw = 0 for _,drop in ipairs(self.drops) do if math.random(1, drop.chance) == 1 then local d = ItemStack(drop.name.." "..math.random(drop.min, drop.max)) --- default.drop_item(pos,d) local pos2 = pos pos2.y = pos2.y + 0.5 -- drop items half block higher - --minetest.add_item(pos2,d) -local obj = minetest.add_item(pos2, d) -if obj then - obj:setvelocity({x=math.random(-1,1), y=5, z=math.random(-1,1)}) -end + + local obj = minetest.add_item(pos2, d) + if obj then + obj:setvelocity({x=math.random(-1,1), y=5, z=math.random(-1,1)}) + end end end @@ -760,20 +743,22 @@ function mobs:register_spawn(name, nodes, max_light, min_light, chance, active_o interval = 30, chance = chance, action = function(pos, node, _, active_object_count_wider) - if active_object_count_wider > active_object_count then - return - end - if not mobs.spawning_mobs[name] then + + -- do not spawn if too many in one active area + if active_object_count_wider > active_object_count + or not mobs.spawning_mobs[name] then return end - -- Check if protected area mobs will not spawn + -- spawn above node + pos.y = pos.y + 1 + + -- Check if protected area, if so mobs will not spawn if mobs.protected == 1 and minetest.is_protected(pos, "") then return end - pos.y = pos.y+1 - + -- check if light and height levels are ok to spawn if not minetest.get_node_light(pos) or minetest.get_node_light(pos) > max_light or minetest.get_node_light(pos) < min_light @@ -781,21 +766,20 @@ function mobs:register_spawn(name, nodes, max_light, min_light, chance, active_o return end + -- are we spawning inside a node? if minetest.registered_nodes[minetest.get_node(pos).name].walkable then return end - - pos.y = pos.y+1 - + pos.y = pos.y + 1 if minetest.registered_nodes[minetest.get_node(pos).name].walkable then return end - - pos.y = pos.y-1 + pos.y = pos.y - 1 if minetest.setting_getbool("display_mob_spawn") then minetest.chat_send_all("[mobs] Add "..name.." at "..minetest.pos_to_string(pos)) end + -- spawn mob local mob = minetest.add_entity(pos, name) - -- set mob hp + -- set mob health (randomly between min and max) if mob then mob = mob:get_luaentity() mob.object:set_hp( math.random(mob.hp_min, mob.hp_max) ) @@ -854,3 +838,24 @@ local weapon = player:get_wielded_item() -- }) -- end end + +-- Spawn Egg +function mobs:register_egg(mob, desc, background, addegg) +local invimg = background +if addegg == 1 then + invimg = invimg.."^mobs_chicken_egg.png" +end +minetest.register_craftitem(mob, { + description = desc, + inventory_image = invimg, + on_place = function(itemstack, placer, pointed_thing) + local pos = pointed_thing.above + if pointed_thing.above and not minetest.is_protected(pos, placer:get_player_name()) then + pos.y = pos.y + 0.5 + minetest.env:add_entity(pos, mob) + itemstack:take_item() + end + return itemstack + end, +}) +end diff --git a/bee.lua b/bee.lua index bd0b5b6..121bb40 100644 --- a/bee.lua +++ b/bee.lua @@ -48,20 +48,7 @@ step = 1, passive = true, }) mobs:register_spawn("mobs:bee", {"group:flower"}, 20, 4, 5000, 1, 31000) - --- Spawn Egg - -minetest.register_craftitem("mobs:bee", { - description = "bee", - inventory_image = "mobs_bee_inv.png", - on_place = function(itemstack, placer, pointed_thing) - if pointed_thing.above and not minetest.is_protected(pointed_thing.above, placer:get_player_name()) then - minetest.env:add_entity(pointed_thing.above, "mobs:bee") - itemstack:take_item() - end - return itemstack - end, -}) +mobs:register_egg("mobs:bee", "Bee", "mobs_bee_inv.png", 0) -- Honey diff --git a/chicken.lua b/chicken.lua index 89bf97e..8b380ef 100644 --- a/chicken.lua +++ b/chicken.lua @@ -57,20 +57,7 @@ mobs:register_mob("mobs:chicken", { }) mobs:register_spawn("mobs:chicken", {"default:dirt_with_grass", "ethereal:bamboo_dirt"}, 20, 8, 9000, 1, 31000) - --- Chicken (right-click to place chicken) - -minetest.register_craftitem("mobs:chicken", { - description = "Chicken", - inventory_image = "mobs_chicken_inv.png", - on_place = function(itemstack, placer, pointed_thing) - if pointed_thing.above and not minetest.is_protected(pointed_thing.above, placer:get_player_name()) then - minetest.env:add_entity(pointed_thing.above, "mobs:chicken") - itemstack:take_item() - end - return itemstack - end, -}) +mobs:register_egg("mobs:chicken", "Chicken", "mobs_chicken_inv.png", 0) -- Egg (can be fried in furnace) diff --git a/cow.lua b/cow.lua index 7643330..bc5eb2f 100644 --- a/cow.lua +++ b/cow.lua @@ -82,6 +82,7 @@ mobs:register_mob("mobs:cow", { passive = true, }) mobs:register_spawn("mobs:cow", {"default:dirt_with_grass", "ethereal:green_dirt_top", "ethereal:prairie_dirt"}, 20, 0, 11000, 1, 31000) +mobs:register_egg("mobs:cow", "Cow", "default_grass.png", 1) -- Bucket of Milk @@ -133,16 +134,3 @@ minetest.register_craft({ {'mobs:cheeseblock'}, } }) - --- Spawn Egg -minetest.register_craftitem("mobs:cow", { - description = "Cow Spawn Egg", - inventory_image = "default_grass.png^mobs_chicken_egg.png", - on_place = function(itemstack, placer, pointed_thing) - if pointed_thing.above and not minetest.is_protected(pointed_thing.above, placer:get_player_name()) then - minetest.env:add_entity(pointed_thing.above, "mobs:cow") - itemstack:take_item() - end - return itemstack - end, -}) diff --git a/dirtmonster.lua b/dirtmonster.lua index c2ce8cf..1500822 100644 --- a/dirtmonster.lua +++ b/dirtmonster.lua @@ -51,16 +51,4 @@ mobs:register_mob("mobs:dirt_monster", { blood_texture = "default_dirt.png", }) mobs:register_spawn("mobs:dirt_monster", {"default:dirt_with_grass", "ethereal:gray_dirt_top"}, 5, -1, 7000, 1, 31000) - --- Spawn Egg -minetest.register_craftitem("mobs:dirt_monster", { - description = "Dirt Monster Egg", - inventory_image = "default_dirt.png^mobs_chicken_egg.png", - on_place = function(itemstack, placer, pointed_thing) - if pointed_thing.above and not minetest.is_protected(pointed_thing.above, placer:get_player_name()) then - minetest.env:add_entity(pointed_thing.above, "mobs:dirt_monster") - itemstack:take_item() - end - return itemstack - end, -}) +mobs:register_egg("mobs:dirt_monster", "Dirt Monster", "default_dirt.png", 1) diff --git a/dungeonmaster.lua b/dungeonmaster.lua index d000511..1c19a5f 100644 --- a/dungeonmaster.lua +++ b/dungeonmaster.lua @@ -70,6 +70,7 @@ mobs:register_mob("mobs:dungeon_master", { blood_texture = "mobs_blood.png", }) mobs:register_spawn("mobs:dungeon_master", {"default:stone"}, 5, -1, 7000, 1, -70) +mobs:register_egg("mobs:dungeon_master", "Dungeon Master", "fire_basic_flame.png", 1) -- Fireball (weapon) @@ -111,16 +112,3 @@ mobs:register_arrow("mobs:fireball", { end end }) - --- Spawn Egg -minetest.register_craftitem("mobs:dungeon_master", { - description = "Dungeon Master Egg", - inventory_image = "fire_basic_flame.png^mobs_chicken_egg.png", - on_place = function(itemstack, placer, pointed_thing) - if pointed_thing.above and not minetest.is_protected(pointed_thing.above, placer:get_player_name()) then - minetest.env:add_entity(pointed_thing.above, "mobs:dungeon_master") - itemstack:take_item() - end - return itemstack - end, -}) diff --git a/init.lua b/init.lua index 45319a4..8e6f6ce 100644 --- a/init.lua +++ b/init.lua @@ -1,4 +1,4 @@ --- Mob Api (9th Feb 2015) +-- Mob Api (20th Feb 2015) dofile(minetest.get_modpath("mobs").."/api.lua") diff --git a/lava_flan.lua b/lava_flan.lua index 946dc28..dced8a7 100644 --- a/lava_flan.lua +++ b/lava_flan.lua @@ -58,19 +58,8 @@ mobs:register_mob("mobs:lava_flan", { }, jump = true, step = 0.5, + floats = 0, blood_texture = "fire_basic_flame.png", }) mobs:register_spawn("mobs:lava_flan", {"default:lava_source"}, 15, -1, 1000, 3, 0) - --- Spawn Egg -minetest.register_craftitem("mobs:lava_flan", { - description = "Lava Flan Egg", - inventory_image = "default_lava.png^mobs_chicken_egg.png", - on_place = function(itemstack, placer, pointed_thing) - if pointed_thing.above and not minetest.is_protected(pointed_thing.above, placer:get_player_name()) then - minetest.env:add_entity(pointed_thing.above, "mobs:lava_flan") - itemstack:take_item() - end - return itemstack - end, -}) +mobs:register_egg("mobs:lava_flan", "Lava Flan", "default_lava.png", 1) diff --git a/mese_monster.lua b/mese_monster.lua index bdd638c..623acab 100644 --- a/mese_monster.lua +++ b/mese_monster.lua @@ -70,6 +70,7 @@ mobs:register_mob("mobs:mese_monster", { blood_texture = "default_mese_crystal_fragment.png", }) mobs:register_spawn("mobs:mese_monster", {"default:stone"}, 5, -1, 5000, 1, -20) +mobs:register_egg("mobs:mese_monster", "Mese Monster", "default_mese_block.png", 1) -- Mese Monster Crystal Shards (weapon) @@ -92,16 +93,3 @@ mobs:register_arrow("mobs:mese_arrow", { hit_node = function(self, pos, node) end }) - --- Spawn Egg -minetest.register_craftitem("mobs:mese_monster", { - description = "Mese Monster Egg", - inventory_image = "default_mese_block.png^mobs_chicken_egg.png", - on_place = function(itemstack, placer, pointed_thing) - if pointed_thing.above and not minetest.is_protected(pointed_thing.above, placer:get_player_name()) then - minetest.env:add_entity(pointed_thing.above, "mobs:mese_monster") - itemstack:take_item() - end - return itemstack - end, -}) diff --git a/oerkki.lua b/oerkki.lua index 9dc129f..147b818 100644 --- a/oerkki.lua +++ b/oerkki.lua @@ -53,16 +53,4 @@ mobs:register_mob("mobs:oerkki", { blood_texture = "mobs_blood.png", }) mobs:register_spawn("mobs:oerkki", {"default:stone"}, 5, -1, 7000, 1, -10) - --- Spawn Egg -minetest.register_craftitem("mobs:oerkki", { - description = "Oerkki Egg", - inventory_image = "default_obsidian.png^mobs_chicken_egg.png", - on_place = function(itemstack, placer, pointed_thing) - if pointed_thing.above and not minetest.is_protected(pointed_thing.above, placer:get_player_name()) then - minetest.env:add_entity(pointed_thing.above, "mobs:oerkki") - itemstack:take_item() - end - return itemstack - end, -}) +mobs:register_egg("mobs:oerkki", "Oerkki", "default_obsidian.png", 1) diff --git a/rat.lua b/rat.lua index 0a867e3..e39e6ac 100644 --- a/rat.lua +++ b/rat.lua @@ -37,19 +37,7 @@ passive = true, end, }) mobs:register_spawn("mobs:rat", {"default:stone"}, 20, -1, 7000, 1, 31000) - --- Spawn Egg -minetest.register_craftitem("mobs:rat", { - description = "Rat", - inventory_image = "mobs_rat_inventory.png", - on_place = function(itemstack, placer, pointed_thing) - if pointed_thing.above and not minetest.is_protected(pointed_thing.above, placer:get_player_name()) then - minetest.env:add_entity(pointed_thing.above, "mobs:rat") - itemstack:take_item() - end - return itemstack - end, -}) +mobs:register_egg("mobs:rat", "Rat", "mobs_rat_inventory.png", 0) -- Cooked Rat, yummy! diff --git a/sandmonster.lua b/sandmonster.lua index b963325..13983d9 100644 --- a/sandmonster.lua +++ b/sandmonster.lua @@ -50,18 +50,7 @@ mobs:register_mob("mobs:sand_monster", { jump = true, step = 0.5, blood_texture = "mobs_blood.png", + floats = 0, }) mobs:register_spawn("mobs:sand_monster", {"default:desert_sand"}, 20, -1, 7000, 1, 31000) - --- Spawn Egg -minetest.register_craftitem("mobs:sand_monster", { - description = "Sand Monster Egg", - inventory_image = "default_desert_sand.png^mobs_chicken_egg.png", - on_place = function(itemstack, placer, pointed_thing) - if pointed_thing.above and not minetest.is_protected(pointed_thing.above, placer:get_player_name()) then - minetest.env:add_entity(pointed_thing.above, "mobs:sand_monster") - itemstack:take_item() - end - return itemstack - end, -}) +mobs:register_egg("mobs:sand_monster", "Sand Monster", "default_desert_sand.png", 1) diff --git a/sheep.lua b/sheep.lua index 44d04b8..dfb9e08 100644 --- a/sheep.lua +++ b/sheep.lua @@ -75,16 +75,4 @@ mobs:register_mob("mobs:sheep", { end, }) mobs:register_spawn("mobs:sheep", {"default:dirt_with_grass", "ethereal:green_dirt_top"}, 20, 8, 9000, 1, 31000) - --- Spawn Egg -minetest.register_craftitem("mobs:sheep", { - description = "Sheep Spawn Egg", - inventory_image = "wool_white.png^mobs_chicken_egg.png", - on_place = function(itemstack, placer, pointed_thing) - if pointed_thing.above and not minetest.is_protected(pointed_thing.above, placer:get_player_name()) then - minetest.env:add_entity(pointed_thing.above, "mobs:sheep") - itemstack:take_item() - end - return itemstack - end, -}) +mobs:register_egg("mobs:sheep", "Sheep", "wool_white.png", 1) diff --git a/spider.lua b/spider.lua index 1fa09a5..5b1c93d 100644 --- a/spider.lua +++ b/spider.lua @@ -55,8 +55,10 @@ mobs:register_mob("mobs:spider", { jump = true, sounds = {}, step = 1, + floats = 0, }) mobs:register_spawn("mobs:spider", {"default:desert_stone", "ethereal:crystal_topped_dirt"}, 5, -1, 7000, 1, 71) +mobs:register_egg("mobs:spider", "Spider", "mobs_cobweb.png", 1) -- Ethereal crystal spike compatibility @@ -89,21 +91,8 @@ minetest.register_node("mobs:cobweb", { minetest.register_craft({ output = "mobs:cobweb", recipe = { - {"farming:string", "farming:string", "farming:string"}, - {"farming:string", "farming:string", "farming:string"}, - {"farming:string", "farming:string", "farming:string"}, + {"farming:string", "", "farming:string"}, + {"", "farming:string", ""}, + {"farming:string", "", "farming:string"}, } }) - --- Spawn Egg -minetest.register_craftitem("mobs:spider", { - description = "Spider Egg", - inventory_image = "mobs_cobweb.png^mobs_chicken_egg.png", - on_place = function(itemstack, placer, pointed_thing) - if pointed_thing.above and not minetest.is_protected(pointed_thing.above, placer:get_player_name()) then - minetest.env:add_entity(pointed_thing.above, "mobs:spider") - itemstack:take_item() - end - return itemstack - end, -}) diff --git a/stonemonster.lua b/stonemonster.lua index b24bea4..2c9c1e6 100644 --- a/stonemonster.lua +++ b/stonemonster.lua @@ -58,18 +58,7 @@ mobs:register_mob("mobs:stone_monster", { jump = true, step = 0.5, blood_texture = "mobs_blood.png", + floats = 0, }) mobs:register_spawn("mobs:stone_monster", {"default:stone"}, 5, -1, 7000, 1, 0) - --- Spawn Egg -minetest.register_craftitem("mobs:stone_monster", { - description = "Stone Monster Egg", - inventory_image = "default_stone.png^mobs_chicken_egg.png", - on_place = function(itemstack, placer, pointed_thing) - if pointed_thing.above and not minetest.is_protected(pointed_thing.above, placer:get_player_name()) then - minetest.env:add_entity(pointed_thing.above, "mobs:stone_monster") - itemstack:take_item() - end - return itemstack - end, -}) +mobs:register_egg("mobs:stone_monster", "Stone Monster", "default_stone.png", 1) diff --git a/treemonster.lua b/treemonster.lua index 1b13fe5..c6e918f 100644 --- a/treemonster.lua +++ b/treemonster.lua @@ -62,6 +62,7 @@ mobs:register_mob("mobs:tree_monster", { blood_texture = "default_wood.png", }) mobs:register_spawn("mobs:tree_monster", {"default:leaves", "default:jungleleaves"}, 5, -1, 7000, 1, 31000) +mobs:register_egg("mobs:tree_monster", "Tree Monster", "default_tree_top.png", 1) -- Ethereal sapling compatibility @@ -69,16 +70,3 @@ if not minetest.get_modpath("ethereal") then minetest.register_alias("ethereal:tree_sapling", "default:sapling") minetest.register_alias("ethereal:jungle_tree_sapling", "default:junglesapling") end - --- Spawn Egg -minetest.register_craftitem("mobs:tree_monster", { - description = "Tree Monster Egg", - inventory_image = "default_tree_top.png^mobs_chicken_egg.png", - on_place = function(itemstack, placer, pointed_thing) - if pointed_thing.above and not minetest.is_protected(pointed_thing.above, placer:get_player_name()) then - minetest.env:add_entity(pointed_thing.above, "mobs:tree_monster") - itemstack:take_item() - end - return itemstack - end, -}) diff --git a/warthog.lua b/warthog.lua index 52a6376..ec973cb 100644 --- a/warthog.lua +++ b/warthog.lua @@ -60,6 +60,7 @@ passive = true, }) mobs:register_spawn("mobs:pumba", {"ethereal:mushroom_dirt", "default:dirt"}, 20, 8, 9000, 1, 31000) +mobs:register_egg("mobs:pumba", "Warthog", "wool_pink.png", 1) -- Porkchops @@ -81,16 +82,3 @@ minetest.register_craft({ recipe = "mobs:pork_raw", cooktime = 5, }) - --- Spawn Egg -minetest.register_craftitem("mobs:warthog", { - description = "Warthog Egg", - inventory_image = "wool_pink.png^mobs_chicken_egg.png", - on_place = function(itemstack, placer, pointed_thing) - if pointed_thing.above and not minetest.is_protected(pointed_thing.above, placer:get_player_name()) then - minetest.env:add_entity(pointed_thing.above, "mobs:pumba") - itemstack:take_item() - end - return itemstack - end, -})