Make all items overwritable

This commit is contained in:
Wuzzy 2017-06-23 16:29:09 +02:00
parent 93e3af0749
commit 00f1816bdf
2 changed files with 600 additions and 534 deletions

View File

@ -7,11 +7,20 @@
--dofile(minetest.get_modpath("mobs").."/api.lua") --dofile(minetest.get_modpath("mobs").."/api.lua")
--THIS IS THE MASTER ITEM LIST TO USE WITH DEFAULT --THIS IS THE MASTER ITEM LIST TO USE WITH DEFAULT
local function c(id) -- This function checks if the item ID has been overwritten and returns true if it is unchanged
return string.sub(mobs_mc.items[id], 1, 8) == "mobs_mc:" local c
if minetest.get_modpath("mobs_mc_gameconfig") and mobs_mc.override and mobs_mc.override.items then
c = function(id)
return mobs_mc.overrmobs_mc.override.items[id] == nil
end
else
-- No items are overwritten, so always return true
c = function(id)
return true
end
end end
--blaze -- Blaze
if c("blaze_rod") then if c("blaze_rod") then
minetest.register_craftitem("mobs_mc:blaze_rod", { minetest.register_craftitem("mobs_mc:blaze_rod", {
description = "Blaze Rod", description = "Blaze Rod",
@ -19,6 +28,24 @@ if c("blaze_rod") then
wield_image = "mcl_mobitems_blaze_rod.png", wield_image = "mcl_mobitems_blaze_rod.png",
inventory_image = "mcl_mobitems_blaze_rod.png", inventory_image = "mcl_mobitems_blaze_rod.png",
}) })
-- Make blaze rod furnace-burnable. 1.5 times the burn time of a coal lump
local coalcraft, burntime
if minetest.get_modpath("default") then
coalcraft = minetest.get_craft_result({method="fuel", width=1, items={"default:coal_lump"}})
end
if coalcraft then
burntime = math.floor(coalcraft.time * 1.5)
end
if burntime == nil or burntime == 0 then
burntime = 60
end
minetest.register_craft({
type = "fuel",
burntime = burntime,
recipe = "mobs_mc:blaze_rod",
})
end end
if c("blaze_powder") then if c("blaze_powder") then
@ -37,25 +64,7 @@ if c("blaze_rod") and c("blaze_powder") then
}) })
end end
-- Make blaze rod furnace-burnable. 1.5 times the burn time of a coal lump -- Chicken
local coalcraft, burntime
if minetest.get_modpath("default") then
coalcraft = minetest.get_craft_result({method="fuel", width=1, items={"default:coal_lump"}})
end
if coalcraft then
burntime = math.floor(coalcraft.time * 1.5)
end
if burntime == nil or burntime == 0 then
burntime = 60
end
minetest.register_craft({
type = "fuel",
burntime = burntime,
recipe = "mobs_mc:blaze_rod",
})
-- chicken
if c("chicken_raw") then if c("chicken_raw") then
minetest.register_craftitem("mobs_mc:chicken_raw", { minetest.register_craftitem("mobs_mc:chicken_raw", {
description = "Raw Chicken", description = "Raw Chicken",
@ -90,202 +99,231 @@ if c("feather") then
}) })
end end
--cows -- Cow and mooshroom
if c("beef_raw") then
-- Craftitems minetest.register_craftitem("mobs_mc:beef_raw", {
-- beef description = "Raw Beef",
minetest.register_craftitem("mobs_mc:beef_raw", { inventory_image = "mcl_mobitems_beef_raw.png",
description = "Raw Beef", groups = { food = 2, eatable = 3 },
inventory_image = "mcl_mobitems_beef_raw.png", on_use = minetest.item_eat(3),
groups = { food = 2, eatable = 3 }, })
on_use = minetest.item_eat(3),
})
minetest.register_craftitem("mobs_mc:beef_cooked", {
description = "Steak",
inventory_image = "mcl_mobitems_beef_cooked.png",
groups = { food = 2, eatable = 8 },
on_use = minetest.item_eat(8),
})
minetest.register_craft({
type = "cooking",
output = "mobs_mc:beef_cooked",
recipe = "mobs_mc:beef_raw",
cooktime = 5,
})
-- Bowl and mushroom stew
minetest.register_craftitem("mobs_mc:bowl", {
description = "Bowl",
inventory_image = "mcl_core_bowl.png",
})
minetest.register_craft({
output = "mobs_mc:bowl",
recipe = {
{ "group:wood", "", "group:wood" },
{ "", "group:wood", "", },
}
})
minetest.register_craft({
type = "fuel",
recipe = "mobs_mc:bowl",
burntime = 5,
})
minetest.register_craftitem("mobs_mc:mushroom_stew", {
description = "Mushroom Stew",
inventory_image = "farming_mushroom_stew.png",
groups = { food = 3, eatable = 6 },
on_use = minetest.item_eat(6, "mobs_mc:bowl"),
stack_max = 1,
})
-- milk
minetest.register_craftitem("mobs_mc:milk_bucket", {
description = "Milk",
inventory_image = "mobs_bucket_milk.png",
groups = { food = 3, eatable = 1 },
on_use = minetest.item_eat(1, "bucket:bucket_empty"),
stack_max = 1,
})
local dragon_egg_sounds
if minetest.get_modpath("default") then
dragon_egg_sounds = default.node_sound_stone_defaults()
end end
--ender dragon if c("beef_cooked") then
minetest.register_node("mobs_mc:dragon_egg", { minetest.register_craftitem("mobs_mc:beef_cooked", {
description = "Dragon Egg", description = "Steak",
tiles = { inventory_image = "mcl_mobitems_beef_cooked.png",
"mcl_end_dragon_egg.png", groups = { food = 2, eatable = 8 },
"mcl_end_dragon_egg.png", on_use = minetest.item_eat(8),
"mcl_end_dragon_egg.png", })
"mcl_end_dragon_egg.png", end
"mcl_end_dragon_egg.png",
"mcl_end_dragon_egg.png", if c("beef_raw") and c("beef_cooked") then
}, minetest.register_craft({
drawtype = "nodebox", type = "cooking",
is_ground_content = false, output = "mobs_mc:beef_cooked",
paramtype = "light", recipe = "mobs_mc:beef_raw",
light_source = 1, cooktime = 5,
node_box = { })
type = "fixed", end
fixed = {
{-0.375, -0.5, -0.375, 0.375, -0.4375, 0.375},
{-0.5, -0.4375, -0.5, 0.5, -0.1875, 0.5}, if c("milk_bucket") then
{-0.4375, -0.1875, -0.4375, 0.4375, 0, 0.4375}, -- milk
{-0.375, 0, -0.375, 0.375, 0.125, 0.375}, minetest.register_craftitem("mobs_mc:milk_bucket", {
{-0.3125, 0.125, -0.3125, 0.3125, 0.25, 0.3125}, description = "Milk",
{-0.25, 0.25, -0.25, 0.25, 0.3125, 0.25}, inventory_image = "mobs_bucket_milk.png",
{-0.1875, 0.3125, -0.1875, 0.1875, 0.375, 0.1875}, groups = { food = 3, eatable = 1 },
{-0.125, 0.375, -0.125, 0.125, 0.4375, 0.125}, on_use = minetest.item_eat(1, "bucket:bucket_empty"),
{-0.0625, 0.4375, -0.0625, 0.0625, 0.5, 0.0625}, stack_max = 1,
})
end
if c("bowl") then
minetest.register_craftitem("mobs_mc:bowl", {
description = "Bowl",
inventory_image = "mcl_core_bowl.png",
})
minetest.register_craft({
output = "mobs_mc:bowl",
recipe = {
{ "group:wood", "", "group:wood" },
{ "", "group:wood", "", },
} }
}, })
selection_box = {
type = "regular",
},
groups = {snappy = 1, falling_node = 1, deco_block = 1, not_in_creative_inventory = 1, dig_by_piston = 1 },
sounds = dragon_egg_sounds,
-- TODO: Make dragon egg teleport on punching
})
--enderman minetest.register_craft({
minetest.register_craftitem("mobs_mc:ender_eye", { type = "fuel",
description = "Ender Eye", recipe = "mobs_mc:bowl",
burntime = 5,
})
end
inventory_image = "mcl_end_ender_eye.png", if c("mushroom_stew") then
groups = { craftitem = 1 }, minetest.register_craftitem("mobs_mc:mushroom_stew", {
}) description = "Mushroom Stew",
inventory_image = "farming_mushroom_stew.png",
groups = { food = 3, eatable = 6 },
on_use = minetest.item_eat(6, "mobs_mc:bowl"),
stack_max = 1,
})
end
minetest.register_craft({ -- Ender dragon
type = "shapeless", if c("dragon_egg") then
output = 'mobs_mc:ender_eye',
recipe = { 'mobs_mc:blaze_powder', 'mobs_mc:blaze_rod'}, local dragon_egg_sounds
}) if minetest.get_modpath("default") then
dragon_egg_sounds = default.node_sound_stone_defaults()
end
--ender dragon
minetest.register_node("mobs_mc:dragon_egg", {
description = "Dragon Egg",
tiles = {
"mcl_end_dragon_egg.png",
"mcl_end_dragon_egg.png",
"mcl_end_dragon_egg.png",
"mcl_end_dragon_egg.png",
"mcl_end_dragon_egg.png",
"mcl_end_dragon_egg.png",
},
drawtype = "nodebox",
is_ground_content = false,
paramtype = "light",
light_source = 1,
node_box = {
type = "fixed",
fixed = {
{-0.375, -0.5, -0.375, 0.375, -0.4375, 0.375},
{-0.5, -0.4375, -0.5, 0.5, -0.1875, 0.5},
{-0.4375, -0.1875, -0.4375, 0.4375, 0, 0.4375},
{-0.375, 0, -0.375, 0.375, 0.125, 0.375},
{-0.3125, 0.125, -0.3125, 0.3125, 0.25, 0.3125},
{-0.25, 0.25, -0.25, 0.25, 0.3125, 0.25},
{-0.1875, 0.3125, -0.1875, 0.1875, 0.375, 0.1875},
{-0.125, 0.375, -0.125, 0.125, 0.4375, 0.125},
{-0.0625, 0.4375, -0.0625, 0.0625, 0.5, 0.0625},
}
},
selection_box = {
type = "regular",
},
groups = {snappy = 1, falling_node = 1, deco_block = 1, not_in_creative_inventory = 1, dig_by_piston = 1 },
sounds = dragon_egg_sounds,
-- TODO: Make dragon egg teleport on punching
})
end
-- Enderman
if c("ender_eye") then
minetest.register_craftitem("mobs_mc:ender_eye", {
description = "Ender Eye",
inventory_image = "mcl_end_ender_eye.png",
groups = { craftitem = 1 },
})
end
if c("ender_eye") and c("blaze_powder") and c("blaze_rod") then
minetest.register_craft({
type = "shapeless",
output = 'mobs_mc:ender_eye',
recipe = { 'mobs_mc:blaze_powder', 'mobs_mc:blaze_rod'},
})
end
-- Ghast -- Ghast
minetest.register_craftitem("mobs_mc:ghast_tear", { if c("ghast_tear") then
description = "Ghast Tear", minetest.register_craftitem("mobs_mc:ghast_tear", {
_doc_items_longdesc = "A ghast tear is an item used in potion brewing. It is dropped from dead ghasts.", description = "Ghast Tear",
wield_image = "mcl_mobitems_ghast_tear.png", _doc_items_longdesc = "A ghast tear is an item used in potion brewing. It is dropped from dead ghasts.",
inventory_image = "mcl_mobitems_ghast_tear.png", wield_image = "mcl_mobitems_ghast_tear.png",
groups = { brewitem = 1 }, inventory_image = "mcl_mobitems_ghast_tear.png",
}) groups = { brewitem = 1 },
})
end
-- Saddle -- Saddle
if c("saddle") then
minetest.register_craftitem("mobs_mc:saddle", {
description = "Saddle",
inventory_image = "mcl_mobitems_saddle.png",
stack_max = 1,
})
minetest.register_craftitem("mobs_mc:saddle", { if c("saddle") and c("lether") and c("string") and c("iron_ingot") then
description = "Saddle", minetest.register_craft({
inventory_image = "mcl_mobitems_saddle.png", output = "mobs_mc:saddle",
stack_max = 1, recipe = {
}) {"mobs:leather", "mobs:leather", "mobs:leather"},
{"farming:string", "", "farming:string"},
{"default:steel_ingot", "", "default:steel_ingot"}
},
})
end
minetest.register_craft({ -- Pig
output = "mobs_mc:saddle", if c("porkchop_raw") then
recipe = { minetest.register_craftitem("mobs_mc:porkchop_raw", {
{"mobs:leather", "mobs:leather", "mobs:leather"}, description = "Raw Porkchop",
{"farming:string", "", "farming:string"}, inventory_image = "mcl_mobitems_porkchop_raw.png",
{"default:steel_ingot", "", "default:steel_ingot"} groups = { food = 2, eatable = 3 },
}, on_use = minetest.item_eat(3),
}) })
end
if c("porkchop_cooked") then
minetest.register_craftitem("mobs_mc:porkchop_cooked", {
description = "Cooked Porkchop",
inventory_image = "mcl_mobitems_porkchop_cooked.png",
groups = { food = 2, eatable = 8 },
on_use = minetest.item_eat(8),
})
end
--pig if c("porkchop_raw") and c("porkchop_cooked") then
minetest.register_craft({
type = "cooking",
output = "mobs_mc:porkchop_raw",
recipe = "mobs_mc:porkchop_cooked",
cooktime = 5,
})
end
-- pork if c("carrot_on_a_stick") then
minetest.register_craftitem("mobs_mc:porkchop_raw", { minetest.register_tool("mobs_mc:carrot_on_a_stick", {
description = "Raw Porkchop", description = "Carrot on a Stick",
inventory_image = "mcl_mobitems_porkchop_raw.png", wield_image = "mcl_mobitems_carrot_on_a_stick.png",
groups = { food = 2, eatable = 3 }, inventory_image = "mcl_mobitems_carrot_on_a_stick.png",
on_use = minetest.item_eat(3), sounds = { breaks = "default_tool_breaks" },
}) })
end
minetest.register_craftitem("mobs_mc:porkchop_cooked", { -- Poor-man's recipes for carrot on a stick
description = "Cooked Porkchop", if c("carrot_on_a_stick") and c("stick") and c("string") and minetest.get_modpath("farming") then
inventory_image = "mcl_mobitems_porkchop_cooked.png", minetest.register_craft({
groups = { food = 2, eatable = 8 }, output = "mobs_mc:carrot_on_a_stick",
on_use = minetest.item_eat(8), recipe = {
}) {"", "", "farming:string" },
{"", "group:stick", "farming:string" },
{"group:stick", "", "farming:bread" },
}
})
minetest.register_craft({ -- FIXME: Identify correct farming mod (check if it includes the carrot item)
type = "cooking", minetest.register_craft({
output = "mobs_mc:porkchop_raw", output = "mobs_mc:carrot_on_a_stick",
recipe = "mobs_mc:porkchop_cooked", recipe = {
cooktime = 5, {"", "", "farming:string" },
}) {"", "group:stick", "farming:string" },
{"group:stick", "", "farming:carrot" },
}
})
end
minetest.register_tool("mobs_mc:carrot_on_a_stick", { if c("carrot_on_a_stick") and c("stick") and c("string") and minetest.get_modpath("fishing") and minetest.get_modpath("farming") then
description = "Carrot on a Stick",
wield_image = "mcl_mobitems_carrot_on_a_stick.png",
inventory_image = "mcl_mobitems_carrot_on_a_stick.png",
sounds = { breaks = "default_tool_breaks" },
})
minetest.register_craft({
output = "mobs_mc:carrot_on_a_stick",
recipe = {
{"", "", "farming:string" },
{"", "group:stick", "farming:string" },
{"group:stick", "", "farming:bread" },
}
})
minetest.register_craft({
output = "mobs_mc:carrot_on_a_stick",
recipe = {
{"", "", "farming:string" },
{"", "group:stick", "farming:string" },
{"group:stick", "", "farming:carrot" },
}
})
if minetest.get_modpath("fishing") then
minetest.register_craft({ minetest.register_craft({
type = "shapeless", type = "shapeless",
output = "mobs_mc:carrot_on_a_stick", output = "mobs_mc:carrot_on_a_stick",
@ -293,117 +331,131 @@ if minetest.get_modpath("fishing") then
}) })
end end
-- Rabbit
if c("rabbit_raw") then
minetest.register_craftitem("mobs_mc:rabbit_raw", {
description = "Raw Rabbit",
inventory_image = "mcl_mobitems_rabbit_raw.png",
groups = { food = 2, eatable = 3 },
on_use = minetest.item_eat(3),
})
end
--Rabbit if c("rabbit_cooked") then
minetest.register_craftitem("mobs_mc:rabbit_cooked", {
description = "Cooked Rabbit",
inventory_image = "mcl_mobitems_rabbit_cooked.png",
groups = { food = 2, eatable = 5 },
on_use = minetest.item_eat(5),
})
end
-- Items if c("rabbit_raw") and c("rabbit_cooked") then
minetest.register_craftitem("mobs_mc:rabbit_raw", { minetest.register_craft({
description = "Raw Rabbit", type = "cooking",
inventory_image = "mcl_mobitems_rabbit_raw.png", output = "mobs_mc:rabbit_cooked",
groups = { food = 2, eatable = 3 }, recipe = "mobs_mc:rabbit_raw",
on_use = minetest.item_eat(3), cooktime = 5,
}) })
end
minetest.register_craftitem("mobs_mc:rabbit_cooked", { if c("rabbit_hide") then
description = "Cooked Rabbit", minetest.register_craftitem("mobs_mc:rabbit_hide", {
inventory_image = "mcl_mobitems_rabbit_cooked.png", description = "Rabbit Hide",
groups = { food = 2, eatable = 5 }, inventory_image = "mcl_mobitems_rabbit_hide.png"
on_use = minetest.item_eat(5), })
}) end
minetest.register_craft({ if c("leather") and c("rabbit_hide") then
type = "cooking", minetest.register_craft({
output = "mobs_mc:rabbit_cooked", output = "mobs:leather",
recipe = "mobs_mc:rabbit_raw", recipe = {
cooktime = 5, { "mobs_mc:rabbit_hide", "mobs_mc:rabbit_hide" },
}) { "mobs_mc:rabbit_hide", "mobs_mc:rabbit_hide" },
}
})
end
minetest.register_craftitem("mobs_mc:rabbit_hide", { -- Sheep
description = "Rabbit Hide", if c("mutton_raw") then
inventory_image = "mcl_mobitems_rabbit_hide.png" minetest.register_craftitem("mobs_mc:mutton_raw", {
}) description = "Raw Mutton",
inventory_image = "mcl_mobitems_mutton_raw.png",
groups = { food = 2, eatable = 4 },
on_use = minetest.item_eat(4),
})
end
minetest.register_craft({ if c("mutton_cooked") then
output = "mobs:leather", minetest.register_craftitem("mobs_mc:mutton_cooked", {
recipe = { description = "Cooked Mutton",
{ "mobs_mc:rabbit_hide", "mobs_mc:rabbit_hide" }, inventory_image = "mcl_mobitems_mutton_cooked.png",
{ "mobs_mc:rabbit_hide", "mobs_mc:rabbit_hide" }, groups = { food = 2, eatable = 8 },
} on_use = minetest.item_eat(8),
}) })
end
--sheep if c("mutton_raw") and c("mutton_cooked") then
minetest.register_craft({
type = "cooking",
output = "mobs_mc:mutton_cooked",
recipe = "mobs_mc:mutton_raw",
cooktime = 5,
})
end
--mutton -- Shulker
minetest.register_craftitem("mobs_mc:mutton_raw", { if c("shulker_shell") then
description = "Raw Mutton", minetest.register_craftitem("mobs_mc:shulker_shell", {
inventory_image = "mcl_mobitems_mutton_raw.png", description = "Shulker Shell",
groups = { food = 2, eatable = 4 }, inventory_image = "mcl_mobitems_shulker_shell.png",
on_use = minetest.item_eat(4), groups = { craftitem = 1 },
}) })
end
minetest.register_craftitem("mobs_mc:mutton_cooked", { -- Magma cube
description = "Cooked Mutton", if c("magma_cream") then
inventory_image = "mcl_mobitems_mutton_cooked.png", minetest.register_craftitem("mobs_mc:magma_cream", {
groups = { food = 2, eatable = 8 }, description = "Magma Cream",
on_use = minetest.item_eat(8), _doc_items_longdesc = "Magma cream is a crafting component.",
}) wield_image = "mcl_mobitems_magma_cream.png",
inventory_image = "mcl_mobitems_magma_cream.png",
groups = { brewitem = 1 },
})
end
minetest.register_craft({ -- Spider
type = "cooking", if c("spider_eye") then
output = "mobs_mc:mutton_cooked", minetest.register_craftitem("mobs_mc:spider_eye", {
recipe = "mobs_mc:mutton_raw", description = "Spider Eye",
cooktime = 5, _doc_items_longdesc = "Spider eyes are used mainly in crafting and brewing. If you're really desperate, you can eat a spider eye for 2 hunger points, but it will poison you.",
}) inventory_image = "mcl_mobitems_spider_eye.png",
wield_image = "mcl_mobitems_spider_eye.png",
-- Simplified poisonous food
groups = { food = 2, eatable = -2 },
on_use = minetest.item_eat(-2),
})
end
-- Evoker
if c("totem") then
minetest.register_craftitem("mobs_mc:totem", {
description = "Totem",
wield_image = "mcl_mobitems_totem.png",
inventory_image = "mcl_mobitems_totem.png",
groups = {fleshy=3,dig_immediate=3,flammable=2},
stack_max =1,
on_use = minetest.item_eat(20),
})
end
--shulker -- Rotten flesh
if c("rotten_flesh") then
minetest.register_craftitem("mobs_mc:shulker_shell", { minetest.register_craftitem("mobs_mc:rotten_flesh", {
description = "Shulker Shell", description = "Rotten Flesh",
inventory_image = "mcl_mobitems_shulker_shell.png", inventory_image = "mobs_rotten_flesh.png",
groups = { craftitem = 1 }, -- Simplified poisonous food
}) groups = { food = 2, eatable = -4 },
on_use = minetest.item_eat(-4),
--magma cube })
minetest.register_craftitem("mobs_mc:magma_cream", { end
description = "Magma Cream",
_doc_items_longdesc = "Magma cream is a crafting component.",
wield_image = "mcl_mobitems_magma_cream.png",
inventory_image = "mcl_mobitems_magma_cream.png",
groups = { brewitem = 1 },
})
--spider
minetest.register_craftitem("mobs_mc:spider_eye", {
description = "Spider Eye",
_doc_items_longdesc = "Spider eyes are used mainly in crafting and brewing. If you're really desperate, you can eat a spider eye for 2 hunger points, but it will poison you.",
inventory_image = "mcl_mobitems_spider_eye.png",
wield_image = "mcl_mobitems_spider_eye.png",
-- Simplified poisonous food
groups = { food = 2, eatable = -2 },
on_use = minetest.item_eat(-2),
})
--vex
minetest.register_craftitem("mobs_mc:totem", {
description = "Totem",
wield_image = "mcl_mobitems_totem.png",
inventory_image = "mcl_mobitems_totem.png",
groups = {fleshy=3,dig_immediate=3,flammable=2},
stack_max =1,
on_use = minetest.item_eat(20),
})
--zombie
-- meat rotted
minetest.register_craftitem("mobs_mc:rotten_flesh", {
description = "Rotten Flesh",
inventory_image = "mobs_rotten_flesh.png",
-- Simplified poisonous food
groups = { food = 2, eatable = -4 },
on_use = minetest.item_eat(-4),
})

View File

@ -6,73 +6,92 @@
--maikerumines throwing code --maikerumines throwing code
--arrow (weapon) --arrow (weapon)
minetest.register_craftitem("mobs_mc:arrow", {
description = "Arrow",
inventory_image = "throwing_arrow_2.png",
})
minetest.register_node("mobs_mc:arrow_box", { local c
drawtype = "nodebox", if minetest.get_modpath("mobs_mc_gameconfig") and mobs_mc.override and mobs_mc.override.items then
node_box = { c = function(id)
type = "fixed", return mobs_mc.override.items[id] == nil
fixed = { end
-- Shaft else
{-6.5/17, -1.5/17, -1.5/17, 6.5/17, 1.5/17, 1.5/17}, -- No items are overwritten, so always return true
--Spitze c = function(id)
{-4.5/17, 2.5/17, 2.5/17, -3.5/17, -2.5/17, -2.5/17}, return true
{-8.5/17, 0.5/17, 0.5/17, -6.5/17, -0.5/17, -0.5/17}, end
--Federn end
{6.5/17, 1.5/17, 1.5/17, 7.5/17, 2.5/17, 2.5/17}, if c("arrow") then
{7.5/17, -2.5/17, 2.5/17, 6.5/17, -1.5/17, 1.5/17}, minetest.register_craftitem("mobs_mc:arrow", {
{7.5/17, 2.5/17, -2.5/17, 6.5/17, 1.5/17, -1.5/17}, description = "Arrow",
{6.5/17, -1.5/17, -1.5/17, 7.5/17, -2.5/17, -2.5/17}, inventory_image = "throwing_arrow_2.png",
})
{7.5/17, 2.5/17, 2.5/17, 8.5/17, 3.5/17, 3.5/17}, minetest.register_node("mobs_mc:arrow_box", {
{8.5/17, -3.5/17, 3.5/17, 7.5/17, -2.5/17, 2.5/17}, drawtype = "nodebox",
{8.5/17, 3.5/17, -3.5/17, 7.5/17, 2.5/17, -2.5/17}, node_box = {
{7.5/17, -2.5/17, -2.5/17, 8.5/17, -3.5/17, -3.5/17}, type = "fixed",
} fixed = {
}, -- Shaft
tiles = {"throwing_arrow.png", "throwing_arrow.png", "throwing_arrow_back.png", "throwing_arrow_front.png", "throwing_arrow_2.png", "throwing_arrow.png"}, {-6.5/17, -1.5/17, -1.5/17, 6.5/17, 1.5/17, 1.5/17},
groups = {not_in_creative_inventory=1}, --Spitze
}) {-4.5/17, 2.5/17, 2.5/17, -3.5/17, -2.5/17, -2.5/17},
{-8.5/17, 0.5/17, 0.5/17, -6.5/17, -0.5/17, -0.5/17},
--Federn
{6.5/17, 1.5/17, 1.5/17, 7.5/17, 2.5/17, 2.5/17},
{7.5/17, -2.5/17, 2.5/17, 6.5/17, -1.5/17, 1.5/17},
{7.5/17, 2.5/17, -2.5/17, 6.5/17, 1.5/17, -1.5/17},
{6.5/17, -1.5/17, -1.5/17, 7.5/17, -2.5/17, -2.5/17},
{7.5/17, 2.5/17, 2.5/17, 8.5/17, 3.5/17, 3.5/17},
{8.5/17, -3.5/17, 3.5/17, 7.5/17, -2.5/17, 2.5/17},
{8.5/17, 3.5/17, -3.5/17, 7.5/17, 2.5/17, -2.5/17},
{7.5/17, -2.5/17, -2.5/17, 8.5/17, -3.5/17, -3.5/17},
}
},
tiles = {"throwing_arrow.png", "throwing_arrow.png", "throwing_arrow_back.png", "throwing_arrow_front.png", "throwing_arrow_2.png", "throwing_arrow.png"},
groups = {not_in_creative_inventory=1},
})
local THROWING_ARROW_ENTITY={
physical = false,
timer=0,
visual = "wielditem",
visual_size = {x=0.1, y=0.1},
textures = {"mobs_mc:arrow_box"},
velocity = 10,
lastpos={},
collisionbox = {0,0,0,0,0,0},
}
local THROWING_ARROW_ENTITY={ --ARROW CODE
physical = false, THROWING_ARROW_ENTITY.on_step = function(self, dtime)
timer=0, self.timer=self.timer+dtime
visual = "wielditem", local pos = self.object:getpos()
visual_size = {x=0.1, y=0.1}, local node = minetest.get_node(pos)
textures = {"mobs_mc:arrow_box"},
velocity = 10,
lastpos={},
collisionbox = {0,0,0,0,0,0},
}
minetest.add_particle({
pos = pos,
vel = {x=0, y=0, z=0},
acc = {x=0, y=0, z=0},
expirationtime = .3,
size = 1,
collisiondetection = false,
vertical = false,
texture = "mobs_mc_arrow_particle.png",
})
--ARROW CODE if self.timer>0.2 then
THROWING_ARROW_ENTITY.on_step = function(self, dtime) local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 1.5)
self.timer=self.timer+dtime for k, obj in pairs(objs) do
local pos = self.object:getpos() if obj:get_luaentity() ~= nil then
local node = minetest.get_node(pos) if obj:get_luaentity().name ~= "mobs_mc:arrow_entity" and obj:get_luaentity().name ~= "__builtin:item" then
local damage = 3
minetest.add_particle({ minetest.sound_play("damage", {pos = pos})
pos = pos, obj:punch(self.object, 1.0, {
vel = {x=0, y=0, z=0}, full_punch_interval=1.0,
acc = {x=0, y=0, z=0}, damage_groups={fleshy=damage},
expirationtime = .3, }, nil)
size = 1, self.object:remove()
collisiondetection = false, end
vertical = false, else
texture = "mobs_mc_arrow_particle.png",
})
if self.timer>0.2 then
local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 1.5)
for k, obj in pairs(objs) do
if obj:get_luaentity() ~= nil then
if obj:get_luaentity().name ~= "mobs_mc:arrow_entity" and obj:get_luaentity().name ~= "__builtin:item" then
local damage = 3 local damage = 3
minetest.sound_play("damage", {pos = pos}) minetest.sound_play("damage", {pos = pos})
obj:punch(self.object, 1.0, { obj:punch(self.object, 1.0, {
@ -81,208 +100,203 @@ minetest.add_particle({
}, nil) }, nil)
self.object:remove() self.object:remove()
end end
else end
local damage = 3 end
minetest.sound_play("damage", {pos = pos})
obj:punch(self.object, 1.0, { if self.lastpos.x~=nil then
full_punch_interval=1.0, if node.name ~= "air" then
damage_groups={fleshy=damage}, minetest.sound_play("bowhit1", {pos = pos})
}, nil) minetest.add_item(self.lastpos, 'mobs_mc:arrow')
self.object:remove() self.object:remove()
end end
end end
self.lastpos={x=pos.x, y=pos.y, z=pos.z}
end end
if self.lastpos.x~=nil then
if node.name ~= "air" then minetest.register_entity("mobs_mc:arrow_entity", THROWING_ARROW_ENTITY)
minetest.sound_play("bowhit1", {pos = pos})
minetest.add_item(self.lastpos, 'mobs_mc:arrow')
self.object:remove() minetest.register_craft({
output = 'mobs_mc:arrow 4',
recipe = {
{mobs_mc.items.flint},
{mobs_mc.items.stick},
{mobs_mc.items.feather},
}
})
arrows = {
{"mobs_mc:arrow", "mobs_mc:arrow_entity" },
}
local throwing_shoot_arrow = function(itemstack, player)
for _,arrow in ipairs(arrows) do
if player:get_inventory():get_stack("main", player:get_wield_index()+1):get_name() == arrow[1] then
if not minetest.settings:get_bool("creative_mode") then
player:get_inventory():remove_item("main", arrow[1])
end
local playerpos = player:getpos()
--local obj = minetest.env:add_entity({x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, arrow[2]) --current
local obj = minetest.add_entity({x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, arrow[2]) --mc
local dir = player:get_look_dir()
obj:setvelocity({x=dir.x*22, y=dir.y*22, z=dir.z*22})
obj:setacceleration({x=dir.x*-3, y=-10, z=dir.z*-3})
obj:setyaw(player:get_look_yaw()+math.pi)
minetest.sound_play("throwing_sound", {pos=playerpos})
if obj:get_luaentity().player == "" then
obj:get_luaentity().player = player
end
obj:get_luaentity().node = player:get_inventory():get_stack("main", 1):get_name()
return true
end
end end
return false
end end
self.lastpos={x=pos.x, y=pos.y, z=pos.z}
end end
if c("bow") then
minetest.register_entity("mobs_mc:arrow_entity", THROWING_ARROW_ENTITY) minetest.register_tool("mobs_mc:bow_wood", {
description = "Bow",
inventory_image = "mobs_mc_bow.png",
minetest.register_craft({ on_use = function(itemstack, user, pointed_thing)
output = 'mobs_mc:arrow 4', if throwing_shoot_arrow(itemstack, user, pointed_thing) then
recipe = { if not minetest.settings:get_bool("creative_mode") then
{mobs_mc.items.flint}, itemstack:add_wear(65535/50)
{mobs_mc.items.stick}, end
{mobs_mc.items.feather},
}
})
arrows = {
{"mobs_mc:arrow", "mobs_mc:arrow_entity" },
}
local throwing_shoot_arrow = function(itemstack, player)
for _,arrow in ipairs(arrows) do
if player:get_inventory():get_stack("main", player:get_wield_index()+1):get_name() == arrow[1] then
if not minetest.settings:get_bool("creative_mode") then
player:get_inventory():remove_item("main", arrow[1])
end end
local playerpos = player:getpos() return itemstack
--local obj = minetest.env:add_entity({x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, arrow[2]) --current end,
local obj = minetest.add_entity({x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, arrow[2]) --mc })
local dir = player:get_look_dir()
obj:setvelocity({x=dir.x*22, y=dir.y*22, z=dir.z*22}) minetest.register_craft({
obj:setacceleration({x=dir.x*-3, y=-10, z=dir.z*-3}) output = 'mobs_mc:bow_wood',
obj:setyaw(player:get_look_yaw()+math.pi) recipe = {
minetest.sound_play("throwing_sound", {pos=playerpos}) {mobs_mc.items.string, mobs_mc.items.stick, ''},
if obj:get_luaentity().player == "" then {mobs_mc.items.string, '', mobs_mc.items.stick},
obj:get_luaentity().player = player {mobs_mc.items.string, mobs_mc.items.stick, ''},
end }
obj:get_luaentity().node = player:get_inventory():get_stack("main", 1):get_name() })
return true
end
end
return false
end end
minetest.register_tool("mobs_mc:bow_wood", {
description = "Bow",
inventory_image = "mobs_mc_bow.png",
on_use = function(itemstack, user, pointed_thing)
if throwing_shoot_arrow(itemstack, user, pointed_thing) then
if not minetest.settings:get_bool("creative_mode") then
itemstack:add_wear(65535/50)
end
end
return itemstack
end,
})
minetest.register_craft({
output = 'mobs_mc:bow_wood',
recipe = {
{mobs_mc.items.string, mobs_mc.items.stick, ''},
{mobs_mc.items.string, '', mobs_mc.items.stick},
{mobs_mc.items.string, mobs_mc.items.stick, ''},
}
})
-- egg throwing item -- egg throwing item
-- egg entity -- egg entity
mobs:register_arrow("mobs_mc:egg_entity", { if c("egg") then
visual = "sprite", mobs:register_arrow("mobs_mc:egg_entity", {
visual_size = {x=.5, y=.5}, visual = "sprite",
textures = {"mobs_chicken_egg.png"}, visual_size = {x=.5, y=.5},
velocity = 6, textures = {"mobs_chicken_egg.png"},
velocity = 6,
hit_player = function(self, player) hit_player = function(self, player)
player:punch(minetest.get_player_by_name(self.playername) or self.object, 1.0, { player:punch(minetest.get_player_by_name(self.playername) or self.object, 1.0, {
full_punch_interval = 1.0, full_punch_interval = 1.0,
damage_groups = {}, damage_groups = {},
}, nil) }, nil)
end, end,
hit_mob = function(self, player) hit_mob = function(self, player)
player:punch(minetest.get_player_by_name(self.playername) or self.object, 1.0, { player:punch(minetest.get_player_by_name(self.playername) or self.object, 1.0, {
full_punch_interval = 1.0, full_punch_interval = 1.0,
damage_groups = {}, damage_groups = {},
}, nil) }, nil)
end, end,
hit_node = function(self, pos, node) hit_node = function(self, pos, node)
if math.random(1, 10) > 1 then if math.random(1, 10) > 1 then
return return
end
pos.y = pos.y + 1
local nod = minetest.get_node_or_nil(pos)
if not nod
or not minetest.registered_nodes[nod.name]
or minetest.registered_nodes[nod.name].walkable == true then
return
end
local mob = minetest.add_entity(pos, "mobs_mc:chicken")
local ent2 = mob:get_luaentity()
mob:set_properties({
visual_size = {
x = ent2.base_size.x / 2,
y = ent2.base_size.y / 2
},
collisionbox = {
ent2.base_colbox[1] / 2,
ent2.base_colbox[2] / 2,
ent2.base_colbox[3] / 2,
ent2.base_colbox[4] / 2,
ent2.base_colbox[5] / 2,
ent2.base_colbox[6] / 2
},
})
ent2.child = true
ent2.tamed = true
ent2.owner = self.playername
end end
})
pos.y = pos.y + 1 local egg_GRAVITY = 9
local egg_VELOCITY = 19
local nod = minetest.get_node_or_nil(pos) -- shoot egg
local mobs_shoot_egg = function (item, player, pointed_thing)
if not nod local playerpos = player:getpos()
or not minetest.registered_nodes[nod.name]
or minetest.registered_nodes[nod.name].walkable == true then
return
end
local mob = minetest.add_entity(pos, "mobs_mc:chicken") minetest.sound_play("default_place_node_hard", {
local ent2 = mob:get_luaentity() pos = playerpos,
gain = 1.0,
mob:set_properties({ max_hear_distance = 5,
visual_size = {
x = ent2.base_size.x / 2,
y = ent2.base_size.y / 2
},
collisionbox = {
ent2.base_colbox[1] / 2,
ent2.base_colbox[2] / 2,
ent2.base_colbox[3] / 2,
ent2.base_colbox[4] / 2,
ent2.base_colbox[5] / 2,
ent2.base_colbox[6] / 2
},
}) })
ent2.child = true local obj = minetest.add_entity({
ent2.tamed = true x = playerpos.x,
ent2.owner = self.playername y = playerpos.y +1.5,
z = playerpos.z
}, "mobs_mc:egg_entity")
local ent = obj:get_luaentity()
local dir = player:get_look_dir()
ent.velocity = egg_VELOCITY -- needed for api internal timing
ent.switch = 1 -- needed so that egg doesn't despawn straight away
obj:setvelocity({
x = dir.x * egg_VELOCITY,
y = dir.y * egg_VELOCITY,
z = dir.z * egg_VELOCITY
})
obj:setacceleration({
x = dir.x * -3,
y = -egg_GRAVITY,
z = dir.z * -3
})
-- pass player name to egg for chick ownership
local ent2 = obj:get_luaentity()
ent2.playername = player:get_player_name()
item:take_item()
return item
end end
})
local egg_GRAVITY = 9 minetest.register_craftitem("mobs_mc:egg", {
local egg_VELOCITY = 19 description = "Egg",
inventory_image = "mobs_chicken_egg.png",
-- shoot egg on_use = mobs_shoot_egg,
local mobs_shoot_egg = function (item, player, pointed_thing)
local playerpos = player:getpos()
minetest.sound_play("default_place_node_hard", {
pos = playerpos,
gain = 1.0,
max_hear_distance = 5,
}) })
local obj = minetest.add_entity({
x = playerpos.x,
y = playerpos.y +1.5,
z = playerpos.z
}, "mobs_mc:egg_entity")
local ent = obj:get_luaentity()
local dir = player:get_look_dir()
ent.velocity = egg_VELOCITY -- needed for api internal timing
ent.switch = 1 -- needed so that egg doesn't despawn straight away
obj:setvelocity({
x = dir.x * egg_VELOCITY,
y = dir.y * egg_VELOCITY,
z = dir.z * egg_VELOCITY
})
obj:setacceleration({
x = dir.x * -3,
y = -egg_GRAVITY,
z = dir.z * -3
})
-- pass player name to egg for chick ownership
local ent2 = obj:get_luaentity()
ent2.playername = player:get_player_name()
item:take_item()
return item
end end
-- chicken
minetest.register_craftitem("mobs_mc:egg", {
description = "Egg",
inventory_image = "mobs_chicken_egg.png",
on_use = mobs_shoot_egg,
})
--end maikerumine code --end maikerumine code
if minetest.settings:get_bool("log_mods") then if minetest.settings:get_bool("log_mods") then